From 76fe1163c235931b2fd4eb033735f32e11f1a080 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 27 Aug 2015 09:22:03 +0200 Subject: [PATCH] Update scond_wait_timeout --- libretro-common/rthreads/rthreads.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libretro-common/rthreads/rthreads.c b/libretro-common/rthreads/rthreads.c index f4d20fd61e..a3496b6051 100644 --- a/libretro-common/rthreads/rthreads.c +++ b/libretro-common/rthreads/rthreads.c @@ -383,6 +383,7 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us) return ret == WAIT_OBJECT_0; #else int ret; + int64_t seconds, remainder; struct timespec now = {0}; #ifdef __MACH__ @@ -413,11 +414,11 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us) clock_gettime(CLOCK_REALTIME, &now); #endif - now.tv_sec += timeout_us / 1000000; - now.tv_nsec += timeout_us * 1000; + seconds = timeout_us / INT64_C(1000000); + remainder = timeout_us % INT64_C(1000000); - now.tv_sec += now.tv_nsec / 1000000000; - now.tv_nsec = now.tv_nsec % 1000000000; + now.tv_sec += seconds; + now.tv_nsec += remainder * INT64_C(1000); ret = pthread_cond_timedwait(&cond->cond, &lock->lock, &now); return (ret == 0);