1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1995-2009
5 * The RTS stores some "global" values on behalf of libraries, so that
6 * some libraries can ensure that certain top-level things are shared
7 * even when multiple versions of the library are loaded. e.g. see
8 * Data.Typeable and GHC.Conc.
10 * ---------------------------------------------------------------------------*/
12 #include "PosixSource.h"
18 static StgStablePtr typeableStore = 0;
19 static StgStablePtr signalHandlerStore = 0;
22 Mutex globalStoreLock;
29 signalHandlerStore = 0;
31 initMutex(&globalStoreLock);
39 closeMutex(&globalStoreLock);
41 if(typeableStore!=0) {
42 freeStablePtr((StgStablePtr)typeableStore);
45 if(signalHandlerStore!=0) {
46 freeStablePtr((StgStablePtr)signalHandlerStore);
52 getOrSetTypeableStore(StgStablePtr ptr)
54 StgStablePtr ret = typeableStore;
57 ACQUIRE_LOCK(&globalStoreLock);
61 typeableStore = ret = ptr;
64 RELEASE_LOCK(&globalStoreLock);
71 getOrSetSignalHandlerStore(StgStablePtr ptr)
73 StgStablePtr ret = signalHandlerStore;
76 ACQUIRE_LOCK(&globalStoreLock);
77 ret=signalHandlerStore;
80 signalHandlerStore = ret = ptr;
83 RELEASE_LOCK(&globalStoreLock);