authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-04-30 11:19:15+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-04-30 13:28:50-04:00
logb23a87953a7a4030af3d9acf8deacb85162dd275
tree6112e4b9d6f37e71b7d063d0f1ceea489cb889a9
parent7192ca14b7d5db62f3c38c49d36b07d6be86c6b9

Fast-forward std.os.bits.wasi to match preview1 snapshot ABI

`wasi_snapshot_preview1` introduced a couple of ABI changes. This commit fast-forwards the types and consts defined in `std.os.bits.wasi` to match those changes.

1 files changed, 58 insertions(+), 36 deletions(-)

lib/std/os/bits/wasi.zig+58-36
...@@ -1,7 +1,19 @@...@@ -1,7 +1,19 @@
1// Convenience types and consts used by std.os module
1pub const STDIN_FILENO = 0;2pub const STDIN_FILENO = 0;
2pub const STDOUT_FILENO = 1;3pub const STDOUT_FILENO = 1;
3pub const STDERR_FILENO = 2;4pub const STDERR_FILENO = 2;
45
6pub const mode_t = u32;
7
8pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc
9
10pub const timespec = extern struct {
11 tv_sec: time_t,
12 tv_nsec: isize,
13};
14
15// As defined in the wasi_snapshot_preview1 spec file:
16// https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx
5pub const advice_t = u8;17pub const advice_t = u8;
6pub const ADVICE_NORMAL: advice_t = 0;18pub const ADVICE_NORMAL: advice_t = 0;
7pub const ADVICE_SEQUENTIAL: advice_t = 1;19pub const ADVICE_SEQUENTIAL: advice_t = 1;
...@@ -21,10 +33,12 @@ pub const device_t = u64;...@@ -21,10 +33,12 @@ pub const device_t = u64;
21pub const dircookie_t = u64;33pub const dircookie_t = u64;
22pub const DIRCOOKIE_START: dircookie_t = 0;34pub const DIRCOOKIE_START: dircookie_t = 0;
2335
36pub const dirnamlen_t = u32;
37
24pub const dirent_t = extern struct {38pub const dirent_t = extern struct {
25 d_next: dircookie_t,39 d_next: dircookie_t,
26 d_ino: inode_t,40 d_ino: inode_t,
27 d_namlen: u32,41 d_namlen: dirnamlen_t,
28 d_type: filetype_t,42 d_type: filetype_t,
29};43};
3044
...@@ -111,12 +125,12 @@ pub const event_t = extern struct {...@@ -111,12 +125,12 @@ pub const event_t = extern struct {
111 userdata: userdata_t,125 userdata: userdata_t,
112 @"error": errno_t,126 @"error": errno_t,
113 @"type": eventtype_t,127 @"type": eventtype_t,
114 u: extern union {128 fd_readwrite: eventfdreadwrite_t,
115 fd_readwrite: extern struct {129};
116 nbytes: filesize_t,130
117 flags: eventrwflags_t,131pub const eventfdreadwrite_t = extern struct {
118 },132 nbytes: filesize_t,
119 },133 flags: eventrwflags_t,
120};134};
121135
122pub const eventrwflags_t = u16;136pub const eventrwflags_t = u16;
...@@ -130,7 +144,6 @@ pub const EVENTTYPE_FD_WRITE: eventtype_t = 2;...@@ -130,7 +144,6 @@ pub const EVENTTYPE_FD_WRITE: eventtype_t = 2;
130pub const exitcode_t = u32;144pub const exitcode_t = u32;
131145
132pub const fd_t = u32;146pub const fd_t = u32;
133pub const mode_t = u32;
134147
135pub const fdflags_t = u16;148pub const fdflags_t = u16;
136pub const FDFLAG_APPEND: fdflags_t = 0x0001;149pub const FDFLAG_APPEND: fdflags_t = 0x0001;
...@@ -180,7 +193,7 @@ pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;...@@ -180,7 +193,7 @@ pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;
180pub const inode_t = u64;193pub const inode_t = u64;
181pub const ino_t = inode_t;194pub const ino_t = inode_t;
182195
183pub const linkcount_t = u32;196pub const linkcount_t = u64;
184197
185pub const lookupflags_t = u32;198pub const lookupflags_t = u32;
186pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001;199pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001;
...@@ -196,11 +209,15 @@ pub const PREOPENTYPE_DIR: preopentype_t = 0;...@@ -196,11 +209,15 @@ pub const PREOPENTYPE_DIR: preopentype_t = 0;
196209
197pub const prestat_t = extern struct {210pub const prestat_t = extern struct {
198 pr_type: preopentype_t,211 pr_type: preopentype_t,
199 u: extern union {212 u: prestat_u_t,
200 dir: extern struct {213};
201 pr_name_len: usize,214
202 },215pub const prestat_dir_t = extern struct {
203 },216 pr_name_len: usize,
217};
218
219pub const prestat_u_t = extern union {
220 dir: prestat_dir_t,
204};221};
205222
206pub const riflags_t = u16;223pub const riflags_t = u16;
...@@ -248,6 +265,7 @@ pub const SHUT_WR: sdflags_t = 0x02;...@@ -248,6 +265,7 @@ pub const SHUT_WR: sdflags_t = 0x02;
248pub const siflags_t = u16;265pub const siflags_t = u16;
249266
250pub const signal_t = u8;267pub const signal_t = u8;
268pub const SIGNONE: signal_t = 0;
251pub const SIGHUP: signal_t = 1;269pub const SIGHUP: signal_t = 1;
252pub const SIGINT: signal_t = 2;270pub const SIGINT: signal_t = 2;
253pub const SIGQUIT: signal_t = 3;271pub const SIGQUIT: signal_t = 3;
...@@ -284,32 +302,36 @@ pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001;...@@ -284,32 +302,36 @@ pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001;
284302
285pub const subscription_t = extern struct {303pub const subscription_t = extern struct {
286 userdata: userdata_t,304 userdata: userdata_t,
287 @"type": eventtype_t,305 u: subscription_u_t,
288 u: extern union {306};
289 clock: extern struct {307
290 identifier: userdata_t,308pub const subscription_clock_t = extern struct {
291 clock_id: clockid_t,309 id: clock_id_t,
292 timeout: timestamp_t,310 timeout: timestamp_t,
293 precision: timestamp_t,311 precision: timestamp_t,
294 flags: subclockflags_t,312 flags: subclockflags_t,
295 },313};
296 fd_readwrite: extern struct {314
297 fd: fd_t,315pub const subscription_fd_readwrite_t = extern struct {
298 },316 fd: fd_t,
299 },317};
318
319pub const subscription_u_t = extern struct {
320 tag: eventtype_t,
321 u: subscription_u_u_t,
322};
323
324pub const subscription_u_u_t = extern union {
325 clock: subscription_clock_t,
326 fd_read: subscription_fd_readwrite_t,
327 fd_write: subscription_fd_readwrite_t,
300};328};
301329
302pub const timestamp_t = u64;330pub const timestamp_t = u64;
303pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc
304331
305pub const userdata_t = u64;332pub const userdata_t = u64;
306333
307pub const whence_t = u8;334pub const whence_t = u8;
308pub const WHENCE_CUR: whence_t = 0;335pub const WHENCE_SET: whence_t = 0;
309pub const WHENCE_END: whence_t = 1;336pub const WHENCE_CUR: whence_t = 1;
310pub const WHENCE_SET: whence_t = 2;337pub const WHENCE_END: whence_t = 2;
311
312pub const timespec = extern struct {
313 tv_sec: time_t,
314 tv_nsec: isize,
315};