X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=lib%2Fgettime.c;h=bb59c44ff0e432349526646479da115d64cffc99;hb=63a4dabcae87d368cccb3365f2266b8941ba8915;hp=9a4e342f18e0cd8a7a922988c9fc0f88baf57f25;hpb=a8a88eddaa90432e6ec1b8d9d5c9842bc91afd1d;p=debian%2Fgzip diff --git a/lib/gettime.c b/lib/gettime.c index 9a4e342..bb59c44 100644 --- a/lib/gettime.c +++ b/lib/gettime.c @@ -28,21 +28,22 @@ void gettime (struct timespec *ts) { -#if HAVE_NANOTIME - nanotime (ts); +#if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME + clock_gettime (CLOCK_REALTIME, ts); #else + struct timeval tv; + gettimeofday (&tv, NULL); + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = tv.tv_usec * 1000; +#endif +} -# if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME - if (clock_gettime (CLOCK_REALTIME, ts) == 0) - return; -# endif - - { - struct timeval tv; - gettimeofday (&tv, NULL); - ts->tv_sec = tv.tv_sec; - ts->tv_nsec = tv.tv_usec * 1000; - } +/* Return the current system time as a struct timespec. */ -#endif +struct timespec +current_timespec (void) +{ + struct timespec ts; + gettime (&ts); + return ts; }