fixed futures (processor-count) on OS X (was previously always returning 1)
svn: r16924
This commit is contained in:
parent
9367b1bbad
commit
074450e268
|
@ -612,6 +612,7 @@ Scheme_Object *touch(int argc, Scheme_Object *argv[])
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#elif OS_X
|
#elif OS_X
|
||||||
|
#include <sys/param.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#elif WINDOWS
|
#elif WINDOWS
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -625,24 +626,12 @@ Scheme_Object *processor_count(int argc, Scheme_Object *argv[])
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
cpucount = sysconf(_SC_NPROCESSORS_ONLN);
|
cpucount = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
#elif OS_X
|
#elif OS_X
|
||||||
int mib[4];
|
size_t size = sizeof(cpucount) ;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
/* set the mib for hw.ncpu */
|
if (sysctlbyname("hw.ncpu", &cpucount, &size, NULL, 0))
|
||||||
mib[0] = CTL_HW;
|
{
|
||||||
mib[1] = HW_AVAILCPU; // alternatively, try HW_NCPU;
|
cpucount = 1;
|
||||||
|
}
|
||||||
/* get the number of CPUs from the system */
|
|
||||||
sysctl(mib, 2, &cpucount, &len, NULL, 0);
|
|
||||||
if (cpucount < 1)
|
|
||||||
{
|
|
||||||
mib[1] = HW_NCPU;
|
|
||||||
sysctl(mib, 2, &cpucount, &len, NULL, 0);
|
|
||||||
if(cpucount < 1)
|
|
||||||
{
|
|
||||||
cpucount = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif WINDOWS
|
#elif WINDOWS
|
||||||
SYSTEM_INFO sysinfo;
|
SYSTEM_INFO sysinfo;
|
||||||
GetSystemInfo(&sysinfo);
|
GetSystemInfo(&sysinfo);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user