From ddbdee33f5df83398252f5348d1c5938f7ea654a Mon Sep 17 00:00:00 2001 From: simonmar Date: Mon, 15 Dec 2003 14:28:39 +0000 Subject: [PATCH] [project @ 2003-12-15 14:28:39 by simonmar] Fix bogosity in implementation of ACQUIRE_LOCK/RELEASE_LOCK on Win32. These functions were essentially doing nothing, due to a missing dereference on the argument. I've rewritten them as inlines (to catch type errors) and added some checking of the return values, which should help catch errors like this in the future. --- ghc/rts/OSThreads.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 -- 1.7.10.4