#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
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
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);
}