diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sem.c | 19 | ||||
-rw-r--r-- | src/status.c | 8 |
2 files changed, 12 insertions, 15 deletions
@@ -186,20 +186,17 @@ zix_sem_timed_wait(ZixSem* sem, struct timespec ts = {0, 0}; - if (clock_gettime(CLOCK_REALTIME, &ts)) { - return ZIX_STATUS_ERROR; - } - - ts.tv_sec += (time_t)seconds; - ts.tv_nsec += (long)nanoseconds; - int r = 0; - while ((r = sem_timedwait(&sem->sem, &ts)) && errno == EINTR) { - // Interrupted, try again + if (!(r = clock_gettime(CLOCK_REALTIME, &ts))) { + ts.tv_sec += (time_t)seconds; + ts.tv_nsec += (long)nanoseconds; + + while ((r = sem_timedwait(&sem->sem, &ts)) && errno == EINTR) { + // Interrupted, try again + } } - return r ? (errno == ETIMEDOUT ? ZIX_STATUS_TIMEOUT : zix_errno_status(errno)) - : ZIX_STATUS_SUCCESS; + return r ? zix_errno_status(errno) : ZIX_STATUS_SUCCESS; # endif } diff --git a/src/status.c b/src/status.c index a0bb17e..ed48952 100644 --- a/src/status.c +++ b/src/status.c @@ -41,10 +41,6 @@ zix_errno_status(const int e) switch (e) { case 0: return ZIX_STATUS_SUCCESS; -#ifdef EAGAIN - case EAGAIN: - return ZIX_STATUS_NO_MEM; -#endif #ifdef EEXIST case EEXIST: return ZIX_STATUS_EXISTS; @@ -57,6 +53,10 @@ zix_errno_status(const int e) case EPERM: return ZIX_STATUS_BAD_PERMS; #endif +#ifdef ETIMEDOUT + case ETIMEDOUT: + return ZIX_STATUS_TIMEOUT; +#endif default: break; } |