* Call these consecutively to minimise drift...
*/
if (clock_gettime(CLOCK_REALTIME, &ts_realtime) < 0) return -1;
- if (clock_gettime(CLOCK_MONOTONIC, &ts_monotime) < 0) return -1;
+ if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts_monotime) < 0) return -1;
atomic_store_explicit(&our_realtime,
fr_time_delta_unwrap(fr_time_delta_from_timespec(&ts_realtime)) -
tzset(); /* Populate timezone, daylight and tzname globals */
struct timespec ts;
- if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) return -1;
+ if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) < 0) return -1;
our_epoch = fr_time_delta_unwrap(fr_time_delta_from_timespec(&ts));
return fr_time_sync();
return CMP(fr_unix_time_unwrap(a), fr_unix_time_unwrap(b));
}
+#ifndef CLOCK_MONOTONIC_RAW
+#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
+#endif
+
/** Return a relative time since the server our_epoch
*
* This time is useful for doing time comparisons, deltas, etc.
static inline fr_time_t fr_time(void)
{
struct timespec ts;
- (void) clock_gettime(CLOCK_MONOTONIC, &ts);
+ (void) clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
return fr_time_wrap(fr_time_delta_unwrap(fr_time_delta_from_timespec(&ts)) - our_epoch);
}