authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-30 23:15:33-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-30 23:15:33-04:00
log1df85d1509711554722743a706bbb2012a19a10e
treeb0ae675a8fbd2e8dc69895ffb5168cd693e25611
parentcfedd3aca286881510e4a298756d4a5676e22137
parent83ff94b1cc761a4f8a222314b26700b13de100a9
signaturelock-open Commit is signed but in an unrecognized format.

Merge branch 'FireFox317-clear-cache'


2 files changed, 36 insertions(+), 30 deletions(-)

lib/std/special/compiler_rt.zig+22-3
......@@ -10,10 +10,29 @@ comptime {
1010 const strong_linkage = if (is_test) builtin.GlobalLinkage.Internal else builtin.GlobalLinkage.Strong;
1111
1212 switch (builtin.arch) {
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 => {
15 @export(@import("compiler_rt/clear_cache.zig").clear_cache, .{ .name = "__clear_cache", .linkage = linkage });
13 .i386,
14 .x86_64,
15 => @export(@import("compiler_rt/stack_probe.zig").zig_probe_stack, .{
16 .name = "__zig_probe_stack",
17 .linkage = linkage,
18 }),
19
20 .aarch64,
21 .aarch64_be,
22 .aarch64_32,
23 => @export(@import("compiler_rt/clear_cache.zig").clear_cache, .{
24 .name = "__clear_cache",
25 .linkage = linkage,
26 }),
27
28 .arm, .armeb, .thumb, .thumbeb => switch (builtin.os.tag) {
29 .linux => @export(@import("compiler_rt/clear_cache.zig").clear_cache, .{
30 .name = "__clear_cache",
31 .linkage = linkage,
32 }),
33 else => {},
1634 },
35
1736 else => {},
1837 }
1938
lib/std/special/compiler_rt/clear_cache.zig+14-27
......@@ -45,33 +45,20 @@ pub fn clear_cache(start: usize, end: usize) callconv(.C) void {
4545 @compileError("TODO");
4646 // FlushInstructionCache(GetCurrentProcess(), start, end - start);
4747 } else if (arm32 and !apple) {
48 @compileError("TODO");
49 //#if defined(__FreeBSD__) || defined(__NetBSD__)
50 // struct arm_sync_icache_args arg;
51 //
52 // arg.addr = (uintptr_t)start;
53 // arg.len = (uintptr_t)end - (uintptr_t)start;
54 //
55 // sysarch(ARM_SYNC_ICACHE, &arg);
56 //#elif defined(__linux__)
57 //// We used to include asm/unistd.h for the __ARM_NR_cacheflush define, but
58 //// it also brought many other unused defines, as well as a dependency on
59 //// kernel headers to be installed.
60 ////
61 //// This value is stable at least since Linux 3.13 and should remain so for
62 //// compatibility reasons, warranting it's re-definition here.
63 //#define __ARM_NR_cacheflush 0x0f0002
64 // register int start_reg __asm("r0") = (int)(intptr_t)start;
65 // const register int end_reg __asm("r1") = (int)(intptr_t)end;
66 // const register int flags __asm("r2") = 0;
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
48 if (os == .freebsd or os == .netbsd) {
49 // struct arm_sync_icache_args arg;
50 //
51 // arg.addr = (uintptr_t)start;
52 // arg.len = (uintptr_t)end - (uintptr_t)start;
53 //
54 // sysarch(ARM_SYNC_ICACHE, &arg);
55 @compileError("TODO: implement for NetBSD/FreeBSD");
56 } else if (os == .linux) {
57 const result = std.os.linux.syscall3(std.os.linux.SYS_cacheflush, start, end, 0);
58 std.debug.assert(result == 0);
59 } else {
60 @compileError("no __clear_cache implementation available for this target");
61 }
7562 } else if (os == .linux and mips) {
7663 @compileError("TODO");
7764 //const uintptr_t start_int = (uintptr_t)start;