summaryrefslogtreecommitdiff
path: root/sem_post_multiple.c
diff options
context:
space:
mode:
authorrpj <rpj>2004-10-19 13:24:40 +0000
committerrpj <rpj>2004-10-19 13:24:40 +0000
commit8c8bcc5d1737002a9d153105c16b262d2e201efa (patch)
treeba43c6049cc7e361a3eb875015aeb4032c01c559 /sem_post_multiple.c
parent45b1b8cb2a6588f9316f780d8cefe11c181a9a17 (diff)
Semaphore speedups - alpha, but passes testsuite
Diffstat (limited to 'sem_post_multiple.c')
-rw-r--r--sem_post_multiple.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sem_post_multiple.c b/sem_post_multiple.c
index 43c71a6..e30e01a 100644
--- a/sem_post_multiple.c
+++ b/sem_post_multiple.c
@@ -76,6 +76,9 @@ sem_post_multiple (sem_t * sem, int count)
*/
{
int result = 0;
+#ifndef NEED_SEM
+ long waiters;
+#endif
if (sem == NULL || *sem == NULL || count <= 0)
{
@@ -88,7 +91,8 @@ sem_post_multiple (sem_t * sem, int count)
#else /* NEED_SEM */
- else if (!ReleaseSemaphore ((*sem)->sem, count, 0))
+ else if ((waiters = -InterlockedExchangeAdd((LPLONG) &(*sem)->value, (LONG) count)) > 0
+ && !ReleaseSemaphore((*sem)->sem, (waiters<=count)?waiters:count, 0))
#endif /* NEED_SEM */