diff options
author | Harry Sintonen <sintonen@iki.fi> | 2020-12-05 21:21:14 +0200 |
---|---|---|
committer | Harry Sintonen <sintonen@iki.fi> | 2020-12-05 21:21:14 +0200 |
commit | 57b97a4c910e3294b1ed441acea55da2f9ca3cb1 (patch) | |
tree | 032d0cc9ef765d619c9db8159e3473e28396fafa /src | |
parent | 03087e7a761df300c2d8cd6e072890f8e1059dfa (diff) |
Use CLOCK_MONOTONIC_RAW when available
Diffstat (limited to 'src')
-rw-r--r-- | src/util/timestamp.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/util/timestamp.cc b/src/util/timestamp.cc index 2e2efe2..a50f734 100644 --- a/src/util/timestamp.cc +++ b/src/util/timestamp.cc @@ -48,6 +48,12 @@ #include <stdio.h> #endif +#ifdef CLOCK_MONOTONIC_RAW +#define CLOCKTYPE CLOCK_MONOTONIC_RAW +#else +#define CLOCKTYPE CLOCK_MONOTONIC +#endif + static uint64_t millis_cache = -1; uint64_t frozen_timestamp( void ) @@ -73,7 +79,7 @@ void freeze_timestamp( void ) // Check for presence, for OS X SDK >= 10.12 and runtime < 10.12 &clock_gettime != NULL && #endif - clock_gettime( CLOCK_MONOTONIC, &tp ) == 0 ) { + clock_gettime( CLOCKTYPE, &tp ) == 0 ) { uint64_t millis = tp.tv_nsec / 1000000; millis += uint64_t( tp.tv_sec ) * 1000; |