diff options
author | rpj <rpj> | 2005-05-06 07:31:28 +0000 |
---|---|---|
committer | rpj <rpj> | 2005-05-06 07:31:28 +0000 |
commit | 78f83cfa240ec14874b22c7302ff8d306c130aaf (patch) | |
tree | bf29a117aecb99e9ecb2d30bad398d8b20392b49 /sem_post.c | |
parent | e3845d9b6b0a18ffdfdf0cefd811a17fce62f1ac (diff) |
''
Diffstat (limited to 'sem_post.c')
-rw-r--r-- | sem_post.c | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -68,6 +68,7 @@ sem_post (sem_t * sem) * ERRNO * EINVAL 'sem' is not a valid semaphore, * ENOSYS semaphores are not supported, + * ERANGE semaphore count is too big * * ------------------------------------------------------ */ @@ -81,23 +82,29 @@ sem_post (sem_t * sem) } else if ((result = pthread_mutex_lock (&s->lock)) == 0) { -#ifdef NEED_SEM - - if (++s->value <= 0) + if (s->value < _POSIX_SEM_VALUE_MAX) { - if (!SetEvent(s->sem)) +#ifdef NEED_SEM + if (++s->value <= 0 + && !SetEvent(s->sem)) { + s->value--; result = EINVAL; } - } #else - if (++s->value <= 0 - && !ReleaseSemaphore (s->sem, 1, NULL)) + if (++s->value <= 0 + && !ReleaseSemaphore (s->sem, 1, NULL)) + { + s->value--; + result = EINVAL; + } +#endif /* NEED_SEM */ + } + else { - result = EINVAL; + result = ERANGE; } -#endif /* NEED_SEM */ - + (void) pthread_mutex_unlock (&s->lock); } |