diff options
-rw-r--r-- | osdep/timer-linux.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/osdep/timer-linux.c b/osdep/timer-linux.c index 1378e6ea7e..4ab19b6490 100644 --- a/osdep/timer-linux.c +++ b/osdep/timer-linux.c @@ -40,12 +40,22 @@ void mp_sleep_us(int64_t us) #endif } +#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && defined(CLOCK_MONOTONIC) +uint64_t mp_raw_time_us(void) +{ + struct timespec ts; + if (clock_gettime(CLOCK_MONOTONIC, &ts)) + abort(); + return ts.tv_sec * 1000000LL + ts.tv_nsec / 1000; +} +#else uint64_t mp_raw_time_us(void) { struct timeval tv; gettimeofday(&tv,NULL); return tv.tv_sec * 1000000LL + tv.tv_usec; } +#endif void mp_raw_time_init(void) { |