diff options
Diffstat (limited to 'System/Posix/DynamicLinker')
-rw-r--r-- | System/Posix/DynamicLinker/ByteString.hsc | 14 | ||||
-rw-r--r-- | System/Posix/DynamicLinker/Common.hsc | 14 | ||||
-rw-r--r-- | System/Posix/DynamicLinker/Module.hsc | 58 | ||||
-rw-r--r-- | System/Posix/DynamicLinker/Module/ByteString.hsc | 28 | ||||
-rw-r--r-- | System/Posix/DynamicLinker/Prim.hsc | 12 |
5 files changed, 63 insertions, 63 deletions
diff --git a/System/Posix/DynamicLinker/ByteString.hsc b/System/Posix/DynamicLinker/ByteString.hsc index 2e9a6b0..b13c808 100644 --- a/System/Posix/DynamicLinker/ByteString.hsc +++ b/System/Posix/DynamicLinker/ByteString.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.DynamicLinker.ByteString -- Copyright : (c) Volker Stolz <vs@foldr.org> 2003 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -27,16 +27,16 @@ module System.Posix.DynamicLinker.ByteString ( -- Usage: -- ****** --- +-- -- Let's assume you want to open a local shared library \'foo\' (.\/libfoo.so) -- offering a function -- @char \* mogrify (char\*,int)@ -- and invoke @str = mogrify("test",1)@: --- --- +-- +-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun --- +-- -- withDL "libfoo.so" [RTLD_NOW] \$ \\ mod -> do -- funptr <- dlsym mod "mogrify" -- let fun = fun__ funptr @@ -44,7 +44,7 @@ module System.Posix.DynamicLinker.ByteString ( -- strptr <- fun str 1 -- strstr <- peekCString strptr -- ... --- +-- where @@ -54,7 +54,7 @@ import System.Posix.DynamicLinker.Prim #include "HsUnix.h" import Control.Exception ( bracket ) -import Control.Monad ( liftM ) +import Control.Monad ( liftM ) import Foreign import System.Posix.ByteString.FilePath diff --git a/System/Posix/DynamicLinker/Common.hsc b/System/Posix/DynamicLinker/Common.hsc index 8e1321d..ff36a28 100644 --- a/System/Posix/DynamicLinker/Common.hsc +++ b/System/Posix/DynamicLinker/Common.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.DynamicLinker.Common -- Copyright : (c) Volker Stolz <vs@foldr.org> 2003 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -27,16 +27,16 @@ module System.Posix.DynamicLinker.Common ( -- Usage: -- ****** --- +-- -- Let's assume you want to open a local shared library \'foo\' (.\/libfoo.so) -- offering a function -- @char \* mogrify (char\*,int)@ -- and invoke @str = mogrify("test",1)@: --- --- +-- +-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun --- +-- -- withDL "libfoo.so" [RTLD_NOW] \$ \\ mod -> do -- funptr <- dlsym mod "mogrify" -- let fun = fun__ funptr @@ -44,7 +44,7 @@ module System.Posix.DynamicLinker.Common ( -- strptr <- fun str 1 -- strstr <- peekCString strptr -- ... --- +-- where @@ -59,7 +59,7 @@ dlclose (DLHandle h) = throwDLErrorIf_ "dlclose" (/= 0) $ c_dlclose h dlclose h = error $ "dlclose: invalid argument" ++ (show h) dlerror :: IO String -dlerror = c_dlerror >>= peekCString +dlerror = c_dlerror >>= peekCString -- |'dlsym' returns the address binding of the symbol described in @symbol@, -- as it occurs in the shared object identified by @source@. diff --git a/System/Posix/DynamicLinker/Module.hsc b/System/Posix/DynamicLinker/Module.hsc index aa18d83..d971fa7 100644 --- a/System/Posix/DynamicLinker/Module.hsc +++ b/System/Posix/DynamicLinker/Module.hsc @@ -8,7 +8,7 @@ -- Module : System.Posix.DynamicLinker.Module -- Copyright : (c) Volker Stolz <vs@foldr.org> 2003 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -23,15 +23,15 @@ module System.Posix.DynamicLinker.Module ( -- Usage: -- ****** --- +-- -- Let's assume you want to open a local shared library 'foo' (./libfoo.so) -- offering a function -- char * mogrify (char*,int) -- and invoke str = mogrify("test",1): --- +-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun --- +-- -- withModule (Just ".") ("libfoo.so") [RTLD_NOW] $ \ mod -> do -- funptr <- moduleSymbol mod "mogrify" -- let fun = fun__ funptr @@ -45,16 +45,16 @@ module System.Posix.DynamicLinker.Module ( , moduleSymbol -- :: Source -> String -> IO (FunPtr a) , moduleClose -- :: Module -> IO Bool , moduleError -- :: IO String - , withModule -- :: Maybe String - -- -> String - -- -> [ModuleFlags ] - -- -> (Module -> IO a) - -- -> IO a - , withModule_ -- :: Maybe String - -- -> String - -- -> [ModuleFlags] - -- -> (Module -> IO a) - -- -> IO () + , withModule -- :: Maybe String + -- -> String + -- -> [ModuleFlags ] + -- -> (Module -> IO a) + -- -> IO a + , withModule_ -- :: Maybe String + -- -> String + -- -> [ModuleFlags] + -- -> (Module -> IO a) + -- -> IO () ) where @@ -84,38 +84,38 @@ moduleSymbol :: Module -> String -> IO (FunPtr a) moduleSymbol file sym = dlsym (DLHandle (unModule file)) sym -- Closes a module (EXPORTED) --- +-- moduleClose :: Module -> IO () moduleClose file = dlclose (DLHandle (unModule file)) -- Gets a string describing the last module error (EXPORTED) --- +-- moduleError :: IO String moduleError = dlerror -- Convenience function, cares for module open- & closing -- additionally returns status of `moduleClose' (EXPORTED) --- -withModule :: Maybe String - -> String - -> [RTLDFlags] - -> (Module -> IO a) - -> IO a +-- +withModule :: Maybe String + -> String + -> [RTLDFlags] + -> (Module -> IO a) + -> IO a withModule mdir file flags p = do let modPath = case mdir of Nothing -> file - Just dir -> dir ++ if ((head (reverse dir)) == '/') + Just dir -> dir ++ if ((head (reverse dir)) == '/') then file - else ('/':file) + else ('/':file) modu <- moduleOpen modPath flags result <- p modu moduleClose modu return result -withModule_ :: Maybe String - -> String - -> [RTLDFlags] - -> (Module -> IO a) - -> IO () +withModule_ :: Maybe String + -> String + -> [RTLDFlags] + -> (Module -> IO a) + -> IO () withModule_ dir file flags p = withModule dir file flags p >>= \ _ -> return () diff --git a/System/Posix/DynamicLinker/Module/ByteString.hsc b/System/Posix/DynamicLinker/Module/ByteString.hsc index dc0832a..325dae3 100644 --- a/System/Posix/DynamicLinker/Module/ByteString.hsc +++ b/System/Posix/DynamicLinker/Module/ByteString.hsc @@ -6,7 +6,7 @@ -- Module : System.Posix.DynamicLinker.Module.ByteString -- Copyright : (c) Volker Stolz <vs@foldr.org> 2003 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -21,15 +21,15 @@ module System.Posix.DynamicLinker.Module.ByteString ( -- Usage: -- ****** --- +-- -- Let's assume you want to open a local shared library 'foo' (./libfoo.so) -- offering a function -- char * mogrify (char*,int) -- and invoke str = mogrify("test",1): --- +-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun --- +-- -- withModule (Just ".") ("libfoo.so") [RTLD_NOW] $ \ mod -> do -- funptr <- moduleSymbol mod "mogrify" -- let fun = fun__ funptr @@ -43,16 +43,16 @@ module System.Posix.DynamicLinker.Module.ByteString ( , moduleSymbol -- :: Source -> String -> IO (FunPtr a) , moduleClose -- :: Module -> IO Bool , moduleError -- :: IO String - , withModule -- :: Maybe String - -- -> String - -- -> [ModuleFlags ] - -- -> (Module -> IO a) - -- -> IO a - , withModule_ -- :: Maybe String - -- -> String - -- -> [ModuleFlags] - -- -> (Module -> IO a) - -- -> IO () + , withModule -- :: Maybe String + -- -> String + -- -> [ModuleFlags ] + -- -> (Module -> IO a) + -- -> IO a + , withModule_ -- :: Maybe String + -- -> String + -- -> [ModuleFlags] + -- -> (Module -> IO a) + -- -> IO () ) where diff --git a/System/Posix/DynamicLinker/Prim.hsc b/System/Posix/DynamicLinker/Prim.hsc index 9e4dde7..e737918 100644 --- a/System/Posix/DynamicLinker/Prim.hsc +++ b/System/Posix/DynamicLinker/Prim.hsc @@ -9,7 +9,7 @@ -- Module : System.Posix.DynamicLinker.Prim -- Copyright : (c) Volker Stolz <vs@foldr.org> 2003 -- License : BSD-style (see the file libraries/base/LICENSE) --- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX) @@ -39,10 +39,10 @@ where #include "HsUnix.h" -import Data.Bits ( (.|.) ) -import Foreign.Ptr ( Ptr, FunPtr, nullPtr ) +import Data.Bits ( (.|.) ) +import Foreign.Ptr ( Ptr, FunPtr, nullPtr ) import Foreign.C.Types -import Foreign.C.String ( CString ) +import Foreign.C.String ( CString ) -- |On some hosts (e.g. SuSe and Ubuntu Linux) 'RTLD_NEXT' (and @@ -75,10 +75,10 @@ haveRtldLocal = True -- |Flags for 'System.Posix.DynamicLinker.dlopen'. -data RTLDFlags +data RTLDFlags = RTLD_LAZY | RTLD_NOW - | RTLD_GLOBAL + | RTLD_GLOBAL | RTLD_LOCAL deriving (Show, Read) |