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