diff options
author | rpj <rpj> | 2005-05-06 07:27:10 +0000 |
---|---|---|
committer | rpj <rpj> | 2005-05-06 07:27:10 +0000 |
commit | 7523c7c4d75652f67cd31cb123e1268790394c8b (patch) | |
tree | 0920ebf089ccb971e0878542f85486171a541a8a /sem_post.c | |
parent | cf42850c77554311e62d3780f6a36cbc38e5e002 (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); } |