1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
From 560380189ff29687e011eada93774af59452f2c5 Mon Sep 17 00:00:00 2001
From: Wenlong Zhang <zhangwenlong@loongson.cn>
Date: Wed, 6 Mar 2024 03:28:59 +0000
Subject: [PATCH] add loongarch suopport for abseil-cpp
---
absl/base/internal/direct_mmap.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/absl/base/internal/direct_mmap.h b/absl/base/internal/direct_mmap.h
index 1beb2ee..80fcbbb 100644
--- a/absl/base/internal/direct_mmap.h
+++ b/absl/base/internal/direct_mmap.h
@@ -80,7 +80,8 @@ inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd,
(defined(__PPC__) && !defined(__PPC64__)) || \
(defined(__riscv) && __riscv_xlen == 32) || \
(defined(__s390__) && !defined(__s390x__)) || \
- (defined(__sparc__) && !defined(__arch64__))
+ (defined(__sparc__) && !defined(__arch64__)) || \
+ defined(__loongarch64)
// On these architectures, implement mmap with mmap2.
static int pagesize = 0;
if (pagesize == 0) {
@@ -99,6 +100,10 @@ inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd,
// Workaround by invoking __mmap2() instead.
return __mmap2(start, length, prot, flags, fd,
static_cast<size_t>(offset / pagesize));
+#elif defined(__loongarch64)
+ return reinterpret_cast<void*>(
+ syscall(SYS_mmap, start, length, prot, flags, fd,
+ static_cast<unsigned long>(offset / pagesize))); // NOLINT
#else
return reinterpret_cast<void*>(
syscall(SYS_mmap2, start, length, prot, flags, fd,
--
2.43.0
|