corsis / clock

High-resolution clock functions: monotonic, realtime, cputime.
Other
58 stars 25 forks source link

Allow extra Clock constructors in clockToConst #59

Closed brandon-leapyear closed 5 years ago

brandon-leapyear commented 5 years ago

:sparkles: This is an old work account. Please reference @brandonchinn178 for all future communication :sparkles:


My Mac (10.14) has CLOCK_MONOTONIC_RAW defined, as evidenced by the Clock constructor:

Prelude> import System.Clock
Prelude System.Clock> :info Clock
data Clock
  = Monotonic
  | Realtime
  | ProcessCPUTime
  | ThreadCPUTime
  | MonotonicRaw

Which then errors in clockToConst if MonotonicRaw is passed. The logic for clockToConst should follow the same logic as the Clock constructor; that is, don't put the CLOCK_MONOTONIC_RAW/CLOCK_BOOTTIME/etc. within the Linux else-block, but only check the relevant C++ flags.

CetinSert commented 5 years ago

@brandon-leapyear do I understand correctly that this means MonotonicRaw is now available on Mac and no longer Linux-specific? If yes, I will amend the documentation. Do you know since which version of Mac?


https://bugs.python.org/issue35716 - mentions CLOCK_MONOTONIC_RAW has been available since macOS 10.12.

brandon-leapyear commented 5 years ago

:sparkles: This is an old work account. Please reference @brandonchinn178 for all future communication :sparkles:


^ I guess there it is. It's strange though; the man page says only Linux, but I've found a few other places that recognize Mac:

llelf commented 5 years ago

They are all system-specific. MacOS has some more that are not present on GNU/Linux. Not to mention all other BSDs.

cartazio commented 5 years ago

@brandon-leapyear new enough macs have it, OS X prior to (macOS 10.12) DO NOT have clock_gettime

https://gitlab.haskell.org/ghc/ghc/wikis/building/preparation/mac-osx#supporting-older-os-x-versions-with-your-build