diff options
| author | Ben Gamari <ben@smart-cactus.org> | 2016-11-30 10:54:45 -0500 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2016-11-30 10:56:10 -0500 |
| commit | e2330b6dde805a5507898c3c4ddf38599df969da (patch) | |
| tree | d52c52b99f510553b2d1733d006747d75be68a6d /compiler/ghci | |
| parent | 03766cdbd26855e50719bd8ffcaf19898bd33f16 (diff) | |
| download | haskell-e2330b6dde805a5507898c3c4ddf38599df969da.tar.gz | |
Revert "Make globals use sharedCAF"
This reverts commit 6f7ed1e51bf360621a3c2a447045ab3012f68575 due to breakage of
the build on Windows.
Diffstat (limited to 'compiler/ghci')
| -rw-r--r-- | compiler/ghci/Linker.hs | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs index 7379c46772..4a0b62f904 100644 --- a/compiler/ghci/Linker.hs +++ b/compiler/ghci/Linker.hs @@ -1,10 +1,11 @@ {-# LANGUAGE CPP, NondecreasingIndentation, TupleSections, RecordWildCards #-} {-# OPTIONS_GHC -fno-cse #-} --- -fno-cse is needed for GLOBAL_VAR's to behave properly - -- -- (c) The University of Glasgow 2002-2006 -- + +-- -fno-cse is needed for GLOBAL_VAR's to behave properly + -- | The dynamic linker for GHCi. -- -- This module deals with the top-level issues of dynamic linking, @@ -15,7 +16,10 @@ module Linker ( getHValue, showLinkerState, extendLinkEnv, deleteFromLinkEnv, extendLoadedPkgs, linkPackages,initDynLinker,linkModule, - linkCmdLineLibs + linkCmdLineLibs, + + -- Saving/restoring globals + PersistentLinkerState, saveLinkerGlobals, restoreLinkerGlobals ) where #include "HsVersions.h" @@ -62,11 +66,6 @@ import System.Directory import Exception -#if __GLASGOW_HASKELL__ >= 709 -import Foreign -#else -import Foreign.Safe -#endif {- ********************************************************************** @@ -85,22 +84,9 @@ library to side-effect the PLS and for those changes to be reflected here. The PersistentLinkerState maps Names to actual closures (for interpreted code only), for use during linking. -} -#if STAGE < 2 + GLOBAL_VAR_M(v_PersistentLinkerState, newMVar (panic "Dynamic linker not initialised"), MVar PersistentLinkerState) GLOBAL_VAR(v_InitLinkerDone, False, Bool) -- Set True when dynamic linker is initialised -#else -SHARED_GLOBAL_VAR_M( v_PersistentLinkerState - , getOrSetLibHSghcPersistentLinkerState - , "getOrSetLibHSghcPersistentLinkerState" - , newMVar (panic "Dynamic linker not initialised") - , MVar PersistentLinkerState) --- Set True when dynamic linker is initialised -SHARED_GLOBAL_VAR( v_InitLinkerDone - , getOrSetLibHSghcInitLinkerDone - , "getOrSetLibHSghcInitLinkerDone" - , False - , Bool) -#endif modifyPLS_ :: (PersistentLinkerState -> IO PersistentLinkerState) -> IO () modifyPLS_ f = readIORef v_PersistentLinkerState >>= flip modifyMVar_ f @@ -1442,3 +1428,17 @@ maybePutStr dflags s maybePutStrLn :: DynFlags -> String -> IO () maybePutStrLn dflags s = maybePutStr dflags (s ++ "\n") + +{- ********************************************************************** + + Tunneling global variables into new instance of GHC library + + ********************************************************************* -} + +saveLinkerGlobals :: IO (MVar PersistentLinkerState, Bool) +saveLinkerGlobals = liftM2 (,) (readIORef v_PersistentLinkerState) (readIORef v_InitLinkerDone) + +restoreLinkerGlobals :: (MVar PersistentLinkerState, Bool) -> IO () +restoreLinkerGlobals (pls, ild) = do + writeIORef v_PersistentLinkerState pls + writeIORef v_InitLinkerDone ild |
