| ... | @@ -45,33 +45,20 @@ pub fn clear_cache(start: usize, end: usize) callconv(.C) void { | ... | @@ -45,33 +45,20 @@ 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, but | 57 | const result = std.os.linux.syscall3(std.os.linux.SYS_cacheflush, start, end, 0); |
| 58 | //// it also brought many other unused defines, as well as a dependency on | 58 | std.debug.assert(result == 0); |
| 59 | //// kernel headers to be installed. | 59 | } else { |
| 60 | //// | 60 | @compileError("no __clear_cache implementation available for this target"); |
| 61 | //// This value is stable at least since Linux 3.13 and should remain so for | 61 | } |
| 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 | | |
| 75 | } else if (os == .linux and mips) { | 62 | } else if (os == .linux and mips) { |
| 76 | @compileError("TODO"); | 63 | @compileError("TODO"); |
| 77 | //const uintptr_t start_int = (uintptr_t)start; | 64 | //const uintptr_t start_int = (uintptr_t)start; |