Commit 0ee0be10 authored by Simon Marlow's avatar Simon Marlow

Add getNumberOfProcessors(), FIX MacOS X build problem (hopefully)

Somebody needs to implement getNumberOfProcessors() for MacOS X,
currently it will return 1.
parent 88445139
......@@ -185,6 +185,9 @@ void *getThreadLocalVar (ThreadLocalKey *key);
void setThreadLocalVar (ThreadLocalKey *key, void *value);
void freeThreadLocalKey (ThreadLocalKey *key);
// Processors and affinity
nat getNumberOfProcessors (void);
#endif // !CMINUSMINUS
#else
......
......@@ -1152,17 +1152,7 @@ error = rtsTrue;
#if defined(PROFILING)
RtsFlags.ParFlags.nNodes = 1;
#else
#if defined(mingw32_HOST_OS)
{
SYSTEM_INFO si;
GetSystemInfo(&si);
RtsFlags.ParFlags.nNodes = si.dwNumberOfProcessors;
}
#elif defined(HAVE_SYSCONF)
RtsFlags.ParFlags.nNodes = sysconf(_SC_NPROCESSORS_CONF);
#else
RtsFlags.ParFlags.nNodes = 1;
#endif
RtsFlags.ParFlags.nNodes = getNumberOfProcessors();
#endif
} else {
RtsFlags.ParFlags.nNodes
......
......@@ -179,6 +179,24 @@ forkOS_createThread ( HsStablePtr entry )
return result;
}
nat
getNumberOfProcessors (void)
{
static nat nproc = 0;
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);
#else
nproc = 1;
#endif
}
return nproc;
}
#else /* !defined(THREADED_RTS) */
int
......
......@@ -232,6 +232,20 @@ forkOS_createThread ( HsStablePtr entry )
(unsigned*)&pId) == 0);
}
nat
getNumberOfProcessors (void)
{
static nat nproc = 0;
if (nproc == 0) {
SYSTEM_INFO si;
GetSystemInfo(&si);
nproc = si.dwNumberOfProcessors;
}
return nproc;
}
#else /* !defined(THREADED_RTS) */
int
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment