{-# LINE 1 "libraries/unix/System/Posix/DynamicLinker/ByteString.hsc" #-}
{-# LINE 2 "libraries/unix/System/Posix/DynamicLinker/ByteString.hsc" #-}
{-# LANGUAGE Safe #-}
{-# LINE 6 "libraries/unix/System/Posix/DynamicLinker/ByteString.hsc" #-}
module System.Posix.DynamicLinker.ByteString (
    module System.Posix.DynamicLinker.Prim,
    dlopen,
    dlsym,
    dlerror,
    dlclose,
    withDL, withDL_,
    undl,
    )
where
import System.Posix.DynamicLinker.Common
import System.Posix.DynamicLinker.Prim
import Control.Exception        ( bracket )
import Control.Monad    ( liftM )
import Foreign
import System.Posix.ByteString.FilePath
dlopen :: RawFilePath -> [RTLDFlags] -> IO DL
dlopen path flags = do
  withFilePath path $ \ p -> do
    liftM DLHandle $ throwDLErrorIf "dlopen" (== nullPtr) $ c_dlopen p (packRTLDFlags flags)
withDL :: RawFilePath -> [RTLDFlags] -> (DL -> IO a) -> IO a
withDL file flags f = bracket (dlopen file flags) (dlclose) f
withDL_ :: RawFilePath -> [RTLDFlags] -> (DL -> IO a) -> IO ()
withDL_ file flags f = withDL file flags f >> return ()