1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-10-28 23:34:53 +03:00

Remove futex_supports_pshared

Both NPTL and HTL support PTHREAD_PROCESS_SHARED, and since the removal of
the NaCL port there are no other pthread implementations.
This commit is contained in:
Andreas Schwab
2023-01-12 23:18:33 +01:00
parent 3b39822a82
commit ed5da9d659
8 changed files with 9 additions and 69 deletions

View File

@@ -17,15 +17,13 @@
#include <errno.h> #include <errno.h>
#include "pthreadP.h" #include "pthreadP.h"
#include <futex-internal.h>
#include <shlib-compat.h> #include <shlib-compat.h>
int int
__pthread_barrierattr_setpshared (pthread_barrierattr_t *attr, int pshared) __pthread_barrierattr_setpshared (pthread_barrierattr_t *attr, int pshared)
{ {
int err = futex_supports_pshared (pshared); if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
if (err != 0) return EINVAL;
return err;
((struct pthread_barrierattr *) attr)->pshared = pshared; ((struct pthread_barrierattr *) attr)->pshared = pshared;

View File

@@ -17,15 +17,13 @@
#include <errno.h> #include <errno.h>
#include <pthreadP.h> #include <pthreadP.h>
#include <futex-internal.h>
#include <shlib-compat.h> #include <shlib-compat.h>
int int
__pthread_condattr_setpshared (pthread_condattr_t *attr, int pshared) __pthread_condattr_setpshared (pthread_condattr_t *attr, int pshared)
{ {
int err = futex_supports_pshared (pshared); if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
if (err != 0) return EINVAL;
return err;
int *valuep = &((struct pthread_condattr *) attr)->value; int *valuep = &((struct pthread_condattr *) attr)->value;

View File

@@ -17,7 +17,6 @@
#include <errno.h> #include <errno.h>
#include <pthreadP.h> #include <pthreadP.h>
#include <futex-internal.h>
#include <shlib-compat.h> #include <shlib-compat.h>
int int
@@ -25,9 +24,8 @@ __pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, int pshared)
{ {
struct pthread_mutexattr *iattr; struct pthread_mutexattr *iattr;
int err = futex_supports_pshared (pshared); if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
if (err != 0) return EINVAL;
return err;
iattr = (struct pthread_mutexattr *) attr; iattr = (struct pthread_mutexattr *) attr;

View File

@@ -17,7 +17,6 @@
#include <errno.h> #include <errno.h>
#include "pthreadP.h" #include "pthreadP.h"
#include <futex-internal.h>
#include <shlib-compat.h> #include <shlib-compat.h>
int int
@@ -25,9 +24,8 @@ __pthread_rwlockattr_setpshared (pthread_rwlockattr_t *attr, int pshared)
{ {
struct pthread_rwlockattr *iattr; struct pthread_rwlockattr *iattr;
int err = futex_supports_pshared (pshared); if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
if (err != 0) return EINVAL;
return err;
iattr = (struct pthread_rwlockattr *) attr; iattr = (struct pthread_rwlockattr *) attr;

View File

@@ -20,7 +20,6 @@
#include <shlib-compat.h> #include <shlib-compat.h>
#include "semaphoreP.h" #include "semaphoreP.h"
#include <kernel-features.h> #include <kernel-features.h>
#include <futex-internal.h>
int int
@@ -34,13 +33,6 @@ __new_sem_init (sem_t *sem, int pshared, unsigned int value)
__set_errno (EINVAL); __set_errno (EINVAL);
return -1; 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. */ /* Map to the internal type. */
struct new_sem *isem = (struct new_sem *) sem; 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; isem->nwaiters = 0;
#endif #endif
isem->private = (pshared == PTHREAD_PROCESS_PRIVATE isem->private = (pshared == 0 ? FUTEX_PRIVATE : FUTEX_SHARED);
? FUTEX_PRIVATE : FUTEX_SHARED);
return 0; return 0;
} }

View File

@@ -22,18 +22,4 @@
#include <pthread.h> #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 */ #endif /* futex-internal.h */

View File

@@ -38,12 +38,6 @@
return values that callers need to handle. return values that callers need to handle.
The private flag must be either FUTEX_PRIVATE or FUTEX_SHARED. 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 Given that waking other threads waiting on a futex involves concurrent
accesses to the futex word, you must use atomic operations to access the 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 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). */ 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 /* Atomically wrt other futex operations on the same futex, this blocks iff
the value *FUTEX_WORD matches the expected value. This is the value *FUTEX_WORD matches the expected value. This is
semantically equivalent to: semantically equivalent to:

View File

@@ -23,7 +23,6 @@
#include "semaphoreP.h" #include "semaphoreP.h"
#include <shm-directory.h> #include <shm-directory.h>
#include <sem_routines.h> #include <sem_routines.h>
#include <futex-internal.h>
#include <libc-lock.h> #include <libc-lock.h>
#include <string.h> #include <string.h>
#include <shlib-compat.h> #include <shlib-compat.h>
@@ -36,14 +35,6 @@ __sem_open (const char *name, int oflag, ...)
int fd; int fd;
sem_t *result; 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; struct shmdir_name dirname;
int ret = __shm_get_name (&dirname, name, true); int ret = __shm_get_name (&dirname, name, true);
if (ret != 0) if (ret != 0)