0001-mutex-Fix-build-on-32-bit-architectures-using-64-bit-time_t.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From e2a05a19e9dc51287e19cc9f11fd91449219e361 Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Sun, 15 Nov 2020 12:10:28 -0800
  4. Subject: [PATCH] mutex: Fix build on 32-bit architectures using 64-bit time_t
  5. mutex code uses SYS_futex, which it expects 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. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  11. [Retrieved from:
  12. https://github.com/capnproto/capnproto/commit/e2a05a19e9dc51287e19cc9f11fd91449219e361]
  13. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  14. ---
  15. c++/src/kj/mutex.c++ | 6 ++++++
  16. 1 file changed, 6 insertions(+)
  17. diff --git a/c++/src/kj/mutex.c++ b/c++/src/kj/mutex.c++
  18. index c81cead7b..e1594b117 100644
  19. --- a/c++/src/kj/mutex.c++
  20. +++ b/c++/src/kj/mutex.c++
  21. @@ -39,7 +39,13 @@
  22. #ifndef SYS_futex
  23. // Missing on Android/Bionic.
  24. +#ifdef __NR_futex
  25. #define SYS_futex __NR_futex
  26. +#elif defined(SYS_futex_time64)
  27. +#define SYS_futex SYS_futex_time64
  28. +#else
  29. +#error "Need working SYS_futex"
  30. +#endif
  31. #endif
  32. #ifndef FUTEX_WAIT_PRIVATE