]> git.ozlabs.org Git - ccan/blobdiff - ccan/time/time.c
time: time_mono() helpers.
[ccan] / ccan / time / time.c
index 54cb3f4b73ae601cf469592237bc165748593e4c..8e7fbffe739da0ba6cebed78b8c7624023269e1b 100644 (file)
@@ -25,6 +25,17 @@ struct timeabs time_now(void)
 }
 #endif /* HAVE_CLOCK_GETTIME || HAVE_CLOCK_GETTIME_IN_LIBRT */
 
 }
 #endif /* HAVE_CLOCK_GETTIME || HAVE_CLOCK_GETTIME_IN_LIBRT */
 
+struct timemono time_mono(void)
+{
+       struct timemono ret;
+#ifdef TIME_HAVE_MONOTONIC
+       clock_gettime(CLOCK_MONOTONIC, &ret.ts);
+#else /* Best we can do */
+       ret.ts = time_now().ts;
+#endif /* !HAVE_TIME_MONOTONIC */
+       return ret;
+}
+
 struct timerel time_divide(struct timerel t, unsigned long div)
 {
        struct timerel res;
 struct timerel time_divide(struct timerel t, unsigned long div)
 {
        struct timerel res;