mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
wasi: use __wasi_proc_exit instead of posix.exit
This commit is contained in:
parent
72bcd5a4a5
commit
fe9cd0b4bc
@ -1,4 +1,4 @@
|
||||
use @import("wasi/core.zig");
|
||||
pub use @import("wasi/core.zig");
|
||||
|
||||
pub const STDIN_FILENO = 0;
|
||||
pub const STDOUT_FILENO = 1;
|
||||
|
||||
@ -14,14 +14,16 @@ comptime {
|
||||
@export("main", main, strong_linkage);
|
||||
} else if (builtin.os == builtin.Os.windows) {
|
||||
@export("WinMainCRTStartup", WinMainCRTStartup, strong_linkage);
|
||||
} else if (builtin.os == builtin.Os.wasi) {
|
||||
@export("_start", wasiStart, strong_linkage);
|
||||
} else {
|
||||
@export("_start", _start, strong_linkage);
|
||||
}
|
||||
}
|
||||
|
||||
nakedcc fn _start() noreturn {
|
||||
if (builtin.os == builtin.Os.wasi) {
|
||||
std.os.wasi.__wasi_proc_exit(callMain());
|
||||
}
|
||||
|
||||
switch (builtin.arch) {
|
||||
builtin.Arch.x86_64 => {
|
||||
argc_ptr = asm ("lea (%%rsp), %[argc]"
|
||||
@ -45,16 +47,6 @@ nakedcc fn _start() noreturn {
|
||||
@noInlineCall(posixCallMainAndExit);
|
||||
}
|
||||
|
||||
nakedcc fn wasiStart() noreturn {
|
||||
// TODO: Decide if alloc at init is acceptable for args and env
|
||||
// @llvm.wasm.mem.grow.i32
|
||||
// __wasi_args_get()
|
||||
// __wasi_args_sizes_get()
|
||||
// __wasi_environ_get()
|
||||
// __wasi_environ_sizes_get()
|
||||
std.os.posix.exit(callMain());
|
||||
}
|
||||
|
||||
extern fn WinMainCRTStartup() noreturn {
|
||||
@setAlignStack(16);
|
||||
if (!builtin.single_threaded) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user