aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-10-04 15:38:16 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2016-10-04 15:46:20 +0200
commitc1c191717f5ef2a32ab668c4f82dbe4d89616314 (patch)
treeaa28002259d8e9a6f2882146c87b5a66f33a0ddc
parent952cf985dca6a97ee662f3b189788089abd2ef57 (diff)
downloadliberty-c1c191717f5ef2a32ab668c4f82dbe4d89616314.tar.gz
liberty-c1c191717f5ef2a32ab668c4f82dbe4d89616314.tar.xz
liberty-c1c191717f5ef2a32ab668c4f82dbe4d89616314.zip
Use CLOCK_MONOTONIC_RAW for timers if available
Should make timers work more precisely on Linux.
-rw-r--r--liberty.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/liberty.c b/liberty.c
index c3051d8..1c71ab1 100644
--- a/liberty.c
+++ b/liberty.c
@@ -83,7 +83,10 @@
extern char **environ;
-#ifdef _POSIX_MONOTONIC_CLOCK
+#ifdef CLOCK_MONOTONIC_RAW
+// This should be more accurate for shorter intervals
+#define CLOCK_BEST CLOCK_MONOTONIC_RAW
+#elif defined _POSIX_MONOTONIC_CLOCK
#define CLOCK_BEST CLOCK_MONOTONIC
#else // ! _POSIX_MONOTIC_CLOCK
#define CLOCK_BEST CLOCK_REALTIME