runtime: replace hw.ncpu with hw.logicalcpu for Mac OS X
authorEugene Akentyev <ak3ntev@gmail.com>
Thu, 7 Apr 2016 03:44:59 +0000 (03:44 +0000)
committerAustin Seipp <austin@well-typed.com>
Thu, 7 Apr 2016 03:47:34 +0000 (03:47 +0000)
Reviewed By: erikd, austin

Differential Revision: https://phabricator.haskell.org/D2082

GHC Trac Issues: #8594

rts/posix/OSThreads.c

index 91f9523..1562ee4 100644 (file)
@@ -237,9 +237,15 @@ 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) || defined(freebsd_HOST_OS)
+#elif defined(darwin_HOST_OS)
         size_t size = sizeof(nat);
-        if(0 != sysctlbyname("hw.ncpu",&nproc,&size,NULL,0))
+        if(sysctlbyname("hw.logicalcpu",&nproc,&size,NULL,0) != 0) {
+            if(sysctlbyname("hw.ncpu",&nproc,&size,NULL,0) != 0)
+                nproc = 1;
+        }
+#elif defined(freebsd_HOST_OS)
+        size_t size = sizeof(nat);
+        if(sysctlbyname("hw.ncpu",&nproc,&size,NULL,0) != 0)
             nproc = 1;
 #else
         nproc = 1;