Read System Clock for Monotonic Time #1627
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the
janet_gettimeimplementation for OSX <10.12 to read the system clock for(os/clock :monotonic). As far as I was able to find online this is a monotonic clock, although it produces different values fromclock_gettime(CLOCK_MONOTONIC, ...)on the same system. I can speculate that this is related toSYSTEM_CLOCKmonotonic time being implemented withmach_absolute_timewhich is documented to not advance during sleep, and I suspect thatclock_gettime(CLOCK_MONOTONIC, ...)does.Resources:
clock_get_timeimplementation for theSYSTEM_CLOCK: https://github.com/apple-oss-distributions/xnu/blob/e3723e1f17661b24996789d8afc084c0c3303b26/osfmk/kern/clock_oldops.c#L284-L296 and https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/osfmk/arm/rtclock.c#L248-L260mach_absolute_timeandmach_continuous_timedefinitions: https://github.com/apple-oss-distributions/xnu/blob/e3723e1f17661b24996789d8afc084c0c3303b26/osfmk/mach/mach_time.h#L55-L68clock_gettimeon OS X before 10.12: https://stackoverflow.com/questions/11680461/monotonic-clock-on-osx