llvm-extra-0.6.0.2: Utility functions for the llvm interface

Safe HaskellNone

LLVM.Extra.ForeignPtr

Description

Deprecated: It does not really belong here. Its functionality was moved to synthesizer-llvm.

Synopsis

Documentation

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

newParam :: (Storable b, MakeValueTuple b, C (ValueTuple b)) => FunPtr (Ptr a -> IO ()) -> FunPtr (Ptr (Struct (ValueTuple b)) -> 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, C (ValueTuple a)) => ForeignPtr a -> (Ptr (Struct (ValueTuple a)) -> IO b) -> IO bSource