2 % (c) The University of Glasgow 2001-2008
5 ByteCodeGen: Generate machine-code sequences for foreign import
8 module ByteCodeFFI ( moan64, newExec ) where
15 moan64 :: String -> SDoc -> a
19 "\nGHCi's bytecode generation machinery can't handle 64-bit\n" ++
20 "code properly yet. You can work around this for the time being\n" ++
21 "by compiling this module and all those it imports to object code,\n" ++
22 "and re-starting your GHCi session. The panic below contains information,\n" ++
23 "intended for the GHC implementors, about the exact place where GHC gave up.\n"
29 newExec :: Storable a => [a] -> IO (FunPtr ())
31 = do ptr <- _allocateExec (fromIntegral $ codeSize undefined code)
33 return (castPtrToFunPtr ptr)
35 codeSize :: Storable a => a -> [a] -> Int
36 codeSize dummy array = sizeOf(dummy) * length array
38 foreign import ccall unsafe "allocateExec"
39 _allocateExec :: CUInt -> IO (Ptr a)