diff options
author | Cheng Shao <cheng.shao@tweag.io> | 2021-11-02 19:59:32 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-12-14 20:52:37 -0500 |
commit | 7c2609d8e951159f07dbca97d1076d029f431f44 (patch) | |
tree | cc668455da1c0eba2dc2393a27e7aa62a98df487 /libraries/base/System | |
parent | a5d8d47f2a95de4b66c7299c25c301b89e6252f6 (diff) | |
download | haskell-7c2609d8e951159f07dbca97d1076d029f431f44.tar.gz |
base: fix clockid_t usage when it's a pointer type in C
Closes #20607.
Diffstat (limited to 'libraries/base/System')
-rw-r--r-- | libraries/base/System/CPUTime/Posix/ClockGetTime.hsc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libraries/base/System/CPUTime/Posix/ClockGetTime.hsc b/libraries/base/System/CPUTime/Posix/ClockGetTime.hsc index d7f244431c..f24dec3b14 100644 --- a/libraries/base/System/CPUTime/Posix/ClockGetTime.hsc +++ b/libraries/base/System/CPUTime/Posix/ClockGetTime.hsc @@ -21,12 +21,12 @@ import System.CPUTime.Utils getCPUTime :: IO Integer getCPUTime = fmap snd $ withTimespec $ \ts -> throwErrnoIfMinus1_ "clock_gettime" - $ clock_gettime (#const CLOCK_PROCESS_CPUTIME_ID) ts + $ clock_gettime cLOCK_PROCESS_CPUTIME_ID ts getCpuTimePrecision :: IO Integer getCpuTimePrecision = fmap snd $ withTimespec $ \ts -> throwErrnoIfMinus1_ "clock_getres" - $ clock_getres (#const CLOCK_PROCESS_CPUTIME_ID) ts + $ clock_getres cLOCK_PROCESS_CPUTIME_ID ts data Timespec @@ -40,8 +40,9 @@ withTimespec action = u_nsec <- (#peek struct timespec,tv_nsec) p_ts :: IO CLong return (r, cTimeToInteger u_sec * 1e12 + fromIntegral u_nsec * 1e3) -foreign import capi unsafe "time.h clock_getres" clock_getres :: CInt -> Ptr Timespec -> IO CInt -foreign import capi unsafe "time.h clock_gettime" clock_gettime :: CInt -> Ptr Timespec -> IO CInt +foreign import capi unsafe "time.h clock_getres" clock_getres :: CUIntPtr -> Ptr Timespec -> IO CInt +foreign import capi unsafe "time.h clock_gettime" clock_gettime :: CUIntPtr -> Ptr Timespec -> IO CInt +foreign import capi unsafe "time.h value CLOCK_PROCESS_CPUTIME_ID" cLOCK_PROCESS_CPUTIME_ID :: CUIntPtr #else |