Remove unused variables
[glibc.git] / sysdeps / nacl / lowlevellock-futex.h
blob5382f685ff426b8c09667767f8695c847b5e7916
1 /* Low-level locking access to futex facilities. NaCl version.
2 Copyright (C) 2015-2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _LOWLEVELLOCK_FUTEX_H
20 #define _LOWLEVELLOCK_FUTEX_H 1
22 #include <nacl-interfaces.h>
23 #include <time.h>
26 #pragma GCC diagnostic ignored "-Wunused-value" /* XXX */
28 /* Values for 'private' parameter of locking macros. Note pthreadP.h
29 optimizes for these exact values, though they are not required. */
30 #define LLL_PRIVATE 0
31 #define LLL_SHARED 128
33 #define FUTEX_PRIVATE_FLAG 0 /* XXX */
36 /* Wait while *FUTEXP == VAL for an lll_futex_wake call on FUTEXP. */
37 #define lll_futex_wait(futexp, val, private) \
38 ((void) (private), \
39 - __nacl_irt_futex.futex_wait_abs ((volatile int *) (futexp), val, NULL))
41 /* Wait until a lll_futex_wake call on FUTEXP, or TIMEOUT elapses. */
42 #define lll_futex_timed_wait(futexp, val, timeout, private) \
43 ({ \
44 /* This timeout is relative, but the IRT call wants it absolute. */\
45 const struct timespec *_to = (timeout); \
46 struct timespec _ts; \
47 int _err = 0; \
48 if (_to != NULL \
49 && __glibc_likely ((_err = __nacl_irt_clock.clock_gettime \
50 (CLOCK_REALTIME, &_ts)) == 0)) \
51 { \
52 _ts.tv_sec += _to->tv_sec; \
53 _ts.tv_nsec += _to->tv_nsec; \
54 while (_ts.tv_nsec >= 1000000000) \
55 { \
56 _ts.tv_nsec -= 1000000000; \
57 ++_ts.tv_sec; \
58 } \
59 _to = &_ts; \
60 } \
61 if (_err == 0) \
62 _err = __nacl_irt_futex.futex_wait_abs \
63 ((volatile int *) (futexp), val, _to); \
64 (void) (private); \
65 -_err; \
68 /* Wake up up to NR waiters on FUTEXP. */
69 #define lll_futex_wake(futexp, nr, private) \
70 ({ \
71 int _woken; \
72 (void) (private); \
73 - __nacl_irt_futex.futex_wake ((volatile int *) (futexp), nr, &_woken); \
76 /* NaCl does not support the requeue operation. The only use of this is in
77 pthread_cond_broadcast, which handles an error return by falling back to
78 plain lll_futex_wake. */
79 #define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
80 ((futexp), (nr_wake), (nr_move), (mutex), (val), (private), -ENOSYS)
82 /* NaCl does not support the special wake-unlock operation. The only use
83 of this is in pthread_cond_signal, which handles an error return by
84 falling back to plain lll_futex_wake. */
85 /* Wake up up to NR_WAKE waiters on FUTEXP and NR_WAKE2 on FUTEXP2. */
86 #define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
87 ((futexp), (nr_wake), (nr_wake2), (futexp2), (private), -ENOSYS)
90 #endif /* lowlevellock-futex.h */