diff --git a/System/Clock.hsc b/System/Clock.hsc index c92e632..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 @@ -127,12 +128,9 @@ 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 () +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) @@ -174,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) @@ -183,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 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: