From 90e51c061912a2f0e043ff846250f322b8f2cf19 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Wed, 23 Aug 2023 01:19:30 +0300 Subject: [PATCH] always using CLOCK_MONOTONIC --- linters/cppcheck.h | 2 -- src/libs/tools.h | 14 ++------------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/linters/cppcheck.h b/linters/cppcheck.h index 72c1730..8fb50f0 100644 --- a/linters/cppcheck.h +++ b/linters/cppcheck.h @@ -2,5 +2,3 @@ #define WITH_GPIO #define JANUS_PLUGIN_INIT(...) { __VA_ARGS__ } #define EVTHREAD_USE_PTHREADS_IMPLEMENTED 1 -#define CLOCK_MONOTONIC_RAW 1 -#define CLOCK_MONOTONIC_FAST 1 diff --git a/src/libs/tools.h b/src/libs/tools.h index b324965..1b3a17f 100644 --- a/src/libs/tools.h +++ b/src/libs/tools.h @@ -117,29 +117,19 @@ INLINE void us_get_now(clockid_t clk_id, time_t *sec, long *msec) { } } -#if defined(CLOCK_MONOTONIC_RAW) -# define _X_CLOCK_MONOTONIC CLOCK_MONOTONIC_RAW -#elif defined(CLOCK_MONOTONIC_FAST) -# define _X_CLOCK_MONOTONIC CLOCK_MONOTONIC_FAST -#else -# define _X_CLOCK_MONOTONIC CLOCK_MONOTONIC -#endif - INLINE long double us_get_now_monotonic(void) { time_t sec; long msec; - us_get_now(_X_CLOCK_MONOTONIC, &sec, &msec); + us_get_now(CLOCK_MONOTONIC, &sec, &msec); return (long double)sec + ((long double)msec) / 1000; } INLINE uint64_t us_get_now_monotonic_u64(void) { struct timespec ts; - assert(!clock_gettime(_X_CLOCK_MONOTONIC, &ts)); + assert(!clock_gettime(CLOCK_MONOTONIC, &ts)); return (uint64_t)(ts.tv_nsec / 1000) + (uint64_t)ts.tv_sec * 1000000; } -#undef _X_CLOCK_MONOTONIC - INLINE uint64_t us_get_now_id(void) { const uint64_t now = us_get_now_monotonic_u64(); return (uint64_t)us_triple_u32(now) | ((uint64_t)us_triple_u32(now + 12345) << 32);