From: Bob van Loosen Date: Sun, 26 Feb 2012 22:16:58 +0000 (+0100) Subject: fixed: the timeout value of pthread_cond_timedwait has to be referenced to CLOCK_REALTIME X-Git-Tag: upstream/2.2.0~1^2~33^2~29 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1ea419fa5dcfa91666239d6ff86520605f95ba51;p=deb_libcec.git fixed: the timeout value of pthread_cond_timedwait has to be referenced to CLOCK_REALTIME --- diff --git a/src/lib/platform/posix/os-threads.h b/src/lib/platform/posix/os-threads.h index 5216ffe..c37beed 100644 --- a/src/lib/platform/posix/os-threads.h +++ b/src/lib/platform/posix/os-threads.h @@ -48,13 +48,12 @@ namespace PLATFORM inline struct timespec GetAbsTime(uint64_t iIncreaseBy = 0) { - struct timespec abstime; - struct timeval now; - gettimeofday(&now, NULL); - iIncreaseBy += now.tv_usec / 1000; - abstime.tv_sec = now.tv_sec + (time_t)(iIncreaseBy / 1000); - abstime.tv_nsec = (int32_t)((iIncreaseBy % (uint32_t)1000) * (uint32_t)1000000); - return abstime; + struct timespec now; + clock_gettime(CLOCK_REALTIME, &now); + now.tv_nsec += iIncreaseBy % 1000 * 1000000; + now.tv_sec += iIncreaseBy / 1000 + now.tv_nsec / 1000000000; + now.tv_nsec %= 1000000000; + return now; } typedef pthread_t thread_t;