summaryrefslogtreecommitdiff
path: root/libraries/base
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-02-02 14:41:41 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-05 19:12:01 -0500
commitfe789978453bfd4e5ff456a6be57fc8041664d75 (patch)
tree4be620f0225abd40ed292744cdeed6c17134b25c /libraries/base
parent003df39c8103823d8aac4b65f0e06cf49580f5e8 (diff)
downloadhaskell-fe789978453bfd4e5ff456a6be57fc8041664d75.tar.gz
IntVar: fix allocation size
As found by @phadej in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4740/diffs#note_327510 Also fix FastMutInt which allocating the size in bits instead of bytes.
Diffstat (limited to 'libraries/base')
-rw-r--r--libraries/base/GHC/Event/IntVar.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/libraries/base/GHC/Event/IntVar.hs b/libraries/base/GHC/Event/IntVar.hs
index f52deebd00..f973a34bfb 100644
--- a/libraries/base/GHC/Event/IntVar.hs
+++ b/libraries/base/GHC/Event/IntVar.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE Trustworthy #-}
+{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP, MagicHash, NoImplicitPrelude, UnboxedTuples #-}
module GHC.Event.IntVar
@@ -9,13 +10,15 @@ module GHC.Event.IntVar
) where
import GHC.Base
+import GHC.Bits
data IntVar = IntVar (MutableByteArray# RealWorld)
newIntVar :: Int -> IO IntVar
newIntVar n = do
+ let !(I# size) = finiteBitSize (0 :: Int) `unsafeShiftR` 3
iv <- IO $ \s ->
- case newByteArray# 1# s of
+ case newByteArray# size s of
(# s', mba #) -> (# s', IntVar mba #)
writeIntVar iv n
return iv