Cope with libraries in libraries/foo/bar rather than just libraries/foo
[ghc-hetmet.git] / includes / OSThreads.h
index 32429b5..d79b9af 100644 (file)
@@ -16,8 +16,8 @@
 
 #if CMINUSMINUS
 
-#define ACQUIRE_LOCK(mutex) pthread_mutex_lock(mutex)
-#define RELEASE_LOCK(mutex) pthread_mutex_unlock(mutex)
+#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
@@ -79,6 +79,18 @@ typedef pthread_key_t   ThreadLocalKey;
 #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 <windows.h>
 
 typedef HANDLE Condition;
@@ -143,6 +155,8 @@ typedef HANDLE Mutex;
 #define ASSERT_LOCK_HELD(mutex) /* nothing */
 #endif
 
+#endif // CMINUSMINUS
+
 # else
 #  error "Threads not supported"
 # endif