From 610dde15a88f12cc540424eb3eb3ed61f3876f74 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Fri, 27 Jan 2023 20:02:49 +0200 Subject: xz: Use clock_gettime() even if CLOCK_MONOTONIC isn't available. mythread.h and thus liblzma already does it. --- src/xz/mytime.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/xz/mytime.c') diff --git a/src/xz/mytime.c b/src/xz/mytime.c index 0b0e2be7..8d5e994f 100644 --- a/src/xz/mytime.c +++ b/src/xz/mytime.c @@ -12,7 +12,7 @@ #include "private.h" -#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_CLOCK_MONOTONIC) +#ifdef HAVE_CLOCK_GETTIME # include #else # include @@ -35,14 +35,19 @@ static uint64_t next_flush; static uint64_t mytime_now(void) { -#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_CLOCK_MONOTONIC) +#ifdef HAVE_CLOCK_GETTIME + struct timespec tv; + +# ifdef HAVE_CLOCK_MONOTONIC // If CLOCK_MONOTONIC was available at compile time but for some // reason isn't at runtime, fallback to CLOCK_REALTIME which // according to POSIX is mandatory for all implementations. static clockid_t clk_id = CLOCK_MONOTONIC; - struct timespec tv; while (clock_gettime(clk_id, &tv)) clk_id = CLOCK_REALTIME; +# else + clock_gettime(CLOCK_REALTIME, &tv); +# endif return (uint64_t)tv.tv_sec * 1000 + (uint64_t)(tv.tv_nsec / 1000000); #else -- cgit v1.2.3