projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Please the -Wall police by moving a variable declaration; really FIX getNumberOfProce...
[ghc-hetmet.git]
/
rts
/
posix
/
OSThreads.c
diff --git
a/rts/posix/OSThreads.c
b/rts/posix/OSThreads.c
index
9bcd56f
..
324701d
100644
(file)
--- a/
rts/posix/OSThreads.c
+++ b/
rts/posix/OSThreads.c
@@
-23,6
+23,11
@@
#include <string.h>
#endif
#include <string.h>
#endif
+#if defined(darwin_HOST_OS)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
+
#if !defined(HAVE_PTHREAD_H)
#error pthreads.h is required for the threaded RTS on Posix platforms
#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);
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
#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) {
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);
}
}
sched_setaffinity(0, sizeof(cpu_set_t), &cs);
}