0001-os-linux-Fix-build-when-__NR_futex-is-not-available.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. Newer architectures like riscv32 do not define __NR_futex intentionally
  6. since it uses 64bit time_t from very beginning, therefore only caters to
  7. futex_time64 syscall
  8. Upstream-Status: Pending
  9. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  10. ---
  11. lib/direct/os/linux/glibc/system.c | 8 ++++++--
  12. 1 file changed, 6 insertions(+), 2 deletions(-)
  13. diff --git a/lib/direct/os/linux/glibc/system.c b/lib/direct/os/linux/glibc/system.c
  14. index 373a711..d027a70 100644
  15. --- a/lib/direct/os/linux/glibc/system.c
  16. +++ b/lib/direct/os/linux/glibc/system.c
  17. @@ -36,6 +36,7 @@
  18. #include <errno.h>
  19. #include <signal.h>
  20. +#include <sys/syscall.h>
  21. #include <unistd.h>
  22. #include <linux/unistd.h>
  23. @@ -46,6 +47,10 @@
  24. #include <direct/system.h>
  25. #include <direct/util.h>
  26. +#if !defined(SYS_futex) && defined(SYS_futex_time64)
  27. +# define SYS_futex SYS_futex_time64
  28. +#endif
  29. +
  30. D_LOG_DOMAIN( Direct_Futex, "Direct/Futex", "Direct Futex" );
  31. D_LOG_DOMAIN( Direct_Trap, "Direct/Trap", "Direct Trap" );
  32. @@ -239,10 +244,9 @@ direct_futex( int *uaddr, int op, int val, const struct timespec *timeout, int *
  33. }
  34. #endif
  35. - ret = syscall( __NR_futex, uaddr, op, val, timeout, uaddr2, val3 );
  36. + ret = syscall( SYS_futex, uaddr, op, val, timeout, uaddr2, val3 );
  37. if (ret < 0)
  38. return errno2result( errno );
  39. return DR_OK;
  40. }
  41. -
  42. --
  43. 2.29.2