This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC v2 06/20] sysdeps/futex: Use futex_time64 if avaliable


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]