| ... | @@ -1,5 +1,8 @@ | ... | @@ -1,5 +1,8 @@ |
| 1 | pub use @import("wasi/core.zig"); | 1 | pub use @import("wasi/core.zig"); |
| 2 | | 2 | |
| | 3 | // Based on https://github.com/CraneStation/wasi-sysroot/blob/wasi/libc-bottom-half/headers/public/wasi/core.h |
| | 4 | // and https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-api.md |
| | 5 | |
| 3 | pub const STDIN_FILENO = 0; | 6 | pub const STDIN_FILENO = 0; |
| 4 | pub const STDOUT_FILENO = 1; | 7 | pub const STDOUT_FILENO = 1; |
| 5 | pub const STDERR_FILENO = 2; | 8 | pub const STDERR_FILENO = 2; |
| ... | @@ -82,7 +85,7 @@ pub const ETXTBSY = 74; | ... | @@ -82,7 +85,7 @@ pub const ETXTBSY = 74; |
| 82 | pub const EXDEV = 75; | 85 | pub const EXDEV = 75; |
| 83 | pub const ENOTCAPABLE = 76; | 86 | pub const ENOTCAPABLE = 76; |
| 84 | | 87 | |
| 85 | // TODO: figure out what's going on here | 88 | // TODO: implement this like darwin does |
| 86 | pub fn getErrno(r: usize) usize { | 89 | pub fn getErrno(r: usize) usize { |
| 87 | const signed_r = @bitCast(isize, r); | 90 | const signed_r = @bitCast(isize, r); |
| 88 | return if (signed_r > -4096 and signed_r < 0) @intCast(usize, -signed_r) else 0; | 91 | return if (signed_r > -4096 and signed_r < 0) @intCast(usize, -signed_r) else 0; |