diff options
Diffstat (limited to 'libutils/Timers.cpp')
-rw-r--r-- | libutils/Timers.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libutils/Timers.cpp b/libutils/Timers.cpp index 5293cd2..4687d4d 100644 --- a/libutils/Timers.cpp +++ b/libutils/Timers.cpp @@ -32,9 +32,9 @@ #include <windows.h> #endif +#if defined(HAVE_ANDROID_OS) nsecs_t systemTime(int clock) { -#if defined(HAVE_POSIX_CLOCKS) static const clockid_t clocks[] = { CLOCK_REALTIME, CLOCK_MONOTONIC, @@ -46,14 +46,19 @@ nsecs_t systemTime(int clock) t.tv_sec = t.tv_nsec = 0; clock_gettime(clocks[clock], &t); return nsecs_t(t.tv_sec)*1000000000LL + t.tv_nsec; +} #else - // we don't support the clocks here. +nsecs_t systemTime(int /*clock*/) +{ + // Clock support varies widely across hosts. Mac OS doesn't support + // posix clocks, older glibcs don't support CLOCK_BOOTTIME and Windows + // is windows. struct timeval t; t.tv_sec = t.tv_usec = 0; gettimeofday(&t, NULL); return nsecs_t(t.tv_sec)*1000000000LL + nsecs_t(t.tv_usec)*1000LL; -#endif } +#endif int toMillisecondTimeoutDelay(nsecs_t referenceTime, nsecs_t timeoutTime) { |