X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fposix%2FOSThreads.c;h=ee4958a2e84e079db17b34484fd1336039f5cfa9;hb=dd3d9333b2e2f6a0959bb4aebbad5bf23e968fb6;hp=cff37824cbc40cf1485d87c29295684be8ff0ab7;hpb=a91cc8496bf4ea7fe1e3ad9d97836152f3939ffa;p=ghc-hetmet.git diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c index cff3782..ee4958a 100644 --- a/rts/posix/OSThreads.c +++ b/rts/posix/OSThreads.c @@ -93,19 +93,36 @@ 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); #endif return; } +void +closeMutex(Mutex* pMut) +{ + pthread_mutex_destroy(pMut); +} void newThreadLocalKey (ThreadLocalKey *key) @@ -135,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 ) {