Use https links in user-facing startup and error messages
[ghc.git] / rts / Globals.c
index 1aafe21..c9980d9 100644 (file)
@@ -7,8 +7,13 @@
  * even when multiple versions of the library are loaded.  e.g. see
  * Data.Typeable and GHC.Conc.
  *
- * If/when we switch to a dynamically-linked GHCi, this can all go
- * away, because there would be just one copy of each library.
+ * How are multiple versions of a library loaded? Examples:
+ *
+ *   base - a statically-linked ghci has its own copy, so might libraries it
+ *          dynamically loads
+ *
+ *   libHSghc - a statically-linked ghc has its own copy and so will Core
+ *              plugins it dynamically loads.
  *
  * ---------------------------------------------------------------------------*/
 
@@ -16,7 +21,7 @@
 #include "Rts.h"
 
 #include "Globals.h"
-#include "Stable.h"
+#include "StablePtr.h"
 
 typedef enum {
     GHCConcSignalSignalHandlerStore,
@@ -27,10 +32,16 @@ typedef enum {
     SystemEventThreadIOManagerThreadStore,
     SystemTimerThreadEventManagerStore,
     SystemTimerThreadIOManagerThreadStore,
+    LibHSghcFastStringTable,
+    LibHSghcPersistentLinkerState,
+    LibHSghcInitLinkerDone,
+    LibHSghcGlobalDynFlags,
+    LibHSghcStaticOptions,
+    LibHSghcStaticOptionsReady,
     MaxStoreKey
 } StoreKey;
 
-#ifdef THREADED_RTS
+#if defined(THREADED_RTS)
 Mutex globalStoreLock;
 #endif
 
@@ -39,11 +50,11 @@ static StgStablePtr store[MaxStoreKey];
 void
 initGlobalStore(void)
 {
-    nat i;
+    uint32_t i;
     for (i=0; i < MaxStoreKey; i++) {
         store[i] = 0;
     }
-#ifdef THREADED_RTS
+#if defined(THREADED_RTS)
     initMutex(&globalStoreLock);
 #endif
 }
@@ -51,8 +62,8 @@ initGlobalStore(void)
 void
 exitGlobalStore(void)
 {
-    nat i;
-#ifdef THREADED_RTS
+    uint32_t i;
+#if defined(THREADED_RTS)
     closeMutex(&globalStoreLock);
 #endif
     for (i=0; i < MaxStoreKey; i++) {
@@ -67,64 +78,36 @@ static StgStablePtr getOrSetKey(StoreKey key, StgStablePtr ptr)
 {
     StgStablePtr ret = store[key];
     if(ret==0) {
-#ifdef THREADED_RTS
+#if defined(THREADED_RTS)
         ACQUIRE_LOCK(&globalStoreLock);
         ret = store[key];
         if(ret==0) {
 #endif
             store[key] = ret = ptr;
-#ifdef THREADED_RTS
+#if defined(THREADED_RTS)
         }
         RELEASE_LOCK(&globalStoreLock);
 #endif
     }
     return ret;
-}    
-
-StgStablePtr
-getOrSetGHCConcSignalSignalHandlerStore(StgStablePtr ptr)
-{
-    return getOrSetKey(GHCConcSignalSignalHandlerStore,ptr);
-}
-
-StgStablePtr
-getOrSetGHCConcWindowsPendingDelaysStore(StgStablePtr ptr)
-{
-    return getOrSetKey(GHCConcWindowsPendingDelaysStore,ptr);
-}
-
-StgStablePtr
-getOrSetGHCConcWindowsIOManagerThreadStore(StgStablePtr ptr)
-{
-    return getOrSetKey(GHCConcWindowsIOManagerThreadStore,ptr);
-}
-
-StgStablePtr
-getOrSetGHCConcWindowsProddingStore(StgStablePtr ptr)
-{
-    return getOrSetKey(GHCConcWindowsProddingStore,ptr);
-}
-
-StgStablePtr
-getOrSetSystemEventThreadEventManagerStore(StgStablePtr ptr)
-{
-    return getOrSetKey(SystemEventThreadEventManagerStore,ptr);
-}
-
-StgStablePtr
-getOrSetSystemEventThreadIOManagerThreadStore(StgStablePtr ptr)
-{
-    return getOrSetKey(SystemEventThreadIOManagerThreadStore,ptr);
-}
-
-StgStablePtr
-getOrSetSystemTimerThreadEventManagerStore(StgStablePtr ptr)
-{
-    return getOrSetKey(SystemTimerThreadEventManagerStore,ptr);
 }
 
-StgStablePtr
-getOrSetSystemTimerThreadIOManagerThreadStore(StgStablePtr ptr)
-{
-    return getOrSetKey(SystemTimerThreadIOManagerThreadStore,ptr);
-}
+#define mkStoreAccessor(name) \
+    StgStablePtr \
+    getOrSet##name(StgStablePtr ptr) \
+    { return getOrSetKey(name, ptr); }
+
+mkStoreAccessor(GHCConcSignalSignalHandlerStore)
+mkStoreAccessor(GHCConcWindowsPendingDelaysStore)
+mkStoreAccessor(GHCConcWindowsIOManagerThreadStore)
+mkStoreAccessor(GHCConcWindowsProddingStore)
+mkStoreAccessor(SystemEventThreadEventManagerStore)
+mkStoreAccessor(SystemEventThreadIOManagerThreadStore)
+mkStoreAccessor(SystemTimerThreadEventManagerStore)
+mkStoreAccessor(SystemTimerThreadIOManagerThreadStore)
+mkStoreAccessor(LibHSghcFastStringTable)
+mkStoreAccessor(LibHSghcPersistentLinkerState)
+mkStoreAccessor(LibHSghcInitLinkerDone)
+mkStoreAccessor(LibHSghcGlobalDynFlags)
+mkStoreAccessor(LibHSghcStaticOptions)
+mkStoreAccessor(LibHSghcStaticOptionsReady)