From c091b3344badac6241b85c6cf2f7dacb0f06047c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Jacke?= Date: Mon, 30 Aug 2010 12:10:29 +0200 Subject: [PATCH] lib/util: add function to query the monotonic clock with the required fallback to the realtime clock --- lib/util/time.c | 10 ++++++++++ lib/util/time.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/lib/util/time.c b/lib/util/time.c index 571219b810b..5557346b9b0 100644 --- a/lib/util/time.c +++ b/lib/util/time.c @@ -55,6 +55,16 @@ _PUBLIC_ void GetTimeOfDay(struct timeval *tval) #endif } +/** +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); + } +} + #define TIME_FIXUP_CONSTANT 11644473600LL diff --git a/lib/util/time.h b/lib/util/time.h index cf6dc1caa75..90890cdbc81 100644 --- a/lib/util/time.h +++ b/lib/util/time.h @@ -51,6 +51,11 @@ a gettimeofday wrapper _PUBLIC_ void GetTimeOfDay(struct timeval *tval); /** +a wrapper to preferably get the monotonic time +**/ +_PUBLIC_ void clock_gettime_mono(struct timespec *tp); + +/** interpret an 8 byte "filetime" structure to a time_t It's originally in "100ns units since jan 1st 1601" **/ -- 2.11.4.GIT