Commit 30d8d383 authored by simonmar's avatar simonmar
Browse files

[project @ 2005-03-07 15:59:27 by simonmar]

Include WORD_SIZE_IN_BITS in the interface header, and test it when
reading.  Fixes a problem whereby GHC on a 64-bit platform will crash
if it tries to read an interface file generated by the same version of
GHC on a 32-bit platform.
parent bcacf0b7
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
module BinIface ( writeBinIface, readBinIface, v_IgnoreHiWay ) where module BinIface ( writeBinIface, readBinIface, v_IgnoreHiWay ) where
#include "HsVersions.h" #include "HsVersions.h"
#include "MachDeps.h"
import HscTypes import HscTypes
import BasicTypes import BasicTypes
...@@ -25,12 +26,11 @@ import Binary ...@@ -25,12 +26,11 @@ import Binary
import Util import Util
import DATA_IOREF import DATA_IOREF
import DATA_WORD ( Word8 )
import EXCEPTION ( throwDyn ) import EXCEPTION ( throwDyn )
import Monad ( when ) import Monad ( when )
import Outputable import Outputable
#include "HsVersions.h"
-- --------------------------------------------------------------------------- -- ---------------------------------------------------------------------------
writeBinIface :: FilePath -> ModIface -> IO () writeBinIface :: FilePath -> ModIface -> IO ()
writeBinIface hi_path mod_iface writeBinIface hi_path mod_iface
...@@ -111,6 +111,7 @@ instance Binary ModIface where ...@@ -111,6 +111,7 @@ instance Binary ModIface where
put_ bh (show opt_HiVersion) put_ bh (show opt_HiVersion)
build_tag <- readIORef v_Build_tag build_tag <- readIORef v_Build_tag
put bh build_tag put bh build_tag
put_ bh (WORD_SIZE_IN_BITS :: Word8)
put_ bh mod put_ bh mod
put_ bh is_boot put_ bh is_boot
put_ bh mod_vers put_ bh mod_vers
...@@ -146,6 +147,15 @@ instance Binary ModIface where ...@@ -146,6 +147,15 @@ instance Binary ModIface where
"mismatched interface file ways: expected " "mismatched interface file ways: expected "
++ build_tag ++ ", found " ++ check_way)) ++ build_tag ++ ", found " ++ check_way))
check_ws <- get bh
let our_ws = WORD_SIZE_IN_BITS :: Word8
when (check_ws /= our_ws) $
-- use userError because this will be caught by readIface
-- which will emit an error msg containing the iface module name.
throwDyn (ProgramError (
"mismatched word size: expected "
++ show our_ws ++ ", found " ++ show check_ws))
mod_name <- get bh mod_name <- get bh
is_boot <- get bh is_boot <- get bh
mod_vers <- get bh mod_vers <- get bh
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment