From 8008273439be481134e43f48e1c252f3b7a8c550 Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 1 May 2002 15:48:48 +0000 Subject: [PATCH] [project @ 2002-05-01 15:48:48 by simonmar] Clean up the code to load a dynamic library some more and hopefully make it work on Windows (untested). --- ghc/compiler/ghci/InteractiveUI.hs | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 5e3c444..d2a96fc 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,6 +1,6 @@ {-# OPTIONS -#include "Linker.h" -#include "SchedAPI.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.122 2002/05/01 15:46:15 simonmar Exp $ +-- $Id: InteractiveUI.hs,v 1.123 2002/05/01 15:48:48 simonmar Exp $ -- -- GHC Interactive User Interface -- @@ -1119,20 +1119,8 @@ locateOneObj (d:ds) lib -- Loading a dyanmic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32) #ifdef mingw32_TARGET_OS -loadDynamic paths rootname = do +loadDynamic paths rootname = addDLL rootname -- ignore paths on windows (why? --SDM) - maybe_errmsg <- addDLL rootname - if maybe_errmsg == nullPtr - then return Nothing - else do str <- peekCString maybe_errmsg - return (Just str) - -addDLL :: String -> String -> IO (Ptr CChar) -addDLL path lib = do - withCString path $ \c_path -> do - withCString lib $ \c_lib -> do - maybe_errmsg <- c_addDLL c_path c_lib - return maybe_errmsg #else @@ -1150,6 +1138,8 @@ loadDynamic [] rootname = do mkSOName root = "lib" ++ root ++ ".so" +#endif + addDLL :: String -> IO (Maybe String) addDLL str = do maybe_errmsg <- withCString str $ \dll -> c_addDLL dll @@ -1161,11 +1151,6 @@ addDLL str = do foreign import ccall "addDLL" unsafe c_addDLL :: CString -> IO CString -foreign import ccall "dlerror" unsafe - dlerror :: IO CString - -#endif - ----------------------------------------------------------------------------- -- timing & statistics -- 1.7.10.4