X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=includes%2FOSThreads.h;h=d79b9affc7586ab64dc290f28a5d3d5e538723d2;hb=479f9fcbe056864fd5daff01d0e00d4a432b3658;hp=90431445b7befaf93a4d200a2405a5a54d1937fa;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/includes/OSThreads.h b/includes/OSThreads.h index 9043144..d79b9af 100644 --- a/includes/OSThreads.h +++ b/includes/OSThreads.h @@ -14,6 +14,14 @@ # if defined(HAVE_PTHREAD_H) && !defined(WANT_NATIVE_WIN32_THREADS) +#if CMINUSMINUS + +#define ACQUIRE_LOCK(mutex) foreign "C" pthread_mutex_lock(mutex) +#define RELEASE_LOCK(mutex) foreign "C" pthread_mutex_unlock(mutex) +#define ASSERT_LOCK_HELD(mutex) /* nothing */ + +#else + #include typedef pthread_cond_t Condition; @@ -68,11 +76,27 @@ typedef pthread_key_t ThreadLocalKey; #endif +#endif // CMINUSMINUS + # elif defined(HAVE_WINDOWS_H) + +#if CMINUSMINUS + +/* We jump through a hoop here to get a CCall EnterCriticalSection + and LeaveCriticalSection, as that's what C-- wants. */ + +#define ACQUIRE_LOCK(mutex) foreign "stdcall" EnterCriticalSection(mutex) +#define RELEASE_LOCK(mutex) foreign "stdcall" LeaveCriticalSection(mutex) +#define ASSERT_LOCK_HELD(mutex) /* nothing */ + +#else + #include typedef HANDLE Condition; typedef DWORD OSThreadId; +// don't be tempted to use HANDLE as the OSThreadId: there can be +// many HANDLES to a given thread, so comparison would not work. typedef DWORD ThreadLocalKey; #define OSThreadProcAttr __stdcall @@ -131,10 +155,14 @@ typedef HANDLE Mutex; #define ASSERT_LOCK_HELD(mutex) /* nothing */ #endif +#endif // CMINUSMINUS + # else # error "Threads not supported" # endif + +#ifndef CMINUSMINUS // // General thread operations // @@ -146,6 +174,7 @@ typedef void OSThreadProcAttr OSThreadProc(void *); extern int createOSThread ( OSThreadId* tid, OSThreadProc *startProc, void *param); +extern rtsBool osThreadIsAlive ( OSThreadId id ); // // Condition Variables @@ -161,6 +190,7 @@ extern rtsBool waitCondition ( Condition* pCond, // Mutexes // extern void initMutex ( Mutex* pMut ); +extern void closeMutex ( Mutex* pMut ); // // Thread-local storage @@ -168,6 +198,9 @@ extern void initMutex ( Mutex* pMut ); void newThreadLocalKey (ThreadLocalKey *key); void *getThreadLocalVar (ThreadLocalKey *key); void setThreadLocalVar (ThreadLocalKey *key, void *value); +void freeThreadLocalKey (ThreadLocalKey *key); + +#endif // !CMINUSMINUS #else