# if defined(HAVE_PTHREAD_H) && !defined(WANT_NATIVE_WIN32_THREADS)
+#if CMINUSMINUS
+
+#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
+
#include <pthread.h>
typedef pthread_cond_t Condition;
#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) 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;
typedef DWORD OSThreadId;
+// don't be tempted to use HANDLE as the OSThreadId: there can be
+// many HANDLES to a given thread, so comparison would not work.
typedef DWORD ThreadLocalKey;
#define OSThreadProcAttr __stdcall
#define ASSERT_LOCK_HELD(mutex) /* nothing */
#endif
+#endif // CMINUSMINUS
+
# else
# error "Threads not supported"
# endif
+
+#ifndef CMINUSMINUS
//
// General thread operations
//
extern int createOSThread ( OSThreadId* tid,
OSThreadProc *startProc, void *param);
+extern rtsBool osThreadIsAlive ( OSThreadId id );
//
// Condition Variables
void newThreadLocalKey (ThreadLocalKey *key);
void *getThreadLocalVar (ThreadLocalKey *key);
void setThreadLocalVar (ThreadLocalKey *key, void *value);
+void freeThreadLocalKey (ThreadLocalKey *key);
+
+#endif // !CMINUSMINUS
#else