Commit 16ed3e3c authored by Simon Marlow's avatar Simon Marlow

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.
parent bf3339dd
......@@ -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
......
......@@ -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)
......
......@@ -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 */
......@@ -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;
}
......
......@@ -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
......
......@@ -7,6 +7,7 @@
* --------------------------------------------------------------------------*/
#include "PosixSource.h"
#define KEEP_LOCKCLOSURE
#include "Rts.h"
#include "SchedAPI.h"
#include "RtsUtils.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment