summaryrefslogtreecommitdiff
path: root/sem_trywait.c
diff options
context:
space:
mode:
Diffstat (limited to 'sem_trywait.c')
-rw-r--r--sem_trywait.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sem_trywait.c b/sem_trywait.c
index 342ee06..253c10e 100644
--- a/sem_trywait.c
+++ b/sem_trywait.c
@@ -92,8 +92,9 @@ sem_trywait (sem_t * sem)
{
result = EINVAL;
}
- else if (WaitForSingleObject ((*sem)->sem, 0) == WAIT_TIMEOUT)
+ else if (InterlockedDecrement((LPLONG) &(*sem)->value) < 0)
{
+ (void) InterlockedIncrement((LPLONG) &(*sem)->value);
result = EAGAIN;
}