Commit 2b569f55 authored by Simon Marlow's avatar Simon Marlow

add getOrSetSignalHandlerStore, much like getOrSetTypeableStore

Part of the fix for #3171
parent e06849a1
/* -----------------------------------------------------------------------------
*
* (c) The GHC Team, 2006
*
* Support for shared Typeable
*
* ---------------------------------------------------------------------------*/
#ifndef GHC_RTS_TYPEABLE_H
#define GHC_RTS_TYPEABLE_H
void initTypeableStore(void);
void exitTypeableStore(void);
StgPtr getOrSetTypeableStore(StgPtr);
#endif
......@@ -26,7 +26,7 @@
#include "RtsUtils.h"
#include "Schedule.h"
#include "Sparks.h"
#include "RtsTypeable.h"
#include "RtsGlobals.h"
#include "Timer.h"
#include "Trace.h"
......@@ -639,6 +639,7 @@ typedef struct _RtsSymbolVal {
SymI_HasProto(freeHaskellFunctionPtr) \
SymI_HasProto(freeStablePtr) \
SymI_HasProto(getOrSetTypeableStore) \
SymI_HasProto(getOrSetSignalHandlerStore) \
SymI_HasProto(gcdIntegerzh_fast) \
SymI_HasProto(gcdIntegerIntzh_fast) \
SymI_HasProto(gcdIntzh_fast) \
......
......@@ -30,7 +30,7 @@
#include "ThreadLabels.h"
#include "BlockAlloc.h"
#include "Trace.h"
#include "RtsTypeable.h"
#include "RtsGlobals.h"
#include "Stable.h"
#include "Hpc.h"
#include "FileLock.h"
......@@ -243,7 +243,7 @@ hs_init(int *argc, char **argv[])
getStablePtr((StgPtr)blockedIndefinitely_closure);
/* initialise the shared Typeable store */
initTypeableStore();
initGlobalStore();
/* initialise file locking, if necessary */
#if !defined(mingw32_HOST_OS)
......@@ -488,7 +488,7 @@ hs_exit_(rtsBool wait_foreign)
freeScheduler();
/* free shared Typeable store */
exitTypeableStore();
exitGlobalStore();
/* free file locking tables, if necessary */
#if !defined(mingw32_HOST_OS)
......
/* -----------------------------------------------------------------------------
*
* (c) The GHC Team, 1995-2005
*
* Data.Typeable support
*
* ---------------------------------------------------------------------------*/
#include "Rts.h"
#include "RtsTypeable.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
closeMutex(&typeableStoreLock);
#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