Skip to content

Commit

Permalink
rvtimer: Use faster clocksources where possible
Browse files Browse the repository at this point in the history
- On FreeBSD, there is CLOCK_MONOTONIC_FAST which is much faster than CLOCK_MONOTONIC but more coarse
- On Linux, there is CLOCK_MONOTONIC_COARSE
  • Loading branch information
LekKit authored Mar 22, 2024
1 parent de3017b commit f791aa5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/rvtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ uint64_t rvtimer_clocksource(uint64_t freq)
}

#elif defined(CLOCK_REALTIME) || defined(CLOCK_MONOTONIC)
// Use POSIX clock_gettime(), with a monotonic clock if possible
// Use POSIX clock_gettime(), with a fast monotonic clock if possible
#include <unistd.h>
#if defined(CLOCK_MONOTONIC_RAW)
#if defined(CLOCK_MONOTONIC_FAST)
#define CHOSEN_POSIX_CLOCK CLOCK_MONOTONIC_FAST
#elif defined(CLOCK_MONOTONIC_COARSE)
#define CHOSEN_POSIX_CLOCK CLOCK_MONOTONIC_COARSE
#elif defined(CLOCK_MONOTONIC_RAW)
#define CHOSEN_POSIX_CLOCK CLOCK_MONOTONIC_RAW
#elif defined(CLOCK_MONOTONIC)
#define CHOSEN_POSIX_CLOCK CLOCK_MONOTONIC
Expand Down

0 comments on commit f791aa5

Please sign in to comment.