summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Tennie <sven.tennie@gmail.com>2020-10-31 13:32:38 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-09-23 15:59:38 -0400
commit022d9717d06542c2345e27ef018390a9d034a1f1 (patch)
treea09d409906ffafc2cea1ce6501f9464e575831f8
parent69b35afd2e11a1cac93e803d6da00c1760b9fa3b (diff)
downloadhaskell-022d9717d06542c2345e27ef018390a9d034a1f1.tar.gz
base: Generalize newStablePtrPrimMVar
Make it polymorphic in the type of the MVar's value. This simple generalization makes it usable for `MVar a` instead of only `MVar ()` values.
-rw-r--r--libraries/base/GHC/Conc/Sync.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/libraries/base/GHC/Conc/Sync.hs b/libraries/base/GHC/Conc/Sync.hs
index c51afb9d83..8bab43b966 100644
--- a/libraries/base/GHC/Conc/Sync.hs
+++ b/libraries/base/GHC/Conc/Sync.hs
@@ -624,10 +624,10 @@ data PrimMVar
-- @hs_try_putmvar()@. The RTS wants a 'StablePtr' to the underlying
-- 'MVar#', but a 'StablePtr#' can only refer to lifted types, so we
-- have to cheat by coercing.
-newStablePtrPrimMVar :: MVar () -> IO (StablePtr PrimMVar)
+newStablePtrPrimMVar :: MVar a -> IO (StablePtr PrimMVar)
newStablePtrPrimMVar (MVar m) = IO $ \s0 ->
case makeStablePtr# (unsafeCoerce# m :: PrimMVar) s0 of
- -- Coerce unlifted m :: MVar# RealWorld ()
+ -- Coerce unlifted m :: MVar# RealWorld a
-- to lifted PrimMVar
-- apparently because mkStablePtr is not representation-polymorphic
(# s1, sp #) -> (# s1, StablePtr sp #)