aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/lowlevellock-futex.h
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/lowlevellock-futex.h')
-rw-r--r--sysdeps/unix/sysv/linux/lowlevellock-futex.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/sysdeps/unix/sysv/linux/lowlevellock-futex.h b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
index 030a14b8dc..cfa796be2b 100644
--- a/sysdeps/unix/sysv/linux/lowlevellock-futex.h
+++ b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
@@ -82,12 +82,32 @@
__lll_private_flag (FUTEX_WAIT, private), \
val, timeout)
-#define lll_futex_timed_wait_bitset(futexp, val, timeout, clockbit, private) \
- lll_futex_syscall (6, futexp, \
- __lll_private_flag (FUTEX_WAIT_BITSET | (clockbit), \
- private), \
- val, timeout, NULL /* Unused. */, \
- FUTEX_BITSET_MATCH_ANY)
+/* Verify whether the supplied clockid is supported by
+ lll_futex_clock_wait_bitset. */
+#define lll_futex_supported_clockid(clockid) \
+ ((clockid) == CLOCK_REALTIME || (clockid) == CLOCK_MONOTONIC)
+
+/* The kernel currently only supports CLOCK_MONOTONIC or
+ CLOCK_REALTIME timeouts for FUTEX_WAIT_BITSET. We could attempt to
+ convert others here but currently do not. */
+#define lll_futex_clock_wait_bitset(futexp, val, clockid, timeout, private) \
+ ({ \
+ long int __ret; \
+ if (lll_futex_supported_clockid (clockid)) \
+ { \
+ const unsigned int clockbit = \
+ (clockid == CLOCK_REALTIME) ? FUTEX_CLOCK_REALTIME : 0; \
+ const int op = \
+ __lll_private_flag (FUTEX_WAIT_BITSET | clockbit, private); \
+ \
+ __ret = lll_futex_syscall (6, futexp, op, val, \
+ timeout, NULL /* Unused. */, \
+ FUTEX_BITSET_MATCH_ANY); \
+ } \
+ else \
+ __ret = -EINVAL; \
+ __ret; \
+ })
#define lll_futex_wake(futexp, nr, private) \
lll_futex_syscall (4, futexp, \