diff --git a/ghc/lib/exts/IOExts.lhs b/ghc/lib/exts/IOExts.lhs index 1b65497a758a98966b6384a37ddb8129ddf9e93c..04f539d43a38c3ef1c506782f6038e4c7d68b4d3 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} +