From: Lennart Poettering Date: Thu, 22 Jun 2017 18:59:48 +0000 (+0200) Subject: timer: convert property_get_next_elapse_monotonic() to use usec_shift_clock() X-Git-Tag: v234~108^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=79fc8b9623354a98ca81b4d35e576e9c9e3bf687;p=thirdparty%2Fsystemd.git timer: convert property_get_next_elapse_monotonic() to use usec_shift_clock() Let's use the generic clock shifting logic here. --- diff --git a/src/core/dbus-timer.c b/src/core/dbus-timer.c index efbb0e8915c..c98282a5d4c 100644 --- a/src/core/dbus-timer.c +++ b/src/core/dbus-timer.c @@ -144,28 +144,14 @@ static int property_get_next_elapse_monotonic( sd_bus_error *error) { Timer *t = userdata; - usec_t x; assert(bus); assert(reply); assert(t); - if (t->next_elapse_monotonic_or_boottime <= 0) - x = 0; - else if (t->wake_system) { - usec_t a, b; - - a = now(CLOCK_MONOTONIC); - b = now(clock_boottime_or_monotonic()); - - if (t->next_elapse_monotonic_or_boottime + a > b) - x = t->next_elapse_monotonic_or_boottime + a - b; - else - x = 0; - } else - x = t->next_elapse_monotonic_or_boottime; - - return sd_bus_message_append(reply, "t", x); + return sd_bus_message_append(reply, "t", + (uint64_t) usec_shift_clock(t->next_elapse_monotonic_or_boottime, + TIMER_MONOTONIC_CLOCK(t), CLOCK_MONOTONIC)); } const sd_bus_vtable bus_timer_vtable[] = { diff --git a/src/core/timer.h b/src/core/timer.h index 9c4b64f8981..546c60d7507 100644 --- a/src/core/timer.h +++ b/src/core/timer.h @@ -78,6 +78,8 @@ struct Timer { char *stamp_path; }; +#define TIMER_MONOTONIC_CLOCK(t) ((t)->wake_system && clock_boottime_supported() ? CLOCK_BOOTTIME_ALARM : CLOCK_MONOTONIC) + void timer_free_values(Timer *t); extern const UnitVTable timer_vtable;