3 -- (c) The University of Glasgow 2002-2006
5 -- Unboxed mutable Ints
9 FastMutInt, newFastMutInt,
10 readFastMutInt, writeFastMutInt
16 #define SIZEOF_HSINT INT_SIZE_IN_BYTES
23 #if __GLASGOW_HASKELL__ < 411
24 newByteArray# = newCharArray#
29 #ifdef __GLASGOW_HASKELL__
30 data FastMutInt = FastMutInt (MutableByteArray# RealWorld)
32 newFastMutInt :: IO FastMutInt
33 newFastMutInt = IO $ \s ->
34 case newByteArray# size s of { (# s, arr #) ->
35 (# s, FastMutInt arr #) }
36 where I# size = SIZEOF_HSINT
38 readFastMutInt :: FastMutInt -> IO Int
39 readFastMutInt (FastMutInt arr) = IO $ \s ->
40 case readIntArray# arr 0# s of { (# s, i #) ->
43 writeFastMutInt :: FastMutInt -> Int -> IO ()
44 writeFastMutInt (FastMutInt arr) (I# i) = IO $ \s ->
45 case writeIntArray# arr 0# i s of { s ->