
* Removed the i386ancient standalone tarball build for linux, which was increasingly unable to support new git-annex features. * Removed support for building with ghc older than 9.0.2, and with older versions of haskell libraries than are in current Debian stable. * stack.yaml: Update to lts-23.2. Note that i386ancient was targeting linux 2.6.32, which has been EOL for over 9 years now. Any old system still using such a kernel is certainly highly insecure. And I suspect i386ancient had its own insecurities due to haskell libraries and C libraries not having been updated.
33 lines
918 B
Haskell
33 lines
918 B
Haskell
{- Monotonic clocks
|
|
-
|
|
- Copyright 2024 Joey Hess <id@joeyh.name>
|
|
-
|
|
- License: BSD-2-clause
|
|
-}
|
|
|
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
module Utility.MonotonicClock where
|
|
|
|
import qualified System.Clock as Clock
|
|
#ifdef linux_HOST_OS
|
|
import Utility.Exception
|
|
#endif
|
|
|
|
newtype MonotonicTimestamp = MonotonicTimestamp Integer
|
|
deriving (Show, Eq, Ord, Num)
|
|
|
|
-- On linux, this uses a clock that advances while the system is suspended,
|
|
-- except for on very old kernels (eg 2.6.32).
|
|
-- On other systems, that is not available, and the monotonic clock will
|
|
-- not advance while suspended.
|
|
currentMonotonicTimestamp :: IO MonotonicTimestamp
|
|
currentMonotonicTimestamp =
|
|
(MonotonicTimestamp . fromIntegral . Clock.sec) <$>
|
|
#ifdef linux_HOST_OS
|
|
(tryNonAsync (Clock.getTime Clock.Boottime)
|
|
>>= either (const $ Clock.getTime Clock.Monotonic) return)
|
|
#else
|
|
Clock.getTime Clock.Monotonic
|
|
#endif
|