From d52314edb138b6ecd7e888c588f83917b0ee2c29 Mon Sep 17 00:00:00 2001 From: Marios Titas Date: Sun, 2 Oct 2022 23:12:43 +0300 Subject: [PATCH] Use capi for syscalls that break under musl's handling of 64-bit time_t --- lib/Data/Time/Clock/Internal/CTimespec.hsc | 4 ++-- lib/Data/Time/Clock/Internal/CTimeval.hs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Data/Time/Clock/Internal/CTimespec.hsc b/lib/Data/Time/Clock/Internal/CTimespec.hsc index d699cc79..75575e3d 100644 --- a/lib/Data/Time/Clock/Internal/CTimespec.hsc +++ b/lib/Data/Time/Clock/Internal/CTimespec.hsc @@ -28,9 +28,9 @@ instance Storable CTimespec where #{poke struct timespec, tv_sec } p s #{poke struct timespec, tv_nsec} p ns -foreign import ccall unsafe "time.h clock_gettime" +foreign import capi unsafe "time.h clock_gettime" clock_gettime :: ClockID -> Ptr CTimespec -> IO CInt -foreign import ccall unsafe "time.h clock_getres" +foreign import capi unsafe "time.h clock_getres" clock_getres :: ClockID -> Ptr CTimespec -> IO CInt -- | Get the resolution of the given clock. diff --git a/lib/Data/Time/Clock/Internal/CTimeval.hs b/lib/Data/Time/Clock/Internal/CTimeval.hs index f9ba6596..beb39501 100644 --- a/lib/Data/Time/Clock/Internal/CTimeval.hs +++ b/lib/Data/Time/Clock/Internal/CTimeval.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE Safe #-} +{-# LANGUAGE CApiFFI #-} module Data.Time.Clock.Internal.CTimeval where @@ -23,7 +24,7 @@ instance Storable CTimeval where pokeElemOff (castPtr p) 0 s pokeElemOff (castPtr p) 1 mus -foreign import ccall unsafe "time.h gettimeofday" gettimeofday :: Ptr CTimeval -> Ptr () -> IO CInt +foreign import capi unsafe "sys/time.h gettimeofday" gettimeofday :: Ptr CTimeval -> Ptr () -> IO CInt -- | Get the current POSIX time from the system clock. getCTimeval :: IO CTimeval