2 * this header includes functions to support broken systems
3 * without clock_gettime() or CLOCK_MONOTONIC
6 #ifndef HAVE_TYPE_CLOCKID_T
10 #ifndef HAVE_CLOCK_GETTIME
11 # ifndef CLOCK_REALTIME
12 # define CLOCK_REALTIME 0 /* whatever */
14 static int fake_clock_gettime(clockid_t clk_id
, struct timespec
*res
)
17 int r
= gettimeofday(&tv
, NULL
);
19 assert(0 == r
&& "gettimeofday() broke!?");
20 res
->tv_sec
= tv
.tv_sec
;
21 res
->tv_nsec
= tv
.tv_usec
* 1000;
25 # define clock_gettime fake_clock_gettime
26 #endif /* broken systems w/o clock_gettime() */
30 * CLOCK_MONOTONIC is not guaranteed to be a macro, either
32 #ifndef CLOCK_MONOTONIC
33 # if (!defined(_POSIX_MONOTONIC_CLOCK) || !defined(HAVE_CLOCK_MONOTONIC))
34 # define CLOCK_MONOTONIC CLOCK_REALTIME