From 6a84f2c1da0f8d9fd1946caa55a336ebacfeb392 Mon Sep 17 00:00:00 2001 From: Thomas Pedersen Date: Thu, 10 Jun 2021 17:15:47 -0700 Subject: [PATCH] Posix: fix event_wait_timed() (#346) event_wait_timed() was ignoring a timeout of 1000 ms. Presumably this is because pthread_cond_timedwait() only considers tv_nsec less than one second. Convert the timeout in miliseconds to second and nanosecond components to fix this. Co-authored-by: alfred gedeon <28123637+alfred2g@users.noreply.github.com> --- portable/ThirdParty/GCC/Posix/utils/wait_for_event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c b/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c index 29368d234..894c6314f 100644 --- a/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c +++ b/portable/ThirdParty/GCC/Posix/utils/wait_for_event.c @@ -76,8 +76,8 @@ bool event_wait_timed( struct event * ev, int ret = 0; clock_gettime( CLOCK_REALTIME, &ts ); - //ts.tv_sec += ms; - ts.tv_nsec += (ms * 1000000); + ts.tv_sec += ms / 1000; + ts.tv_nsec += ((ms % 1000) * 1000000); pthread_mutex_lock( &ev->mutex ); while( (ev->event_triggered == false) && (ret == 0) )