diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-03-10 13:20:49 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2021-03-10 13:20:49 -0500 |
commit | e6c9b1e6ddd82fab47207ff17efeabdf0deb6fc7 (patch) | |
tree | 0564b3db9fa8d65018a07fafc6ac1877ce122787 /compiler/GHC/Utils | |
parent | 7d212b4912edbf388e9d54a19fb3a3bffc9ec5c0 (diff) | |
download | haskell-e6c9b1e6ddd82fab47207ff17efeabdf0deb6fc7.tar.gz |
FastMutInt: Ensure that newFastMutInt initializes value
Updates haddock submodule.
Diffstat (limited to 'compiler/GHC/Utils')
-rw-r--r-- | compiler/GHC/Utils/Binary.hs | 20 | ||||
-rw-r--r-- | compiler/GHC/Utils/BufHandle.hs | 3 |
2 files changed, 8 insertions, 15 deletions
diff --git a/compiler/GHC/Utils/Binary.hs b/compiler/GHC/Utils/Binary.hs index 5ee0806cc1..a925b0a999 100644 --- a/compiler/GHC/Utils/Binary.hs +++ b/compiler/GHC/Utils/Binary.hs @@ -134,10 +134,8 @@ instance Binary BinData where dataHandle :: BinData -> IO BinHandle dataHandle (BinData size bin) = do - ixr <- newFastMutInt - szr <- newFastMutInt - writeFastMutInt ixr 0 - writeFastMutInt szr size + ixr <- newFastMutInt 0 + szr <- newFastMutInt size binr <- newIORef bin return (BinMem noUserData ixr szr binr) @@ -215,10 +213,8 @@ openBinMem size | otherwise = do arr <- mallocForeignPtrBytes size arr_r <- newIORef arr - ix_r <- newFastMutInt - writeFastMutInt ix_r 0 - sz_r <- newFastMutInt - writeFastMutInt sz_r size + ix_r <- newFastMutInt 0 + sz_r <- newFastMutInt size return (BinMem noUserData ix_r sz_r arr_r) tellBin :: BinHandle -> IO (Bin a) @@ -251,10 +247,8 @@ readBinMem filename = do error ("Binary.readBinMem: only read " ++ show count ++ " bytes") hClose h arr_r <- newIORef arr - ix_r <- newFastMutInt - writeFastMutInt ix_r 0 - sz_r <- newFastMutInt - writeFastMutInt sz_r filesize + ix_r <- newFastMutInt 0 + sz_r <- newFastMutInt filesize return (BinMem noUserData ix_r sz_r arr_r) -- expand the size of the array to include a specified offset @@ -896,7 +890,7 @@ lazyGet bh = do a <- unsafeInterleaveIO $ do -- NB: Use a fresh off_r variable in the child thread, for thread -- safety. - off_r <- newFastMutInt + off_r <- newFastMutInt 0 getAt bh { _off_r = off_r } p_a seekBin bh p -- skip over the object for now return a diff --git a/compiler/GHC/Utils/BufHandle.hs b/compiler/GHC/Utils/BufHandle.hs index b0b829f96f..aed15610cb 100644 --- a/compiler/GHC/Utils/BufHandle.hs +++ b/compiler/GHC/Utils/BufHandle.hs @@ -46,8 +46,7 @@ data BufHandle = BufHandle {-#UNPACK#-}!(Ptr Word8) newBufHandle :: Handle -> IO BufHandle newBufHandle hdl = do ptr <- mallocBytes buf_size - r <- newFastMutInt - writeFastMutInt r 0 + r <- newFastMutInt 0 return (BufHandle ptr r hdl) buf_size :: Int |