attempt to support broken/crazy systems
[clogger.git] / ext / clogger_ext / broken_system_compat.h
blobf58307e6ef91abbba7eb54ae08dd7a6c92e265f1
1 /*
2 * this header includes functions to support broken systems
3 * without clock_gettime() or CLOCK_MONOTONIC
4 */
6 #ifndef HAVE_CLOCK_GETTIME
7 # ifndef CLOCK_REALTIME
8 # define CLOCK_REALTIME 0 /* whatever */
9 # endif
10 static int fake_clock_gettime(int clk_id, struct timespec *res)
12 struct timeval tv;
13 int r = gettimeofday(&tv, NULL);
15 assert(0 == r && "gettimeofday() broke!?");
16 res->tv_sec = tv.tv_sec;
17 res->tv_nsec = tv.tv_usec * 1000;
19 return r;
21 # define clock_gettime fake_clock_gettime
22 #endif /* broken systems w/o clock_gettime() */
24 /* UGH */
25 #ifndef _POSIX_MONOTONIC_CLOCK
26 # define CLOCK_MONOTONIC CLOCK_REALTIME
27 #endif