diff options
| author | Roy Marples <roy@marples.name> | 2008-08-01 13:15:11 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-08-01 13:15:11 +0000 |
| commit | b5329d0e46028d623454756a1da81013474aab65 (patch) | |
| tree | 138c120e632c8fd6638b44af6f8e2efd1983fe80 /common.c | |
| parent | 6e8e514928d59cb195e6616f1b0eda92baae63ae (diff) | |
| download | dhcpcd-b5329d0e46028d623454756a1da81013474aab65.tar.xz | |
Brute force detection of monotonic clock as sysconf is unreliable. Instead rely on clock_gettime failing gracefully with an invalid clockid (which it should do).
Diffstat (limited to 'common.c')
| -rw-r--r-- | common.c | 12 |
1 files changed, 1 insertions, 11 deletions
@@ -193,25 +193,16 @@ get_monotonic(struct timeval *tp) struct timespec ts; static clockid_t posix_clock; -#ifdef FORCE_MONOTONIC if (!posix_clock_set) { - posix_clock = CLOCK_MONOTONIC; - posix_clock_set = 1; - clock_monotonic = 1; - } -#else - if (!posix_clock_set) { - if (sysconf(_SC_MONOTONIC_CLOCK) >= 0) { + if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { posix_clock = CLOCK_MONOTONIC; clock_monotonic = 1; } else { posix_clock = CLOCK_REALTIME; logger(LOG_WARNING, NO_MONOTONIC); } - posix_clock_set = 1; } -#endif if (clock_gettime(posix_clock, &ts) == -1) return -1; @@ -220,7 +211,6 @@ get_monotonic(struct timeval *tp) tp->tv_usec = ts.tv_nsec / 1000; return 0; #else - if (!posix_clock_set) { logger(LOG_WARNING, NO_MONOTONIC); posix_clock_set = 1; |
