From: sof Date: Mon, 12 Apr 1999 18:32:17 +0000 (+0000) Subject: [project @ 1999-04-12 18:32:17 by sof] X-Git-Tag: Approximately_9120_patches~6324 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=226b50628defd1795cca5b5b476aba55dccfb227;p=ghc-hetmet.git [project @ 1999-04-12 18:32:17 by sof] Added Haskell wrapper for freeHaskellFunctionPtr() --- diff --git a/ghc/lib/exts/IOExts.lhs b/ghc/lib/exts/IOExts.lhs index 1b65497..04f539d 100644 --- a/ghc/lib/exts/IOExts.lhs +++ b/ghc/lib/exts/IOExts.lhs @@ -52,6 +52,8 @@ module IOExts #endif , unsafePtrEq + + , freeHaskellFunctionPtr ) where @@ -73,6 +75,7 @@ import PrelGHC import PrelHandle import PrelErr import IO ( hPutStr, hPutChar ) +import PrelAddr ( Addr ) #endif import Ix @@ -184,3 +187,18 @@ performGC = _ccall_GC_ performGC #endif \end{code} +When using 'foreign export dynamic' to dress up a Haskell +IO action to look like a C function pointer, a little bit +of memory is allocated (along with a stable pointer to +the Haskell IO action). When done with the C function +pointer, you'll need to call @freeHaskellFunctionPtr()@ to +let go of these resources - here's the Haskell wrapper for +that RTS entry point, should you want to free it from +within Haskell. + +\begin{code} +foreign import ccall "freeHaskellFunctionPtr" + freeHaskellFunctionPtr :: Addr -> IO () + +\end{code} +