From: Lars Op den Kamp Date: Mon, 27 Feb 2012 14:32:13 +0000 (+0100) Subject: platform: use gettimeofday() on darwin in GetAbsTime(), as it is specified in OS... X-Git-Tag: upstream/2.2.0~1^2~33^2~20 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=28b0f9fb414370ecd61b93722bfd7d129ea009a8;p=deb_libcec.git platform: use gettimeofday() on darwin in GetAbsTime(), as it is specified in OS-X dev guide --- diff --git a/src/lib/platform/posix/os-threads.h b/src/lib/platform/posix/os-threads.h index c37beed..fc28fc9 100644 --- a/src/lib/platform/posix/os-threads.h +++ b/src/lib/platform/posix/os-threads.h @@ -49,7 +49,14 @@ namespace PLATFORM inline struct timespec GetAbsTime(uint64_t iIncreaseBy = 0) { struct timespec now; + #ifdef __APPLE__ + struct timeval tv; + gettimeofday(&tv, NULL); + now.tv_sec = tv.tv_sec + 0; + now.tv_nsec = 0; + #else clock_gettime(CLOCK_REALTIME, &now); + #endif now.tv_nsec += iIncreaseBy % 1000 * 1000000; now.tv_sec += iIncreaseBy / 1000 + now.tv_nsec / 1000000000; now.tv_nsec %= 1000000000;