Andrew Geissler | e231d58 | 2020-05-05 08:53:09 -0500 | [diff] [blame] | 1 | From 04e28fdda03b545a0f7b446a784ec2fa7249cbb8 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 29 Apr 2020 15:37:40 -0700 |
| 4 | Subject: [PATCH] Fix build on riscv32 |
| 5 | |
| 6 | Define __NR_mmap in terms of __NR_mmap2 and __NR_futex interms of |
| 7 | __NR_futex_time64 for rv32, since there calls dont exist for rv32 |
| 8 | |
| 9 | Also recognise rv32 as a new 32bit platform |
| 10 | |
| 11 | Upstream-Status: Submitted [https://github.com/abseil/abseil-cpp/pull/675] |
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 13 | --- |
| 14 | absl/base/internal/direct_mmap.h | 5 +++++ |
| 15 | absl/base/internal/spinlock_linux.inc | 4 ++++ |
| 16 | absl/synchronization/internal/waiter.cc | 4 ++++ |
| 17 | 3 files changed, 13 insertions(+) |
| 18 | |
| 19 | --- a/third_party/abseil-cpp/absl/base/internal/direct_mmap.h |
| 20 | +++ b/third_party/abseil-cpp/absl/base/internal/direct_mmap.h |
| 21 | @@ -26,6 +26,10 @@ |
| 22 | |
| 23 | #ifdef __linux__ |
| 24 | |
| 25 | +#if !defined(__NR_mmap) && defined(__riscv) && __riscv_xlen == 32 |
| 26 | +# define __NR_mmap __NR_mmap2 |
| 27 | +#endif |
| 28 | + |
| 29 | #include <sys/types.h> |
| 30 | #ifdef __BIONIC__ |
| 31 | #include <sys/syscall.h> |
| 32 | @@ -72,6 +76,7 @@ inline void* DirectMmap(void* start, siz |
| 33 | #if defined(__i386__) || defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) || \ |
| 34 | (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || \ |
| 35 | (defined(__PPC__) && !defined(__PPC64__)) || \ |
| 36 | + (defined(__riscv) && __riscv_xlen == 32) || \ |
| 37 | (defined(__s390__) && !defined(__s390x__)) |
| 38 | // On these architectures, implement mmap with mmap2. |
| 39 | static int pagesize = 0; |
| 40 | --- a/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc |
| 41 | +++ b/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc |
| 42 | @@ -14,6 +14,10 @@ |
| 43 | // |
| 44 | // This file is a Linux-specific part of spinlock_wait.cc |
| 45 | |
| 46 | +#if !defined(__NR_futex) && defined(__riscv) && __riscv_xlen == 32 |
| 47 | +# define __NR_futex __NR_futex_time64 |
| 48 | +#endif |
| 49 | + |
| 50 | #include <linux/futex.h> |
| 51 | #include <sys/syscall.h> |
| 52 | #include <unistd.h> |
| 53 | --- a/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc |
| 54 | +++ b/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc |
| 55 | @@ -24,6 +24,10 @@ |
| 56 | #include <unistd.h> |
| 57 | #endif |
| 58 | |
| 59 | +#if !defined(__NR_futex) && defined(__riscv) && __riscv_xlen == 32 |
| 60 | +# define __NR_futex __NR_futex_time64 |
| 61 | +#endif |
| 62 | + |
| 63 | #ifdef __linux__ |
| 64 | #include <linux/futex.h> |
| 65 | #include <sys/syscall.h> |