lib/util: add function to query the monotonic clock with the required fallback to...
authorBjörn Jacke <bj@sernet.de>
Mon, 30 Aug 2010 10:10:29 +0000 (12:10 +0200)
committerBjörn Jacke <bj@sernet.de>
Tue, 31 Aug 2010 08:25:03 +0000 (10:25 +0200)
lib/util/time.c
lib/util/time.h

index 571219b810b52408b06231183e72091da847423c..5557346b9b035f5544974a6c4255dd2267efe75f 100644 (file)
@@ -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
 
index cf6dc1caa7584f722e656f4a1e39dbfd3feb72c2..90890cdbc81f7f3ef51461b1cb3ff7da9e240a92 100644 (file)
@@ -50,6 +50,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"