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. --- sysdeps/nptl/aio_misc.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sysdeps/nptl/aio_misc.h') diff --git a/sysdeps/nptl/aio_misc.h b/sysdeps/nptl/aio_misc.h index d5d1c08d0f..4a6ebfc9b3 100644 --- a/sysdeps/nptl/aio_misc.h +++ b/sysdeps/nptl/aio_misc.h @@ -22,14 +22,14 @@ #include #include -#include +#include #define DONT_NEED_AIO_MISC_COND 1 #define AIO_MISC_NOTIFY(waitlist) \ do { \ if (*waitlist->counterp > 0 && --*waitlist->counterp == 0) \ - lll_futex_wake (waitlist->counterp, 1, LLL_PRIVATE); \ + futex_wake ((unsigned int *) waitlist->counterp, 1, FUTEX_PRIVATE); \ } while (0) #define AIO_MISC_WAIT(result, futex, timeout, cancel) \ @@ -48,9 +48,9 @@ int status; \ do \ { \ - status = lll_futex_timed_wait (futexaddr, oldval, timeout, \ - LLL_PRIVATE); \ - if (status != -EWOULDBLOCK) \ + status = futex_reltimed_wait ((unsigned int *) futexaddr, oldval, \ + timeout, FUTEX_PRIVATE); \ + if (status != EAGAIN) \ break; \ \ oldval = *futexaddr; \ @@ -60,12 +60,12 @@ if (cancel) \ LIBC_CANCEL_RESET (oldtype); \ \ - if (status == -EINTR) \ + if (status == EINTR) \ result = EINTR; \ - else if (status == -ETIMEDOUT) \ + else if (status == ETIMEDOUT) \ result = EAGAIN; \ else \ - assert (status == 0 || status == -EWOULDBLOCK); \ + assert (status == 0 || status == EAGAIN); \ \ pthread_mutex_lock (&__aio_requests_mutex); \ } \ -- cgit v1.2.3