[PATCH] D158375: [llvm-exegesis] Use mmap2 when mmap is unavailable to fix riscv32 build

Khem Raj via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 25 10:43:57 PDT 2023


raj.khem updated this revision to Diff 553538.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158375/new/

https://reviews.llvm.org/D158375

Files:
  llvm/tools/llvm-exegesis/lib/X86/Target.cpp
  llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp


Index: llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
===================================================================
--- llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
+++ llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
@@ -635,11 +635,12 @@
 #define MAP_FIXED_NOREPLACE MAP_FIXED
 #endif
 
-// 32 bit ARM doesn't have mmap and uses mmap2 instead. The only difference
-// between the two syscalls is that mmap2's offset parameter is in terms 4096
-// byte offsets rather than individual bytes, so for our purposes they are
-// effectively the same as all ofsets here are set to 0.
-#ifdef __arm__
+// some 32-bit architectures e.g. ARM, RISCV32 don't have mmap and use mmap2
+// instead. The only difference between the two syscalls is that mmap2's
+// offset parameter is in terms of 4096 byte offsets rather than individual
+// bytes, so for our purposes they are effectively the same as all ofsets
+// here are set to 0.
+#if defined(SYS_mmap2) && !defined(SYS_mmap)
 #define SYS_mmap SYS_mmap2
 #endif
 
Index: llvm/tools/llvm-exegesis/lib/X86/Target.cpp
===================================================================
--- llvm/tools/llvm-exegesis/lib/X86/Target.cpp
+++ llvm/tools/llvm-exegesis/lib/X86/Target.cpp
@@ -1087,11 +1087,12 @@
 #define MAP_FIXED_NOREPLACE MAP_FIXED
 #endif
 
-// 32 bit ARM doesn't have mmap and uses mmap2 instead. The only difference
-// between the two syscalls is that mmap2's offset parameter is in terms 4096
-// byte offsets rather than individual bytes, so for our purposes they are
-// effectively the same as all ofsets here are set to 0.
-#ifdef __arm__
+// some 32-bit architectures e.g. ARM, RISCV32 don't have mmap and use mmap2
+// instead. The only difference between the two syscalls is that mmap2's
+// offset parameter is in terms of 4096 byte offsets rather than individual
+// bytes, so for our purposes they are effectively the same as all ofsets
+// here are set to 0.
+#if defined(SYS_mmap2) && !defined(SYS_mmap)
 #define SYS_mmap SYS_mmap2
 #endif
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158375.553538.patch
Type: text/x-patch
Size: 2038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230825/1f5bb313/attachment.bin>


More information about the llvm-commits mailing list