mirror of
				https://sourceware.org/git/glibc.git
				synced 2025-10-30 10:45:40 +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:
		| @@ -17,15 +17,13 @@ | ||||
|  | ||||
| #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; | ||||
|  | ||||
|   | ||||
| @@ -17,15 +17,13 @@ | ||||
|  | ||||
| #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; | ||||
|  | ||||
|   | ||||
| @@ -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; | ||||
|  | ||||
|   | ||||
| @@ -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; | ||||
|  | ||||
|   | ||||
| @@ -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; | ||||
| } | ||||
|   | ||||
| @@ -22,18 +22,4 @@ | ||||
|  | ||||
| #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 */ | ||||
|   | ||||
| @@ -38,12 +38,6 @@ | ||||
|    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: | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user