From 6fb677c4f64920d0a6d0133f1ccd6f36564f4159 Mon Sep 17 00:00:00 2001 From: Shritesh Bhattarai Date: Thu, 2 May 2019 11:25:25 -0500 Subject: [PATCH 1/3] wasi: native os.abort --- std/os.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/std/os.zig b/std/os.zig index 50904f7345..0912b7a2c5 100644 --- a/std/os.zig +++ b/std/os.zig @@ -200,7 +200,7 @@ pub fn abort() noreturn { c.abort(); } switch (builtin.os) { - Os.linux, Os.macosx, Os.ios, Os.freebsd, Os.netbsd, Os.wasi => { + Os.linux, Os.macosx, Os.ios, Os.freebsd, Os.netbsd => { _ = posix.raise(posix.SIGABRT); _ = posix.raise(posix.SIGKILL); while (true) {} @@ -211,6 +211,12 @@ pub fn abort() noreturn { } windows.ExitProcess(3); }, + Os.wasi => { + _ = wasi.proc_raise(wasi.SIGABRT); + // TODO: Is SIGKILL even necessary? + _ = wasi.proc_raise(wasi.SIGKILL); + while (true) {} + }, Os.uefi => { // TODO there's gotta be a better thing to do here than loop forever while (true) {} From 84682eb8626ae44e1098df8147e460c96242f703 Mon Sep 17 00:00:00 2001 From: Shritesh Bhattarai Date: Thu, 2 May 2019 11:26:33 -0500 Subject: [PATCH 2/3] wasi: implement os.exit --- std/os.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/std/os.zig b/std/os.zig index 0912b7a2c5..3276ac2b1d 100644 --- a/std/os.zig +++ b/std/os.zig @@ -245,6 +245,9 @@ pub fn exit(status: u8) noreturn { Os.windows => { windows.ExitProcess(status); }, + Os.wasi => { + wasi.proc_exit(status); + }, else => @compileError("Unsupported OS"), } } From a530a111a51151474047656e4ed65815ef10ac42 Mon Sep 17 00:00:00 2001 From: Shritesh Bhattarai Date: Thu, 2 May 2019 11:33:10 -0500 Subject: [PATCH 3/3] wasi: remove posix-y exit --- std/os/wasi.zig | 4 ---- 1 file changed, 4 deletions(-) diff --git a/std/os/wasi.zig b/std/os/wasi.zig index df1b099bb3..e598cd6257 100644 --- a/std/os/wasi.zig +++ b/std/os/wasi.zig @@ -10,10 +10,6 @@ pub fn getErrno(r: usize) usize { return if (signed_r > -4096 and signed_r < 0) @intCast(usize, -signed_r) else 0; } -pub fn exit(status: i32) noreturn { - proc_exit(@bitCast(exitcode_t, isize(status))); -} - pub fn write(fd: i32, buf: [*]const u8, count: usize) usize { var nwritten: usize = undefined;