aboutsummaryrefslogtreecommitdiffhomepage
path: root/System/Posix/DynamicLinker.hsc
diff options
context:
space:
mode:
authorGravatar Max Bolingbroke <batterseapower@hotmail.com>2011-05-14 22:45:27 +0100
committerGravatar Max Bolingbroke <batterseapower@hotmail.com>2011-05-14 22:45:27 +0100
commitbb8a27d14a63fcd126a924d32c69b7694ea709d9 (patch)
treefc8fd365f738a6f77bc31a96efd470fbf2bd51dc /System/Posix/DynamicLinker.hsc
parentb7b180d23472dca03fb4c809cd86bcd6d3f01ea9 (diff)
Improved Unicode support in the light of PEP383
Diffstat (limited to 'System/Posix/DynamicLinker.hsc')
-rw-r--r--System/Posix/DynamicLinker.hsc16
1 files changed, 11 insertions, 5 deletions
diff --git a/System/Posix/DynamicLinker.hsc b/System/Posix/DynamicLinker.hsc
index 1aa897b..418ce39 100644
--- a/System/Posix/DynamicLinker.hsc
+++ b/System/Posix/DynamicLinker.hsc
@@ -51,11 +51,17 @@ import System.Posix.DynamicLinker.Prim
import Control.Exception ( bracket )
import Control.Monad ( liftM )
import Foreign.Ptr ( Ptr, nullPtr, FunPtr, nullFunPtr )
-import Foreign.C.String ( withCString, peekCString )
-
-dlopen :: String -> [RTLDFlags] -> IO DL
+import Foreign.C.String
+#if __GLASGOW_HASKELL__ > 611
+import System.Posix.Internals ( withFilePath )
+#else
+withFilePath :: FilePath -> (CString -> IO a) -> IO a
+withFilePath = withCString
+#endif
+
+dlopen :: FilePath -> [RTLDFlags] -> IO DL
dlopen path flags = do
- withCString path $ \ p -> do
+ withFilePath path $ \ p -> do
liftM DLHandle $ throwDLErrorIf "dlopen" (== nullPtr) $ c_dlopen p (packRTLDFlags flags)
dlclose :: DL -> IO ()
@@ -70,7 +76,7 @@ dlerror = c_dlerror >>= peekCString
dlsym :: DL -> String -> IO (FunPtr a)
dlsym source symbol = do
- withCString symbol $ \ s -> do
+ withCAString symbol $ \ s -> do
throwDLErrorIf "dlsym" (== nullFunPtr) $ c_dlsym (packDL source) s
withDL :: String -> [RTLDFlags] -> (DL -> IO a) -> IO a