authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2021-07-30 21:45:28+07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-07-30 13:23:41-04:00
log7aaea20e7e5e98bc5b2c4c8ddcf8f6aaa4a9c55d
tree93a149f6f84354f4abaa708c8766b19d9ddb6373
parentf6b1fa9e29ccab77a54e92dc13a7eb8e407bdbbc

Add freeAndExit() implementation for Linux/SPARCv9


1 files changed, 26 insertions(+), 0 deletions(-)

lib/std/Thread.zig+26
...@@ -798,6 +798,32 @@ const LinuxThreadImpl = struct {...@@ -798,6 +798,32 @@ const LinuxThreadImpl = struct {
798 [len] "r" (self.mapped.len)798 [len] "r" (self.mapped.len)
799 : "memory"799 : "memory"
800 ),800 ),
801 .sparcv9 => asm volatile (
802 \\ # SPARCs really don't like it when active stack frames
803 \\ # is unmapped (it will result in a segfault), so we
804 \\ # force-deactivate it by running `restore` until
805 \\ # all frames are cleared.
806 \\ 1:
807 \\ cmp %%sp, 0
808 \\ beq 2f
809 \\ restore
810 \\ ba 1f
811 \\ 2:
812 \\ mov 73, %%g1
813 \\ mov %[ptr], %%o0
814 \\ mov %[len], %%o1
815 \\ # Flush register window contents to prevent background
816 \\ # memory access before unmapping the stack.
817 \\ flushw
818 \\ t 0x6d
819 \\ mov 1, %%g1
820 \\ mov 1, %%o0
821 \\ t 0x6d
822 :
823 : [ptr] "r" (@ptrToInt(self.mapped.ptr)),
824 [len] "r" (self.mapped.len)
825 : "memory"
826 ),
801 else => |cpu_arch| @compileError("Unsupported linux arch: " ++ @tagName(cpu_arch)),827 else => |cpu_arch| @compileError("Unsupported linux arch: " ++ @tagName(cpu_arch)),
802 }828 }
803 unreachable;829 unreachable;