X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftime%2Ftime.c;h=d0542f5654e86f06e69bc40c530ce0c989643e92;hb=80e95491125b762e46fa4295cafb43fe21e15136;hp=54cb3f4b73ae601cf469592237bc165748593e4c;hpb=c92b496623f29cfb3ac1ade8e52ffbfa95ab5bcf;p=ccan diff --git a/ccan/time/time.c b/ccan/time/time.c index 54cb3f4b..d0542f56 100644 --- a/ccan/time/time.c +++ b/ccan/time/time.c @@ -3,7 +3,7 @@ #include #include -#if !HAVE_CLOCK_GETTIME && !HAVE_CLOCK_GETTIME_IN_LIBRT +#if !HAVE_CLOCK_GETTIME #include struct timeabs time_now(void) @@ -23,7 +23,18 @@ struct timeabs time_now(void) clock_gettime(CLOCK_REALTIME, &ret.ts); return TIMEABS_CHECK(ret); } -#endif /* HAVE_CLOCK_GETTIME || HAVE_CLOCK_GETTIME_IN_LIBRT */ +#endif /* HAVE_CLOCK_GETTIME */ + +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) {