\begin{code}
{-# OPTIONS -#include "Linker.h" #-}
module Linker (
+ initLinker, -- :: IO ()
loadObj, -- :: String -> IO ()
unloadObj, -- :: String -> IO ()
- lookupSymbol, -- :: String -> IO (Maybe Addr)
+ lookupSymbol, -- :: String -> IO (Maybe (Ptr a))
resolveObjs, -- :: IO ()
+ addDLL -- :: String -> IO Bool
) where
-import Addr
+import Foreign ( Ptr, nullPtr )
import PrelByteArr
import PrelPack (packString)
import Panic ( panic )
lookupSymbol str = do
addr <- c_lookupSymbol (packString str)
- if addr == nullAddr
+ if addr == nullPtr
then return Nothing
else return (Just addr)
then panic "resolveObjs: failed"
else return ()
+addDLL str = do
+ r <- c_addDLL (packString str)
+ return (r == 0)
type PackedString = ByteArray Int
foreign import "lookupSymbol" unsafe
- c_lookupSymbol :: PackedString -> IO Addr
+ c_lookupSymbol :: PackedString -> IO (Ptr a)
foreign import "loadObj" unsafe
c_loadObj :: PackedString -> IO Int
foreign import "resolveObjs" unsafe
c_resolveObjs :: IO Int
+
+foreign import "initLinker" unsafe
+ initLinker :: IO ()
+
+foreign import "addDLL" unsafe
+ c_addDLL :: PackedString -> IO Int
+
\end{code}