X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftime%2Ftime.c;fp=ccan%2Ftime%2Ftime.c;h=8e7fbffe739da0ba6cebed78b8c7624023269e1b;hp=54cb3f4b73ae601cf469592237bc165748593e4c;hb=95ff2139520130dd98a0503e3c4f441c69a68f5a;hpb=daf9ee7d8e2b683ff05283beb1843611ad8c9e8a diff --git a/ccan/time/time.c b/ccan/time/time.c index 54cb3f4b..8e7fbffe 100644 --- a/ccan/time/time.c +++ b/ccan/time/time.c @@ -25,6 +25,17 @@ struct timeabs time_now(void) } #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;