[commit: ghc] master: runtime: replace hw.ncpu with hw.logicalcpu for Mac OS X (eda273b)

git at git.haskell.org git at git.haskell.org
Thu Apr 7 03:45:30 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/eda273bc0be4f2316758e121f5f0ed85c3460c7f/ghc

>---------------------------------------------------------------

commit eda273bc0be4f2316758e121f5f0ed85c3460c7f
Author: Eugene Akentyev <ak3ntev at gmail.com>
Date:   Thu Apr 7 03:44:59 2016 +0000

    runtime: replace hw.ncpu with hw.logicalcpu for Mac OS X
    
    Reviewed By: erikd, austin
    
    Differential Revision: https://phabricator.haskell.org/D2082
    
    GHC Trac Issues: #8594


>---------------------------------------------------------------

eda273bc0be4f2316758e121f5f0ed85c3460c7f
 rts/posix/OSThreads.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c
index 91f9523..1562ee4 100644
--- a/rts/posix/OSThreads.c
+++ b/rts/posix/OSThreads.c
@@ -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;



More information about the ghc-commits mailing list