diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdEvent.c b/modules/libcom/src/osi/os/RTEMS-posix/osdEvent.c index 54dfccfff..abd9a8e9a 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdEvent.c +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdEvent.c @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include @@ -66,7 +66,7 @@ epicsEventWaitWithTimeout(epicsEventId pSem, double timeOut) { int sc; rtems_interval delay; - int rate = rtems_clock_get_ticks_per_second(); + rtems_interval rate = rtems_clock_get_ticks_per_second(); if (!rate) return epicsEventError; @@ -78,11 +78,16 @@ epicsEventWaitWithTimeout(epicsEventId pSem, double timeOut) else return epicsEventWaitTimeout; } - else if (timeOut >= (double) INT_MAX / rate) { - delay = 0; + else if (timeOut < (double) UINT32_MAX / rate) { + delay = timeOut * rate; + if (delay == 0) { + /* 0 < timeOut < 1/rate; round up */ + delay = 1; + } } else { - delay = timeOut * rate; + /* timeOut is NaN or too big to represent; wait forever */ + delay = RTEMS_NO_TIMEOUT; } sc = rtems_binary_semaphore_wait_timed_ticks(&pSem->rbs, delay);