[project @ 2001-10-29 13:25:19 by simonmar]
[ghc-hetmet.git] / ghc / compiler / ghci / ByteCodeItbls.lhs
index 7a42b8d..6caac2f 100644 (file)
@@ -4,6 +4,9 @@
 \section[ByteCodeItbls]{Generate infotables for interpreter-made bytecodes}
 
 \begin{code}
+
+{-# OPTIONS -optc-DNON_POSIX_SOURCE #-}
+
 module ByteCodeItbls ( ItblEnv, ItblPtr, mkITbls ) where
 
 #include "HsVersions.h"
@@ -16,6 +19,7 @@ import TyCon          ( TyCon, tyConFamilySize, isDataTyCon, tyConDataCons )
 import Constants       ( mIN_SIZE_NonUpdHeapObject )
 import ClosureInfo     ( mkVirtHeapOffsets )
 import FastString      ( FastString(..) )
+import Util             ( lengthIs, listLengthCmp )
 
 import Foreign         ( Storable(..), Word8, Word16, Word32, Word64, Ptr(..), 
                          malloc, castPtr, plusPtr, Addr )
@@ -52,7 +56,7 @@ mkITbl :: TyCon -> IO ItblEnv
 mkITbl tc
    | not (isDataTyCon tc) 
    = return emptyFM
-   | n == length dcs  -- paranoia; this is an assertion.
+   | dcs `lengthIs` n -- paranoia; this is an assertion.
    = make_constr_itbls dcs
      where
         dcs = tyConDataCons tc
@@ -64,7 +68,7 @@ cONSTR = 1  -- as defined in ghc/includes/ClosureTypes.h
 -- Assumes constructors are numbered from zero, not one
 make_constr_itbls :: [DataCon] -> IO ItblEnv
 make_constr_itbls cons
-   | length cons <= 8
+   | listLengthCmp cons 8 /= GT -- <= 8 elements in the list
    = do is <- mapM mk_vecret_itbl (zip cons [0..])
        return (listToFM is)
    | otherwise