| ... | @@ -1,7 +1,19 @@ | ... | @@ -1,7 +1,19 @@ |
| | 1 | // Convenience types and consts used by std.os module |
| 1 | pub const STDIN_FILENO = 0; | 2 | pub const STDIN_FILENO = 0; |
| 2 | pub const STDOUT_FILENO = 1; | 3 | pub const STDOUT_FILENO = 1; |
| 3 | pub const STDERR_FILENO = 2; | 4 | pub const STDERR_FILENO = 2; |
| 4 | | 5 | |
| | 6 | pub const mode_t = u32; |
| | 7 | |
| | 8 | pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc |
| | 9 | |
| | 10 | pub 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 |
| 5 | pub const advice_t = u8; | 17 | pub const advice_t = u8; |
| 6 | pub const ADVICE_NORMAL: advice_t = 0; | 18 | pub const ADVICE_NORMAL: advice_t = 0; |
| 7 | pub const ADVICE_SEQUENTIAL: advice_t = 1; | 19 | pub const ADVICE_SEQUENTIAL: advice_t = 1; |
| ... | @@ -21,10 +33,12 @@ pub const device_t = u64; | ... | @@ -21,10 +33,12 @@ pub const device_t = u64; |
| 21 | pub const dircookie_t = u64; | 33 | pub const dircookie_t = u64; |
| 22 | pub const DIRCOOKIE_START: dircookie_t = 0; | 34 | pub const DIRCOOKIE_START: dircookie_t = 0; |
| 23 | | 35 | |
| | 36 | pub const dirnamlen_t = u32; |
| | 37 | |
| 24 | pub const dirent_t = extern struct { | 38 | pub 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 | }; |
| 30 | | 44 | |
| ... | @@ -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, | 131 | pub const eventfdreadwrite_t = extern struct { |
| 118 | }, | 132 | nbytes: filesize_t, |
| 119 | }, | 133 | flags: eventrwflags_t, |
| 120 | }; | 134 | }; |
| 121 | | 135 | |
| 122 | pub const eventrwflags_t = u16; | 136 | pub 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; |
| 130 | pub const exitcode_t = u32; | 144 | pub const exitcode_t = u32; |
| 131 | | 145 | |
| 132 | pub const fd_t = u32; | 146 | pub const fd_t = u32; |
| 133 | pub const mode_t = u32; | | |
| 134 | | 147 | |
| 135 | pub const fdflags_t = u16; | 148 | pub const fdflags_t = u16; |
| 136 | pub const FDFLAG_APPEND: fdflags_t = 0x0001; | 149 | pub 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; |
| 180 | pub const inode_t = u64; | 193 | pub const inode_t = u64; |
| 181 | pub const ino_t = inode_t; | 194 | pub const ino_t = inode_t; |
| 182 | | 195 | |
| 183 | pub const linkcount_t = u32; | 196 | pub const linkcount_t = u64; |
| 184 | | 197 | |
| 185 | pub const lookupflags_t = u32; | 198 | pub const lookupflags_t = u32; |
| 186 | pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001; | 199 | pub 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; |
| 196 | | 209 | |
| 197 | pub const prestat_t = extern struct { | 210 | pub 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 | }, | 215 | pub const prestat_dir_t = extern struct { |
| 203 | }, | 216 | pr_name_len: usize, |
| | 217 | }; |
| | 218 | |
| | 219 | pub const prestat_u_t = extern union { |
| | 220 | dir: prestat_dir_t, |
| 204 | }; | 221 | }; |
| 205 | | 222 | |
| 206 | pub const riflags_t = u16; | 223 | pub 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; |
| 248 | pub const siflags_t = u16; | 265 | pub const siflags_t = u16; |
| 249 | | 266 | |
| 250 | pub const signal_t = u8; | 267 | pub const signal_t = u8; |
| | 268 | pub const SIGNONE: signal_t = 0; |
| 251 | pub const SIGHUP: signal_t = 1; | 269 | pub const SIGHUP: signal_t = 1; |
| 252 | pub const SIGINT: signal_t = 2; | 270 | pub const SIGINT: signal_t = 2; |
| 253 | pub const SIGQUIT: signal_t = 3; | 271 | pub 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; |
| 284 | | 302 | |
| 285 | pub const subscription_t = extern struct { | 303 | pub 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, | 308 | pub 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, | 315 | pub const subscription_fd_readwrite_t = extern struct { |
| 298 | }, | 316 | fd: fd_t, |
| 299 | }, | 317 | }; |
| | 318 | |
| | 319 | pub const subscription_u_t = extern struct { |
| | 320 | tag: eventtype_t, |
| | 321 | u: subscription_u_u_t, |
| | 322 | }; |
| | 323 | |
| | 324 | pub 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 | }; |
| 301 | | 329 | |
| 302 | pub const timestamp_t = u64; | 330 | pub const timestamp_t = u64; |
| 303 | pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc | | |
| 304 | | 331 | |
| 305 | pub const userdata_t = u64; | 332 | pub const userdata_t = u64; |
| 306 | | 333 | |
| 307 | pub const whence_t = u8; | 334 | pub const whence_t = u8; |
| 308 | pub const WHENCE_CUR: whence_t = 0; | 335 | pub const WHENCE_SET: whence_t = 0; |
| 309 | pub const WHENCE_END: whence_t = 1; | 336 | pub const WHENCE_CUR: whence_t = 1; |
| 310 | pub const WHENCE_SET: whence_t = 2; | 337 | pub const WHENCE_END: whence_t = 2; |
| 311 | | | |
| 312 | pub const timespec = extern struct { | | |
| 313 | tv_sec: time_t, | | |
| 314 | tv_nsec: isize, | | |
| 315 | }; | | |