Closed orion1vi closed 1 year ago
cc @kasper93
Why?
Because CLOCK_MONOTONIC_RAW means different things between Apple and Linux. Also matches macOS < 10.12 fallback, besides not requiring the timebase conversion.
I know what you are saying, but what functional change are you trying to make? In other words, what is the issue you are trying to fix? I don't mind either way, just asking what's the purpose of this change.
A more consistent behaviour between systems I guess.
I used CLOCK_MONOTONIC_RAW
because libc++ also is using it for steady_clock. I'm fine changing it, if you feel it is better.
I looked into why it was changed https://reviews.llvm.org/D74341 and took closer look for what purposes the clock is used in libplacebo and it shouldn't matter much that it increments while system is sleeping, so I'll close this.
CLOCK_MONOTONIC_RAW on apple platforms is a monotonic clock that gets incremented while system is suspended, the clock_id that should actually be used is CLOCK_UPTIME_RAW, this clock does not get incremented while system is suspended and matches time value of mach_absolute_time but with timebase ratio applied, so returned time is in nano seconds.
Fixes discrepancy with PL_CLOCK_MACH path.
See: https://github.com/apple-oss-distributions/Libc/blob/c5a3293354e22262702a3add5b2dfc9bb0b93b85/gen/clock_gettime.c#L168