diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-12-06 17:08:06 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-12-06 17:08:06 +0100 |
commit | 078666f4399f368e2f3dd82b5081dc1ad9b9fdc2 (patch) | |
tree | 247882ab50a9e32a659aa513751f9e16ec310207 /System/Posix/DynamicLinker/Module.hsc | |
parent | 558b0fb4eaa4aebc823022b3e1d560da3faad658 (diff) |
`M-x untabify` && `M-x delete-trailing-whitespace`
Diffstat (limited to 'System/Posix/DynamicLinker/Module.hsc')
-rw-r--r-- | System/Posix/DynamicLinker/Module.hsc | 58 |
1 files changed, 29 insertions, 29 deletions
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 () |