llvm-extra- Utility functions for the llvm interface




newInit :: FunPtr (Ptr a -> IO ()) -> FunPtr (IO (Ptr a)) -> IO (ForeignPtr a)Source

newParam :: (Storable b, MakeValueTuple b bl, C bl bp) => FunPtr (Ptr a -> IO ()) -> FunPtr (Ptr bp -> IO (Ptr a)) -> b -> IO (ForeignPtr a)Source

new :: Storable a => IO () -> a -> IO (ForeignPtr a)Source

Adding the finalizer to a ForeignPtr seems to be the only way that warrants execution of the finalizer (not too early and not never). However, the normal ForeignPtr finalizers must be independent from Haskell runtime. In contrast to ForeignPtr finalizers, addFinalizer adds finalizers to boxes, that are optimized away. Thus finalizers are run too early or not at all. Concurrent.ForeignPtr and using threaded execution is the only way to get finalizers in Haskell IO.

with :: (Storable a, MakeValueTuple a al, C al ap) => ForeignPtr a -> (Ptr ap -> IO b) -> IO bSource