Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: xz/src/common/tuklib_cpucores.c

Issue 2869016: Add an unpatched version of xz, XZ Utils, to /trunk/deps/third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « xz/src/common/tuklib_cpucores.h ('k') | xz/src/common/tuklib_exit.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file tuklib_cpucores.c
4 /// \brief Get the number of CPU cores online
5 //
6 // Author: Lasse Collin
7 //
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
10 //
11 ///////////////////////////////////////////////////////////////////////////////
12
13 #include "tuklib_cpucores.h"
14
15 #if defined(TUKLIB_CPUCORES_SYSCTL)
16 # ifdef HAVE_SYS_PARAM_H
17 # include <sys/param.h>
18 # endif
19 # include <sys/sysctl.h>
20
21 #elif defined(TUKLIB_CPUCORES_SYSCONF)
22 # include <unistd.h>
23
24 // HP-UX
25 #elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC)
26 # include <sys/param.h>
27 # include <sys/pstat.h>
28 #endif
29
30
31 extern uint32_t
32 tuklib_cpucores(void)
33 {
34 uint32_t ret = 0;
35
36 #if defined(TUKLIB_CPUCORES_SYSCTL)
37 int name[2] = { CTL_HW, HW_NCPU };
38 int cpus;
39 size_t cpus_size = sizeof(cpus);
40 if (sysctl(name, 2, &cpus, &cpus_size, NULL, 0) != -1
41 && cpus_size == sizeof(cpus) && cpus > 0)
42 ret = cpus;
43
44 #elif defined(TUKLIB_CPUCORES_SYSCONF)
45 # ifdef _SC_NPROCESSORS_ONLN
46 // Most systems
47 const long cpus = sysconf(_SC_NPROCESSORS_ONLN);
48 # else
49 // IRIX
50 const long cpus = sysconf(_SC_NPROC_ONLN);
51 # endif
52 if (cpus > 0)
53 ret = cpus;
54
55 #elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC)
56 struct pst_dynamic pst;
57 if (pstat_getdynamic(&pst, sizeof(pst), 1, 0) != -1)
58 ret = pst.psd_proc_cnt;
59 #endif
60
61 return ret;
62 }
OLDNEW
« no previous file with comments | « xz/src/common/tuklib_cpucores.h ('k') | xz/src/common/tuklib_exit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698