X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fposix%2FOSThreads.c;fp=rts%2Fposix%2FOSThreads.c;h=d4d43821344dd29319a8c06e4a526ad41164aea4;hb=97c4b27494addf0231724ca8339e818511256dcf;hp=84b111fcb7404f4795a9b51be19f5b1583352ad3;hpb=a664d7385d97a2e4743d448aa3dddd911190f472;p=ghc-hetmet.git diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c index 84b111f..d4d4382 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 @@ -196,12 +201,16 @@ nat getNumberOfProcessors (void) { static nat nproc = 0; + size_t size = sizeof(nat); if (nproc == 0) { #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) nproc = sysconf(_SC_NPROCESSORS_ONLN); #elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_CONF) nproc = sysconf(_SC_NPROCESSORS_CONF); +#elif defined(darwin_HOST_OS) + if(0 != sysctlbyname("hw.ncpu",&nproc,&size,NULL,0)) + nproc = 1; #else nproc = 1; #endif