static void unixCheckClockType() { #if (_POSIX_MONOTONIC_CLOCK-0 == 0) if (is_likely(load_acquire(monotonicClockChecked))) return; # if defined(_SC_MONOTONIC_CLOCK) // detect if the system support monotonic timers long x = sysconf(_SC_MONOTONIC_CLOCK); store_release(monotonicClockAvailable, x >= 200112L); # endif store_release(monotonicClockChecked, true); #endif }
static inline void do_gettime(qint64 *sec, qint64 *frac) { #if (_POSIX_MONOTONIC_CLOCK-0 >= 0) unixCheckClockType(); if (is_likely(monotonicClockAvailable)) { timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); *sec = ts.tv_sec; *frac = ts.tv_nsec; return; } #endif *sec = 0; *frac = 0; }