module GHC.RTS.Flags.Utils where
import Data.Bits
import Data.Word
import Foreign.Ptr
import Foreign.Storable
import GHC.RTS.Flags (RTSFlags)
foreign import ccall "&RtsFlags" rtsFlagsPtr :: Ptr RTSFlags
rtsBlockShift :: Int
rtsBlockShift :: Int
rtsBlockShift = Int
12
rtsBlockSize :: Word32
rtsBlockSize :: Word32
rtsBlockSize = Word32
1 Word32 -> Int -> Word32
forall a. Bits a => a -> Int -> a
.<<. Int
rtsBlockShift
setRTSOptsM :: Word32 -> IO ()
setRTSOptsM :: Word32 -> IO ()
setRTSOptsM Word32
m = Ptr RTSFlags -> Int -> Word32 -> IO ()
forall b. Ptr b -> Int -> Word32 -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr RTSFlags
rtsFlagsPtr Int
28 (Word32 -> IO ()) -> Word32 -> IO ()
forall a b. (a -> b) -> a -> b
$ Word32 -> Word32 -> Word32
forall a. Integral a => a -> a -> a
div Word32
m Word32
rtsBlockSize
setRTSOptsA :: Word32 -> IO ()
setRTSOptsA :: Word32 -> IO ()
setRTSOptsA Word32
a = Ptr RTSFlags -> Int -> Word32 -> IO ()
forall b. Ptr b -> Int -> Word32 -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr RTSFlags
rtsFlagsPtr Int
32 (Word32 -> IO ()) -> Word32 -> IO ()
forall a b. (a -> b) -> a -> b
$ Word32 -> Word32 -> Word32
forall a. Integral a => a -> a -> a
div Word32
a Word32
rtsBlockSize
setRTSOptsH :: Word32 -> IO ()
setRTSOptsH :: Word32 -> IO ()
setRTSOptsH Word32
h = Ptr RTSFlags -> Int -> Word32 -> IO ()
forall b. Ptr b -> Int -> Word32 -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
pokeByteOff Ptr RTSFlags
rtsFlagsPtr Int
48 (Word32 -> IO ()) -> Word32 -> IO ()
forall a b. (a -> b) -> a -> b
$ Word32 -> Word32 -> Word32
forall a. Integral a => a -> a -> a
div Word32
h Word32
rtsBlockSize