summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-06-04 15:09:37 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-05 03:48:25 -0400
commit9a28680d2e23e7b25dd7254a439aea31dfae32d5 (patch)
treed6b41a447d8bfb5c907f5e278c7e5f1127c6c450
parent1713cbb038116c2d703238b47f78c4861232db8e (diff)
downloadhaskell-9a28680d2e23e7b25dd7254a439aea31dfae32d5.tar.gz
Put Unique related global variables in the RTS (#19940)
-rw-r--r--compiler/cbits/genSym.c6
-rw-r--r--includes/rts/Globals.h2
-rw-r--r--rts/Globals.c3
-rw-r--r--rts/RtsSymbols.c2
4 files changed, 13 insertions, 0 deletions
diff --git a/compiler/cbits/genSym.c b/compiler/cbits/genSym.c
index 8a47d77f27..eed2b4f142 100644
--- a/compiler/cbits/genSym.c
+++ b/compiler/cbits/genSym.c
@@ -1,9 +1,15 @@
#include <Rts.h>
#include <assert.h>
#include "Unique.h"
+#include "ghcversion.h"
+// These global variables have been moved into the RTS. It allows them to be
+// shared with plugins even if two different instances of the GHC library are
+// loaded at the same time (#19940)
+#if !MIN_VERSION_GLASGOW_HASKELL(9,3,0,0)
HsInt ghc_unique_counter = 0;
HsInt ghc_unique_inc = 1;
+#endif
#define UNIQUE_BITS (sizeof (HsInt) * 8 - UNIQUE_TAG_BITS)
#define UNIQUE_MASK ((1ULL << UNIQUE_BITS) - 1)
diff --git a/includes/rts/Globals.h b/includes/rts/Globals.h
index 8d8df48b21..bd3aa637db 100644
--- a/includes/rts/Globals.h
+++ b/includes/rts/Globals.h
@@ -32,3 +32,5 @@ mkStoreAccessorPrototype(LibHSghcFastStringTable)
mkStoreAccessorPrototype(LibHSghcGlobalHasPprDebug)
mkStoreAccessorPrototype(LibHSghcGlobalHasNoDebugOutput)
mkStoreAccessorPrototype(LibHSghcGlobalHasNoStateHack)
+extern HsInt ghc_unique_counter;
+extern HsInt ghc_unique_inc;
diff --git a/rts/Globals.c b/rts/Globals.c
index 5569ee7910..848581e4d2 100644
--- a/rts/Globals.c
+++ b/rts/Globals.c
@@ -107,3 +107,6 @@ mkStoreAccessor(LibHSghcFastStringTable)
mkStoreAccessor(LibHSghcGlobalHasPprDebug)
mkStoreAccessor(LibHSghcGlobalHasNoDebugOutput)
mkStoreAccessor(LibHSghcGlobalHasNoStateHack)
+
+HsInt ghc_unique_counter = 0;
+HsInt ghc_unique_inc = 1;
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index 752b0f702d..2380ac7135 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -659,6 +659,8 @@
SymI_HasProto(getOrSetLibHSghcGlobalHasPprDebug) \
SymI_HasProto(getOrSetLibHSghcGlobalHasNoDebugOutput) \
SymI_HasProto(getOrSetLibHSghcGlobalHasNoStateHack) \
+ SymI_HasProto(ghc_unique_counter) \
+ SymI_HasProto(ghc_unique_inc) \
SymI_HasProto(genericRaise) \
SymI_HasProto(getProgArgv) \
SymI_HasProto(getFullProgArgv) \