authorgravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2020-03-31 00:19:19+02:00
committergravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2020-03-31 00:29:41+02:00
logf6f03cd90f5c0a8cce7981b16f384b088f41c319
treeeb23e2a5ff1125cd8dbadb5f17f7fe9b760fa7ff
parentcfedd3aca286881510e4a298756d4a5676e22137

compiler-rt: implement clear_cache for arm32-linux


2 files changed, 20 insertions(+), 28 deletions(-)

lib/std/special/compiler_rt.zig+1-1
...@@ -11,7 +11,7 @@ comptime {...@@ -11,7 +11,7 @@ comptime {
1111
12 switch (builtin.arch) {12 switch (builtin.arch) {
13 .i386, .x86_64 => @export(@import("compiler_rt/stack_probe.zig").zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage }),13 .i386, .x86_64 => @export(@import("compiler_rt/stack_probe.zig").zig_probe_stack, .{ .name = "__zig_probe_stack", .linkage = linkage }),
14 .aarch64, .aarch64_be, .aarch64_32 => {14 .aarch64, .aarch64_be, .aarch64_32, .arm, .armeb, .thumb, .thumbeb => {
15 @export(@import("compiler_rt/clear_cache.zig").clear_cache, .{ .name = "__clear_cache", .linkage = linkage });15 @export(@import("compiler_rt/clear_cache.zig").clear_cache, .{ .name = "__clear_cache", .linkage = linkage });
16 },16 },
17 else => {},17 else => {},
lib/std/special/compiler_rt/clear_cache.zig+19-27
...@@ -45,33 +45,25 @@ pub fn clear_cache(start: usize, end: usize) callconv(.C) void {...@@ -45,33 +45,25 @@ pub fn clear_cache(start: usize, end: usize) callconv(.C) void {
45 @compileError("TODO");45 @compileError("TODO");
46 // FlushInstructionCache(GetCurrentProcess(), start, end - start);46 // FlushInstructionCache(GetCurrentProcess(), start, end - start);
47 } else if (arm32 and !apple) {47 } else if (arm32 and !apple) {
48 @compileError("TODO");48 if (os == .freebsd or os == .netbsd) {
49 //#if defined(__FreeBSD__) || defined(__NetBSD__)49 // struct arm_sync_icache_args arg;
50 // struct arm_sync_icache_args arg;50 //
51 //51 // arg.addr = (uintptr_t)start;
52 // arg.addr = (uintptr_t)start;52 // arg.len = (uintptr_t)end - (uintptr_t)start;
53 // arg.len = (uintptr_t)end - (uintptr_t)start;53 //
54 //54 // sysarch(ARM_SYNC_ICACHE, &arg);
55 // sysarch(ARM_SYNC_ICACHE, &arg);55 @compileError("TODO: implement for NetBSD/FreeBSD");
56 //#elif defined(__linux__)56 } else if (os == .linux) {
57 //// We used to include asm/unistd.h for the __ARM_NR_cacheflush define, but57 const result = std.os.linux.syscall3(
58 //// it also brought many other unused defines, as well as a dependency on58 std.os.linux.SYS_cacheflush,
59 //// kernel headers to be installed.59 start,
60 ////60 end,
61 //// This value is stable at least since Linux 3.13 and should remain so for61 0,
62 //// compatibility reasons, warranting it's re-definition here.62 );
63 //#define __ARM_NR_cacheflush 0x0f000263 std.debug.assert(result == 0);
64 // register int start_reg __asm("r0") = (int)(intptr_t)start;64 } else {
65 // const register int end_reg __asm("r1") = (int)(intptr_t)end;65 @compileError("compilerrt_abort");
66 // const register int flags __asm("r2") = 0;66 }
67 // const register int syscall_nr __asm("r7") = __ARM_NR_cacheflush;
68 // __asm __volatile("svc 0x0"
69 // : "=r"(start_reg)
70 // : "r"(syscall_nr), "r"(start_reg), "r"(end_reg), "r"(flags));
71 // assert(start_reg == 0 && "Cache flush syscall failed.");
72 //#else
73 // compilerrt_abort();
74 //#endif
75 } else if (os == .linux and mips) {67 } else if (os == .linux and mips) {
76 @compileError("TODO");68 @compileError("TODO");
77 //const uintptr_t start_int = (uintptr_t)start;69 //const uintptr_t start_int = (uintptr_t)start;