[project @ 2004-07-21 10:47:28 by simonmar]
[ghc-hetmet.git] / ghc / rts / OSThreads.h
index 571c90e..a65e002 100644 (file)
@@ -31,6 +31,8 @@ typedef pthread_t       OSThreadId;
 # elif defined(HAVE_WINDOWS_H)
 #include <windows.h>
 
+#include "RtsUtils.h"
+
 typedef HANDLE Condition;
 typedef HANDLE Mutex;
 typedef DWORD OSThreadId;
@@ -38,8 +40,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