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// Convenience types and consts used by std.os module
12pub const STDIN_FILENO = 0;
23pub const STDOUT_FILENO = 1;
34pub 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
517pub const advice_t = u8;
618pub const ADVICE_NORMAL: advice_t = 0;
719pub const ADVICE_SEQUENTIAL: advice_t = 1;
......@@ -21,10 +33,12 @@ pub const device_t = u64;
2133pub const dircookie_t = u64;
2234pub const DIRCOOKIE_START: dircookie_t = 0;
2335
36pub const dirnamlen_t = u32;
37
2438pub const dirent_t = extern struct {
2539 d_next: dircookie_t,
2640 d_ino: inode_t,
27 d_namlen: u32,
41 d_namlen: dirnamlen_t,
2842 d_type: filetype_t,
2943};
3044
......@@ -111,12 +125,12 @@ pub const event_t = extern struct {
111125 userdata: userdata_t,
112126 @"error": errno_t,
113127 @"type": eventtype_t,
114 u: extern union {
115 fd_readwrite: extern struct {
116 nbytes: filesize_t,
117 flags: eventrwflags_t,
118 },
119 },
128 fd_readwrite: eventfdreadwrite_t,
129};
130
131pub const eventfdreadwrite_t = extern struct {
132 nbytes: filesize_t,
133 flags: eventrwflags_t,
120134};
121135
122136pub const eventrwflags_t = u16;
......@@ -130,7 +144,6 @@ pub const EVENTTYPE_FD_WRITE: eventtype_t = 2;
130144pub const exitcode_t = u32;
131145
132146pub const fd_t = u32;
133pub const mode_t = u32;
134147
135148pub const fdflags_t = u16;
136149pub const FDFLAG_APPEND: fdflags_t = 0x0001;
......@@ -180,7 +193,7 @@ pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;
180193pub const inode_t = u64;
181194pub const ino_t = inode_t;
182195
183pub const linkcount_t = u32;
196pub const linkcount_t = u64;
184197
185198pub const lookupflags_t = u32;
186199pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001;
......@@ -196,11 +209,15 @@ pub const PREOPENTYPE_DIR: preopentype_t = 0;
196209
197210pub const prestat_t = extern struct {
198211 pr_type: preopentype_t,
199 u: extern union {
200 dir: extern struct {
201 pr_name_len: usize,
202 },
203 },
212 u: prestat_u_t,
213};
214
215pub const prestat_dir_t = extern struct {
216 pr_name_len: usize,
217};
218
219pub const prestat_u_t = extern union {
220 dir: prestat_dir_t,
204221};
205222
206223pub const riflags_t = u16;
......@@ -248,6 +265,7 @@ pub const SHUT_WR: sdflags_t = 0x02;
248265pub const siflags_t = u16;
249266
250267pub const signal_t = u8;
268pub const SIGNONE: signal_t = 0;
251269pub const SIGHUP: signal_t = 1;
252270pub const SIGINT: signal_t = 2;
253271pub const SIGQUIT: signal_t = 3;
......@@ -284,32 +302,36 @@ pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001;
284302
285303pub const subscription_t = extern struct {
286304 userdata: userdata_t,
287 @"type": eventtype_t,
288 u: extern union {
289 clock: extern struct {
290 identifier: userdata_t,
291 clock_id: clockid_t,
292 timeout: timestamp_t,
293 precision: timestamp_t,
294 flags: subclockflags_t,
295 },
296 fd_readwrite: extern struct {
297 fd: fd_t,
298 },
299 },
305 u: subscription_u_t,
306};
307
308pub const subscription_clock_t = extern struct {
309 id: clock_id_t,
310 timeout: timestamp_t,
311 precision: timestamp_t,
312 flags: subclockflags_t,
313};
314
315pub const subscription_fd_readwrite_t = extern struct {
316 fd: fd_t,
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,
300328};
301329
302330pub const timestamp_t = u64;
303pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc
304331
305332pub const userdata_t = u64;
306333
307334pub const whence_t = u8;
308pub const WHENCE_CUR: whence_t = 0;
309pub const WHENCE_END: whence_t = 1;
310pub const WHENCE_SET: whence_t = 2;
311
312pub const timespec = extern struct {
313 tv_sec: time_t,
314 tv_nsec: isize,
315};
335pub const WHENCE_SET: whence_t = 0;
336pub const WHENCE_CUR: whence_t = 1;
337pub const WHENCE_END: whence_t = 2;