-
-newExec :: Storable a => [a] -> IO (FunPtr ())
-newExec code
- = alloca $ \pcode -> do
- ptr <- _allocateExec (fromIntegral $ codeSize undefined code) pcode
- pokeArray ptr code
- code <- peek pcode
- return (castPtrToFunPtr code)
- where
- codeSize :: Storable a => a -> [a] -> Int
- codeSize dummy array = sizeOf(dummy) * length array
-
-foreign import ccall unsafe "allocateExec"
- _allocateExec :: CUInt -> Ptr (Ptr a) -> IO (Ptr a)