X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=includes%2FOSThreads.h;h=dd7f91a92dc8d9a0cf88449555e9b67dbd57a091;hb=19b0b165a24606dbdb1f4dd7728da7346845a5a0;hp=fd5064231311276bf605827a5ec7e415a6393bed;hpb=3f9e522bb0e53ce262f68424870e2bbc9135b70a;p=ghc-hetmet.git diff --git a/includes/OSThreads.h b/includes/OSThreads.h index fd50642..dd7f91a 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) pthread_mutex_lock(mutex) +#define RELEASE_LOCK(mutex) pthread_mutex_unlock(mutex) +#define ASSERT_LOCK_HELD(mutex) /* nothing */ + +#else + #include typedef pthread_cond_t Condition; @@ -68,7 +76,21 @@ 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) CCallEnterCriticalSection(mutex) +#define RELEASE_LOCK(mutex) CCallLeaveCriticalSection(mutex) +#define ASSERT_LOCK_HELD(mutex) /* nothing */ + +#else + #include typedef HANDLE Condition; @@ -133,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 // @@ -174,6 +200,8 @@ void *getThreadLocalVar (ThreadLocalKey *key); void setThreadLocalVar (ThreadLocalKey *key, void *value); void freeThreadLocalKey (ThreadLocalKey *key); +#endif // !CMINUSMINUS + #else #define ACQUIRE_LOCK(l)