Commit 1ba28510 authored by Mr Kerckhove's avatar Mr Kerckhove Committed by Ben Gamari
Browse files

Expose monotonic time from GHC.Event.Clock

This diff exposes the monotonic time api from GHC.Event.Clock.

This is necessary for future work on regression tests (#D4074) for
the timeout problems (8684, for example) in #D4041, #D4011, #D4012

Test Plan: Still builds ...

Reviewers: nh2, bgamari, austin, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4079
parent 3befc1af
{-# LANGUAGE Trustworthy #-} {-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NoImplicitPrelude #-}
module GHC.Event.Clock module GHC.Clock
( getMonotonicTime ( getMonotonicTime
, getMonotonicTimeNSec , getMonotonicTimeNSec
) where ) where
...@@ -11,11 +11,15 @@ import GHC.Real ...@@ -11,11 +11,15 @@ import GHC.Real
import Data.Word import Data.Word
-- | Return monotonic time in seconds, since some unspecified starting point -- | Return monotonic time in seconds, since some unspecified starting point
--
-- @since 4.11.0.0
getMonotonicTime :: IO Double getMonotonicTime :: IO Double
getMonotonicTime = do w <- getMonotonicTimeNSec getMonotonicTime = do w <- getMonotonicTimeNSec
return (fromIntegral w / 1000000000) return (fromIntegral w / 1000000000)
-- | Return monotonic time in nanoseconds, since some unspecified starting point -- | Return monotonic time in nanoseconds, since some unspecified starting point
--
-- @since 4.11.0.0
foreign import ccall unsafe "getMonotonicNSec" foreign import ccall unsafe "getMonotonicNSec"
getMonotonicTimeNSec :: IO Word64 getMonotonicTimeNSec :: IO Word64
...@@ -43,11 +43,11 @@ import Data.Foldable (sequence_) ...@@ -43,11 +43,11 @@ import Data.Foldable (sequence_)
import Data.IORef (IORef, atomicModifyIORef', mkWeakIORef, newIORef, readIORef, import Data.IORef (IORef, atomicModifyIORef', mkWeakIORef, newIORef, readIORef,
writeIORef) writeIORef)
import GHC.Base import GHC.Base
import GHC.Clock (getMonotonicTimeNSec)
import GHC.Conc.Signal (runHandlers) import GHC.Conc.Signal (runHandlers)
import GHC.Num (Num(..)) import GHC.Num (Num(..))
import GHC.Real (fromIntegral) import GHC.Real (fromIntegral)
import GHC.Show (Show(..)) import GHC.Show (Show(..))
import GHC.Event.Clock (getMonotonicTimeNSec)
import GHC.Event.Control import GHC.Event.Control
import GHC.Event.Internal (Backend, Event, evtRead, Timeout(..)) import GHC.Event.Internal (Backend, Event, evtRead, Timeout(..))
import GHC.Event.Unique (Unique, UniqueSource, newSource, newUnique) import GHC.Event.Unique (Unique, UniqueSource, newSource, newUnique)
......
...@@ -204,6 +204,7 @@ Library ...@@ -204,6 +204,7 @@ Library
GHC.Base GHC.Base
GHC.ByteOrder GHC.ByteOrder
GHC.Char GHC.Char
GHC.Clock
GHC.Conc GHC.Conc
GHC.Conc.IO GHC.Conc.IO
GHC.Conc.Signal GHC.Conc.Signal
...@@ -369,7 +370,6 @@ Library ...@@ -369,7 +370,6 @@ Library
other-modules: other-modules:
GHC.Event.Arr GHC.Event.Arr
GHC.Event.Array GHC.Event.Array
GHC.Event.Clock
GHC.Event.Control GHC.Event.Control
GHC.Event.EPoll GHC.Event.EPoll
GHC.Event.IntTable GHC.Event.IntTable
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment