From a2f0363f817a58c4d3f439aa515a3b1d73efde36 Mon Sep 17 00:00:00 2001 From: Torvald Riegel Date: Thu, 4 Dec 2014 14:12:23 +0100 Subject: Add and use new glibc-internal futex API. This adds new functions for futex operations, starting with wait, abstimed_wait, reltimed_wait, wake. They add documentation and error checking according to the current draft of the Linux kernel futex manpage. Waiting with absolute or relative timeouts is split into separate functions. This allows for removing a few cases of code duplication in pthreads code, which uses absolute timeouts; also, it allows us to put platform-specific code to go from an absolute to a relative timeout into the platform-specific futex abstractions.. Futex operations that can be canceled are also split out into separate functions suffixed by "_cancelable". There are separate versions for both Linux and NaCl; while they currently differ only slightly, my expectation is that the separate versions of lowlevellock-futex.h will eventually be merged into futex-internal.h when we get to move the lll_ functions over to the new futex API. --- nptl/pthread_barrier_init.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'nptl/pthread_barrier_init.c') diff --git a/nptl/pthread_barrier_init.c b/nptl/pthread_barrier_init.c index 5ea9fad291..8fe15ecba5 100644 --- a/nptl/pthread_barrier_init.c +++ b/nptl/pthread_barrier_init.c @@ -36,6 +36,7 @@ __pthread_barrier_init (barrier, attr, count) { struct pthread_barrier *ibarrier; + /* XXX EINVAL is not specified by POSIX as a possible error code. */ if (__glibc_unlikely (count == 0)) return EINVAL; @@ -44,11 +45,6 @@ __pthread_barrier_init (barrier, attr, count) ? iattr = (struct pthread_barrierattr *) attr : &default_barrierattr); - if (iattr->pshared != PTHREAD_PROCESS_PRIVATE - && __builtin_expect (iattr->pshared != PTHREAD_PROCESS_SHARED, 0)) - /* Invalid attribute. */ - return EINVAL; - ibarrier = (struct pthread_barrier *) barrier; /* Initialize the individual fields. */ @@ -57,14 +53,10 @@ __pthread_barrier_init (barrier, attr, count) ibarrier->init_count = count; ibarrier->curr_event = 0; -#ifdef __ASSUME_PRIVATE_FUTEX + /* XXX Don't use FUTEX_SHARED or FUTEX_PRIVATE as long as there are still + assembly implementations that expect the value determined below. */ ibarrier->private = (iattr->pshared != PTHREAD_PROCESS_PRIVATE ? 0 : FUTEX_PRIVATE_FLAG); -#else - ibarrier->private = (iattr->pshared != PTHREAD_PROCESS_PRIVATE - ? 0 : THREAD_GETMEM (THREAD_SELF, - header.private_futex)); -#endif return 0; } -- cgit 1.4.1