Skip to content

Commit e7ff902

Browse files
rednebBodigrim
authored andcommitted
Use capi for syscalls that break under musl's handling of 64-bit time_t
1 parent d212fc3 commit e7ff902

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

System/Posix/DynamicLinker/Prim.hsc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CApiFFI #-}
12
{-# LANGUAGE Trustworthy #-}
23
{-# OPTIONS_GHC -Wno-trustworthy-safe #-}
34

@@ -84,10 +85,10 @@ data RTLDFlags
8485
| RTLD_LOCAL
8586
deriving (Show, Read)
8687

87-
foreign import ccall unsafe "dlopen" c_dlopen :: CString -> CInt -> IO (Ptr ())
88-
foreign import ccall unsafe "dlsym" c_dlsym :: Ptr () -> CString -> IO (FunPtr a)
89-
foreign import ccall unsafe "dlerror" c_dlerror :: IO CString
90-
foreign import ccall unsafe "dlclose" c_dlclose :: (Ptr ()) -> IO CInt
88+
foreign import capi unsafe "dlfcn.h dlopen" c_dlopen :: CString -> CInt -> IO (Ptr ())
89+
foreign import capi unsafe "dlfcn.h dlsym" c_dlsym :: Ptr () -> CString -> IO (FunPtr a)
90+
foreign import capi unsafe "dlfcn.h dlerror" c_dlerror :: IO CString
91+
foreign import capi unsafe "dlfcn.h dlclose" c_dlclose :: (Ptr ()) -> IO CInt
9192

9293
packRTLDFlags :: [RTLDFlags] -> CInt
9394
packRTLDFlags flags = foldl (\ s f -> (packRTLDFlag f) .|. s) 0 flags

System/Posix/Files/Common.hsc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CApiFFI #-}
12
{-# LANGUAGE Trustworthy #-}
23

34
-----------------------------------------------------------------------------
@@ -452,12 +453,12 @@ toCTimeSpec t = CTimeSpec (CTime sec) (truncate $ 10^(9::Int) * frac)
452453
#endif
453454

454455
#ifdef HAVE_UTIMENSAT
455-
foreign import ccall unsafe "utimensat"
456+
foreign import capi unsafe "sys/stat.h utimensat"
456457
c_utimensat :: CInt -> CString -> Ptr CTimeSpec -> CInt -> IO CInt
457458
#endif
458459

459460
#if HAVE_FUTIMENS
460-
foreign import ccall unsafe "futimens"
461+
foreign import capi unsafe "sys/stat.h futimens"
461462
c_futimens :: CInt -> Ptr CTimeSpec -> IO CInt
462463
#endif
463464

@@ -480,16 +481,16 @@ toCTimeVal t = CTimeVal sec (truncate $ 10^(6::Int) * frac)
480481
(sec, frac) = if (frac' < 0) then (sec' - 1, frac' + 1) else (sec', frac')
481482
(sec', frac') = properFraction $ toRational t
482483

483-
foreign import ccall unsafe "utimes"
484+
foreign import capi unsafe "sys/time.h utimes"
484485
c_utimes :: CString -> Ptr CTimeVal -> IO CInt
485486

486487
#ifdef HAVE_LUTIMES
487-
foreign import ccall unsafe "lutimes"
488+
foreign import capi unsafe "sys/time.h lutimes"
488489
c_lutimes :: CString -> Ptr CTimeVal -> IO CInt
489490
#endif
490491

491492
#if HAVE_FUTIMES
492-
foreign import ccall unsafe "futimes"
493+
foreign import capi unsafe "sys/time.h futimes"
493494
c_futimes :: CInt -> Ptr CTimeVal -> IO CInt
494495
#endif
495496

0 commit comments

Comments
 (0)