0001-Use-SYS_futex-instead-of-__NR_futex.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. From 83068f9b71aea16d1ad036fdcc326de1027b5585 Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Sun, 15 Nov 2020 22:13:29 -0800
  4. Subject: [PATCH] Use SYS_futex instead of __NR_futex
  5. SYS_futex is expected from system C library.
  6. in glibc (/usr/include/bits/syscall.h defines it in terms of of NR_futex)
  7. rv32 is using 64bit time_t from get go unlike other 32bit architectures
  8. in glibc, therefore it wont have NR_futex defined but just NR_futex_time64
  9. this aliases it to NR_futex so that SYS_futex is then defined for rv32
  10. Upstream-Status: Submitted [https://github.com/jackaudio/jack2/pull/670]
  11. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  12. ---
  13. linux/JackLinuxFutex.cpp | 10 +++++++---
  14. 1 file changed, 7 insertions(+), 3 deletions(-)
  15. diff --git a/linux/JackLinuxFutex.cpp b/linux/JackLinuxFutex.cpp
  16. index deff006b..aef99cd2 100644
  17. --- a/linux/JackLinuxFutex.cpp
  18. +++ b/linux/JackLinuxFutex.cpp
  19. @@ -29,6 +29,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. #include <syscall.h>
  21. #include <linux/futex.h>
  22. +#if !defined(SYS_futex) && defined(SYS_futex_time64)
  23. +#define SYS_futex SYS_futex_time64
  24. +#endif
  25. +
  26. namespace Jack
  27. {
  28. @@ -67,7 +71,7 @@ bool JackLinuxFutex::Signal()
  29. if (! fFutex->internal) return true;
  30. }
  31. - ::syscall(__NR_futex, fFutex, fFutex->internal ? FUTEX_WAKE_PRIVATE : FUTEX_WAKE, 1, NULL, NULL, 0);
  32. + ::syscall(SYS_futex, fFutex, fFutex->internal ? FUTEX_WAKE_PRIVATE : FUTEX_WAKE, 1, NULL, NULL, 0);
  33. return true;
  34. }
  35. @@ -94,7 +98,7 @@ bool JackLinuxFutex::Wait()
  36. if (__sync_bool_compare_and_swap(&fFutex->futex, 1, 0))
  37. return true;
  38. - if (::syscall(__NR_futex, fFutex, fFutex->internal ? FUTEX_WAIT_PRIVATE : FUTEX_WAIT, 0, NULL, NULL, 0) != 0 && errno != EWOULDBLOCK)
  39. + if (::syscall(SYS_futex, fFutex, fFutex->internal ? FUTEX_WAIT_PRIVATE : FUTEX_WAIT, 0, NULL, NULL, 0) != 0 && errno != EWOULDBLOCK)
  40. return false;
  41. }
  42. }
  43. @@ -122,7 +126,7 @@ bool JackLinuxFutex::TimedWait(long usec)
  44. if (__sync_bool_compare_and_swap(&fFutex->futex, 1, 0))
  45. return true;
  46. - if (::syscall(__NR_futex, fFutex, fFutex->internal ? FUTEX_WAIT_PRIVATE : FUTEX_WAIT, 0, &timeout, NULL, 0) != 0 && errno != EWOULDBLOCK)
  47. + if (::syscall(SYS_futex, fFutex, fFutex->internal ? FUTEX_WAIT_PRIVATE : FUTEX_WAIT, 0, &timeout, NULL, 0) != 0 && errno != EWOULDBLOCK)
  48. return false;
  49. }
  50. }
  51. --
  52. 2.29.2