diff --git a/System/Posix/DynamicLinker/Prim.hsc b/System/Posix/DynamicLinker/Prim.hsc index 7b0d736f..29e6eca8 100644 --- a/System/Posix/DynamicLinker/Prim.hsc +++ b/System/Posix/DynamicLinker/Prim.hsc @@ -1,3 +1,4 @@ +{-# LANGUAGE CApiFFI #-} {-# LANGUAGE Trustworthy #-} {-# OPTIONS_GHC -Wno-trustworthy-safe #-} @@ -84,10 +85,17 @@ data RTLDFlags | RTLD_LOCAL deriving (Show, Read) -foreign import ccall unsafe "dlopen" c_dlopen :: CString -> CInt -> IO (Ptr ()) +#if defined(HAVE_DLFCN_H) +foreign import capi safe "dlfcn.h dlopen" c_dlopen :: CString -> CInt -> IO (Ptr ()) +foreign import capi unsafe "dlfcn.h dlsym" c_dlsym :: Ptr () -> CString -> IO (FunPtr a) +foreign import capi unsafe "dlfcn.h dlerror" c_dlerror :: IO CString +foreign import capi safe "dlfcn.h dlclose" c_dlclose :: (Ptr ()) -> IO CInt +#else +foreign import ccall safe "dlopen" c_dlopen :: CString -> CInt -> IO (Ptr ()) foreign import ccall unsafe "dlsym" c_dlsym :: Ptr () -> CString -> IO (FunPtr a) foreign import ccall unsafe "dlerror" c_dlerror :: IO CString -foreign import ccall unsafe "dlclose" c_dlclose :: (Ptr ()) -> IO CInt +foreign import ccall safe "dlclose" c_dlclose :: (Ptr ()) -> IO CInt +#endif // HAVE_DLFCN_H packRTLDFlags :: [RTLDFlags] -> CInt packRTLDFlags flags = foldl (\ s f -> (packRTLDFlag f) .|. s) 0 flags diff --git a/System/Posix/Files/Common.hsc b/System/Posix/Files/Common.hsc index 5dce50c1..7aef5cef 100644 --- a/System/Posix/Files/Common.hsc +++ b/System/Posix/Files/Common.hsc @@ -1,3 +1,4 @@ +{-# LANGUAGE CApiFFI #-} {-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- @@ -452,12 +453,12 @@ toCTimeSpec t = CTimeSpec (CTime sec) (truncate $ 10^(9::Int) * frac) #endif #ifdef HAVE_UTIMENSAT -foreign import ccall unsafe "utimensat" +foreign import capi unsafe "sys/stat.h utimensat" c_utimensat :: CInt -> CString -> Ptr CTimeSpec -> CInt -> IO CInt #endif #if HAVE_FUTIMENS -foreign import ccall unsafe "futimens" +foreign import capi unsafe "sys/stat.h futimens" c_futimens :: CInt -> Ptr CTimeSpec -> IO CInt #endif @@ -480,16 +481,16 @@ toCTimeVal t = CTimeVal sec (truncate $ 10^(6::Int) * frac) (sec, frac) = if (frac' < 0) then (sec' - 1, frac' + 1) else (sec', frac') (sec', frac') = properFraction $ toRational t -foreign import ccall unsafe "utimes" +foreign import capi unsafe "sys/time.h utimes" c_utimes :: CString -> Ptr CTimeVal -> IO CInt #ifdef HAVE_LUTIMES -foreign import ccall unsafe "lutimes" +foreign import capi unsafe "sys/time.h lutimes" c_lutimes :: CString -> Ptr CTimeVal -> IO CInt #endif #if HAVE_FUTIMES -foreign import ccall unsafe "futimes" +foreign import capi unsafe "sys/time.h futimes" c_futimes :: CInt -> Ptr CTimeVal -> IO CInt #endif