compiler-rt: implement clear_cache for arm32-linux

This commit is contained in:
Timon Kruiper 2020-03-31 00:19:19 +02:00
parent cfedd3aca2
commit f6f03cd90f
2 changed files with 20 additions and 28 deletions

View File

@ -11,7 +11,7 @@ comptime {
switch (builtin.arch) {
.i386, .x86_64 => @export(@import("compiler_rt/stack_probe.zig").zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage }),
.aarch64, .aarch64_be, .aarch64_32 => {
.aarch64, .aarch64_be, .aarch64_32, .arm, .armeb, .thumb, .thumbeb => {
@export(@import("compiler_rt/clear_cache.zig").clear_cache, .{ .name = "__clear_cache", .linkage = linkage });
},
else => {},

View File

@ -45,33 +45,25 @@ pub fn clear_cache(start: usize, end: usize) callconv(.C) void {
@compileError("TODO");
// FlushInstructionCache(GetCurrentProcess(), start, end - start);
} else if (arm32 and !apple) {
@compileError("TODO");
//#if defined(__FreeBSD__) || defined(__NetBSD__)
// struct arm_sync_icache_args arg;
//
// arg.addr = (uintptr_t)start;
// arg.len = (uintptr_t)end - (uintptr_t)start;
//
// sysarch(ARM_SYNC_ICACHE, &arg);
//#elif defined(__linux__)
//// We used to include asm/unistd.h for the __ARM_NR_cacheflush define, but
//// it also brought many other unused defines, as well as a dependency on
//// kernel headers to be installed.
////
//// This value is stable at least since Linux 3.13 and should remain so for
//// compatibility reasons, warranting it's re-definition here.
//#define __ARM_NR_cacheflush 0x0f0002
// register int start_reg __asm("r0") = (int)(intptr_t)start;
// const register int end_reg __asm("r1") = (int)(intptr_t)end;
// const register int flags __asm("r2") = 0;
// const register int syscall_nr __asm("r7") = __ARM_NR_cacheflush;
// __asm __volatile("svc 0x0"
// : "=r"(start_reg)
// : "r"(syscall_nr), "r"(start_reg), "r"(end_reg), "r"(flags));
// assert(start_reg == 0 && "Cache flush syscall failed.");
//#else
// compilerrt_abort();
//#endif
if (os == .freebsd or os == .netbsd) {
// struct arm_sync_icache_args arg;
//
// arg.addr = (uintptr_t)start;
// arg.len = (uintptr_t)end - (uintptr_t)start;
//
// sysarch(ARM_SYNC_ICACHE, &arg);
@compileError("TODO: implement for NetBSD/FreeBSD");
} else if (os == .linux) {
const result = std.os.linux.syscall3(
std.os.linux.SYS_cacheflush,
start,
end,
0,
);
std.debug.assert(result == 0);
} else {
@compileError("compilerrt_abort");
}
} else if (os == .linux and mips) {
@compileError("TODO");
//const uintptr_t start_int = (uintptr_t)start;