From: Marios Titas Date: Sun, 2 Oct 2022 20:12:32 +0000 (+0300) Subject: [PATCH] Use capi for syscalls that break under musl's handling of 64-bit time_t X-Git-Tag: archive/raspbian/9.6.6-2+rpi1~2^2^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=44958d35359414b19f9cf45e7ff0af282fc4e4ac;p=ghc.git [PATCH] Use capi for syscalls that break under musl's handling of 64-bit time_t Gbp-Pq: Name time_t-unix --- diff --git a/libraries/unix/System/Posix/DynamicLinker/Prim.hsc b/libraries/unix/System/Posix/DynamicLinker/Prim.hsc index f014bb6c..8b879d55 100644 --- a/libraries/unix/System/Posix/DynamicLinker/Prim.hsc +++ b/libraries/unix/System/Posix/DynamicLinker/Prim.hsc @@ -1,3 +1,4 @@ +{-# LANGUAGE CApiFFI #-} {-# LANGUAGE Trustworthy #-} #if __GLASGOW_HASKELL__ >= 709 {-# OPTIONS_GHC -fno-warn-trustworthy-safe #-} @@ -81,10 +82,10 @@ data RTLDFlags | RTLD_LOCAL deriving (Show, Read) -foreign import ccall unsafe "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 capi unsafe "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 unsafe "dlfcn.h dlclose" c_dlclose :: (Ptr ()) -> IO CInt packRTLDFlags :: [RTLDFlags] -> CInt packRTLDFlags flags = foldl (\ s f -> (packRTLDFlag f) .|. s) 0 flags diff --git a/libraries/unix/System/Posix/Files/Common.hsc b/libraries/unix/System/Posix/Files/Common.hsc index cc594cc3..93f2867e 100644 --- a/libraries/unix/System/Posix/Files/Common.hsc +++ b/libraries/unix/System/Posix/Files/Common.hsc @@ -1,3 +1,4 @@ +{-# LANGUAGE CApiFFI #-} {-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- @@ -420,12 +421,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 @@ -448,16 +449,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