diff options
Diffstat (limited to 'libc/bionic/semaphore.c')
| -rw-r--r-- | libc/bionic/semaphore.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libc/bionic/semaphore.c b/libc/bionic/semaphore.c index 0c94600..84b9314 100644 --- a/libc/bionic/semaphore.c +++ b/libc/bionic/semaphore.c @@ -180,7 +180,7 @@ int sem_post(sem_t *sem) if (sem == NULL) return EINVAL; - if (__atomic_inc((volatile int*)&sem->count) == 0) + if (__atomic_inc((volatile int*)&sem->count) >= 0) __futex_wake(&sem->count, 1); return 0; @@ -196,7 +196,8 @@ int sem_trywait(sem_t *sem) if (__atomic_dec_if_positive(&sem->count) > 0) { return 0; } else { - return EAGAIN; + errno = EAGAIN; + return -1; } } |
