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 @@ ...@@ -26,7 +26,7 @@
#include "RtsUtils.h" #include "RtsUtils.h"
#include "Schedule.h" #include "Schedule.h"
#include "Sparks.h" #include "Sparks.h"
#include "RtsTypeable.h" #include "RtsGlobals.h"
#include "Timer.h" #include "Timer.h"
#include "Trace.h" #include "Trace.h"
...@@ -639,6 +639,7 @@ typedef struct _RtsSymbolVal { ...@@ -639,6 +639,7 @@ typedef struct _RtsSymbolVal {
SymI_HasProto(freeHaskellFunctionPtr) \ SymI_HasProto(freeHaskellFunctionPtr) \
SymI_HasProto(freeStablePtr) \ SymI_HasProto(freeStablePtr) \
SymI_HasProto(getOrSetTypeableStore) \ SymI_HasProto(getOrSetTypeableStore) \
SymI_HasProto(getOrSetSignalHandlerStore) \
SymI_HasProto(gcdIntegerzh_fast) \ SymI_HasProto(gcdIntegerzh_fast) \
SymI_HasProto(gcdIntegerIntzh_fast) \ SymI_HasProto(gcdIntegerIntzh_fast) \
SymI_HasProto(gcdIntzh_fast) \ SymI_HasProto(gcdIntzh_fast) \
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "ThreadLabels.h" #include "ThreadLabels.h"
#include "BlockAlloc.h" #include "BlockAlloc.h"
#include "Trace.h" #include "Trace.h"
#include "RtsTypeable.h" #include "RtsGlobals.h"
#include "Stable.h" #include "Stable.h"
#include "Hpc.h" #include "Hpc.h"
#include "FileLock.h" #include "FileLock.h"
...@@ -243,7 +243,7 @@ hs_init(int *argc, char **argv[]) ...@@ -243,7 +243,7 @@ hs_init(int *argc, char **argv[])
getStablePtr((StgPtr)blockedIndefinitely_closure); getStablePtr((StgPtr)blockedIndefinitely_closure);
/* initialise the shared Typeable store */ /* initialise the shared Typeable store */
initTypeableStore(); initGlobalStore();
/* initialise file locking, if necessary */ /* initialise file locking, if necessary */
#if !defined(mingw32_HOST_OS) #if !defined(mingw32_HOST_OS)
...@@ -488,7 +488,7 @@ hs_exit_(rtsBool wait_foreign) ...@@ -488,7 +488,7 @@ hs_exit_(rtsBool wait_foreign)
freeScheduler(); freeScheduler();
/* free shared Typeable store */ /* free shared Typeable store */
exitTypeableStore(); exitGlobalStore();
/* free file locking tables, if necessary */ /* free file locking tables, if necessary */
#if !defined(mingw32_HOST_OS) #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