htl: Add support for semaphore maximum value

This commit is contained in:
Samuel Thibault 2020-02-09 22:44:08 +00:00
parent 819bb5e660
commit 5e77ec7c6e
2 changed files with 10 additions and 0 deletions

View File

@ -30,6 +30,13 @@ __sem_post (sem_t *sem)
if (sem->__value > 0)
/* Do a quick up. */
{
if (sem->__value == SEM_VALUE_MAX)
{
__pthread_spin_unlock (&sem->__lock);
errno = EOVERFLOW;
return -1;
}
assert (sem->__queue == NULL);
sem->__value++;
__pthread_spin_unlock (&sem->__lock);

View File

@ -41,3 +41,6 @@
/* The number of threads per process. */
#define _POSIX_THREAD_THREADS_MAX 64
/* Maximum value the semaphore can have. */
#define SEM_VALUE_MAX (2147483647)