summaryrefslogtreecommitdiff
path: root/sem_wait.c
diff options
context:
space:
mode:
Diffstat (limited to 'sem_wait.c')
-rw-r--r--sem_wait.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sem_wait.c b/sem_wait.c
index e2e171c..0c2ed59 100644
--- a/sem_wait.c
+++ b/sem_wait.c
@@ -92,8 +92,14 @@ sem_wait (sem_t * sem)
#else /* NEED_SEM */
- result = pthreadCancelableWait ((*sem)->sem);
-
+ sem_t s = *sem;
+
+ if (InterlockedDecrement((LPLONG) &s->value) < 0)
+ {
+ /* Must wait */
+ result = pthreadCancelableWait (s->sem);
+ }
+
#endif /* NEED_SEM */
}