[project @ 1999-04-12 18:32:17 by sof]
authorsof <unknown>
Mon, 12 Apr 1999 18:32:17 +0000 (18:32 +0000)
committersof <unknown>
Mon, 12 Apr 1999 18:32:17 +0000 (18:32 +0000)
Added Haskell wrapper for freeHaskellFunctionPtr()

ghc/lib/exts/IOExts.lhs

index 1b65497..04f539d 100644 (file)
@@ -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}
+