X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fposix%2FOSThreads.c;h=324701d40d84f3a981e8aa67a98a438633fa881e;hb=f50be7e999d666670c4ca0910c8a3065ea2f2411;hp=9bcd56f8adec73eb3c76a44df54f51a4bade7201;hpb=77998ef4dc3277c3037460125d8fc8a7dc8ead75;p=ghc-hetmet.git diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c index 9bcd56f..324701d 100644 --- a/rts/posix/OSThreads.c +++ b/rts/posix/OSThreads.c @@ -23,6 +23,11 @@ #include #endif +#if defined(darwin_HOST_OS) +#include +#include +#endif + #if !defined(HAVE_PTHREAD_H) #error pthreads.h is required for the threaded RTS on Posix platforms #endif @@ -202,6 +207,10 @@ getNumberOfProcessors (void) nproc = sysconf(_SC_NPROCESSORS_ONLN); #elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_CONF) nproc = sysconf(_SC_NPROCESSORS_CONF); +#elif defined(darwin_HOST_OS) + size_t size = sizeof(nat); + if(0 != sysctlbyname("hw.ncpu",&nproc,&size,NULL,0)) + nproc = 1; #else nproc = 1; #endif @@ -224,7 +233,7 @@ setThreadAffinity (nat n, nat m) nproc = getNumberOfProcessors(); CPU_ZERO(&cs); for (i = n; i < nproc; i+=m) { - CPU_SET(n, &cs); + CPU_SET(i, &cs); } sched_setaffinity(0, sizeof(cpu_set_t), &cs); }