\begin{code}
{-# OPTIONS -#include "Linker.h" #-}
+
+-- so that we can see defn of LEADING_UNDERSCORE
+#include "../includes/config.h"
+
module Linker (
initLinker, -- :: IO ()
loadObj, -- :: String -> IO ()
unloadObj, -- :: String -> IO ()
lookupSymbol, -- :: String -> IO (Maybe (Ptr a))
resolveObjs, -- :: IO ()
+ addDLL -- :: String -> IO (Ptr CChar)
) where
+import CTypes ( CChar )
import Foreign ( Ptr, nullPtr )
import PrelByteArr
import PrelPack (packString)
-- RTS Linker Interface
-- ---------------------------------------------------------------------------
-lookupSymbol str = do
+lookupSymbol str_in = do
+# ifdef LEADING_UNDERSCORE
+ let str = '_':str_in
+# else
+ let str = str_in
+# endif
addr <- c_lookupSymbol (packString str)
if addr == nullPtr
then return Nothing
then panic "resolveObjs: failed"
else return ()
+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}