summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/Cmm.h2
-rw-r--r--includes/OSThreads.h14
-rw-r--r--includes/SMP.h20
-rw-r--r--rts/HeapStackCheck.cmm4
-rw-r--r--rts/PrimOps.cmm20
-rw-r--r--rts/Schedule.c1
6 files changed, 48 insertions, 13 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 */
diff --git a/rts/HeapStackCheck.cmm b/rts/HeapStackCheck.cmm
index aae28cb77f..e9ddf5b69e 100644
--- a/rts/HeapStackCheck.cmm
+++ b/rts/HeapStackCheck.cmm
@@ -841,7 +841,7 @@ INFO_TABLE_RET( stg_block_takemvar, 1/*framesize*/, 0/*bitmap*/, RET_SMALL )
stg_block_takemvar_finally
{
#ifdef THREADED_RTS
- foreign "C" unlockClosure(R3 "ptr", stg_EMPTY_MVAR_info);
+ unlockClosure(R3, stg_EMPTY_MVAR_info);
#endif
jump StgReturn;
}
@@ -867,7 +867,7 @@ INFO_TABLE_RET( stg_block_putmvar, 2/*framesize*/, 0/*bitmap*/, RET_SMALL )
stg_block_putmvar_finally
{
#ifdef THREADED_RTS
- foreign "C" unlockClosure(R3 "ptr", stg_FULL_MVAR_info);
+ unlockClosure(R3, stg_FULL_MVAR_info);
#endif
jump StgReturn;
}
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index 12322f297f..800f93ed89 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -1533,7 +1533,7 @@ takeMVarzh_fast
}
#if defined(THREADED_RTS)
- foreign "C" unlockClosure(mvar "ptr", stg_FULL_MVAR_info) [];
+ unlockClosure(mvar, stg_FULL_MVAR_info);
#endif
RET_P(val);
}
@@ -1543,7 +1543,7 @@ takeMVarzh_fast
StgMVar_value(mvar) = stg_END_TSO_QUEUE_closure;
#if defined(THREADED_RTS)
- foreign "C" unlockClosure(mvar "ptr", stg_EMPTY_MVAR_info) [];
+ unlockClosure(mvar, stg_EMPTY_MVAR_info);
#else
SET_INFO(mvar,stg_EMPTY_MVAR_info);
#endif
@@ -1569,7 +1569,7 @@ tryTakeMVarzh_fast
if (info == stg_EMPTY_MVAR_info) {
#if defined(THREADED_RTS)
- foreign "C" unlockClosure(mvar "ptr", stg_EMPTY_MVAR_info) [];
+ unlockClosure(mvar, stg_EMPTY_MVAR_info);
#endif
/* HACK: we need a pointer to pass back,
* so we abuse NO_FINALIZER_closure
@@ -1606,7 +1606,7 @@ tryTakeMVarzh_fast
StgMVar_tail(mvar) = stg_END_TSO_QUEUE_closure;
}
#if defined(THREADED_RTS)
- foreign "C" unlockClosure(mvar "ptr", stg_FULL_MVAR_info) [];
+ unlockClosure(mvar, stg_FULL_MVAR_info);
#endif
}
else
@@ -1614,7 +1614,7 @@ tryTakeMVarzh_fast
/* No further putMVars, MVar is now empty */
StgMVar_value(mvar) = stg_END_TSO_QUEUE_closure;
#if defined(THREADED_RTS)
- foreign "C" unlockClosure(mvar "ptr", stg_EMPTY_MVAR_info) [];
+ unlockClosure(mvar, stg_EMPTY_MVAR_info);
#else
SET_INFO(mvar,stg_EMPTY_MVAR_info);
#endif
@@ -1676,7 +1676,7 @@ putMVarzh_fast
}
#if defined(THREADED_RTS)
- foreign "C" unlockClosure(mvar "ptr", stg_EMPTY_MVAR_info) [];
+ unlockClosure(mvar, stg_EMPTY_MVAR_info);
#endif
jump %ENTRY_CODE(Sp(0));
}
@@ -1686,7 +1686,7 @@ putMVarzh_fast
StgMVar_value(mvar) = R2;
#if defined(THREADED_RTS)
- foreign "C" unlockClosure(mvar "ptr", stg_FULL_MVAR_info) [];
+ unlockClosure(mvar, stg_FULL_MVAR_info);
#else
SET_INFO(mvar,stg_FULL_MVAR_info);
#endif
@@ -1712,7 +1712,7 @@ tryPutMVarzh_fast
if (info == stg_FULL_MVAR_info) {
#if defined(THREADED_RTS)
- foreign "C" unlockClosure(mvar "ptr", stg_FULL_MVAR_info) [];
+ unlockClosure(mvar, stg_FULL_MVAR_info);
#endif
RET_N(0);
}
@@ -1742,7 +1742,7 @@ tryPutMVarzh_fast
}
#if defined(THREADED_RTS)
- foreign "C" unlockClosure(mvar "ptr", stg_EMPTY_MVAR_info) [];
+ unlockClosure(mvar, stg_EMPTY_MVAR_info);
#endif
}
else
@@ -1751,7 +1751,7 @@ tryPutMVarzh_fast
StgMVar_value(mvar) = R2;
#if defined(THREADED_RTS)
- foreign "C" unlockClosure(mvar "ptr", stg_FULL_MVAR_info) [];
+ unlockClosure(mvar, stg_FULL_MVAR_info);
#else
SET_INFO(mvar,stg_FULL_MVAR_info);
#endif
diff --git a/rts/Schedule.c b/rts/Schedule.c
index c61287f9f9..441e97924e 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -7,6 +7,7 @@
* --------------------------------------------------------------------------*/
#include "PosixSource.h"
+#define KEEP_LOCKCLOSURE
#include "Rts.h"
#include "SchedAPI.h"
#include "RtsUtils.h"