Andrew Geissler | 4b7c115 | 2020-11-30 19:55:29 -0600 | [diff] [blame^] | 1 | From 7df69c3a784ab2cc4770bdb366cf788cdb78099a Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sun, 15 Nov 2020 12:30:41 -0800 |
| 4 | Subject: [PATCH] os/linux: Fix build when __NR_futex is not available |
| 5 | |
| 6 | Newer architectures like riscv32 do not define __NR_futex intentionally |
| 7 | since it uses 64bit time_t from very beginning, therefore only caters to |
| 8 | futex_time64 syscall |
| 9 | |
| 10 | Upstream-Status: Pending |
| 11 | |
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 13 | --- |
| 14 | lib/direct/os/linux/glibc/system.c | 8 ++++++-- |
| 15 | 1 file changed, 6 insertions(+), 2 deletions(-) |
| 16 | |
| 17 | diff --git a/lib/direct/os/linux/glibc/system.c b/lib/direct/os/linux/glibc/system.c |
| 18 | index 373a711..d027a70 100644 |
| 19 | --- a/lib/direct/os/linux/glibc/system.c |
| 20 | +++ b/lib/direct/os/linux/glibc/system.c |
| 21 | @@ -36,6 +36,7 @@ |
| 22 | |
| 23 | #include <errno.h> |
| 24 | #include <signal.h> |
| 25 | +#include <sys/syscall.h> |
| 26 | #include <unistd.h> |
| 27 | |
| 28 | #include <linux/unistd.h> |
| 29 | @@ -46,6 +47,10 @@ |
| 30 | #include <direct/system.h> |
| 31 | #include <direct/util.h> |
| 32 | |
| 33 | +#if !defined(SYS_futex) && defined(SYS_futex_time64) |
| 34 | +# define SYS_futex SYS_futex_time64 |
| 35 | +#endif |
| 36 | + |
| 37 | D_LOG_DOMAIN( Direct_Futex, "Direct/Futex", "Direct Futex" ); |
| 38 | D_LOG_DOMAIN( Direct_Trap, "Direct/Trap", "Direct Trap" ); |
| 39 | |
| 40 | @@ -239,10 +244,9 @@ direct_futex( int *uaddr, int op, int val, const struct timespec *timeout, int * |
| 41 | } |
| 42 | #endif |
| 43 | |
| 44 | - ret = syscall( __NR_futex, uaddr, op, val, timeout, uaddr2, val3 ); |
| 45 | + ret = syscall( SYS_futex, uaddr, op, val, timeout, uaddr2, val3 ); |
| 46 | if (ret < 0) |
| 47 | return errno2result( errno ); |
| 48 | |
| 49 | return DR_OK; |
| 50 | } |
| 51 | - |
| 52 | -- |
| 53 | 2.29.2 |
| 54 | |