summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2009-10-14 13:06:12 +0000
committerSimon Marlow <marlowsd@gmail.com>2009-10-14 13:06:12 +0000
commit79e9cfa32cc3b94428e1199ce550bb62c50bf8e6 (patch)
tree1304c1a2fe909f8ac3fc35963e6f8345bceeb8fc /includes
parent2354f96975dc845b1c62b4c72d770be4b638ebba (diff)
downloadhaskell-79e9cfa32cc3b94428e1199ce550bb62c50bf8e6.tar.gz
Fixes for cross-compiling to a different word size
This patch eliminates a couple of places where we were assuming that the host word size is the same as the target word size. Also a little refactoring: Constants now exports the types TargetInt and TargetWord corresponding to the Int/Word type on the target platform, and I moved the definitions of tARGET_INT_MAX and friends from Literal to Constants. Thanks to Barney Stratford <barney_stratford@fastmail.fm> for helping track down the problem and fix it. We now know that GHC can successfully cross-compile from 32-bit to 64-bit.
Diffstat (limited to 'includes')
-rw-r--r--includes/HaskellConstants.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/includes/HaskellConstants.hs b/includes/HaskellConstants.hs
index 666728ccd8..1c1bb4891a 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