Commit 52589e05 authored by ei@vuokko.info's avatar ei@vuokko.info

Add shared Typeable support

parent 22afade6
/* -----------------------------------------------------------------------------
*
* (c) The GHC Team, 2006
*
* Support for shared Typeable
*
* ---------------------------------------------------------------------------*/
#ifndef GHC_RTS_TYPEABLE_H
#define GHC_RTS_TYPEABLE_H
#include "Stg.h"
void initTypeableStore(void);
void exitTypeableStore(void);
StgPtr getOrSetTypeableStore(StgPtr);
#endif
......@@ -27,6 +27,7 @@
#include "Schedule.h"
#include "Storage.h"
#include "Sparks.h"
#include "RtsTypeable.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
......@@ -508,6 +509,7 @@ typedef struct _RtsSymbolVal {
SymX(forkOS_createThread) \
SymX(freeHaskellFunctionPtr) \
SymX(freeStablePtr) \
SymX(getOrSetTypeableStore) \
SymX(gcdIntegerzh_fast) \
SymX(gcdIntegerIntzh_fast) \
SymX(gcdIntzh_fast) \
......
......@@ -28,6 +28,7 @@
#include "ThreadLabels.h"
#include "BlockAlloc.h"
#include "Trace.h"
#include "RtsTypeable.h"
#if defined(RTS_GTK_FRONTPANEL)
#include "FrontPanel.h"
......@@ -196,6 +197,9 @@ hs_init(int *argc, char **argv[])
/* initialise the stable pointer table */
initStablePtrTable();
/* initialise the shared Typeable store */
initTypeableStore();
#if defined(DEBUG)
/* initialise thread label table (tso->char*) */
initThreadLabelTable();
......@@ -390,6 +394,9 @@ hs_exit(void)
// also outputs the stats (+RTS -s) info.
exitStorage();
/* free shared Typeable store */
exitTypeableStore();
/* initialise the stable pointer table */
exitStablePtrTable();
......
#include "RtsTypeable.h"
#include "Rts.h"
static StgPtr typeableStore = 0;
#ifdef THREADED_RTS
Mutex typeableStoreLock;
#endif
void
initTypeableStore()
{
typeableStore=0;
#ifdef THREADED_RTS
initMutex(&typeableStoreLock);
#endif
}
void
exitTypeableStore()
{
#ifdef THREADED_RTS
/* TODO: Free Mutex! */
#endif
if(typeableStore!=0) {
freeStablePtr((StgStablePtr)typeableStore);
typeableStore=0;
}
}
StgPtr
getOrSetTypeableStore(StgPtr ptr)
{
StgPtr ret = typeableStore;
if(ret==0) {
#ifdef THREADED_RTS
ACQUIRE_LOCK(&typeableStoreLock);
ret=typeableStore;
if(ret==0) {
#endif
typeableStore = ret = ptr;
#ifdef THREADED_RTS
}
RELEASE_LOCK(&typeableStoreLock);
#endif
}
return ret;
}
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