return pthread_self();
}
+rtsBool
+osThreadIsAlive(OSThreadId id STG_UNUSED)
+{
+ // no good way to implement this on POSIX, AFAICT. Returning true
+ // is safe.
+ return rtsTrue;
+}
+
void
initMutex(Mutex* pMut)
{
-#if defined(DEBUG) && defined(linux_HOST_OS)
+#if defined(DEBUG)
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_ERRORCHECK_NP);
+ pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_ERRORCHECK);
pthread_mutex_init(pMut,&attr);
#else
pthread_mutex_init(pMut,NULL);
}
}
+void
+freeThreadLocalKey (ThreadLocalKey *key)
+{
+ int r;
+ if ((r = pthread_key_delete(*key)) != 0) {
+ barf("freeThreadLocalKey: %s", strerror(r));
+ }
+}
+
static void *
forkOS_createThreadWrapper ( void * 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