--- now.c 2015-05-24 03:40:25.000000000 -0400
+++ now.c 2017-08-07 09:58:32.000000000 -0400
-#if defined(__MACH__) && !defined(__gnu_hurd__)
-/* Fake up clock_gettime() on OS X. */
-# include <mach/mach_time.h>
-# define CLOCK_REALTIME 0
-# define CLOCK_MONOTONIC 1
- static uint64_t mono_first = 0;
- int clock_gettime(clockid_t clk_id, struct timespec *tp) {
- if (clk_id == CLOCK_REALTIME) {
- gettimeofday(&tv, NULL);
- tp->tv_sec = tv.tv_sec;
- tp->tv_nsec = tv.tv_usec * 1000;
- if (clk_id == CLOCK_MONOTONIC) {
- uint64_t t = mach_absolute_time();
- mach_timebase_info_data_t timebase;
- mach_timebase_info(&timebase);
- uint64_t tdiff = (t - mono_first) * timebase.numer / timebase.denom;
- tp->tv_sec = tdiff / 1000000000;
- tp->tv_nsec = tdiff % 1000000000;
static struct timespec clock_real, clock_mono;
static int now_initialized = 0;