From a6849dd2ad8fabdca0a10fb99dd01c4f661cf295 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Tue, 20 Apr 2021 19:04:41 +0200 Subject: [PATCH] tmr: fix FreeBSD and OpenBSD (#97) * tmr: fix FreeBSD CLOCK_MONOTONIC * fix gettimeofday --- src/tmr/tmr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tmr/tmr.c b/src/tmr/tmr.c index 32ae932af..5e9022c9d 100644 --- a/src/tmr/tmr.c +++ b/src/tmr/tmr.c @@ -3,7 +3,7 @@ * * Copyright (C) 2010 Creytiv.com */ -#ifdef DARWIN +#if defined(FREEBSD) || defined(OPENBSD) || defined(DARWIN) #define _DEFAULT_SOURCE 1 #else #define _POSIX_C_SOURCE 199309L @@ -142,7 +142,11 @@ uint64_t tmr_jiffies_usec(void) #else struct timespec now; +#if defined(FREEBSD) || defined(OPENBSD) + if (0 != clock_gettime(CLOCK_MONOTONIC, &now)) { +#else if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &now)) { +#endif DEBUG_WARNING("jiffies: clock_gettime() failed (%m)\n", errno); return 0; }