summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2007-06-26 21:10:58 +0000
committerSimon Marlow <simonmar@microsoft.com>2007-06-26 21:10:58 +0000
commit16ed3e3cd3ba05ae7222f8da2c80f8294540817d (patch)
tree1d7a5e64f6f9c498a0801bd724a7eb46a7d6110e /includes
parentbf3339dd17b16dcc13212cd016a7c44a58183336 (diff)
downloadhaskell-16ed3e3cd3ba05ae7222f8da2c80f8294540817d.tar.gz
Make the threaded RTS compilable using -fasm
We needed to turn some inline C functions and C macros into either real C functions or C-- macros.
Diffstat (limited to 'includes')
-rw-r--r--includes/Cmm.h2
-rw-r--r--includes/OSThreads.h14
-rw-r--r--includes/SMP.h20
3 files changed, 35 insertions, 1 deletions
diff --git a/includes/Cmm.h b/includes/Cmm.h
index 4a4d0eab77..c238a84238 100644
--- a/includes/Cmm.h
+++ b/includes/Cmm.h
@@ -273,6 +273,8 @@
#include "DerivedConstants.h"
#include "ClosureTypes.h"
#include "StgFun.h"
+#include "OSThreads.h"
+#include "SMP.h"
/*
* Need MachRegs, because some of the RTS code is conditionally
diff --git a/includes/OSThreads.h b/includes/OSThreads.h
index fd50642313..32429b5794 100644
--- a/includes/OSThreads.h
+++ b/includes/OSThreads.h
@@ -14,6 +14,14 @@
# 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,6 +76,8 @@ typedef pthread_key_t ThreadLocalKey;
#endif
+#endif // CMINUSMINUS
+
# elif defined(HAVE_WINDOWS_H)
#include <windows.h>
@@ -137,6 +147,8 @@ typedef HANDLE Mutex;
# error "Threads not supported"
# endif
+
+#ifndef CMINUSMINUS
//
// General thread operations
//
@@ -174,6 +186,8 @@ void *getThreadLocalVar (ThreadLocalKey *key);
void setThreadLocalVar (ThreadLocalKey *key, void *value);
void freeThreadLocalKey (ThreadLocalKey *key);
+#endif // !CMINUSMINUS
+
#else
#define ACQUIRE_LOCK(l)
diff --git a/includes/SMP.h b/includes/SMP.h
index 74fbf9ad2d..f574ec8100 100644
--- a/includes/SMP.h
+++ b/includes/SMP.h
@@ -16,6 +16,14 @@
* Unregisterised builds are ok, but only 1 CPU supported.
*/
+#ifdef CMINUSMINUS
+
+#define unlockClosure(ptr,info) \
+ prim %write_barrier() []; \
+ StgHeader_info(ptr) = info;
+
+#else
+
#if defined(THREADED_RTS)
#if defined(TICKY_TICKY)
@@ -175,7 +183,15 @@ write_barrier(void) {
#define SPIN_COUNT 4000
-INLINE_HEADER StgInfoTable *
+#ifdef KEEP_LOCKCLOSURE
+// We want a callable copy of lockClosure() so that we can refer to it
+// from .cmm files compiled using the native codegen.
+extern StgInfoTable *lockClosure(StgClosure *p);
+INLINE_ME
+#else
+INLINE_HEADER
+#endif
+StgInfoTable *
lockClosure(StgClosure *p)
{
StgWord info;
@@ -323,3 +339,5 @@ INLINE_HEADER void unlockTSO(StgTSO *tso)
{ unlockClosure((StgClosure*)tso, (StgInfoTable*)&stg_TSO_info); }
#endif /* SMP_H */
+
+#endif /* CMINUSMINUS */