Hoogle Search
Within LTS Haskell 24.52 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
unsafeForeignPtrToPtr :: ForeignPtr a -> Ptr aghc-internal GHC.Internal.Foreign.ForeignPtr.Unsafe This function extracts the pointer component of a foreign pointer. This is a potentially dangerous operations, as if the argument to unsafeForeignPtrToPtr is the last usage occurrence of the given foreign pointer, then its finalizer(s) will be run, which potentially invalidates the plain pointer just obtained. Hence, touchForeignPtr must be used wherever it has to be guaranteed that the pointer lives on - i.e., has another usage occurrence. To avoid subtle coding errors, hand written marshalling code should preferably use withForeignPtr rather than combinations of unsafeForeignPtrToPtr and touchForeignPtr. However, the latter routines are occasionally preferred in tool generated marshalling code.
PlainForeignPtr :: !IORef Finalizers -> ForeignPtrContentsghc-internal GHC.Internal.ForeignPtr The pointer refers to unmanaged memory that was allocated by a foreign function (typically using malloc). The finalizer frequently calls the C function free or some variant of it.
addForeignPtrConcFinalizer :: ForeignPtr a -> IO () -> IO ()ghc-internal GHC.Internal.ForeignPtr This function adds a finalizer to the given ForeignPtr. The finalizer will run before all other finalizers for the same object which have already been registered. This is a variant of addForeignPtrFinalizer, where the finalizer is an arbitrary IO action. When finalization is triggered by GC, the finalizer will run in a new thread. When finalization is triggered by explicitly calling finalizeForeignPtr, the finalizer will run immediately on the current Haskell thread. NB. Be very careful with these finalizers. One common trap is that if a finalizer references another finalized value, it does not prevent that value from being finalized. In particular, Handles are finalized objects, so a finalizer should not refer to a Handle (including stdout, stdin, or stderr).
addForeignPtrFinalizer :: FinalizerPtr a -> ForeignPtr a -> IO ()ghc-internal GHC.Internal.ForeignPtr This function adds a finalizer to the given foreign object. The finalizer will run before all other finalizers for the same object which have already been registered.
addForeignPtrFinalizerEnv :: FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()ghc-internal GHC.Internal.ForeignPtr Like addForeignPtrFinalizer but the finalizer is passed an additional environment parameter.
castForeignPtr :: ForeignPtr a -> ForeignPtr bghc-internal GHC.Internal.ForeignPtr This function casts a ForeignPtr parameterised by one type into another type.
finalizeForeignPtr :: ForeignPtr a -> IO ()ghc-internal GHC.Internal.ForeignPtr Causes the finalizers associated with a foreign pointer to be run immediately. The foreign pointer must not be used again after this function is called. If the foreign pointer does not support finalizers, this is a no-op.
mallocForeignPtr :: Storable a => IO (ForeignPtr a)ghc-internal GHC.Internal.ForeignPtr Allocate some memory and return a ForeignPtr to it. The memory will be released automatically when the ForeignPtr is discarded. mallocForeignPtr is equivalent to
do { p <- malloc; newForeignPtr finalizerFree p }although it may be implemented differently internally: you may not assume that the memory returned by mallocForeignPtr has been allocated with malloc. GHC notes: mallocForeignPtr has a heavily optimised implementation in GHC. It uses pinned memory in the garbage collected heap, so the ForeignPtr does not require a finalizer to free the memory. Use of mallocForeignPtr and associated functions is strongly recommended in preference to newForeignPtr with a finalizer.mallocForeignPtrAlignedBytes :: Int -> Int -> IO (ForeignPtr a)ghc-internal GHC.Internal.ForeignPtr This function is similar to mallocForeignPtrBytes, except that the size and alignment of the memory required is given explicitly as numbers of bytes.
mallocForeignPtrBytes :: Int -> IO (ForeignPtr a)ghc-internal GHC.Internal.ForeignPtr This function is similar to mallocForeignPtr, except that the size of the memory required is given explicitly as a number of bytes.