X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=includes%2FHaskellConstants.hs;h=1c1bb4891a2fda950466320d8a975ef4563d2e31;hb=f9d15f9fccae4706fbdf8ee4ecaef7da9953cb74;hp=666728ccd8073842a99d9357b9d4e68e81e8efe3;hpb=a1d8f7e9ead3ea284abf878ed3015a84eb5d67fb;p=ghc-hetmet.git diff --git a/includes/HaskellConstants.hs b/includes/HaskellConstants.hs index 666728c..1c1bb48 100644 --- a/includes/HaskellConstants.hs +++ b/includes/HaskellConstants.hs @@ -1,5 +1,7 @@ import Data.Bits (shiftL) +import Data.Word +import Data.Int -- This magical #include brings in all the everybody-knows-these magic -- constants unfortunately, we need to be *explicit* about which one @@ -135,6 +137,26 @@ wORD_SIZE = SIZEOF_HSWORD wORD_SIZE_IN_BITS :: Int wORD_SIZE_IN_BITS = wORD_SIZE * 8 +-- Define a fixed-range integral type equivalent to the target Int/Word + +#if SIZEOF_HSWORD == 4 +type TargetInt = Int32 +type TargetWord = Word32 +#elif SIZEOF_HSWORD == 8 +type TargetInt = Int64 +type TargetWord = Word64 +#else +#error unknown SIZEOF_HSWORD +#endif + +tARGET_MIN_INT, tARGET_MAX_INT, tARGET_MAX_WORD :: Integer +tARGET_MIN_INT = fromIntegral (minBound :: TargetInt) +tARGET_MAX_INT = fromIntegral (maxBound :: TargetInt) +tARGET_MAX_WORD = fromIntegral (maxBound :: TargetWord) + +tARGET_MAX_CHAR :: Int +tARGET_MAX_CHAR = 0x10ffff + -- Amount of pointer bits used for semi-tagging constructor closures tAG_BITS :: Int