diff options
author | Torvald Riegel <triegel@redhat.com> | 2014-12-04 14:12:23 +0100 |
---|---|---|
committer | Torvald Riegel <triegel@redhat.com> | 2015-07-10 13:47:09 +0200 |
commit | a2f0363f817a58c4d3f439aa515a3b1d73efde36 (patch) | |
tree | 6204a1208c1421d573e8c91e4523376a18e1dd60 /nptl/pthread_once.c | |
parent | 203c1a898dd2e281eae30f3c57ceb8d4a50b00f4 (diff) | |
download | glibc-a2f0363f817a58c4d3f439aa515a3b1d73efde36.tar.gz |
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.
Diffstat (limited to 'nptl/pthread_once.c')
-rw-r--r-- | nptl/pthread_once.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/nptl/pthread_once.c b/nptl/pthread_once.c index fe6d923794..3c5bc33622 100644 --- a/nptl/pthread_once.c +++ b/nptl/pthread_once.c @@ -17,7 +17,7 @@ <http://www.gnu.org/licenses/>. */ #include "pthreadP.h" -#include <lowlevellock.h> +#include <futex-internal.h> #include <atomic.h> @@ -35,7 +35,7 @@ clear_once_control (void *arg) get interrupted (see __pthread_once), so all we need to relay to other threads is the state being reset again. */ atomic_store_relaxed (once_control, 0); - lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE); + futex_wake ((unsigned int *) once_control, INT_MAX, FUTEX_PRIVATE); } @@ -100,8 +100,10 @@ __pthread_once_slow (pthread_once_t *once_control, void (*init_routine) (void)) is set and __PTHREAD_ONCE_DONE is not. */ if (val == newval) { - /* Same generation, some other thread was faster. Wait. */ - lll_futex_wait (once_control, newval, LLL_PRIVATE); + /* Same generation, some other thread was faster. Wait and + retry. */ + futex_wait_simple ((unsigned int *) once_control, + (unsigned int) newval, FUTEX_PRIVATE); continue; } } @@ -122,7 +124,7 @@ __pthread_once_slow (pthread_once_t *once_control, void (*init_routine) (void)) atomic_store_release (once_control, __PTHREAD_ONCE_DONE); /* Wake up all other threads. */ - lll_futex_wake (once_control, INT_MAX, LLL_PRIVATE); + futex_wake ((unsigned int *) once_control, INT_MAX, FUTEX_PRIVATE); break; } |