summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorJeremie Courreges-Anglas <jca@cvs.openbsd.org>2021-09-17 08:17:43 +0000
committerJeremie Courreges-Anglas <jca@cvs.openbsd.org>2021-09-17 08:17:43 +0000
commita8ce551f6bb01100afb3c7ca03336979fc8a4aa6 (patch)
tree4b6dbf6ec302d6a5463dc6549b1623b09d006d70 /gnu
parent273dea9d5c2f3994fcb44301916138e97ea59009 (diff)
Implement __builtin_clear_cache() on riscv64
Fixes at least ports/devel/libffi as used by ports/lang/python/2. ok kettenis@
Diffstat (limited to 'gnu')
-rw-r--r--gnu/llvm/compiler-rt/lib/builtins/clear_cache.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gnu/llvm/compiler-rt/lib/builtins/clear_cache.c b/gnu/llvm/compiler-rt/lib/builtins/clear_cache.c
index 29e31f55d49..42532b74790 100644
--- a/gnu/llvm/compiler-rt/lib/builtins/clear_cache.c
+++ b/gnu/llvm/compiler-rt/lib/builtins/clear_cache.c
@@ -33,7 +33,7 @@ uintptr_t GetCurrentProcess(void);
#include <machine/sysarch.h>
#endif
-#if defined(__OpenBSD__) && (defined(__arm__) || defined(__mips__))
+#if defined(__OpenBSD__) && (defined(__arm__) || defined(__mips__) || defined(__riscv))
// clang-format off
#include <sys/types.h>
#include <machine/sysarch.h>
@@ -157,6 +157,13 @@ void __clear_cache(void *start, void *end) {
: "=r"(start_reg)
: "r"(start_reg), "r"(end_reg), "r"(flags), "r"(syscall_nr));
assert(start_reg == 0 && "Cache flush syscall failed.");
+#elif defined(__riscv) && defined(__OpenBSD__)
+ struct riscv_sync_icache_args arg;
+
+ arg.addr = (uintptr_t)start;
+ arg.len = (uintptr_t)end - (uintptr_t)start;
+
+ sysarch(RISCV_SYNC_ICACHE, &arg);
#else
#if __APPLE__
// On Darwin, sys_icache_invalidate() provides this functionality