[add header at beginning of program to assert the architecture we are compiling on is compatable with assumptions made during compilation
John Meacham <john@repetae.net>**20070524041622] hunk ./C/FromGrin2.hs 6
+import System.IO.Unsafe
hunk ./C/FromGrin2.hs 11
+import Text.Printf
hunk ./C/FromGrin2.hs 26
+import Grin.Show()
hunk ./C/FromGrin2.hs 28
-import Grin.Show
hunk ./C/FromGrin2.hs 32
-import Support.Tuple
hunk ./C/FromGrin2.hs 42
-type Structure = (Name,[(Name,Type)])
hunk ./C/FromGrin2.hs 83
-compileGrin grin = (hsffi_h ++ jhc_rts_header_h ++ jhc_rts_alloc_c ++ jhc_rts_c ++ jhc_rts2_c ++ P.render ans ++ "\n", snub (reqLibraries req))  where
+compileGrin grin = (hsffi_h ++ jhc_rts_header_h ++ jhc_rts_alloc_c ++ jhc_rts_c ++ jhc_rts2_c ++ generateArchAssertions ++ P.render ans ++ "\n", snub (reqLibraries req))  where
hunk ./C/FromGrin2.hs 105
-convertFunc ffie (n,Tup as :-> body) = do
+convertFunc ffie (n,~(Tup as) :-> body) = do
hunk ./C/FromGrin2.hs 114
-                Just (FfiExport cn Safe CCall) -> name cn
+                Just ~(FfiExport cn Safe CCall) -> name cn
hunk ./C/FromGrin2.hs 249
-                needed (Var v _) = v `Set.member` fve
+                needed ~(Var v _) = v `Set.member` fve
hunk ./C/FromGrin2.hs 308
-        da (Tup [x] :-> e) = da ( x :-> e )
+        da (~(Tup [x]) :-> e) = da ( x :-> e )
hunk ./C/FromGrin2.hs 345
-convertBody (e :>>= Tup xs :-> e') = do
+convertBody (e :>>= ~(Tup xs) :-> e') = do
hunk ./C/FromGrin2.hs 578
-newNode ty (NodeC t as) = do
+newNode ty ~(NodeC t as) = do
hunk ./C/FromGrin2.hs 612
-        fields = (tag ++ zip [ name $ 'a':show i | i <-  [1 ..] ] ts')
+        fields = (tag ++ zip [ name $ 'a':show i | i <-  [(1 :: Int) ..] ] ts')
hunk ./C/FromGrin2.hs 635
-        body = rvar =* functionCall (toName (show $ fn)) [ project' (arg i) (variable aname) | _ <- ts | i <- [1 .. ] ]
+        body = rvar =* functionCall (toName (show $ fn)) [ project' (arg i) (variable aname) | _ <- ts | i <- [(1 :: Int) .. ] ]
hunk ./C/FromGrin2.hs 774
+generateArchAssertions :: String
+generateArchAssertions = unlines (h:map f (filter notVoid as) ++ [t]) where
+    (_,_,as,_) = unsafePerformIO determineArch
+    notVoid pt = primTypeName pt /= "void"
+    f pt = printf "      assert(sizeof(%s) == %d);" (primTypeName pt) (primTypeSizeOf pt)
+    h = "static void\njhc_arch_assert(void)\n{"
+    t = "}"
+
hunk ./data/jhc_rts.c 3
+static void jhc_arch_assert(void);
hunk ./data/jhc_rts.c 96
+        jhc_arch_assert();