Use error-checking mutexes on all platforms when DEBUG is on
[ghc-hetmet.git] / rts / posix / OSThreads.c
index b30d085..ee4958a 100644 (file)
@@ -93,13 +93,25 @@ osThreadId()
   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);
+#if defined(linux_HOST_OS)
     pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_ERRORCHECK_NP);
+#else
+    pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_ERRORCHECK);
+#endif
     pthread_mutex_init(pMut,&attr);
 #else
     pthread_mutex_init(pMut,NULL);
@@ -140,6 +152,15 @@ setThreadLocalVar (ThreadLocalKey *key, void *value)
     }
 }
 
+void
+freeThreadLocalKey (ThreadLocalKey *key)
+{
+    int r;
+    if ((r = pthread_key_delete(*key)) != 0) {
+       barf("freeThreadLocalKey: %s", strerror(r));
+    }
+}
+
 static void *
 forkOS_createThreadWrapper ( void * entry )
 {