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 * If/when we switch to a dynamically-linked GHCi, this can all go
11 * away, because there would be just one copy of each library.
13 * ---------------------------------------------------------------------------*/
15 #include "PosixSource.h"
23 GHCConcSignalSignalHandlerStore,
24 GHCConcWindowsPendingDelaysStore,
25 GHCConcWindowsIOManagerThreadStore,
26 GHCConcWindowsProddingStore,
27 SystemEventThreadEventManagerStore,
28 SystemEventThreadIOManagerThreadStore,
33 Mutex globalStoreLock;
36 static StgStablePtr store[MaxStoreKey];
42 for (i=0; i < MaxStoreKey; i++) {
46 initMutex(&globalStoreLock);
55 closeMutex(&globalStoreLock);
57 for (i=0; i < MaxStoreKey; i++) {
59 freeStablePtr(store[i]);
65 static StgStablePtr getOrSetKey(StoreKey key, StgStablePtr ptr)
67 StgStablePtr ret = store[key];
70 ACQUIRE_LOCK(&globalStoreLock);
74 store[key] = ret = ptr;
77 RELEASE_LOCK(&globalStoreLock);
85 getOrSetTypeableStore(StgStablePtr ptr)
87 return getOrSetKey(TypeableStore,ptr);
91 getOrSetGHCConcSignalSignalHandlerStore(StgStablePtr ptr)
93 return getOrSetKey(GHCConcSignalSignalHandlerStore,ptr);
97 getOrSetGHCConcWindowsPendingDelaysStore(StgStablePtr ptr)
99 return getOrSetKey(GHCConcWindowsPendingDelaysStore,ptr);
103 getOrSetGHCConcWindowsIOManagerThreadStore(StgStablePtr ptr)
105 return getOrSetKey(GHCConcWindowsIOManagerThreadStore,ptr);
109 getOrSetGHCConcWindowsProddingStore(StgStablePtr ptr)
111 return getOrSetKey(GHCConcWindowsProddingStore,ptr);
115 getOrSetSystemEventThreadEventManagerStore(StgStablePtr ptr)
117 return getOrSetKey(SystemEventThreadEventManagerStore,ptr);
121 getOrSetSystemEventThreadIOManagerThreadStore(StgStablePtr ptr)
123 return getOrSetKey(SystemEventThreadIOManagerThreadStore,ptr);