| ... | ... | @@ -25,6 +25,13 @@ pub const device_t = u64; |
| 25 | 25 | pub const dircookie_t = u64; |
| 26 | 26 | pub const DIRCOOKIE_START: dircookie_t = 0; |
| 27 | 27 | |
| 28 | pub const dirent_t = extern struct { |
| 29 | d_next: dircookie_t, |
| 30 | d_ino: inode_t, |
| 31 | d_namlen: u32, |
| 32 | d_type: filetype_t, |
| 33 | }; |
| 34 | |
| 28 | 35 | pub const errno_t = u16; |
| 29 | 36 | pub const ESUCCESS: errno_t = 0; |
| 30 | 37 | pub const E2BIG: errno_t = 1; |
| ... | ... | @@ -104,6 +111,18 @@ pub const ETXTBSY: errno_t = 74; |
| 104 | 111 | pub const EXDEV: errno_t = 75; |
| 105 | 112 | pub const ENOTCAPABLE: errno_t = 76; |
| 106 | 113 | |
| 114 | pub const event_t = extern struct { |
| 115 | userdata: userdata_t, |
| 116 | @"error": errno_t, |
| 117 | @"type": eventtype_t, |
| 118 | u: extern union { |
| 119 | fd_readwrite: extern struct { |
| 120 | nbytes: filesize_t, |
| 121 | flags: eventrwflags_t, |
| 122 | }, |
| 123 | }, |
| 124 | }; |
| 125 | |
| 107 | 126 | pub const eventrwflags_t = u16; |
| 108 | 127 | pub const EVENT_FD_READWRITE_HANGUP: eventrwflags_t = 0x0001; |
| 109 | 128 | |
| ... | ... | @@ -123,10 +142,28 @@ pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004; |
| 123 | 142 | pub const FDFLAG_RSYNC: fdflags_t = 0x0008; |
| 124 | 143 | pub const FDFLAG_SYNC: fdflags_t = 0x0010; |
| 125 | 144 | |
| 145 | const fdstat_t = extern struct { |
| 146 | fs_filetype: filetype_t, |
| 147 | fs_flags: fdflags_t, |
| 148 | fs_rights_base: rights_t, |
| 149 | fs_rights_inheriting: rights_t, |
| 150 | }; |
| 151 | |
| 126 | 152 | pub const filedelta_t = i64; |
| 127 | 153 | |
| 128 | 154 | pub const filesize_t = u64; |
| 129 | 155 | |
| 156 | pub const filestat_t = extern struct { |
| 157 | st_dev: device_t, |
| 158 | st_ino: inode_t, |
| 159 | st_filetype: filetype_t, |
| 160 | st_nlink: linkcount_t, |
| 161 | st_size: filesize_t, |
| 162 | st_atim: timestamp_t, |
| 163 | st_mtim: timestamp_t, |
| 164 | st_ctim: timestamp_t, |
| 165 | }; |
| 166 | |
| 130 | 167 | pub const filetype_t = u8; |
| 131 | 168 | pub const FILETYPE_UNKNOWN: filetype_t = 0; |
| 132 | 169 | pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1; |
| ... | ... | @@ -145,6 +182,11 @@ pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008; |
| 145 | 182 | |
| 146 | 183 | pub const inode_t = u64; |
| 147 | 184 | |
| 185 | pub const iovec_t = extern struct { |
| 186 | buf: [*]u8, |
| 187 | buf_len: usize, |
| 188 | }; |
| 189 | |
| 148 | 190 | pub const linkcount_t = u32; |
| 149 | 191 | |
| 150 | 192 | pub const lookupflags_t = u32; |
| ... | ... | @@ -156,6 +198,18 @@ pub const O_DIRECTORY: oflags_t = 0x0002; |
| 156 | 198 | pub const O_EXCL: oflags_t = 0x0004; |
| 157 | 199 | pub const O_TRUNC: oflags_t = 0x0008; |
| 158 | 200 | |
| 201 | pub const preopentype_t = u8; |
| 202 | pub const PREOPENTYPE_DIR: preopentype_t = 0; |
| 203 | |
| 204 | pub const prestat_t = extern struct { |
| 205 | pr_type: preopentype_t, |
| 206 | u: extern union { |
| 207 | dir: extern struct { |
| 208 | pr_name_len: usize, |
| 209 | }, |
| 210 | }, |
| 211 | }; |
| 212 | |
| 159 | 213 | pub const riflags_t = u16; |
| 160 | 214 | pub const SOCK_RECV_PEEK: riflags_t = 0x0001; |
| 161 | 215 | pub const SOCK_RECV_WAITALL: riflags_t = 0x0002; |
| ... | ... | @@ -235,6 +289,23 @@ pub const SIGSYS: signal_t = 30; |
| 235 | 289 | pub const subclockflags_t = u16; |
| 236 | 290 | pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001; |
| 237 | 291 | |
| 292 | pub const subscription_t = extern struct { |
| 293 | userdata: userdata_t, |
| 294 | @"type": eventtype_t, |
| 295 | u: extern union { |
| 296 | clock: extern struct { |
| 297 | identifier: userdata_t, |
| 298 | clock_id: clockid_t, |
| 299 | timeout: timestamp_t, |
| 300 | precision: timestamp_t, |
| 301 | flags: subclockflags_t, |
| 302 | }, |
| 303 | fd_readwrite: extern struct { |
| 304 | fd: fd_t, |
| 305 | }, |
| 306 | }, |
| 307 | }; |
| 308 | |
| 238 | 309 | pub const timestamp_t = u64; |
| 239 | 310 | |
| 240 | 311 | pub const userdata_t = u64; |
| ... | ... | @@ -253,9 +324,51 @@ pub extern "wasi_unstable" fn clock_time_get(clock_id: clockid_t, precision: tim |
| 253 | 324 | pub extern "wasi_unstable" fn environ_get(environ: [*]?[*]u8, environ_buf: [*]u8) errno_t; |
| 254 | 325 | pub extern "wasi_unstable" fn environ_sizes_get(environ_count: *usize, environ_buf_size: *usize) errno_t; |
| 255 | 326 | |
| 256 | | pub extern "wasi_unstable" fn proc_raise(sig: signal_t) errno_t; |
| 257 | | pub extern "wasi_unstable" fn proc_exit(rval: exitcode_t) noreturn; |
| 258 | | |
| 327 | pub extern "wasi_unstable" fn fd_advise(fd: fd_t, offset: filesize_t, len: filesize_t, advice: advice_t) errno_t; |
| 328 | pub extern "wasi_unstable" fn fd_allocate(fd: fd_t, offset: filesize_t, len: filesize_t) errno_t; |
| 329 | pub extern "wasi_unstable" fn fd_close(fd: fd_t) errno_t; |
| 330 | pub extern "wasi_unstable" fn fd_datasync(fd: fd_t) errno_t; |
| 331 | pub extern "wasi_unstable" fn fd_pread(fd: fd_t, iovs: *const iovec_t, iovs_len: usize, offset: filesize_t, nread: *usize) errno_t; |
| 332 | pub extern "wasi_unstable" fn fd_pwrite(fd: fd_t, iovs: *const ciovec_t, iovs_len: usize, offset: filesize_t, nwritten: *usize) errno_t; |
| 333 | pub extern "wasi_unstable" fn fd_read(fd: fd_t, iovs: *const iovec_t, iovs_len: usize, nread: *usize) errno_t; |
| 334 | pub extern "wasi_unstable" fn fd_readdir(fd: fd_t, buf: [*]u8, buf_len: usize, cookie: dircookie_t, bufused: *usize) errno_t; |
| 335 | pub extern "wasi_unstable" fn fd_renumber(from: fd_t, to: fd_t) errno_t; |
| 336 | pub extern "wasi_unstable" fn fd_seek(fd: fd_t, offset: filedelta_t, whence: whence_t, newoffset: *filesize_t) errno_t; |
| 337 | pub extern "wasi_unstable" fn fd_sync(fd: fd_t) errno_t; |
| 338 | pub extern "wasi_unstable" fn fd_tell(fd: fd_t, newoffset: *filesize_t) errno_t; |
| 259 | 339 | pub extern "wasi_unstable" fn fd_write(fd: fd_t, iovs: *const ciovec_t, iovs_len: usize, nwritten: *usize) errno_t; |
| 260 | 340 | |
| 341 | pub extern "wasi_unstable" fn fd_fdstat_get(fd: fd_t, buf: *fdstat_t) errno_t; |
| 342 | pub extern "wasi_unstable" fn fd_fdstat_set_flags(fd: fd_t, flags: fdflags_t) errno_t; |
| 343 | pub extern "wasi_unstable" fn fd_fdstat_set_rights(fd: fd_t, fs_rights_base: rights_t, fs_rights_inheriting: rights_t) errno_t; |
| 344 | |
| 345 | pub extern "wasi_unstable" fn fd_filestat_get(fd: fd_t, buf: *filestat_t) errno_t; |
| 346 | pub extern "wasi_unstable" fn fd_filestat_set_size(fd: fd_t, st_size: filesize_t) errno_t; |
| 347 | pub extern "wasi_unstable" fn fd_filestat_set_times(fd: fd_t, st_atim: timestamp_t, st_mtim: timestamp_t, fstflags: fstflags_t) errno_t; |
| 348 | |
| 349 | pub extern "wasi_unstable" fn fd_prestat_get(fd: fd_t, buf: *prestat_t) errno_t; |
| 350 | pub extern "wasi_unstable" fn fd_prestat_dir_name(fd: fd_t, path: [*]u8, path_len: usize) errno_t; |
| 351 | |
| 352 | pub extern "wasi_unstable" fn path_create_directory(fd: fd_t, path: [*]const u8, path_len: usize) errno_t; |
| 353 | pub extern "wasi_unstable" fn path_filestat_get(fd: fd_t, flags: lookupflags_t, path: [*]const u8, path_len: usize, buf: *filestat_t) errno_t; |
| 354 | pub extern "wasi_unstable" fn path_filestat_set_times(fd: fd_t, flags: lookupflags_t, path: [*]const u8, path_len: usize, st_atim: timestamp_t, st_mtim: timestamp_t, fstflags: fstflags_t) errno_t; |
| 355 | pub extern "wasi_unstable" fn path_link(old_fd: fd_t, old_flags: lookupflags_t, old_path: [*]const u8, old_path_len: usize, new_fd: fd_t, new_path: [*]const u8, new_path_len: usize) errno_t; |
| 356 | pub extern "wasi_unstable" fn path_open(dirfd: fd_t, dirflags: lookupflags_t, path: [*]const u8, path_len: usize, oflags: oflags_t, fs_rights_base: rights_t, fs_rights_inheriting: rights_t, fs_flags: fdflags_t, fd: *fd_t) errno_t; |
| 357 | pub extern "wasi_unstable" fn path_readlink(fd: fd_t, path: [*]const u8, path_len: usize, buf: [*]u8, buf_len: usize, bufused: *usize) errno_t; |
| 358 | pub extern "wasi_unstable" fn path_remove_directory(fd: fd_t, path: [*]const u8, path_len: usize) errno_t; |
| 359 | pub extern "wasi_unstable" fn path_rename(old_fd: fd_t, old_path: [*]const u8, old_path_len: usize, new_fd: fd_t, new_path: [*]const u8, new_path_len: usize) errno_t; |
| 360 | pub extern "wasi_unstable" fn path_symlink(old_path: [*]const u8, old_path_len: usize, fd: fd_t, new_path: [*]const u8, new_path_len: usize) errno_t; |
| 361 | pub extern "wasi_unstable" fn path_unlink_file(fd: fd_t, path: [*]const u8, path_len: usize) errno_t; |
| 362 | |
| 363 | pub extern "wasi_unstable" fn poll_oneoff(in: *const subscription_t, out: *event_t, nsubscriptions: usize, nevents: *usize) errno_t; |
| 364 | |
| 365 | pub extern "wasi_unstable" fn proc_exit(rval: exitcode_t) noreturn; |
| 366 | pub extern "wasi_unstable" fn proc_raise(sig: signal_t) errno_t; |
| 367 | |
| 261 | 368 | pub extern "wasi_unstable" fn random_get(buf: [*]u8, buf_len: usize) errno_t; |
| 369 | |
| 370 | pub extern "wasi_unstable" fn sched_yield() errno_t; |
| 371 | |
| 372 | pub extern "wasi_unstable" fn sock_recv(sock: fd_t, ri_data: *const iovec_t, ri_data_len: usize, ri_flags: riflags_t, ro_datalen: *usize, ro_flags: *roflags_t) errno_t; |
| 373 | pub extern "wasi_unstable" fn sock_send(sock: fd_t, si_data: *const ciovec_t, si_data_len: usize, si_flags: siflags_t, so_datalen: *usize) errno_t; |
| 374 | pub extern "wasi_unstable" fn sock_shutdown(sock: fd_t, how: sdflags_t) errno_t; |