summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Jacke <bj@sernet.de>2010-08-30 12:10:29 +0200
committerBjörn Jacke <bj@sernet.de>2010-08-31 10:25:03 +0200
commitc091b3344badac6241b85c6cf2f7dacb0f06047c (patch)
tree912cbf0689429d2b7a2054fd29029a616c86d498
parent63b1f2ee813b430e1f4bec3abb28a6266f8a82c8 (diff)
downloadsamba-c091b3344badac6241b85c6cf2f7dacb0f06047c.tar.gz
samba-c091b3344badac6241b85c6cf2f7dacb0f06047c.tar.bz2
samba-c091b3344badac6241b85c6cf2f7dacb0f06047c.zip
lib/util: add function to query the monotonic clock with the required fallback to the realtime clock
-rw-r--r--lib/util/time.c10
-rw-r--r--lib/util/time.h5
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/util/time.c b/lib/util/time.c
index 571219b810..5557346b9b 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 cf6dc1caa7..90890cdbc8 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"
**/