1-- | Platform-specific dynamic linking support. Add new platforms to this file
2-- through conditional compilation.
3{-# LANGUAGE ExistentialQuantification, CPP #-}
4module Util.DynamicLinker where
7import Foreign.Ptr (nullPtr, FunPtr, nullFunPtr)
8import System.Posix.DynamicLinker
10hostDynamicLibExt :: String
12hostDynamicLibExt = "so"
14hostDynamicLibExt = "dylib"
16hostDynamicLibExt = "dll"
19data DynamicLib = Lib { lib_name :: String
23tryLoadLib :: String -> IO (Maybe DynamicLib)
24tryLoadLib lib = do handle <- dlopen (lib ++ "." ++ hostDynamicLibExt) [RTLD_NOW]
25 if undl handle == nullPtr
27 else return . Just $ Lib lib handle
29data ForeignFun = forall a. Fun { fun_name :: String
30 , fun_handle :: FunPtr a
33tryLoadFn :: String -> DynamicLib -> IO (Maybe ForeignFun)
34tryLoadFn fn (Lib _ h) = do cFn <- dlsym h fn
37 else return . Just $ Fun fn cFn
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list