| ... | ... | @@ -1,7 +1,19 @@ |
| 1 | // Convenience types and consts used by std.os module |
| 1 | 2 | pub const STDIN_FILENO = 0; |
| 2 | 3 | pub const STDOUT_FILENO = 1; |
| 3 | 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 | 17 | pub const advice_t = u8; |
| 6 | 18 | pub const ADVICE_NORMAL: advice_t = 0; |
| 7 | 19 | pub const ADVICE_SEQUENTIAL: advice_t = 1; |
| ... | ... | @@ -21,10 +33,12 @@ pub const device_t = u64; |
| 21 | 33 | pub const dircookie_t = u64; |
| 22 | 34 | pub const DIRCOOKIE_START: dircookie_t = 0; |
| 23 | 35 | |
| 36 | pub const dirnamlen_t = u32; |
| 37 | |
| 24 | 38 | pub const dirent_t = extern struct { |
| 25 | 39 | d_next: dircookie_t, |
| 26 | 40 | d_ino: inode_t, |
| 27 | | d_namlen: u32, |
| 41 | d_namlen: dirnamlen_t, |
| 28 | 42 | d_type: filetype_t, |
| 29 | 43 | }; |
| 30 | 44 | |
| ... | ... | @@ -111,12 +125,12 @@ pub const event_t = extern struct { |
| 111 | 125 | userdata: userdata_t, |
| 112 | 126 | @"error": errno_t, |
| 113 | 127 | @"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 | |
| 131 | pub const eventfdreadwrite_t = extern struct { |
| 132 | nbytes: filesize_t, |
| 133 | flags: eventrwflags_t, |
| 120 | 134 | }; |
| 121 | 135 | |
| 122 | 136 | pub const eventrwflags_t = u16; |
| ... | ... | @@ -130,7 +144,6 @@ pub const EVENTTYPE_FD_WRITE: eventtype_t = 2; |
| 130 | 144 | pub const exitcode_t = u32; |
| 131 | 145 | |
| 132 | 146 | pub const fd_t = u32; |
| 133 | | pub const mode_t = u32; |
| 134 | 147 | |
| 135 | 148 | pub const fdflags_t = u16; |
| 136 | 149 | pub const FDFLAG_APPEND: fdflags_t = 0x0001; |
| ... | ... | @@ -180,7 +193,7 @@ pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008; |
| 180 | 193 | pub const inode_t = u64; |
| 181 | 194 | pub const ino_t = inode_t; |
| 182 | 195 | |
| 183 | | pub const linkcount_t = u32; |
| 196 | pub const linkcount_t = u64; |
| 184 | 197 | |
| 185 | 198 | pub const lookupflags_t = u32; |
| 186 | 199 | pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001; |
| ... | ... | @@ -196,11 +209,15 @@ pub const PREOPENTYPE_DIR: preopentype_t = 0; |
| 196 | 209 | |
| 197 | 210 | pub const prestat_t = extern struct { |
| 198 | 211 | 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 | |
| 215 | pub const prestat_dir_t = extern struct { |
| 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 | 223 | pub const riflags_t = u16; |
| ... | ... | @@ -248,6 +265,7 @@ pub const SHUT_WR: sdflags_t = 0x02; |
| 248 | 265 | pub const siflags_t = u16; |
| 249 | 266 | |
| 250 | 267 | pub const signal_t = u8; |
| 268 | pub const SIGNONE: signal_t = 0; |
| 251 | 269 | pub const SIGHUP: signal_t = 1; |
| 252 | 270 | pub const SIGINT: signal_t = 2; |
| 253 | 271 | pub const SIGQUIT: signal_t = 3; |
| ... | ... | @@ -284,32 +302,36 @@ pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001; |
| 284 | 302 | |
| 285 | 303 | pub const subscription_t = extern struct { |
| 286 | 304 | 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 | |
| 308 | pub 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 | |
| 315 | pub const subscription_fd_readwrite_t = extern struct { |
| 316 | fd: fd_t, |
| 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 | 330 | pub const timestamp_t = u64; |
| 303 | | pub const time_t = i64; // match https://github.com/CraneStation/wasi-libc |
| 304 | 331 | |
| 305 | 332 | pub const userdata_t = u64; |
| 306 | 333 | |
| 307 | 334 | pub const whence_t = u8; |
| 308 | | pub const WHENCE_CUR: whence_t = 0; |
| 309 | | pub const WHENCE_END: whence_t = 1; |
| 310 | | pub const WHENCE_SET: whence_t = 2; |
| 311 | | |
| 312 | | pub const timespec = extern struct { |
| 313 | | tv_sec: time_t, |
| 314 | | tv_nsec: isize, |
| 315 | | }; |
| 335 | pub const WHENCE_SET: whence_t = 0; |
| 336 | pub const WHENCE_CUR: whence_t = 1; |
| 337 | pub const WHENCE_END: whence_t = 2; |