Move the genSym stuff from rts into compiler
authorIan Lynagh <ian@well-typed.com>
Fri, 17 May 2013 15:50:08 +0000 (16:50 +0100)
committerIan Lynagh <ian@well-typed.com>
Fri, 17 May 2013 15:50:08 +0000 (16:50 +0100)
It's no longer used by Data.Unique, so there's no need to have it
in rts any more.

compiler/basicTypes/UniqSupply.lhs
compiler/cbits/genSym.c [new file with mode: 0644]
compiler/ghc.cabal.in
includes/rts/Utils.h
rts/Linker.c
rts/RtsUtils.c

index f3fb28a..fb07e73 100644 (file)
@@ -81,7 +81,7 @@ mkSplitUniqSupply c
         -- This is one of the most hammered bits in the whole compiler
         mk_supply
           = unsafeDupableInterleaveIO (
-                genSymZh    >>= \ u_ -> case iUnbox u_ of { u -> (
+                genSym      >>= \ u_ -> case iUnbox u_ of { u -> (
                 mk_supply   >>= \ s1 ->
                 mk_supply   >>= \ s2 ->
                 return (MkSplitUniqSupply (mask `bitOrFastInt` u) s1 s2)
@@ -89,7 +89,7 @@ mkSplitUniqSupply c
        in
        mk_supply
 
-foreign import ccall unsafe "genSymZh" genSymZh :: IO Int
+foreign import ccall unsafe "genSym" genSym :: IO Int
 
 splitUniqSupply (MkSplitUniqSupply _ s1 s2) = (s1, s2)
 listSplitUniqSupply  (MkSplitUniqSupply _ s1 s2) = s1 : listSplitUniqSupply s2
diff --git a/compiler/cbits/genSym.c b/compiler/cbits/genSym.c
new file mode 100644 (file)
index 0000000..2d9779b
--- /dev/null
@@ -0,0 +1,9 @@
+
+#include "Rts.h"
+
+static HsInt GenSymCounter = 0;
+
+HsInt genSym(void) {
+    return GenSymCounter++;
+}
+
index 7ce0a52..90a241f 100644 (file)
@@ -99,6 +99,7 @@ Library
 
     c-sources:
         ghci/keepCAFsForGHCi.c
+        cbits/genSym.c
 
     hs-source-dirs:
         basicTypes
index 1cb52ae..119ec5b 100644 (file)
 #ifndef RTS_UTILS_H
 #define RTS_UTILS_H
 
-// Used in GHC (basicTypes/Unique.lhs, and Data.Unique in the base
-// package.
-HsInt genSymZh(void);
-HsInt resetGenSymZh(void);
-
 /* Alternate to raise(3) for threaded rts, for BSD-based OSes */
 int genericRaise(int sig);
 
index 2bcc522..06cd6d2 100644 (file)
@@ -1108,7 +1108,6 @@ typedef struct _RtsSymbolVal {
       SymI_HasProto(getOrSetSystemTimerThreadIOManagerThreadStore)      \
       SymI_HasProto(getGCStats)                                         \
       SymI_HasProto(getGCStatsEnabled)                                  \
-      SymI_HasProto(genSymZh)                                           \
       SymI_HasProto(genericRaise)                                       \
       SymI_HasProto(getProgArgv)                                        \
       SymI_HasProto(getFullProgArgv)                                    \
index fcbb757..cb9002c 100644 (file)
@@ -137,26 +137,6 @@ heapOverflow(void)
 }
 
 /* -----------------------------------------------------------------------------
-   genSym stuff, used by GHC itself for its splitting unique supply.
-
-   ToDo: put this somewhere sensible.
-   -------------------------------------------------------------------------  */
-
-static HsInt __GenSymCounter = 0;
-
-HsInt
-genSymZh(void)
-{
-    return(__GenSymCounter++);
-}
-HsInt
-resetGenSymZh(void) /* it's your funeral */
-{
-    __GenSymCounter=0;
-    return(__GenSymCounter);
-}
-
-/* -----------------------------------------------------------------------------
    Get the current time as a string.  Used in profiling reports.
    -------------------------------------------------------------------------- */