This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC v2 06/20] sysdeps/futex: Use futex_time64 if avaliable
- From: Alistair Francis <alistair dot francis at wdc dot com>
- To: libc-alpha at sourceware dot org
- Cc: arnd at arndb dot de, adhemerval dot zanella at linaro dot org, fweimer at redhat dot com, palmer at sifive dot com, macro at wdc dot com, zongbox at gmail dot com, zong at andestech dot com, alistair dot francis at wdc dot com, alistair23 at gmail dot com
- Date: Mon, 24 Jun 2019 17:09:01 -0700
- Subject: [RFC v2 06/20] sysdeps/futex: Use futex_time64 if avaliable
- Ironport-sdr: 7eKAv0dfv+u8F6JO+BphLfEb5Gr4+/H5sZPe/ukWqd3/PA0srTqOczFstiRcbqesuWMgQHdSGg mIZn7YCt+tjEJhQSYb211lBWwqrJgEDWf9EXhymv+KP03QteCmblZ6iDbXU/EuD712PwsM79Gy TdgnDbeV0UaVBjLuSW5ZZz04dgIKMvhuD1Zv/UEM5eTVLqbDH78Y61KPEaruuQ0u5ZBK9eB5im 3siFXjVIuDibB3dAI3++kZ78UHUUPC5lVN15Q0VYjexhdTkDztfTLzNsjTAvCnp32iVQ2udKMj mv7+6GKjlWc1EfCyGFSG5k2t
- Ironport-sdr: 0DvivWsFbufqvUXXN8OOxa0klR0dxcu5hXQGseCxMQ0M8gknMM2xQvBHyvHPpxRQuF9MUkk7e6 1WlyVFGkxDVOhOgWxCY0bOSuB4Sg+iy18I8PqpgVySdMUaQhi/lL8fzm6Pziwa02JFzQWQr8wD VdOlG6sGv7YI2FgtUt1MlaBzDlsttjwpFtDa2pGMA7eg6z5jSDtG+V9pM/JjqRdCN+Qu0QTA1f 5DzTSUqlfd+ChQT5XADVzLXABBgEBgx6ShqPgR1sgbRrIXwi4pA8h/BHPeBUvduKGDHNCllBWB KJs=
- References: <cover.1561421042.git.alistair.francis@wdc.com>
The futex syscall isn't avaliable on newer 32-bit architectures
(such as RV32) so if futex_time64 is avaliable lets use that instead.
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
ChangeLog | 1 +
sysdeps/unix/sysv/linux/lowlevellock-futex.h | 28 ++++++++++++++------
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b90c5ab60c..a700783ef3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
* nptl/thrd_sleep.c: Use clock_nanosleep_time64 instead of nanosleep.
* sysdeps/unix/sysv/linux/nanosleep.c: Likewise.
* sysdeps/unix/sysv/linux/nanosleep_nocancel.c: Likewise.
+ * sysdeps/unix/sysv/linux/lowlevellock-futex.h: Use __NR_futex_time64 if we don't have __NR_futex.
2019-06-20 Dmitry V. Levin <ldv@altlinux.org>
Florian Weimer <fweimer@redhat.com>
diff --git a/sysdeps/unix/sysv/linux/lowlevellock-futex.h b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
index 030a14b8dc..e310542bfa 100644
--- a/sysdeps/unix/sysv/linux/lowlevellock-futex.h
+++ b/sysdeps/unix/sysv/linux/lowlevellock-futex.h
@@ -65,14 +65,26 @@
(((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
#endif
-#define lll_futex_syscall(nargs, futexp, op, ...) \
- ({ \
- INTERNAL_SYSCALL_DECL (__err); \
- long int __ret = INTERNAL_SYSCALL (futex, __err, nargs, futexp, op, \
- __VA_ARGS__); \
- (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret, __err)) \
- ? -INTERNAL_SYSCALL_ERRNO (__ret, __err) : 0); \
- })
+/* __NR_futex isn't defined on all archs (RV32) so use __NR_futex_time64 */
+#ifdef __NR_futex_time64
+# define lll_futex_syscall(nargs, futexp, op, ...) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret = INTERNAL_SYSCALL (futex_time64, __err, nargs, futexp, op, \
+ __VA_ARGS__); \
+ (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret, __err)) \
+ ? -INTERNAL_SYSCALL_ERRNO (__ret, __err) : 0); \
+ })
+#else
+# define lll_futex_syscall(nargs, futexp, op, ...) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret = INTERNAL_SYSCALL (futex, __err, nargs, futexp, op, \
+ __VA_ARGS__); \
+ (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret, __err)) \
+ ? -INTERNAL_SYSCALL_ERRNO (__ret, __err) : 0); \
+ })
+#endif
#define lll_futex_wait(futexp, val, private) \
lll_futex_timed_wait (futexp, val, NULL, private)
--
2.22.0