[PATCH] Use capi for syscalls that break under musl's handling of 64-bit time_t
authorMarios Titas <redneb@gmx.com>
Sun, 2 Oct 2022 20:12:32 +0000 (23:12 +0300)
committerIlias Tsitsimpis <iliastsi@debian.org>
Wed, 10 Apr 2024 11:24:01 +0000 (14:24 +0300)
Gbp-Pq: Name time_t-unix

libraries/unix/System/Posix/DynamicLinker/Prim.hsc
libraries/unix/System/Posix/Files/Common.hsc

index f014bb6ca2cb46fc0e5cc6d953a79699f158329e..8b879d555f8ea48eab064a27e4b7323224bd4df0 100644 (file)
@@ -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
index cc594cc3bc567b2b67dea248c07cf11d16e7b36d..93f2867ebb12ac2bb415d0d1d137344df5e7b00c 100644 (file)
@@ -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