From eda461143efe90fc3f59fc3777978ddcff05e085 Mon Sep 17 00:00:00 2001 From: Alexander Vershilov Date: Tue, 19 Jan 2021 23:25:16 +0300 Subject: [PATCH 1/3] Fix conflict resolution during branch merge. --- System/Clock.hsc | 3 --- 1 file changed, 3 deletions(-) diff --git a/System/Clock.hsc b/System/Clock.hsc index c92e632..826ffca 100644 --- a/System/Clock.hsc +++ b/System/Clock.hsc @@ -127,9 +127,6 @@ foreign import ccall unsafe hs_clock_win32_getres_monotonic :: Ptr TimeSpec -> I foreign import ccall unsafe hs_clock_win32_getres_realtime :: Ptr TimeSpec -> IO () foreign import ccall unsafe hs_clock_win32_getres_processtime :: Ptr TimeSpec -> IO () foreign import ccall unsafe hs_clock_win32_getres_threadtime :: Ptr TimeSpec -> IO () -#elif defined(__MACH__) && defined(__APPLE__) -foreign import ccall unsafe hs_clock_darwin_gettime :: #{type clock_id_t} -> Ptr TimeSpec -> IO () -foreign import ccall unsafe hs_clock_darwin_getres :: #{type clock_id_t} -> Ptr TimeSpec -> IO () #else foreign import ccall unsafe clock_gettime :: #{type clockid_t} -> Ptr TimeSpec -> IO () foreign import ccall unsafe clock_getres :: #{type clockid_t} -> Ptr TimeSpec -> IO () From 8dba4fbc00099d5f88fc79eb7b7aa29243aedcf5 Mon Sep 17 00:00:00 2001 From: Alexander Vershilov Date: Tue, 19 Jan 2021 23:25:35 +0300 Subject: [PATCH 2/3] Update clock.cabal to the latest standards --- clock.cabal | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/clock.cabal b/clock.cabal index 3fd007c..98d4fc4 100644 --- a/clock.cabal +++ b/clock.cabal @@ -1,3 +1,4 @@ +cabal-version: >= 1.10 name: clock version: 0.8 stability: stable @@ -49,7 +50,6 @@ homepage: https://github.com/corsis/clock bug-reports: https://github.com/corsis/clock/issues category: System build-type: Simple -cabal-version: >= 1.8 source-repository head @@ -63,11 +63,12 @@ flag llvm library + default-language: Haskell2010 if impl (ghc < 7.6) build-depends: base >= 4.4 && <= 5, ghc-prim build-depends: base >= 2 && <= 5 exposed-modules: System.Clock - extensions: DeriveGeneric + default-extensions: DeriveGeneric DeriveDataTypeable ForeignFunctionInterface ScopedTypeVariables @@ -82,8 +83,7 @@ library test-suite test --- default-language: --- Haskell2010 + default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: @@ -97,6 +97,7 @@ test-suite test , clock benchmark benchmarks + default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: From 157dee5526513e6c5ff2dd3546f12d37996b8400 Mon Sep 17 00:00:00 2001 From: Alexander Vershilov Date: Tue, 19 Jan 2021 23:36:19 +0300 Subject: [PATCH 3/3] Check C methods exit code on unix platforms. Fixes #61. --- System/Clock.hsc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/System/Clock.hsc b/System/Clock.hsc index 826ffca..13815e3 100644 --- a/System/Clock.hsc +++ b/System/Clock.hsc @@ -23,6 +23,7 @@ import Control.Applicative ((<$>), (<*>)) import Data.Int import Data.Word import Data.Typeable (Typeable) +import Foreign.C import Foreign.Ptr import Foreign.Storable import Foreign.Marshal.Alloc @@ -128,8 +129,8 @@ foreign import ccall unsafe hs_clock_win32_getres_realtime :: Ptr TimeSpec -> IO foreign import ccall unsafe hs_clock_win32_getres_processtime :: Ptr TimeSpec -> IO () foreign import ccall unsafe hs_clock_win32_getres_threadtime :: Ptr TimeSpec -> IO () #else -foreign import ccall unsafe clock_gettime :: #{type clockid_t} -> Ptr TimeSpec -> IO () -foreign import ccall unsafe clock_getres :: #{type clockid_t} -> Ptr TimeSpec -> IO () +foreign import ccall unsafe clock_gettime :: #{type clockid_t} -> Ptr TimeSpec -> IO CInt +foreign import ccall unsafe clock_getres :: #{type clockid_t} -> Ptr TimeSpec -> IO CInt #endif #if !defined(_WIN32) @@ -171,7 +172,7 @@ getTime Realtime = allocaAndPeek hs_clock_win32_gettime_realtime getTime ProcessCPUTime = allocaAndPeek hs_clock_win32_gettime_processtime getTime ThreadCPUTime = allocaAndPeek hs_clock_win32_gettime_threadtime #else -getTime clk = allocaAndPeek $! clock_gettime $! clockToConst clk +getTime clk = allocaAndPeek $! throwErrnoIfMinus1_ "clock_gettime" . clock_gettime (clockToConst clk) #endif #if defined(_WIN32) @@ -180,7 +181,7 @@ getRes Realtime = allocaAndPeek hs_clock_win32_getres_realtime getRes ProcessCPUTime = allocaAndPeek hs_clock_win32_getres_processtime getRes ThreadCPUTime = allocaAndPeek hs_clock_win32_getres_threadtime #else -getRes clk = allocaAndPeek $! clock_getres $! clockToConst clk +getRes clk = allocaAndPeek $! throwErrnoIfMinus1_ "clock_getres" . clock_getres (clockToConst clk) #endif -- | TimeSpec structure