authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-03 16:24:00-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-05-03 16:24:00-04:00
log584dd2863a23243c5d587358d0f06b631a5f9575
treea889b25e03ff81254b523fdfeff519375f84838c
parentf86b8e4535c6b7803b724e07d32b1cf72f6d2b2c
parenta530a111a51151474047656e4ed65815ef10ac42
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #2409 from shritesh/wasi_native

WASI std: implement native os.exit and os.abort

2 files changed, 10 insertions(+), 5 deletions(-)

std/os.zig+10-1
......@@ -200,7 +200,7 @@ pub fn abort() noreturn {
200200 c.abort();
201201 }
202202 switch (builtin.os) {
203 Os.linux, Os.macosx, Os.ios, Os.freebsd, Os.netbsd, Os.wasi => {
203 Os.linux, Os.macosx, Os.ios, Os.freebsd, Os.netbsd => {
204204 _ = posix.raise(posix.SIGABRT);
205205 _ = posix.raise(posix.SIGKILL);
206206 while (true) {}
......@@ -211,6 +211,12 @@ pub fn abort() noreturn {
211211 }
212212 windows.ExitProcess(3);
213213 },
214 Os.wasi => {
215 _ = wasi.proc_raise(wasi.SIGABRT);
216 // TODO: Is SIGKILL even necessary?
217 _ = wasi.proc_raise(wasi.SIGKILL);
218 while (true) {}
219 },
214220 Os.uefi => {
215221 // TODO there's gotta be a better thing to do here than loop forever
216222 while (true) {}
......@@ -239,6 +245,9 @@ pub fn exit(status: u8) noreturn {
239245 Os.windows => {
240246 windows.ExitProcess(status);
241247 },
248 Os.wasi => {
249 wasi.proc_exit(status);
250 },
242251 else => @compileError("Unsupported OS"),
243252 }
244253}
std/os/wasi.zig-4
......@@ -10,10 +10,6 @@ pub fn getErrno(r: usize) usize {
1010 return if (signed_r > -4096 and signed_r < 0) @intCast(usize, -signed_r) else 0;
1111}
1212
13pub fn exit(status: i32) noreturn {
14 proc_exit(@bitCast(exitcode_t, isize(status)));
15}
16
1713pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
1814 var nwritten: usize = undefined;
1915