X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FOSThreads.h;h=c2b21b36f8a10a00736173a61d13bcc9ce9dbd93;hb=ddbdee33f5df83398252f5348d1c5938f7ea654a;hp=571c90ea6de088141dc66e5f2d77559ef92e88b9;hpb=1b170b6ca71637cf3574eb1cbb7030c22459826d;p=ghc-hetmet.git diff --git a/ghc/rts/OSThreads.h b/ghc/rts/OSThreads.h index 571c90e..c2b21b3 100644 --- a/ghc/rts/OSThreads.h +++ b/ghc/rts/OSThreads.h @@ -38,8 +38,22 @@ typedef DWORD OSThreadId; #define INIT_MUTEX_VAR 0 #define INIT_COND_VAR 0 -#define ACQUIRE_LOCK(mutex) WaitForSingleObject(mutex,INFINITE) -#define RELEASE_LOCK(mutex) ReleaseMutex(mutex) +static inline void +ACQUIRE_LOCK(Mutex *mutex) +{ + if (WaitForSingleObject(*mutex,INFINITE) == WAIT_FAILED) { + barf("WaitForSingleObject: %d", GetLastError()); + } +} + +static inline void +RELEASE_LOCK(Mutex *mutex) +{ + if (ReleaseMutex(*mutex) == 0) { + barf("ReleaseMutex: %d", GetLastError()); + } +} + # else # error "Threads not supported" # endif