diff options
author | rpj <rpj> | 2004-10-19 13:24:40 +0000 |
---|---|---|
committer | rpj <rpj> | 2004-10-19 13:24:40 +0000 |
commit | 8c8bcc5d1737002a9d153105c16b262d2e201efa (patch) | |
tree | ba43c6049cc7e361a3eb875015aeb4032c01c559 /ptw32_semwait.c | |
parent | 45b1b8cb2a6588f9316f780d8cefe11c181a9a17 (diff) |
Semaphore speedups - alpha, but passes testsuite
Diffstat (limited to 'ptw32_semwait.c')
-rw-r--r-- | ptw32_semwait.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ptw32_semwait.c b/ptw32_semwait.c index 38f31f5..2e9c883 100644 --- a/ptw32_semwait.c +++ b/ptw32_semwait.c @@ -83,7 +83,15 @@ ptw32_semwait (sem_t * sem) #else /* NEED_SEM */ - status = WaitForSingleObject ((*sem)->sem, INFINITE); + if (InterlockedDecrement((LPLONG) &(*sem)->value) < 0) + { + /* Must wait */ + status = WaitForSingleObject ((*sem)->sem, INFINITE); + } + else + { + return 0; + } #endif @@ -100,6 +108,9 @@ ptw32_semwait (sem_t * sem) } else { +#ifndef NEED_SEM + (void) InterlockedIncrement((LPLONG) &(*sem)->value); +#endif result = EINVAL; } } |