Merge pull request #2409 from shritesh/wasi_native

WASI std: implement native os.exit and os.abort
This commit is contained in:
Andrew Kelley 2019-05-03 16:24:00 -04:00 committed by GitHub
commit 584dd2863a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -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) {}
@ -239,6 +245,9 @@ pub fn exit(status: u8) noreturn {
Os.windows => {
windows.ExitProcess(status);
},
Os.wasi => {
wasi.proc_exit(status);
},
else => @compileError("Unsupported OS"),
}
}

View File

@ -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;