summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/time.c14
1 files changed, 12 insertions, 2 deletions
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);
}
/**