mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 13:58:27 +00:00
Merge pull request #2409 from shritesh/wasi_native
WASI std: implement native os.exit and os.abort
This commit is contained in:
commit
584dd2863a
11
std/os.zig
11
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) {}
|
||||
@ -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"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user