From cf87f8587415df2119995e82ccf51bb64e44115b Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Wed, 3 Jul 2013 18:57:57 +0200 Subject: time: prefer CLOCK_BOOTTIME for clock_gettime_mono() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this clock moves on while the machine was suspended. This is what we prefer actually. Signed-off-by: Björn Jacke Reviewed-by: Simo Sorce Autobuild-User(master): Simo Sorce Autobuild-Date(master): Fri Jul 5 16:47:34 CEST 2013 on sn-devel-104 --- lib/util/time.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/util/time.c b/lib/util/time.c index bc87120859..05251dd3b5 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -62,9 +62,19 @@ a wrapper to preferably get the monotonic time **/ _PUBLIC_ void clock_gettime_mono(struct timespec *tp) { - if (clock_gettime(CUSTOM_CLOCK_MONOTONIC,tp) != 0) { - clock_gettime(CLOCK_REALTIME,tp); +/* prefer a suspend aware monotonic CLOCK_BOOTTIME: */ +#ifdef CLOCK_BOOTTIME + if (clock_gettime(CLOCK_BOOTTIME,tp) == 0) { + return; } +#endif +/* then try the monotonic clock: */ +#if CUSTOM_CLOCK_MONOTONIC != CLOCK_REALTIME + if (clock_gettime(CUSTOM_CLOCK_MONOTONIC,tp) == 0) { + return; + } +#endif + clock_gettime(CLOCK_REALTIME,tp); } /** -- cgit