]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Remove futex_supports_pshared
authorAndreas Schwab <schwab@linux-m68k.org>
Thu, 12 Jan 2023 22:18:33 +0000 (23:18 +0100)
committerAndreas Schwab <schwab@linux-m68k.org>
Mon, 8 Sep 2025 13:01:18 +0000 (15:01 +0200)
Both NPTL and HTL support PTHREAD_PROCESS_SHARED, and since the removal of
the NaCL port there are no other pthread implementations.

nptl/pthread_barrierattr_setpshared.c
nptl/pthread_condattr_setpshared.c
nptl/pthread_mutexattr_setpshared.c
nptl/pthread_rwlockattr_setpshared.c
nptl/sem_init.c
sysdeps/htl/futex-internal.h
sysdeps/nptl/futex-internal.h
sysdeps/pthread/sem_open.c

index ae58a2b4fa014a86f27ce1e484bdf36d4d2e5609..74b025818b3af79463a99f892158c16e08735e02 100644 (file)
 
 #include <errno.h>
 #include "pthreadP.h"
-#include <futex-internal.h>
 #include <shlib-compat.h>
 
 int
 __pthread_barrierattr_setpshared (pthread_barrierattr_t *attr, int pshared)
 {
-  int err = futex_supports_pshared (pshared);
-  if (err != 0)
-    return err;
+  if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
+    return EINVAL;
 
   ((struct pthread_barrierattr *) attr)->pshared = pshared;
 
index 13e6f78d18b3a050e1481e6347586e7165b2a8a3..2ab3e9f9e99e48cb2b28d48043400d58f87cb4bf 100644 (file)
 
 #include <errno.h>
 #include <pthreadP.h>
-#include <futex-internal.h>
 #include <shlib-compat.h>
 
 int
 __pthread_condattr_setpshared (pthread_condattr_t *attr, int pshared)
 {
-  int err = futex_supports_pshared (pshared);
-  if (err != 0)
-    return err;
+  if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
+    return EINVAL;
 
   int *valuep = &((struct pthread_condattr *) attr)->value;
 
index fea8ee6d70792c14e43b9ba67e914af8370469ce..d7ef3430c35e2432dade6be594fb266f9b4724a4 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <errno.h>
 #include <pthreadP.h>
-#include <futex-internal.h>
 #include <shlib-compat.h>
 
 int
@@ -25,9 +24,8 @@ __pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, int pshared)
 {
   struct pthread_mutexattr *iattr;
 
-  int err = futex_supports_pshared (pshared);
-  if (err != 0)
-    return err;
+  if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
+    return EINVAL;
 
   iattr = (struct pthread_mutexattr *) attr;
 
index c32d99515a1b9f08e8640f889303be22c906c311..655bcef7262e481b81b932dc4107053d78d8c6be 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <errno.h>
 #include "pthreadP.h"
-#include <futex-internal.h>
 #include <shlib-compat.h>
 
 int
@@ -25,9 +24,8 @@ __pthread_rwlockattr_setpshared (pthread_rwlockattr_t *attr, int pshared)
 {
   struct pthread_rwlockattr *iattr;
 
-  int err = futex_supports_pshared (pshared);
-  if (err != 0)
-    return err;
+  if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
+    return EINVAL;
 
   iattr = (struct pthread_rwlockattr *) attr;
 
index cf17411270318e8d3ddeb69b3a250c75b0b4b4e7..76e1aceb70d1777a0da0deb38b4115a7416d30b5 100644 (file)
@@ -20,7 +20,6 @@
 #include <shlib-compat.h>
 #include "semaphoreP.h"
 #include <kernel-features.h>
-#include <futex-internal.h>
 
 
 int
@@ -34,13 +33,6 @@ __new_sem_init (sem_t *sem, int pshared, unsigned int value)
       __set_errno (EINVAL);
       return -1;
     }
-  pshared = pshared != 0 ? PTHREAD_PROCESS_SHARED : PTHREAD_PROCESS_PRIVATE;
-  int err = futex_supports_pshared (pshared);
-  if (err != 0)
-    {
-      __set_errno (err);
-      return -1;
-    }
 
   /* Map to the internal type.  */
   struct new_sem *isem = (struct new_sem *) sem;
@@ -55,8 +47,7 @@ __new_sem_init (sem_t *sem, int pshared, unsigned int value)
   isem->nwaiters = 0;
 #endif
 
-  isem->private = (pshared == PTHREAD_PROCESS_PRIVATE
-                  ? FUTEX_PRIVATE : FUTEX_SHARED);
+  isem->private = (pshared == 0 ? FUTEX_PRIVATE : FUTEX_SHARED);
 
   return 0;
 }
index 4976fa07c2595af4f15d292379c3de6d44b3e692..7380290183e3d80c0575fcc3cfb01c1bfaee7e76 100644 (file)
 
 #include <pthread.h>
 
-/* Returns EINVAL if PSHARED is neither PTHREAD_PROCESS_PRIVATE nor
-   PTHREAD_PROCESS_SHARED; otherwise, returns 0 if PSHARED is supported, and
-   ENOTSUP if not.  */
-static __always_inline int
-futex_supports_pshared (int pshared)
-{
-  if (__glibc_likely (pshared == PTHREAD_PROCESS_PRIVATE))
-    return 0;
-  else if (pshared == PTHREAD_PROCESS_SHARED)
-    return 0;
-  else
-    return EINVAL;
-}
-
 #endif  /* futex-internal.h */
index 301daccbb1c1b16985675b5ca8dfba6a6a73dac9..2533c91dd31a5b68e1dfd2471e83d83d3cb398e1 100644 (file)
    return values that callers need to handle.
 
    The private flag must be either FUTEX_PRIVATE or FUTEX_SHARED.
-   FUTEX_PRIVATE is always supported, and the implementation can internally
-   use FUTEX_SHARED when FUTEX_PRIVATE is requested.  FUTEX_SHARED is not
-   necessarily supported (use futex_supports_pshared to detect this).
-
-   We expect callers to only use these operations if futexes and the
-   specific futex operations being used are supported (e.g., FUTEX_SHARED).
 
    Given that waking other threads waiting on a futex involves concurrent
    accesses to the futex word, you must use atomic operations to access the
@@ -95,20 +89,6 @@ futex_fatal_error (void)
    We expect a Linux kernel version of 2.6.22 or more recent (since this
    version, EINTR is not returned on spurious wake-ups anymore).  */
 
-/* Returns EINVAL if PSHARED is neither PTHREAD_PROCESS_PRIVATE nor
-   PTHREAD_PROCESS_SHARED; otherwise, returns 0 if PSHARED is supported, and
-   ENOTSUP if not.  */
-static __always_inline int
-futex_supports_pshared (int pshared)
-{
-  if (__glibc_likely (pshared == PTHREAD_PROCESS_PRIVATE))
-    return 0;
-  else if (pshared == PTHREAD_PROCESS_SHARED)
-    return 0;
-  else
-    return EINVAL;
-}
-
 /* Atomically wrt other futex operations on the same futex, this blocks iff
    the value *FUTEX_WORD matches the expected value.  This is
    semantically equivalent to:
index 992786e01b442fe5a6a54431c167a1fff0203738..143b60a0d08a39c56359f7f38fc0381f69cb5c5a 100644 (file)
@@ -23,7 +23,6 @@
 #include "semaphoreP.h"
 #include <shm-directory.h>
 #include <sem_routines.h>
-#include <futex-internal.h>
 #include <libc-lock.h>
 #include <string.h>
 #include <shlib-compat.h>
@@ -36,14 +35,6 @@ __sem_open (const char *name, int oflag, ...)
   int fd;
   sem_t *result;
 
-  /* Check that shared futexes are supported.  */
-  int err = futex_supports_pshared (PTHREAD_PROCESS_SHARED);
-  if (err != 0)
-    {
-      __set_errno (err);
-      return SEM_FAILED;
-    }
-
   struct shmdir_name dirname;
   int ret = __shm_get_name (&dirname, name, true);
   if (ret != 0)