[go: nahoru, domu]

Skip to content

Commit

Permalink
Implement __builtin_clear_cache() on riscv64
Browse files Browse the repository at this point in the history
Fixes at least ports/devel/libffi as used by ports/lang/python/2.
ok kettenis@
  • Loading branch information
jcourreges authored and mordak committed Sep 19, 2021
1 parent c85f802 commit 94c957c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compiler-rt/lib/builtins/clear_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 94c957c

Please sign in to comment.