]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
htl: Add support for semaphore maximum value
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 9 Feb 2020 22:44:08 +0000 (22:44 +0000)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 10 Feb 2020 01:03:54 +0000 (01:03 +0000)
sysdeps/htl/sem-post.c
sysdeps/mach/hurd/bits/local_lim.h

index 77f297314e191e8b66952f00c386e1a8103b885e..2e0be8fc4950c89088ccd4cce50e5d9753c5cf58 100644 (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);
index 348eee74bb0d79fea464ce8b2fd5420f7119c3ef..8e781e4965f7a7758c587da505a008592da84bd0 100644 (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)