remove unused TICK_FREQUENCY
[ghc-hetmet.git] / includes / OSThreads.h
index 9043144..9a3b5aa 100644 (file)
 
 # if defined(HAVE_PTHREAD_H) && !defined(WANT_NATIVE_WIN32_THREADS)
 
+#if CMINUSMINUS
+
+#define ACQUIRE_LOCK(mutex) pthread_mutex_lock(mutex)
+#define RELEASE_LOCK(mutex) pthread_mutex_unlock(mutex)
+#define ASSERT_LOCK_HELD(mutex) /* nothing */
+
+#else
+
 #include <pthread.h>
 
 typedef pthread_cond_t  Condition;
@@ -68,11 +76,24 @@ typedef pthread_key_t   ThreadLocalKey;
 
 #endif
 
+#endif // CMINUSMINUS
+
 # elif defined(HAVE_WINDOWS_H)
+
+#if CMINUSMINUS
+
+#define ACQUIRE_LOCK(mutex) EnterCriticalSection(mutex)
+#define RELEASE_LOCK(mutex) 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
@@ -131,10 +152,14 @@ typedef HANDLE Mutex;
 #define ASSERT_LOCK_HELD(mutex) /* nothing */
 #endif
 
+#endif // CMINUSMINUS
+
 # else
 #  error "Threads not supported"
 # endif
 
+
+#ifndef CMINUSMINUS
 //
 // General thread operations
 //
@@ -146,6 +171,7 @@ typedef void OSThreadProcAttr OSThreadProc(void *);
 
 extern int  createOSThread        ( OSThreadId* tid, 
                                    OSThreadProc *startProc, void *param);
+extern rtsBool osThreadIsAlive    ( OSThreadId id );
 
 //
 // Condition Variables
@@ -161,6 +187,7 @@ extern rtsBool waitCondition      ( Condition* pCond,
 // Mutexes
 //
 extern void initMutex             ( Mutex* pMut );
+extern void closeMutex            ( Mutex* pMut );
 
 //
 // Thread-local storage
@@ -168,6 +195,9 @@ extern void initMutex             ( Mutex* pMut );
 void  newThreadLocalKey (ThreadLocalKey *key);
 void *getThreadLocalVar (ThreadLocalKey *key);
 void  setThreadLocalVar (ThreadLocalKey *key, void *value);
+void  freeThreadLocalKey (ThreadLocalKey *key);
+
+#endif // !CMINUSMINUS
 
 #else