\begin{code}
{-# OPTIONS -#include "Linker.h" #-}
+
module Linker (
initLinker, -- :: IO ()
loadObj, -- :: String -> IO ()
unloadObj, -- :: String -> IO ()
lookupSymbol, -- :: String -> IO (Maybe (Ptr a))
- resolveObjs, -- :: IO ()
+ resolveObjs, -- :: IO Bool
+ addDLL -- :: String -> IO (Ptr CChar)
) where
+import CTypes ( CChar )
import Foreign ( Ptr, nullPtr )
import PrelByteArr
import PrelPack (packString)
import Panic ( panic )
+import DriverUtil ( prefixUnderscore )
-- ---------------------------------------------------------------------------
-- RTS Linker Interface
-- ---------------------------------------------------------------------------
-lookupSymbol str = do
+lookupSymbol str_in = do
+ let str = prefixUnderscore str_in
addr <- c_lookupSymbol (packString str)
if addr == nullPtr
then return Nothing
resolveObjs = do
r <- c_resolveObjs
- if (r == 0)
- then panic "resolveObjs: failed"
- else return ()
+ return (r /= 0) -- returns True <=> success
+addDLL path lib = do
+ maybe_errmsg <- c_addDLL (packString path) (packString lib)
+ return maybe_errmsg
type PackedString = ByteArray Int
foreign import "initLinker" unsafe
initLinker :: IO ()
+
+foreign import "addDLL" unsafe
+ c_addDLL :: PackedString -> PackedString -> IO (Ptr CChar)
\end{code}