diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-03-15 20:18:00 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-03-15 20:18:00 -0400 |
commit | 4cd35a79da4978d9bfcdf274cad5c50b2a81af0a (patch) | |
tree | 984311dcb6c52fae92f3c7aea5ae9b658f32d90c /src | |
parent | c104bde7fed9d851235585eddf24ade53af29873 (diff) | |
parent | 2abd5b5a49ae368b258ffc7257ab703bccda67dd (diff) |
Merge pull request #2843 from NetworkManager/clock_boottime
time-util: fall back to CLOCK_MONOTONIC if CLOCK_BOOTTIME unsupported
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/time-util.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 7ca764abeb..c16460a198 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -47,12 +47,15 @@ static clockid_t map_clock_id(clockid_t c) { /* Some more exotic archs (s390, ppc, …) lack the "ALARM" flavour of the clocks. Thus, clock_gettime() will * fail for them. Since they are essentially the same as their non-ALARM pendants (their only difference is * when timers are set on them), let's just map them accordingly. This way, we can get the correct time even on - * those archs. */ + * those archs. + * + * Also, older kernels don't support CLOCK_BOOTTIME: fall back to CLOCK_MONOTONIC. */ switch (c) { + case CLOCK_BOOTTIME: case CLOCK_BOOTTIME_ALARM: - return CLOCK_BOOTTIME; + return clock_boottime_or_monotonic (); case CLOCK_REALTIME_ALARM: return CLOCK_REALTIME; |