Changeset 11243 in vbox for trunk/src/VBox
- Timestamp:
- Aug 8, 2008 1:19:14 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 34320
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/posix/RTMpGetCount-posix.cpp
r8245 r11243 44 44 RTDECL(RTCPUID) RTMpGetCount(void) 45 45 { 46 int cCpus; NOREF(cCpus);47 48 46 /* 49 47 * The sysconf way (linux and others). 50 48 */ 51 #ifdef _SC_NPROCESSORS_ONLN 52 cCpus = sysconf(_SC_NPROCESSORS_ONLN); 53 if (cCpus >= 1) 54 return cCpus; 49 #if defined(_SC_NPROCESSORS_MAX) || defined(_SC_NPROCESSORS_CONF) || defined(_SC_NPROCESSORS_ONLN) 50 int cCpusSC = -1; 51 # ifdef _SC_NPROCESSORS_MAX 52 int cMax = sysconf(_SC_NPROCESSORS_MAX); 53 cCpusSC = RT_MAX(cCpusSC, cMax); 54 # endif 55 # ifdef _SC_NPROCESSORS_CONF 56 int cConf = sysconf(_SC_NPROCESSORS_CONF); 57 cCpusSC = RT_MAX(cCpusSC, cConf); 58 # endif 59 # ifdef _SC_NPROCESSORS_ONLN 60 int cOnln = sysconf(_SC_NPROCESSORS_ONLN); 61 cCpusSC = RT_MAX(cCpusSC, cOnln); 62 # endif 63 Assert(cCpusSC > 0); 64 if (cCpusSC > 0) 65 return cCpusSC; 55 66 #endif 56 67 … … 62 73 aiMib[0] = CTL_HW; 63 74 aiMib[1] = HW_NCPU; 64 cCpus = -1;75 int cCpus = -1; 65 76 size_t cb = sizeof(cCpus); 66 int rc = sysctl(aiMib, ELEMENTS(aiMib), &cCpus, &cb, NULL, 0);77 int rc = sysctl(aiMib, RT_ELEMENTS(aiMib), &cCpus, &cb, NULL, 0); 67 78 if (rc != -1 && cCpus >= 1) 68 79 return cCpus;
Note:
See TracChangeset
for help on using the changeset viewer.