Patchwork [RFC,v1,02/16] sysdeps/futex: Use __NR_futex_time64 if we don't have __NR_futex

login
register
mail settings
Submitter Alistair Francis
Date June 22, 2019, 4:37 a.m.
Message ID <9e358d4856a30c13d14f79ca45dbbef8a33826b7.1561177967.git.alistair.francis@wdc.com>
Download mbox | patch
Permalink /patch/33261/
State New
Headers show

Comments

Alistair Francis - June 22, 2019, 4:37 a.m.
__NR_futex isn't avaliable on newer 32-bit architectures (such as RV32)
so if it isn't avaliable lets use __NR_futex_time64 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(-)

Patch

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..cde4a9157c 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);                     \
-  })
+#ifndef __NR_futex
+/* __NR_futex isn't defined on all archs (RV32) so use __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)