1<!-- 2This document is derived from the file docs/cloudabi.md at revision 3af51ede669dbca0875d20893dae7f760b052b238 of the CloudABI repository 4hosted here: https://github.com/NuxiNL/cloudabi 5 6The upstream file bears the following notice, though note that the 7file is no longer generated, and contains significant edits: 8 9Copyright (c) 2016-2017 Nuxi (https://nuxi.nl/) and contributors. 10 11Redistribution and use in source and binary forms, with or without 12modification, are permitted provided that the following conditions 13are met: 141. Redistributions of source code must retain the above copyright 15 notice, this list of conditions and the following disclaimer. 162. Redistributions in binary form must reproduce the above copyright 17 notice, this list of conditions and the following disclaimer in the 18 documentation and/or other materials provided with the distribution. 19 20THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30SUCH DAMAGE. 31 32This file is automatically generated. Do not edit. 33 34Source: https://github.com/NuxiNL/cloudabi 35--> 36 37# WASI Core API 38 39This is the API-level documentation for WASI Core. The function names 40are prefixed with "\_\_wasi\_" to reflect how they are spelled in 41flat-namespace contexts, however at the wasm module level, they are 42unprefixed, because they're inside a module namespace (currently 43"wasi\_unstable"). 44 45Functions that start with `__wasi_fd_` operate on file descriptors, 46while functions that start with `__wasi_path_` operate on filesystem 47paths, which are relative to directory file descriptors. 48 49Much inspiration and content here is derived from [CloudABI] and [POSIX], 50though there are also several differences from CloudABI and POSIX. For 51example, WASI Core has no concept of processes in the traditional Unix 52sense. While wasm linear memories have some of the aspects of processes, 53and it's possible to *emulate* the full semantics of processes on top of 54them, this can sometimes be unnatural and inefficient. The goal for 55WASI Core is to be a WebAssembly-native API that exposes APIs that fit 56well into the underlying WebAssembly platform, rather than to directly 57emulate other platforms. 58 59This is also a work in progress, and the API here is still evolving. 60 61[CloudABI]: https://github.com/NuxiNL/cloudabi 62[POSIX]: http://pubs.opengroup.org/onlinepubs/9699919799/ 63 64## System calls 65 66- [`__wasi_args_get()`](#args_get) 67- [`__wasi_args_sizes_get()`](#args_sizes_get) 68- [`__wasi_clock_res_get()`](#clock_res_get) 69- [`__wasi_clock_time_get()`](#clock_time_get) 70- [`__wasi_environ_get()`](#environ_get) 71- [`__wasi_environ_sizes_get()`](#environ_sizes_get) 72- [`__wasi_fd_advise()`](#fd_advise) 73- [`__wasi_fd_allocate()`](#fd_allocate) 74- [`__wasi_fd_close()`](#fd_close) 75- [`__wasi_fd_datasync()`](#fd_datasync) 76- [`__wasi_fd_fdstat_get()`](#fd_fdstat_get) 77- [`__wasi_fd_fdstat_set_flags()`](#fd_fdstat_set_flags) 78- [`__wasi_fd_fdstat_set_rights()`](#fd_fdstat_set_rights) 79- [`__wasi_fd_filestat_get()`](#fd_filestat_get) 80- [`__wasi_fd_filestat_set_size()`](#fd_filestat_set_size) 81- [`__wasi_fd_filestat_set_times()`](#fd_filestat_set_times) 82- [`__wasi_fd_pread()`](#fd_pread) 83- [`__wasi_fd_prestat_get()`](#fd_prestat_get) 84- [`__wasi_fd_prestat_dir_name()`](#fd_prestat_dir_name) 85- [`__wasi_fd_pwrite()`](#fd_pwrite) 86- [`__wasi_fd_read()`](#fd_read) 87- [`__wasi_fd_readdir()`](#fd_readdir) 88- [`__wasi_fd_renumber()`](#fd_renumber) 89- [`__wasi_fd_seek()`](#fd_seek) 90- [`__wasi_fd_sync()`](#fd_sync) 91- [`__wasi_fd_tell()`](#fd_tell) 92- [`__wasi_fd_write()`](#fd_write) 93- [`__wasi_path_create_directory()`](#path_create_directory) 94- [`__wasi_path_filestat_get()`](#path_filestat_get) 95- [`__wasi_path_filestat_set_times()`](#path_filestat_set_times) 96- [`__wasi_path_link()`](#path_link) 97- [`__wasi_path_open()`](#path_open) 98- [`__wasi_path_readlink()`](#path_readlink) 99- [`__wasi_path_remove_directory()`](#path_remove_directory) 100- [`__wasi_path_rename()`](#path_rename) 101- [`__wasi_path_symlink()`](#path_symlink) 102- [`__wasi_path_unlink_file()`](#path_unlink_file) 103- [`__wasi_poll_oneoff()`](#poll_oneoff) 104- [`__wasi_proc_exit()`](#proc_exit) 105- [`__wasi_proc_raise()`](#proc_raise) 106- [`__wasi_random_get()`](#random_get) 107- [`__wasi_sched_yield()`](#sched_yield) 108- [`__wasi_sock_recv()`](#sock_recv) 109- [`__wasi_sock_send()`](#sock_send) 110- [`__wasi_sock_shutdown()`](#sock_shutdown) 111 112### <a href="#args_get" name="args_get"></a>`__wasi_args_get()` 113 114Read command-line argument data. 115 116The sizes of the buffers should match that returned by [`__wasi_args_sizes_get()`](#args_sizes_get). 117 118Inputs: 119 120- <a href="#args_get.argv" name="args_get.argv"></a><code>char \*\*<strong>argv</strong></code> 121 122 A pointer to a buffer to write the argument pointers. 123 124- <a href="#args_get.argv_buf" name="args_get.argv_buf"></a><code>char \*<strong>argv\_buf</strong></code> 125 126 A pointer to a buffer to write the argument string data. 127 128### <a href="#args_sizes_get" name="args_sizes_get"></a>`__wasi_args_sizes_get()` 129 130Return command-line argument data sizes. 131 132Outputs: 133 134- <a href="#args_sizes_get.argc" name="args_sizes_get.argc"></a><code>size\_t \*<strong>argc</strong></code> 135 136 The number of arguments. 137 138- <a href="#args_sizes_get.argv_buf_size" name="args_sizes_get.argv_buf_size"></a><code>size\_t \*<strong>argv\_buf\_size</strong></code> 139 140 The size of the argument string data. 141 142### <a href="#clock_res_get" name="clock_res_get"></a>`__wasi_clock_res_get()` 143 144Return the resolution of a clock. 145 146Implementations are required to provide a non-zero value for supported clocks. 147For unsupported clocks, return [`__WASI_EINVAL`](#errno.inval). 148 149Note: This is similar to `clock_getres` in POSIX. 150 151Inputs: 152 153- <a href="#clock_res_get.clock_id" name="clock_res_get.clock_id"></a><code>[\_\_wasi\_clockid\_t](#clockid) <strong>clock\_id</strong></code> 154 155 The clock for which to return the resolution. 156 157Outputs: 158 159- <a href="#clock_res_get.resolution" name="clock_res_get.resolution"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>resolution</strong></code> 160 161 The resolution of the clock. 162 163### <a href="#clock_time_get" name="clock_time_get"></a>`__wasi_clock_time_get()` 164 165Return the time value of a clock. 166 167Note: This is similar to `clock_gettime` in POSIX. 168 169Inputs: 170 171- <a href="#clock_time_get.clock_id" name="clock_time_get.clock_id"></a><code>[\_\_wasi\_clockid\_t](#clockid) <strong>clock\_id</strong></code> 172 173 The clock for which to return the time. 174 175- <a href="#clock_time_get.precision" name="clock_time_get.precision"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>precision</strong></code> 176 177 The maximum lag (exclusive) that the returned 178 time value may have, compared to its actual 179 value. 180 181Outputs: 182 183- <a href="#clock_time_get.time" name="clock_time_get.time"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>time</strong></code> 184 185 The time value of the clock. 186 187### <a href="#environ_get" name="environ_get"></a>`__wasi_environ_get()` 188 189Read environment variable data. 190 191The sizes of the buffers should match that returned by [`__wasi_environ_sizes_get()`](#environ_sizes_get). 192 193Inputs: 194 195- <a href="#environ_get.environ" name="environ_get.environ"></a><code>char \*\*<strong>environ</strong></code> 196 197 A pointer to a buffer to write the environment variable pointers. 198 199- <a href="#environ_get.environ_buf" name="environ_get.environ_buf"></a><code>char \*<strong>environ\_buf</strong></code> 200 201 A pointer to a buffer to write the environment variable string data. 202 203### <a href="#environ_sizes_get" name="environ_sizes_get"></a>`__wasi_environ_sizes_get()` 204 205Return command-line argument data sizes. 206 207Outputs: 208 209- <a href="#environ_sizes_get.environ_count" name="environ_sizes_get.environ_count"></a><code>size\_t \*<strong>environ\_count</strong></code> 210 211 The number of environment variables. 212 213- <a href="#environ_sizes_get.environ_buf_size" name="environ_sizes_get.environ_buf_size"></a><code>size\_t \*<strong>environ\_buf\_size</strong></code> 214 215 The size of the environment variable string data. 216 217### <a href="#fd_advise" name="fd_advise"></a>`__wasi_fd_advise()` 218 219Provide file advisory information on a file descriptor. 220 221Note: This is similar to `posix_fadvise` in POSIX. 222 223Inputs: 224 225- <a href="#fd_advise.fd" name="fd_advise.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 226 227 The file descriptor for the file for which to provide file advisory information. 228 229- <a href="#fd_advise.offset" name="fd_advise.offset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>offset</strong></code> 230 231 The offset within the file to which the advisory applies. 232 233- <a href="#fd_advise.len" name="fd_advise.len"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>len</strong></code> 234 235 The length of the region to which the advisory applies. 236 237- <a href="#fd_advise.advice" name="fd_advise.advice"></a><code>[\_\_wasi\_advice\_t](#advice) <strong>advice</strong></code> 238 239 The advice. 240 241### <a href="#fd_allocate" name="fd_allocate"></a>`__wasi_fd_allocate()` 242 243Force the allocation of space in a file. 244 245Note: This is similar to `posix_fallocate` in POSIX. 246 247Inputs: 248 249- <a href="#fd_allocate.fd" name="fd_allocate.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 250 251 The file descriptor for the file in which to allocate space. 252 253- <a href="#fd_allocate.offset" name="fd_allocate.offset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>offset</strong></code> 254 255 The offset at which to start the allocation. 256 257- <a href="#fd_allocate.len" name="fd_allocate.len"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>len</strong></code> 258 259 The length of the area that is allocated. 260 261### <a href="#fd_close" name="fd_close"></a>`__wasi_fd_close()` 262 263Close a file descriptor. 264 265Note: This is similar to `close` in POSIX. 266 267Inputs: 268 269- <a href="#fd_close.fd" name="fd_close.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 270 271 The file descriptor to close. 272 273### <a href="#fd_datasync" name="fd_datasync"></a>`__wasi_fd_datasync()` 274 275Synchronize the data of a file to disk. 276 277Note: This is similar to `fdatasync` in POSIX. 278 279Inputs: 280 281- <a href="#fd_datasync.fd" name="fd_datasync.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 282 283 The file descriptor of the file to synchronize to disk. 284 285### <a href="#fd_fdstat_get" name="fd_fdstat_get"></a>`__wasi_fd_fdstat_get()` 286 287Get the attributes of a file descriptor. 288 289Note: This returns similar flags to `fsync(fd, F_GETFL)` in POSIX, as well 290as additional fields. 291 292Inputs: 293 294- <a href="#fd_fdstat_get.fd" name="fd_fdstat_get.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 295 296 The file descriptor to inspect. 297 298- <a href="#fd_fdstat_get.buf" name="fd_fdstat_get.buf"></a><code>[\_\_wasi\_fdstat\_t](#fdstat) \*<strong>buf</strong></code> 299 300 The buffer where the file descriptor's attributes are stored. 301 302### <a href="#fd_fdstat_set_flags" name="fd_fdstat_set_flags"></a>`__wasi_fd_fdstat_set_flags()` 303 304Adjust the flags associated with a file descriptor. 305 306Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX. 307 308Inputs: 309 310- <a href="#fd_fdstat_set_flags.fd" name="fd_fdstat_set_flags.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 311 312 The file descriptor to operate on. 313 314- <a href="#fd_fdstat_set_flags.flags" name="fd_fdstat_set_flags.flags"></a><code>[\_\_wasi\_fdflags\_t](#fdflags) <strong>flags</strong></code> 315 316 The desired values of the file descriptor 317 flags. 318 319### <a href="#fd_fdstat_set_rights" name="fd_fdstat_set_rights"></a>`__wasi_fd_fdstat_set_rights()` 320 321Adjust the rights associated with a file descriptor. 322 323This can only be used to remove rights, and returns 324[`__WASI_ENOTCAPABLE`](#errno.notcapable) if called in a way that would attempt 325to add rights. 326 327Inputs: 328 329- <a href="#fd_fdstat_set_rights.fd" name="fd_fdstat_set_rights.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 330 331 The file descriptor to operate on. 332 333- <a href="#fd_fdstat_set_rights.fs_rights_base" name="fd_fdstat_set_rights.fs_rights_base"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_base</strong></code> and <a href="#fd_fdstat_set_rights.fs_rights_inheriting" name="fd_fdstat_set_rights.fs_rights_inheriting"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_inheriting</strong></code> 334 335 The desired rights of the file descriptor. 336 337### <a href="#fd_filestat_get" name="fd_filestat_get"></a>`__wasi_fd_filestat_get()` 338 339Return the attributes of an open file. 340 341Inputs: 342 343- <a href="#fd_filestat_get.fd" name="fd_filestat_get.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 344 345 The file descriptor to inspect. 346 347- <a href="#fd_filestat_get.buf" name="fd_filestat_get.buf"></a><code>[\_\_wasi\_filestat\_t](#filestat) \*<strong>buf</strong></code> 348 349 The buffer where the file's attributes are 350 stored. 351 352### <a href="#fd_filestat_set_size" name="fd_filestat_set_size"></a>`__wasi_fd_filestat_set_size()` 353 354Adjust the size of an open file. If this increases the file's size, the extra 355bytes are filled with zeros. 356 357Note: This is similar to `ftruncate` in POSIX. 358 359Inputs: 360 361- <a href="#fd_filestat_set_size.fd" name="fd_filestat_set_size.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 362 363 A file descriptor for the file to adjust. 364 365- <a href="#fd_filestat_set_size.st_size" name="fd_filestat_set_size.st_size"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>st\_size</strong></code> 366 367 The desired file size. 368 369### <a href="#fd_filestat_set_times" name="fd_filestat_set_times"></a>`__wasi_fd_filestat_set_times()` 370 371Adjust the timestamps of an open file or directory. 372 373Note: This is similar to `futimens` in POSIX. 374 375Inputs: 376 377- <a href="#fd_filestat_set_times.fd" name="fd_filestat_set_times.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 378 379 The file descriptor to operate on. 380 381- <a href="#fd_filestat_set_times.st_atim" name="fd_filestat_set_times.st_atim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_atim</strong></code> 382 383 The desired values of the data access timestamp. 384 385- <a href="#fd_filestat_set_times.st_mtim" name="fd_filestat_set_times.st_mtim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_mtim</strong></code> 386 387 The desired values of the data modification timestamp. 388 389- <a href="#fd_filestat_set_times.fst_flags" name="fd_filestat_set_times.fst_flags"></a><code>[\_\_wasi\_fstflags\_t](#fstflags) <strong>fst\_flags</strong></code> 390 391 A bitmask indicating which timestamps to adjust. 392 393### <a href="#fd_pread" name="fd_pread"></a>`__wasi_fd_pread()` 394 395Read from a file descriptor, without using and updating the 396file descriptor's offset. 397 398Note: This is similar to `preadv` in POSIX. 399 400Inputs: 401 402- <a href="#fd_pread.fd" name="fd_pread.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 403 404 The file descriptor from which to read data. 405 406- <a href="#fd_pread.iovs" name="fd_pread.iovs"></a><code>const [\_\_wasi\_iovec\_t](#iovec) \*<strong>iovs</strong></code> and <a href="#fd_pread.iovs_len" name="fd_pread.iovs_len"></a><code>size\_t <strong>iovs\_len</strong></code> 407 408 List of scatter/gather vectors in which to store data. 409 410- <a href="#fd_pread.offset" name="fd_pread.offset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>offset</strong></code> 411 412 The offset within the file at which to read. 413 414Outputs: 415 416- <a href="#fd_pread.nread" name="fd_pread.nread"></a><code>size\_t <strong>nread</strong></code> 417 418 The number of bytes read. 419 420### <a href="#fd_prestat_get" name="fd_prestat_get"></a>`__wasi_fd_prestat_get()` 421 422Return a description of the given preopened file descriptor. 423 424Inputs: 425 426- <a href="#fd_prestat_get.fd" name="fd_prestat_get.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 427 428 The file descriptor about which to retrieve information. 429 430- <a href="#fd_prestat_get.buf" name="fd_prestat_get.buf"></a><code>[\_\_wasi\_prestat\_t](#prestat) \*<strong>buf</strong></code> 431 432 The buffer where the description is stored. 433 434### <a href="#fd_prestat_dir_name" name="fd_prestat_dir_name"></a>`__wasi_fd_prestat_dir_name()` 435 436Return a description of the given preopened file descriptor. 437 438Inputs: 439 440- <a href="#fd_prestat_dir_name.fd" name="fd_prestat_dir_name.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 441 442 The file descriptor about which to retrieve information. 443 444- <a href="#fd_prestat_dir_name.path" name="fd_prestat_dir_name.path"></a><code>const char \*<strong>path</strong></code> and <a href="#fd_prestat_dir_name.path_len" name="fd_prestat_dir_name.path_len"></a><code>size\_t <strong>path\_len</strong></code> 445 446 A buffer into which to write the preopened directory name. 447 448### <a href="#fd_pwrite" name="fd_pwrite"></a>`__wasi_fd_pwrite()` 449 450Write to a file descriptor, without using and updating the 451file descriptor's offset. 452 453Note: This is similar to `pwritev` in POSIX. 454 455Inputs: 456 457- <a href="#fd_pwrite.fd" name="fd_pwrite.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 458 459 The file descriptor to which to write data. 460 461- <a href="#fd_pwrite.iovs" name="fd_pwrite.iovs"></a><code>const [\_\_wasi\_ciovec\_t](#ciovec) \*<strong>iovs</strong></code> and <a href="#fd_pwrite.iovs_len" name="fd_pwrite.iovs_len"></a><code>size\_t <strong>iovs\_len</strong></code> 462 463 List of scatter/gather vectors from which to retrieve data. 464 465- <a href="#fd_pwrite.offset" name="fd_pwrite.offset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>offset</strong></code> 466 467 The offset within the file at which to write. 468 469Outputs: 470 471- <a href="#fd_pwrite.nwritten" name="fd_pwrite.nwritten"></a><code>size\_t <strong>nwritten</strong></code> 472 473 The number of bytes written. 474 475### <a href="#fd_read" name="fd_read"></a>`__wasi_fd_read()` 476 477Read from a file descriptor. 478 479Note: This is similar to `readv` in POSIX. 480 481Inputs: 482 483- <a href="#fd_read.fd" name="fd_read.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 484 485 The file descriptor from which to read data. 486 487- <a href="#fd_read.iovs" name="fd_read.iovs"></a><code>const [\_\_wasi\_iovec\_t](#iovec) \*<strong>iovs</strong></code> and <a href="#fd_read.iovs_len" name="fd_read.iovs_len"></a><code>size\_t <strong>iovs\_len</strong></code> 488 489 List of scatter/gather vectors to which to store data. 490 491Outputs: 492 493- <a href="#fd_read.nread" name="fd_read.nread"></a><code>size\_t <strong>nread</strong></code> 494 495 The number of bytes read. 496 497### <a href="#fd_readdir" name="fd_readdir"></a>`__wasi_fd_readdir()` 498 499Read directory entries from a directory. 500 501When successful, the contents of the output buffer consist of 502a sequence of directory entries. Each directory entry consists 503of a [`__wasi_dirent_t`](#dirent) object, followed by [`__wasi_dirent_t::d_namlen`](#dirent.d_namlen) bytes 504holding the name of the directory entry. 505 506This function fills the output buffer as much as possible, 507potentially truncating the last directory entry. This allows 508the caller to grow its read buffer size in case it's too small 509to fit a single large directory entry, or skip the oversized 510directory entry. 511 512Inputs: 513 514- <a href="#fd_readdir.fd" name="fd_readdir.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 515 516 The directory from which to read the directory 517 entries. 518 519- <a href="#fd_readdir.buf" name="fd_readdir.buf"></a><code>void \*<strong>buf</strong></code> and <a href="#fd_readdir.buf_len" name="fd_readdir.buf_len"></a><code>size\_t <strong>buf\_len</strong></code> 520 521 The buffer where directory entries are stored. 522 523- <a href="#fd_readdir.cookie" name="fd_readdir.cookie"></a><code>[\_\_wasi\_dircookie\_t](#dircookie) <strong>cookie</strong></code> 524 525 The location within the directory to start 526 reading. 527 528Outputs: 529 530- <a href="#fd_readdir.bufused" name="fd_readdir.bufused"></a><code>size\_t <strong>bufused</strong></code> 531 532 The number of bytes stored in the read buffer. 533 If less than the size of the read buffer, the 534 end of the directory has been reached. 535 536### <a href="#fd_renumber" name="fd_renumber"></a>`__wasi_fd_renumber()` 537 538Atomically replace a file descriptor by renumbering another 539file descriptor. 540 541Due to the strong focus on thread safety, this environment 542does not provide a mechanism to duplicate or renumber a file 543descriptor to an arbitrary number, like dup2(). This would be 544prone to race conditions, as an actual file descriptor with the 545same number could be allocated by a different thread at the same 546time. 547 548This function provides a way to atomically renumber file 549descriptors, which would disappear if dup2() were to be 550removed entirely. 551 552Inputs: 553 554- <a href="#fd_renumber.from" name="fd_renumber.from"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>from</strong></code> 555 556 The file descriptor to renumber. 557 558- <a href="#fd_renumber.to" name="fd_renumber.to"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>to</strong></code> 559 560 The file descriptor to overwrite. 561 562### <a href="#fd_seek" name="fd_seek"></a>`__wasi_fd_seek()` 563 564Move the offset of a file descriptor. 565 566Note: This is similar to `lseek` in POSIX. 567 568Inputs: 569 570- <a href="#fd_seek.fd" name="fd_seek.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 571 572 The file descriptor to operate on. 573 574- <a href="#fd_seek.offset" name="fd_seek.offset"></a><code>[\_\_wasi\_filedelta\_t](#filedelta) <strong>offset</strong></code> 575 576 The number of bytes to move. 577 578- <a href="#fd_seek.whence" name="fd_seek.whence"></a><code>[\_\_wasi\_whence\_t](#whence) <strong>whence</strong></code> 579 580 The base from which the offset is relative. 581 582Outputs: 583 584- <a href="#fd_seek.newoffset" name="fd_seek.newoffset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>newoffset</strong></code> 585 586 The new offset of the file descriptor, 587 relative to the start of the file. 588 589### <a href="#fd_sync" name="fd_sync"></a>`__wasi_fd_sync()` 590 591Synchronize the data and metadata of a file to disk. 592 593Note: This is similar to `fsync` in POSIX. 594 595Inputs: 596 597- <a href="#fd_sync.fd" name="fd_sync.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 598 599 The file descriptor of the file containing the data 600 and metadata to synchronize to disk. 601 602### <a href="#fd_tell" name="fd_tell"></a>`__wasi_fd_tell()` 603 604Return the current offset of a file descriptor. 605 606Note: This is similar to `lseek(fd, 0, SEEK_CUR)` in POSIX. 607 608Inputs: 609 610- <a href="#fd_tell.fd" name="fd_tell.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 611 612 The file descriptor to inspect. 613 614Outputs: 615 616- <a href="#fd_tell.offset" name="fd_tell.offset"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>offset</strong></code> 617 618 The current offset of the file descriptor, relative to the start of the file. 619 620### <a href="#fd_write" name="fd_write"></a>`__wasi_fd_write()` 621 622Write to a file descriptor. 623 624Note: This is similar to `writev` in POSIX. 625 626Inputs: 627 628- <a href="#fd_write.fd" name="fd_write.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 629 630 The file descriptor to which to write data. 631 632- <a href="#fd_write.iovs" name="fd_write.iovs"></a><code>const [\_\_wasi\_ciovec\_t](#ciovec) \*<strong>iovs</strong></code> and <a href="#fd_write.iovs_len" name="fd_write.iovs_len"></a><code>size\_t <strong>iovs\_len</strong></code> 633 634 List of scatter/gather vectors from which to retrieve data. 635 636Outputs: 637 638- <a href="#fd_write.nwritten" name="fd_write.nwritten"></a><code>size\_t <strong>nwritten</strong></code> 639 640 The number of bytes written. 641 642### <a href="#path_create_directory" name="path_create_directory"></a>`__wasi_path_create_directory()` 643 644Create a directory. 645 646Note: This is similar to `mkdirat` in POSIX. 647 648Inputs: 649 650- <a href="#path_create_directory.fd" name="path_create_directory.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 651 652 The working directory at which the resolution of the path starts. 653 654- <a href="#path_create_directory.path" name="path_create_directory.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_create_directory.path_len" name="path_create_directory.path_len"></a><code>size\_t <strong>path\_len</strong></code> 655 656 The path at which to create the directory. 657 658### <a href="#path_filestat_get" name="path_filestat_get"></a>`__wasi_path_filestat_get()` 659 660Return the attributes of a file or directory. 661 662Note: This is similar to `stat` in POSIX. 663 664Inputs: 665 666- <a href="#path_filestat_get.fd" name="path_filestat_get.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 667 668 The working directory at which the resolution of the path starts. 669 670- <a href="#path_filestat_get.flags" name="path_filestat_get.flags"></a><code>[\_\_wasi\_lookupflags\_t](#lookupflags) <strong>flags</strong></code> 671 672 Flags determining the method of how the path is resolved. 673 674- <a href="#path_filestat_get.path" name="path_filestat_get.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_filestat_get.path_len" name="path_filestat_get.path_len"></a><code>size\_t <strong>path\_len</strong></code> 675 676 The path of the file or directory to inspect. 677 678- <a href="#path_filestat_get.buf" name="path_filestat_get.buf"></a><code>[\_\_wasi\_filestat\_t](#filestat) \*<strong>buf</strong></code> 679 680 The buffer where the file's attributes are 681 stored. 682 683### <a href="#path_filestat_set_times" name="path_filestat_set_times"></a>`__wasi_path_filestat_set_times()` 684 685Adjust the timestamps of a file or directory. 686 687Note: This is similar to `utimensat` in POSIX. 688 689Inputs: 690 691- <a href="#path_filestat_set_times.fd" name="path_filestat_set_times.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 692 693 The working directory at which the resolution of the path starts. 694 695- <a href="#path_filestat_set_times.flags" name="path_filestat_set_times.flags"></a><code>[\_\_wasi\_lookupflags\_t](#lookupflags) <strong>flags</strong></code> 696 697 Flags determining the method of how the path is resolved. 698 699- <a href="#path_filestat_set_times.path" name="path_filestat_set_times.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_filestat_set_times.path_len" name="path_filestat_set_times.path_len"></a><code>size\_t <strong>path\_len</strong></code> 700 701 The path of the file or directory to operate on. 702 703- <a href="#path_filestat_set_times.st_atim" name="path_filestat_set_times.st_atim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_atim</strong></code> 704 705 The desired values of the data access timestamp. 706 707- <a href="#path_filestat_set_times.st_mtim" name="path_filestat_set_times.st_mtim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_mtim</strong></code> 708 709 The desired values of the data modification timestamp. 710 711- <a href="#path_filestat_set_times.fst_flags" name="path_filestat_set_times.fst_flags"></a><code>[\_\_wasi\_fstflags\_t](#fstflags) <strong>fst\_flags</strong></code> 712 713 A bitmask indicating which timestamps to adjust. 714 715### <a href="#path_link" name="path_link"></a>`__wasi_path_link()` 716 717Create a hard link. 718 719Note: This is similar to `linkat` in POSIX. 720 721Inputs: 722 723- <a href="#path_link.old_fd" name="path_link.old_fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>old\_fd</strong></code> 724 725 The working directory at which the resolution of the old path starts. 726 727- <a href="#path_link.old_flags" name="path_link.old_flags"></a><code>[\_\_wasi\_lookupflags\_t](#lookupflags) <strong>old\_flags</strong></code> 728 729 Flags determining the method of how the path is resolved. 730 731- <a href="#path_link.old_path" name="path_link.old_path"></a><code>const char \*<strong>old\_path</strong></code> and <a href="#path_link.old_path_len" name="path_link.old_path_len"></a><code>size\_t <strong>old\_path\_len</strong></code> 732 733 The source path from which to link. 734 735- <a href="#path_link.new_fd" name="path_link.new_fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>new\_fd</strong></code> 736 737 The working directory at which the resolution of the new path starts. 738 739- <a href="#path_link.new_path" name="path_link.new_path"></a><code>const char \*<strong>new\_path</strong></code> and <a href="#path_link.new_path_len" name="path_link.new_path_len"></a><code>size\_t <strong>new\_path\_len</strong></code> 740 741 The destination path at which to create the hard link. 742 743### <a href="#path_open" name="path_open"></a>`__wasi_path_open()` 744 745Open a file or directory. 746 747The returned file descriptor is not guaranteed to be the lowest-numbered 748file descriptor not currently open; it is randomized to prevent 749applications from depending on making assumptions about indexes, since 750this is error-prone in multi-threaded contexts. The returned file 751descriptor is guaranteed to be less than 2<sup>31</sup>. 752 753Note: This is similar to `openat` in POSIX. 754 755Inputs: 756 757- <a href="#path_open.dirfd" name="path_open.dirfd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>dirfd</strong></code> 758 759 The working directory at which the resolution of the path starts. 760 761- <a href="#path_open.dirflags" name="path_open.dirflags"></a><code>[\_\_wasi\_lookupflags\_t](#lookupflags) <strong>dirflags</strong></code> 762 763 Flags determining the method of how the path is resolved. 764 765- <a href="#path_open.path" name="path_open.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_open.path_len" name="path_open.path_len"></a><code>size\_t <strong>path\_len</strong></code> 766 767 The path of the file or directory to open. 768 769- <a href="#path_open.o_flags" name="path_open.o_flags"></a><code>[\_\_wasi\_oflags\_t](#oflags) <strong>o_flags</strong></code> 770 771 The method by which to open the file. 772 773- <a href="#path_open.fs_rights_base" name="path_open.fs_rights_base"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_base</strong></code> and <a href="#path_open.fs_rights_inheriting" name="path_open.fs_rights_inheriting"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_inheriting</strong></code> 774 775 The initial rights of the newly created file descriptor. The 776 implementation is allowed to return a file descriptor with fewer 777 rights than specified, if and only if those rights do not apply 778 to the type of file being opened. 779 780 The *base* rights are rights that will apply to operations using 781 the file descriptor itself, while the *inheriting* rights are 782 rights that apply to file descriptors derived from it. 783 784- <a href="#path_open.fs_flags" name="path_open.fs_flags"></a><code>[\_\_wasi\_fdflags\_t](#fdflags) <strong>fs\_flags</strong></code> 785 786 The initial flags of the file descriptor. 787 788Outputs: 789 790- <a href="#path_open.fd" name="path_open.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 791 792 The file descriptor of the file that has been 793 opened. 794 795### <a href="#path_readlink" name="path_readlink"></a>`__wasi_path_readlink()` 796 797Read the contents of a symbolic link. 798 799Note: This is similar to `readlinkat` in POSIX. 800 801Inputs: 802 803- <a href="#path_readlink.fd" name="path_readlink.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 804 805 The working directory at which the resolution of the path starts. 806 807- <a href="#path_readlink.path" name="path_readlink.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_readlink.path_len" name="path_readlink.path_len"></a><code>size\_t <strong>path\_len</strong></code> 808 809 The path of the symbolic link from which to read. 810 811- <a href="#path_readlink.buf" name="path_readlink.buf"></a><code>char \*<strong>buf</strong></code> and <a href="#path_readlink.buf_len" name="path_readlink.buf_len"></a><code>size\_t <strong>buf\_len</strong></code> 812 813 The buffer to which to write the contents of the symbolic link. 814 815Outputs: 816 817- <a href="#path_readlink.bufused" name="path_readlink.bufused"></a><code>size\_t <strong>bufused</strong></code> 818 819 The number of bytes placed in the buffer. 820 821### <a href="#path_remove_directory" name="path_remove_directory"></a>`__wasi_path_remove_directory()` 822 823Remove a directory. 824 825Return [`__WASI_ENOTEMPTY`](#errno.notempty) if the directory is not empty. 826 827Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. 828 829Inputs: 830 831- <a href="#path_remove_directory.fd" name="path_remove_directory.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 832 833 The working directory at which the resolution of the path starts. 834 835- <a href="#path_remove_directory.path" name="path_remove_directory.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_remove_directory.path_len" name="path_remove_directory.path_len"></a><code>size\_t <strong>path\_len</strong></code> 836 837 The path to a directory to remove. 838 839### <a href="#path_rename" name="path_rename"></a>`__wasi_path_rename()` 840 841Rename a file or directory. 842 843Note: This is similar to `renameat` in POSIX. 844 845Inputs: 846 847- <a href="#path_rename.old_fd" name="path_rename.old_fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>old\_fd</strong></code> 848 849 The working directory at which the resolution of the old path starts. 850 851- <a href="#path_rename.old_path" name="path_rename.old_path"></a><code>const char \*<strong>old\_path</strong></code> and <a href="#path_rename.old_path_len" name="path_rename.old_path_len"></a><code>size\_t <strong>old\_path\_len</strong></code> 852 853 The source path of the file or directory to rename. 854 855- <a href="#path_rename.new_fd" name="path_rename.new_fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>new\_fd</strong></code> 856 857 The working directory at which the resolution of the new path starts. 858 859- <a href="#path_rename.new_path" name="path_rename.new_path"></a><code>const char \*<strong>new\_path</strong></code> and <a href="#path_rename.new_path_len" name="path_rename.new_path_len"></a><code>size\_t <strong>new\_path\_len</strong></code> 860 861 The destination path to which to rename the file or directory. 862 863### <a href="#path_symlink" name="path_symlink"></a>`__wasi_path_symlink()` 864 865Create a symbolic link. 866 867Note: This is similar to `symlinkat` in POSIX. 868 869Inputs: 870 871- <a href="#path_symlink.old_path" name="path_symlink.old_path"></a><code>const char \*<strong>old\_path</strong></code> and <a href="#path_symlink.old_path_len" name="path_symlink.old_path_len"></a><code>size\_t <strong>old_path\_len</strong></code> 872 873 The contents of the symbolic link. 874 875- <a href="#path_symlink.fd" name="path_symlink.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 876 877 The working directory at which the resolution of the path starts. 878 879- <a href="#path_symlink.new_path" name="path_symlink.new_path"></a><code>const char \*<strong>new\_path</strong></code> and <a href="#path_symlink.new_path_len" name="path_symlink.new_path_len"></a><code>size\_t <strong>new\_path\_len</strong></code> 880 881 The destination path at which to create the symbolic link. 882 883### <a href="#path_unlink_file" name="path_unlink_file"></a>`__wasi_path_unlink_file()` 884 885Unlink a file. 886 887Return [`__WASI_EISDIR`](#errno.isdir) if the path refers to a directory. 888 889Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. 890 891Inputs: 892 893- <a href="#path_unlink_file.fd" name="path_unlink_file.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 894 895 The working directory at which the resolution of the path starts. 896 897- <a href="#path_unlink_file.path" name="path_unlink_file.path"></a><code>const char \*<strong>path</strong></code> and <a href="#path_unlink_file.path_len" name="path_unlink_file.path_len"></a><code>size\_t <strong>path\_len</strong></code> 898 899 The path to a file to unlink. 900 901### <a href="#poll_oneoff" name="poll_oneoff"></a>`__wasi_poll_oneoff()` 902 903Concurrently poll for the occurrence of a set of events. 904 905Inputs: 906 907- <a href="#poll_oneoff.in" name="poll_oneoff.in"></a><code>const [\_\_wasi\_subscription\_t](#subscription) \*<strong>in</strong></code> 908 909 The events to which to subscribe. 910 911- <a href="#poll_oneoff.out" name="poll_oneoff.out"></a><code>[\_\_wasi\_event\_t](#event) \*<strong>out</strong></code> 912 913 The events that have occurred. 914 915- <a href="#poll_oneoff.nsubscriptions" name="poll_oneoff.nsubscriptions"></a><code>size\_t <strong>nsubscriptions</strong></code> 916 917 Both the number of subscriptions and events. 918 919Outputs: 920 921- <a href="#poll_oneoff.nevents" name="poll_oneoff.nevents"></a><code>size\_t <strong>nevents</strong></code> 922 923 The number of events stored. 924 925### <a href="#proc_exit" name="proc_exit"></a>`__wasi_proc_exit()` 926 927Terminate the process normally. An exit code of 0 indicates successful 928termination of the program. The meanings of other values is dependent on 929the environment. 930 931Note: This is similar to `_Exit` in POSIX. 932 933Inputs: 934 935- <a href="#proc_exit.rval" name="proc_exit.rval"></a><code>[\_\_wasi\_exitcode\_t](#exitcode) <strong>rval</strong></code> 936 937 The exit code returned by the process. 938 939Does not return. 940 941### <a href="#proc_raise" name="proc_raise"></a>`__wasi_proc_raise()` 942 943Send a signal to the process of the calling thread. 944 945Note: This is similar to `raise` in POSIX. 946 947Inputs: 948 949- <a href="#proc_raise.sig" name="proc_raise.sig"></a><code>[\_\_wasi\_signal\_t](#signal) <strong>sig</strong></code> 950 951 The signal condition to trigger. 952 953### <a href="#random_get" name="random_get"></a>`__wasi_random_get()` 954 955Write high-quality random data into a buffer. 956 957This function blocks when the implementation is unable to immediately 958provide sufficient high-quality random data. 959 960This function may execute slowly, so when large mounts of random 961data are required, it's advisable to use this function to seed a 962pseudo-random number generator, rather than to provide the 963random data directly. 964 965Inputs: 966 967- <a href="#random_get.buf" name="random_get.buf"></a><code>void \*<strong>buf</strong></code> and <a href="#random_get.buf_len" name="random_get.buf_len"></a><code>size\_t <strong>buf\_len</strong></code> 968 969 The buffer to fill with random data. 970 971### <a href="#sched_yield" name="sched_yield"></a>`__wasi_sched_yield()` 972 973Temporarily yield execution of the calling thread. 974 975Note: This is similar to `sched_yield` in POSIX. 976 977### <a href="#sock_recv" name="sock_recv"></a>`__wasi_sock_recv()` 978 979Receive a message from a socket. 980 981Note: This is similar to `recv` in POSIX, though it also supports reading 982the data into multiple buffers in the manner of `readv`. 983 984Inputs: 985 986- <a href="#sock_recv.sock" name="sock_recv.sock"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>sock</strong></code> 987 988 The socket on which to receive data. 989 990- <a href="#sock_recv.ri_data" name="sock_recv.ri_data"></a><code>const [\_\_wasi\_iovec\_t](#iovec) \*<strong>ri\_data</strong></code> and <a href="#sock_recv.ri_data_len" name="sock_recv.ri_data_len"></a><code>size\_t <strong>ri\_data\_len</strong></code> 991 992 List of scatter/gather vectors to which to store data. 993 994- <a href="#sock_recv.ri_flags" name="sock_recv.ri_flags"></a><code>[\_\_wasi\_riflags\_t](#riflags) <strong>ri\_flags</strong></code> 995 996 Message flags. 997 998Outputs: 999 1000- <a href="#sock_recv.ro_datalen" name="sock_recv.ro_datalen"></a><code>size\_t <strong>ro\_datalen</strong></code> 1001 1002 Number of bytes stored in [`ri_data`](#sock_recv.ri_data). 1003 1004- <a href="#sock_recv.ro_flags" name="sock_recv.ro_flags"></a><code>[\_\_wasi\_roflags\_t](#roflags) <strong>ro\_flags</strong></code> 1005 1006 Message flags. 1007 1008### <a href="#sock_send" name="sock_send"></a>`__wasi_sock_send()` 1009 1010Send a message on a socket. 1011 1012Note: This is similar to `send` in POSIX, though it also supports writing 1013the data from multiple buffers in the manner of `writev`. 1014 1015Inputs: 1016 1017- <a href="#sock_send.sock" name="sock_send.sock"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>sock</strong></code> 1018 1019 The socket on which to send data. 1020 1021- <a href="#sock_send.si_data" name="sock_send.si_data"></a><code>const [\_\_wasi\_ciovec\_t](#ciovec) \*<strong>si\_data</strong></code> and <a href="#sock_send.si_data_len" name="sock_send.si_data_len"></a><code>size\_t <strong>si\_data\_len</strong></code> 1022 1023 List of scatter/gather vectors to which to retrieve data 1024 1025- <a href="#sock_send.si_flags" name="sock_send.si_flags"></a><code>[\_\_wasi\_siflags\_t](#siflags) <strong>si\_flags</strong></code> 1026 1027 Message flags. 1028 1029Outputs: 1030 1031- <a href="#sock_send.so_datalen" name="sock_send.so_datalen"></a><code>size\_t <strong>so\_datalen</strong></code> 1032 1033 Number of bytes transmitted. 1034 1035### <a href="#sock_shutdown" name="sock_shutdown"></a>`__wasi_sock_shutdown()` 1036 1037Shut down socket send and receive channels. 1038 1039Note: This is similar to `shutdown` in POSIX. 1040 1041Inputs: 1042 1043- <a href="#sock_shutdown.sock" name="sock_shutdown.sock"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>sock</strong></code> 1044 1045 The socket on which to shutdown channels. 1046 1047- <a href="#sock_shutdown.how" name="sock_shutdown.how"></a><code>[\_\_wasi\_sdflags\_t](#sdflags) <strong>how</strong></code> 1048 1049 Which channels on the socket to shut down. 1050 1051## Types 1052 1053### <a href="#advice" name="advice"></a>`__wasi_advice_t` (`uint8_t`) 1054 1055File or memory access pattern advisory information. 1056 1057Used by [`__wasi_fd_advise()`](#fd_advise). 1058 1059Possible values: 1060 1061- <a href="#advice.dontneed" name="advice.dontneed"></a>**`__WASI_ADVICE_DONTNEED`** 1062 1063 The application expects that it will not access the 1064 specified data in the near future. 1065 1066- <a href="#advice.noreuse" name="advice.noreuse"></a>**`__WASI_ADVICE_NOREUSE`** 1067 1068 The application expects to access the specified data 1069 once and then not reuse it thereafter. 1070 1071- <a href="#advice.normal" name="advice.normal"></a>**`__WASI_ADVICE_NORMAL`** 1072 1073 The application has no advice to give on its behavior 1074 with respect to the specified data. 1075 1076- <a href="#advice.random" name="advice.random"></a>**`__WASI_ADVICE_RANDOM`** 1077 1078 The application expects to access the specified data 1079 in a random order. 1080 1081- <a href="#advice.sequential" name="advice.sequential"></a>**`__WASI_ADVICE_SEQUENTIAL`** 1082 1083 The application expects to access the specified data 1084 sequentially from lower offsets to higher offsets. 1085 1086- <a href="#advice.willneed" name="advice.willneed"></a>**`__WASI_ADVICE_WILLNEED`** 1087 1088 The application expects to access the specified data 1089 in the near future. 1090 1091### <a href="#ciovec" name="ciovec"></a>`__wasi_ciovec_t` (`struct`) 1092 1093A region of memory for scatter/gather writes. 1094 1095Used by [`__wasi_fd_pwrite()`](#fd_pwrite), [`__wasi_fd_write()`](#fd_write), and [`__wasi_sock_send()`](#sock_send). 1096 1097Members: 1098 1099- <a href="#ciovec.buf" name="ciovec.buf"></a><code>const void \*<strong>buf</strong></code> and <a href="#ciovec.buf_len" name="ciovec.buf_len"></a><code>size\_t <strong>buf\_len</strong></code> 1100 1101 The address and length of the buffer to be written. 1102 1103### <a href="#clockid" name="clockid"></a>`__wasi_clockid_t` (`uint32_t`) 1104 1105Identifiers for clocks. 1106 1107Used by [`__wasi_subscription_t`](#subscription), [`__wasi_clock_res_get()`](#clock_res_get), and [`__wasi_clock_time_get()`](#clock_time_get). 1108 1109Possible values: 1110 1111- <a href="#clockid.monotonic" name="clockid.monotonic"></a>**`__WASI_CLOCK_MONOTONIC`** 1112 1113 The store-wide monotonic clock, which is defined as a 1114 clock measuring real time, whose value cannot be 1115 adjusted and which cannot have negative clock jumps. 1116 1117 The epoch of this clock is undefined. The absolute 1118 time value of this clock therefore has no meaning. 1119 1120- <a href="#clockid.process_cputime_id" name="clockid.process_cputime_id"></a>**`__WASI_CLOCK_PROCESS_CPUTIME_ID`** 1121 1122 The CPU-time clock associated with the current 1123 process. 1124 1125- <a href="#clockid.realtime" name="clockid.realtime"></a>**`__WASI_CLOCK_REALTIME`** 1126 1127 The clock measuring real time. Time value 1128 zero corresponds with 1970-01-01T00:00:00Z. 1129 1130- <a href="#clockid.thread_cputime_id" name="clockid.thread_cputime_id"></a>**`__WASI_CLOCK_THREAD_CPUTIME_ID`** 1131 1132 The CPU-time clock associated with the current thread. 1133 1134### <a href="#device" name="device"></a>`__wasi_device_t` (`uint64_t`) 1135 1136Identifier for a device containing a file system. Can be used 1137in combination with [`__wasi_inode_t`](#inode) to uniquely identify a file or 1138directory in the filesystem. 1139 1140Used by [`__wasi_filestat_t`](#filestat). 1141 1142### <a href="#dircookie" name="dircookie"></a>`__wasi_dircookie_t` (`uint64_t`) 1143 1144A reference to the offset of a directory entry. 1145 1146Used by [`__wasi_dirent_t`](#dirent) and [`__wasi_fd_readdir()`](#fd_readdir). 1147 1148Special values: 1149 1150- <a href="#dircookie.start" name="dircookie.start"></a>**`__WASI_DIRCOOKIE_START`** 1151 1152 Permanent reference to the first directory entry 1153 within a directory. 1154 1155### <a href="#dirent" name="dirent"></a>`__wasi_dirent_t` (`struct`) 1156 1157A directory entry. 1158 1159Members: 1160 1161- <a href="#dirent.d_next" name="dirent.d_next"></a><code>[\_\_wasi\_dircookie\_t](#dircookie) <strong>d\_next</strong></code> 1162 1163 The offset of the next directory entry stored in this 1164 directory. 1165 1166- <a href="#dirent.d_ino" name="dirent.d_ino"></a><code>[\_\_wasi\_inode\_t](#inode) <strong>d\_ino</strong></code> 1167 1168 The serial number of the file referred to by this 1169 directory entry. 1170 1171- <a href="#dirent.d_namlen" name="dirent.d_namlen"></a><code>uint32\_t <strong>d\_namlen</strong></code> 1172 1173 The length of the name of the directory entry. 1174 1175- <a href="#dirent.d_type" name="dirent.d_type"></a><code>[\_\_wasi\_filetype\_t](#filetype) <strong>d\_type</strong></code> 1176 1177 The type of the file referred to by this directory 1178 entry. 1179 1180### <a href="#errno" name="errno"></a>`__wasi_errno_t` (`uint16_t`) 1181 1182Error codes returned by functions. 1183 1184Not all of these error codes are returned by the functions 1185provided by this API; some are used in higher-level library layers, 1186and others are provided merely for alignment with POSIX. 1187 1188Used by [`__wasi_event_t`](#event). 1189 1190Possible values: 1191 1192- <a href="#errno.success" name="errno.success"></a>**`__WASI_ESUCCESS`** 1193 1194 No error occurred. System call completed successfully. 1195 1196- <a href="#errno.2big" name="errno.2big"></a>**`__WASI_E2BIG`** 1197 1198 Argument list too long. 1199 1200- <a href="#errno.acces" name="errno.acces"></a>**`__WASI_EACCES`** 1201 1202 Permission denied. 1203 1204- <a href="#errno.addrinuse" name="errno.addrinuse"></a>**`__WASI_EADDRINUSE`** 1205 1206 Address in use. 1207 1208- <a href="#errno.addrnotavail" name="errno.addrnotavail"></a>**`__WASI_EADDRNOTAVAIL`** 1209 1210 Address not available. 1211 1212- <a href="#errno.afnosupport" name="errno.afnosupport"></a>**`__WASI_EAFNOSUPPORT`** 1213 1214 Address family not supported. 1215 1216- <a href="#errno.again" name="errno.again"></a>**`__WASI_EAGAIN`** 1217 1218 Resource unavailable, or operation would block. 1219 1220- <a href="#errno.already" name="errno.already"></a>**`__WASI_EALREADY`** 1221 1222 Connection already in progress. 1223 1224- <a href="#errno.badf" name="errno.badf"></a>**`__WASI_EBADF`** 1225 1226 Bad file descriptor. 1227 1228- <a href="#errno.badmsg" name="errno.badmsg"></a>**`__WASI_EBADMSG`** 1229 1230 Bad message. 1231 1232- <a href="#errno.busy" name="errno.busy"></a>**`__WASI_EBUSY`** 1233 1234 Device or resource busy. 1235 1236- <a href="#errno.canceled" name="errno.canceled"></a>**`__WASI_ECANCELED`** 1237 1238 Operation canceled. 1239 1240- <a href="#errno.child" name="errno.child"></a>**`__WASI_ECHILD`** 1241 1242 No child processes. 1243 1244- <a href="#errno.connaborted" name="errno.connaborted"></a>**`__WASI_ECONNABORTED`** 1245 1246 Connection aborted. 1247 1248- <a href="#errno.connrefused" name="errno.connrefused"></a>**`__WASI_ECONNREFUSED`** 1249 1250 Connection refused. 1251 1252- <a href="#errno.connreset" name="errno.connreset"></a>**`__WASI_ECONNRESET`** 1253 1254 Connection reset. 1255 1256- <a href="#errno.deadlk" name="errno.deadlk"></a>**`__WASI_EDEADLK`** 1257 1258 Resource deadlock would occur. 1259 1260- <a href="#errno.destaddrreq" name="errno.destaddrreq"></a>**`__WASI_EDESTADDRREQ`** 1261 1262 Destination address required. 1263 1264- <a href="#errno.dom" name="errno.dom"></a>**`__WASI_EDOM`** 1265 1266 Mathematics argument out of domain of function. 1267 1268- <a href="#errno.dquot" name="errno.dquot"></a>**`__WASI_EDQUOT`** 1269 1270 Reserved. 1271 1272- <a href="#errno.exist" name="errno.exist"></a>**`__WASI_EEXIST`** 1273 1274 File exists. 1275 1276- <a href="#errno.fault" name="errno.fault"></a>**`__WASI_EFAULT`** 1277 1278 Bad address. 1279 1280- <a href="#errno.fbig" name="errno.fbig"></a>**`__WASI_EFBIG`** 1281 1282 File too large. 1283 1284- <a href="#errno.hostunreach" name="errno.hostunreach"></a>**`__WASI_EHOSTUNREACH`** 1285 1286 Host is unreachable. 1287 1288- <a href="#errno.idrm" name="errno.idrm"></a>**`__WASI_EIDRM`** 1289 1290 Identifier removed. 1291 1292- <a href="#errno.ilseq" name="errno.ilseq"></a>**`__WASI_EILSEQ`** 1293 1294 Illegal byte sequence. 1295 1296- <a href="#errno.inprogress" name="errno.inprogress"></a>**`__WASI_EINPROGRESS`** 1297 1298 Operation in progress. 1299 1300- <a href="#errno.intr" name="errno.intr"></a>**`__WASI_EINTR`** 1301 1302 Interrupted function. 1303 1304- <a href="#errno.inval" name="errno.inval"></a>**`__WASI_EINVAL`** 1305 1306 Invalid argument. 1307 1308- <a href="#errno.io" name="errno.io"></a>**`__WASI_EIO`** 1309 1310 I/O error. 1311 1312- <a href="#errno.isconn" name="errno.isconn"></a>**`__WASI_EISCONN`** 1313 1314 Socket is connected. 1315 1316- <a href="#errno.isdir" name="errno.isdir"></a>**`__WASI_EISDIR`** 1317 1318 Is a directory. 1319 1320- <a href="#errno.loop" name="errno.loop"></a>**`__WASI_ELOOP`** 1321 1322 Too many levels of symbolic links. 1323 1324- <a href="#errno.mfile" name="errno.mfile"></a>**`__WASI_EMFILE`** 1325 1326 File descriptor value too large. 1327 1328- <a href="#errno.mlink" name="errno.mlink"></a>**`__WASI_EMLINK`** 1329 1330 Too many links. 1331 1332- <a href="#errno.msgsize" name="errno.msgsize"></a>**`__WASI_EMSGSIZE`** 1333 1334 Message too large. 1335 1336- <a href="#errno.multihop" name="errno.multihop"></a>**`__WASI_EMULTIHOP`** 1337 1338 Reserved. 1339 1340- <a href="#errno.nametoolong" name="errno.nametoolong"></a>**`__WASI_ENAMETOOLONG`** 1341 1342 Filename too long. 1343 1344- <a href="#errno.netdown" name="errno.netdown"></a>**`__WASI_ENETDOWN`** 1345 1346 Network is down. 1347 1348- <a href="#errno.netreset" name="errno.netreset"></a>**`__WASI_ENETRESET`** 1349 1350 Connection aborted by network. 1351 1352- <a href="#errno.netunreach" name="errno.netunreach"></a>**`__WASI_ENETUNREACH`** 1353 1354 Network unreachable. 1355 1356- <a href="#errno.nfile" name="errno.nfile"></a>**`__WASI_ENFILE`** 1357 1358 Too many files open in system. 1359 1360- <a href="#errno.nobufs" name="errno.nobufs"></a>**`__WASI_ENOBUFS`** 1361 1362 No buffer space available. 1363 1364- <a href="#errno.nodev" name="errno.nodev"></a>**`__WASI_ENODEV`** 1365 1366 No such device. 1367 1368- <a href="#errno.noent" name="errno.noent"></a>**`__WASI_ENOENT`** 1369 1370 No such file or directory. 1371 1372- <a href="#errno.noexec" name="errno.noexec"></a>**`__WASI_ENOEXEC`** 1373 1374 Executable file format error. 1375 1376- <a href="#errno.nolck" name="errno.nolck"></a>**`__WASI_ENOLCK`** 1377 1378 No locks available. 1379 1380- <a href="#errno.nolink" name="errno.nolink"></a>**`__WASI_ENOLINK`** 1381 1382 Reserved. 1383 1384- <a href="#errno.nomem" name="errno.nomem"></a>**`__WASI_ENOMEM`** 1385 1386 Not enough space. 1387 1388- <a href="#errno.nomsg" name="errno.nomsg"></a>**`__WASI_ENOMSG`** 1389 1390 No message of the desired type. 1391 1392- <a href="#errno.noprotoopt" name="errno.noprotoopt"></a>**`__WASI_ENOPROTOOPT`** 1393 1394 Protocol not available. 1395 1396- <a href="#errno.nospc" name="errno.nospc"></a>**`__WASI_ENOSPC`** 1397 1398 No space left on device. 1399 1400- <a href="#errno.nosys" name="errno.nosys"></a>**`__WASI_ENOSYS`** 1401 1402 Function not supported. 1403 1404- <a href="#errno.notconn" name="errno.notconn"></a>**`__WASI_ENOTCONN`** 1405 1406 The socket is not connected. 1407 1408- <a href="#errno.notdir" name="errno.notdir"></a>**`__WASI_ENOTDIR`** 1409 1410 Not a directory or a symbolic link to a directory. 1411 1412- <a href="#errno.notempty" name="errno.notempty"></a>**`__WASI_ENOTEMPTY`** 1413 1414 Directory not empty. 1415 1416- <a href="#errno.notrecoverable" name="errno.notrecoverable"></a>**`__WASI_ENOTRECOVERABLE`** 1417 1418 State not recoverable. 1419 1420- <a href="#errno.notsock" name="errno.notsock"></a>**`__WASI_ENOTSOCK`** 1421 1422 Not a socket. 1423 1424- <a href="#errno.notsup" name="errno.notsup"></a>**`__WASI_ENOTSUP`** 1425 1426 Not supported, or operation not supported on socket. 1427 1428- <a href="#errno.notty" name="errno.notty"></a>**`__WASI_ENOTTY`** 1429 1430 Inappropriate I/O control operation. 1431 1432- <a href="#errno.nxio" name="errno.nxio"></a>**`__WASI_ENXIO`** 1433 1434 No such device or address. 1435 1436- <a href="#errno.overflow" name="errno.overflow"></a>**`__WASI_EOVERFLOW`** 1437 1438 Value too large to be stored in data type. 1439 1440- <a href="#errno.ownerdead" name="errno.ownerdead"></a>**`__WASI_EOWNERDEAD`** 1441 1442 Previous owner died. 1443 1444- <a href="#errno.perm" name="errno.perm"></a>**`__WASI_EPERM`** 1445 1446 Operation not permitted. 1447 1448- <a href="#errno.pipe" name="errno.pipe"></a>**`__WASI_EPIPE`** 1449 1450 Broken pipe. 1451 1452- <a href="#errno.proto" name="errno.proto"></a>**`__WASI_EPROTO`** 1453 1454 Protocol error. 1455 1456- <a href="#errno.protonosupport" name="errno.protonosupport"></a>**`__WASI_EPROTONOSUPPORT`** 1457 1458 Protocol not supported. 1459 1460- <a href="#errno.prototype" name="errno.prototype"></a>**`__WASI_EPROTOTYPE`** 1461 1462 Protocol wrong type for socket. 1463 1464- <a href="#errno.range" name="errno.range"></a>**`__WASI_ERANGE`** 1465 1466 Result too large. 1467 1468- <a href="#errno.rofs" name="errno.rofs"></a>**`__WASI_EROFS`** 1469 1470 Read-only file system. 1471 1472- <a href="#errno.spipe" name="errno.spipe"></a>**`__WASI_ESPIPE`** 1473 1474 Invalid seek. 1475 1476- <a href="#errno.srch" name="errno.srch"></a>**`__WASI_ESRCH`** 1477 1478 No such process. 1479 1480- <a href="#errno.stale" name="errno.stale"></a>**`__WASI_ESTALE`** 1481 1482 Reserved. 1483 1484- <a href="#errno.timedout" name="errno.timedout"></a>**`__WASI_ETIMEDOUT`** 1485 1486 Connection timed out. 1487 1488- <a href="#errno.txtbsy" name="errno.txtbsy"></a>**`__WASI_ETXTBSY`** 1489 1490 Text file busy. 1491 1492- <a href="#errno.xdev" name="errno.xdev"></a>**`__WASI_EXDEV`** 1493 1494 Cross-device link. 1495 1496- <a href="#errno.notcapable" name="errno.notcapable"></a>**`__WASI_ENOTCAPABLE`** 1497 1498 Extension: Capabilities insufficient. 1499 1500### <a href="#event" name="event"></a>`__wasi_event_t` (`struct`) 1501 1502An event that occurred. 1503 1504Used by [`__wasi_poll_oneoff()`](#poll_oneoff). 1505 1506Members: 1507 1508- <a href="#event.userdata" name="event.userdata"></a><code>[\_\_wasi\_userdata\_t](#userdata) <strong>userdata</strong></code> 1509 1510 User-provided value that got attached to 1511 [`__wasi_subscription_t::userdata`](#subscription.userdata). 1512 1513- <a href="#event.error" name="event.error"></a><code>[\_\_wasi\_errno\_t](#errno) <strong>error</strong></code> 1514 1515 If non-zero, an error that occurred while processing 1516 the subscription request. 1517 1518- <a href="#event.type" name="event.type"></a><code>[\_\_wasi\_eventtype\_t](#eventtype) <strong>type</strong></code> 1519 1520 The type of the event that occurred. 1521 1522- When `type` is [`__WASI_EVENTTYPE_FD_READ`](#eventtype.fd_read) or [`__WASI_EVENTTYPE_FD_WRITE`](#eventtype.fd_write): 1523 1524 - <a href="#event.u.fd_readwrite" name="event.u.fd_readwrite"></a>**`u.fd_readwrite`** 1525 1526 - <a href="#event.u.fd_readwrite.nbytes" name="event.u.fd_readwrite.nbytes"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>nbytes</strong></code> 1527 1528 The number of bytes available for reading or writing. 1529 1530 - <a href="#event.u.fd_readwrite.flags" name="event.u.fd_readwrite.flags"></a><code>[\_\_wasi\_eventrwflags\_t](#eventrwflags) <strong>flags</strong></code> 1531 1532 The state of the file descriptor. 1533 1534### <a href="#eventrwflags" name="eventrwflags"></a>`__wasi_eventrwflags_t` (`uint16_t` bitfield) 1535 1536The state of the file descriptor subscribed to with 1537[`__WASI_EVENTTYPE_FD_READ`](#eventtype.fd_read) or [`__WASI_EVENTTYPE_FD_WRITE`](#eventtype.fd_write). 1538 1539Used by [`__wasi_event_t`](#event). 1540 1541Possible values: 1542 1543- <a href="#eventrwflags.hangup" name="eventrwflags.hangup"></a>**`__WASI_EVENT_FD_READWRITE_HANGUP`** 1544 1545 The peer of this socket has closed or disconnected. 1546 1547### <a href="#eventtype" name="eventtype"></a>`__wasi_eventtype_t` (`uint8_t`) 1548 1549Type of a subscription to an event or its occurrence. 1550 1551Used by [`__wasi_event_t`](#event) and [`__wasi_subscription_t`](#subscription). 1552 1553Possible values: 1554 1555- <a href="#eventtype.u.clock" name="eventtype.u.clock"></a>**`__WASI_EVENTTYPE_CLOCK`** 1556 1557 The time value of clock [`__wasi_subscription_t::u.clock.clock_id`](#subscription.u.clock.clock_id) 1558 has reached timestamp [`__wasi_subscription_t::u.clock.timeout`](#subscription.u.clock.timeout). 1559 1560- <a href="#eventtype.fd_read" name="eventtype.fd_read"></a>**`__WASI_EVENTTYPE_FD_READ`** 1561 1562 File descriptor [`__wasi_subscription_t::u.fd_readwrite.fd`](#subscription.u.fd_readwrite.fd) has 1563 data available for reading. This event always triggers 1564 for regular files. 1565 1566- <a href="#eventtype.fd_write" name="eventtype.fd_write"></a>**`__WASI_EVENTTYPE_FD_WRITE`** 1567 1568 File descriptor [`__wasi_subscription_t::u.fd_readwrite.fd`](#subscription.u.fd_readwrite.fd) has 1569 capacity available for writing. This event always 1570 triggers for regular files. 1571 1572### <a href="#exitcode" name="exitcode"></a>`__wasi_exitcode_t` (`uint32_t`) 1573 1574Exit code generated by a process when exiting. 1575 1576Used by [`__wasi_proc_exit()`](#proc_exit). 1577 1578### <a href="#fd" name="fd"></a>`__wasi_fd_t` (`uint32_t`) 1579 1580A file descriptor number. 1581 1582Used by many functions in this API. 1583 1584As in POSIX, three file descriptor numbers are provided to instances 1585on startup -- 0, 1, and 2, (a.k.a. `STDIN_FILENO`, `STDOUT_FILENO`, 1586and `STDERR_FILENO`). 1587 1588Other than these, WASI implementations are not required to allocate 1589new file descriptors in ascending order. 1590 1591### <a href="#fdflags" name="fdflags"></a>`__wasi_fdflags_t` (`uint16_t` bitfield) 1592 1593File descriptor flags. 1594 1595Used by [`__wasi_fdstat_t`](#fdstat), [`__wasi_fd_fdstat_set_flags()`](#fd_fdstat_set_flags), and [`__wasi_path_open()`](#path_open). 1596 1597Possible values: 1598 1599- <a href="#fdflags.append" name="fdflags.append"></a>**`__WASI_FDFLAG_APPEND`** 1600 1601 Append mode: Data written to the file is always 1602 appended to the file's end. 1603 1604- <a href="#fdflags.dsync" name="fdflags.dsync"></a>**`__WASI_FDFLAG_DSYNC`** 1605 1606 Write according to synchronized I/O data integrity 1607 completion. Only the data stored in the file is 1608 synchronized. 1609 1610- <a href="#fdflags.nonblock" name="fdflags.nonblock"></a>**`__WASI_FDFLAG_NONBLOCK`** 1611 1612 Non-blocking mode. 1613 1614- <a href="#fdflags.rsync" name="fdflags.rsync"></a>**`__WASI_FDFLAG_RSYNC`** 1615 1616 Synchronized read I/O operations. 1617 1618- <a href="#fdflags.sync" name="fdflags.sync"></a>**`__WASI_FDFLAG_SYNC`** 1619 1620 Write according to synchronized I/O file integrity completion. 1621 In addition to synchronizing the data stored in the file, the 1622 implementation may also synchronously update the file's metadata. 1623 1624### <a href="#fdstat" name="fdstat"></a>`__wasi_fdstat_t` (`struct`) 1625 1626File descriptor attributes. 1627 1628Used by [`__wasi_fd_fdstat_get()`](#fd_fdstat_get). 1629 1630Members: 1631 1632- <a href="#fdstat.fs_filetype" name="fdstat.fs_filetype"></a><code>[\_\_wasi\_filetype\_t](#filetype) <strong>fs\_filetype</strong></code> 1633 1634 File type. 1635 1636- <a href="#fdstat.fs_flags" name="fdstat.fs_flags"></a><code>[\_\_wasi\_fdflags\_t](#fdflags) <strong>fs\_flags</strong></code> 1637 1638 File descriptor flags. 1639 1640- <a href="#fdstat.fs_rights_base" name="fdstat.fs_rights_base"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_base</strong></code> 1641 1642 Rights that apply to this file descriptor. 1643 1644- <a href="#fdstat.fs_rights_inheriting" name="fdstat.fs_rights_inheriting"></a><code>[\_\_wasi\_rights\_t](#rights) <strong>fs\_rights\_inheriting</strong></code> 1645 1646 Maximum set of rights that may be installed on new 1647 file descriptors that are created through this file 1648 descriptor, e.g., through [`__wasi_path_open()`](#path_open). 1649 1650### <a href="#filedelta" name="filedelta"></a>`__wasi_filedelta_t` (`int64_t`) 1651 1652Relative offset within a file. 1653 1654Used by [`__wasi_fd_seek()`](#fd_seek). 1655 1656### <a href="#filesize" name="filesize"></a>`__wasi_filesize_t` (`uint64_t`) 1657 1658Non-negative file size or length of a region within a file. 1659 1660Used by [`__wasi_event_t`](#event), [`__wasi_filestat_t`](#filestat), [`__wasi_fd_pread()`](#fd_pread), [`__wasi_fd_pwrite()`](#fd_pwrite), [`__wasi_fd_seek()`](#fd_seek), [`__wasi_path_tell()`](#path_tell), [`__wasi_fd_advise()`](#fd_advise), [`__wasi_fd_allocate()`](#fd_allocate), and [`__wasi_fd_filestat_set_size()`](#fd_filestat_set_size). 1661 1662### <a href="#filestat" name="filestat"></a>`__wasi_filestat_t` (`struct`) 1663 1664File attributes. 1665 1666Used by [`__wasi_fd_filestat_get()`](#fd_filestat_get) and [`__wasi_path_filestat_get()`](#path_filestat_get). 1667 1668Members: 1669 1670- <a href="#filestat.st_dev" name="filestat.st_dev"></a><code>[\_\_wasi\_device\_t](#device) <strong>st\_dev</strong></code> 1671 1672 Device ID of device containing the file. 1673 1674- <a href="#filestat.st_ino" name="filestat.st_ino"></a><code>[\_\_wasi\_inode\_t](#inode) <strong>st\_ino</strong></code> 1675 1676 File serial number. 1677 1678- <a href="#filestat.st_filetype" name="filestat.st_filetype"></a><code>[\_\_wasi\_filetype\_t](#filetype) <strong>st\_filetype</strong></code> 1679 1680 File type. 1681 1682- <a href="#filestat.st_nlink" name="filestat.st_nlink"></a><code>[\_\_wasi\_linkcount\_t](#linkcount) <strong>st\_nlink</strong></code> 1683 1684 Number of hard links to the file. 1685 1686- <a href="#filestat.st_size" name="filestat.st_size"></a><code>[\_\_wasi\_filesize\_t](#filesize) <strong>st\_size</strong></code> 1687 1688 For regular files, the file size in bytes. For 1689 symbolic links, the length in bytes of the pathname 1690 contained in the symbolic link. 1691 1692- <a href="#filestat.st_atim" name="filestat.st_atim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_atim</strong></code> 1693 1694 Last data access timestamp. 1695 1696- <a href="#filestat.st_mtim" name="filestat.st_mtim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_mtim</strong></code> 1697 1698 Last data modification timestamp. 1699 1700- <a href="#filestat.st_ctim" name="filestat.st_ctim"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>st\_ctim</strong></code> 1701 1702 Last file status change timestamp. 1703 1704### <a href="#filetype" name="filetype"></a>`__wasi_filetype_t` (`uint8_t`) 1705 1706The type of a file descriptor or file. 1707 1708Used by [`__wasi_dirent_t`](#dirent), [`__wasi_fdstat_t`](#fdstat), and [`__wasi_filestat_t`](#filestat). 1709 1710Possible values: 1711 1712- <a href="#filetype.unknown" name="filetype.unknown"></a>**`__WASI_FILETYPE_UNKNOWN`** 1713 1714 The type of the file descriptor or file is unknown or 1715 is different from any of the other types specified. 1716 1717- <a href="#filetype.block_device" name="filetype.block_device"></a>**`__WASI_FILETYPE_BLOCK_DEVICE`** 1718 1719 The file descriptor or file refers to a block device 1720 inode. 1721 1722- <a href="#filetype.character_device" name="filetype.character_device"></a>**`__WASI_FILETYPE_CHARACTER_DEVICE`** 1723 1724 The file descriptor or file refers to a character 1725 device inode. 1726 1727- <a href="#filetype.directory" name="filetype.directory"></a>**`__WASI_FILETYPE_DIRECTORY`** 1728 1729 The file descriptor or file refers to a directory 1730 inode. 1731 1732- <a href="#filetype.regular_file" name="filetype.regular_file"></a>**`__WASI_FILETYPE_REGULAR_FILE`** 1733 1734 The file descriptor or file refers to a regular file 1735 inode. 1736 1737- <a href="#filetype.socket_dgram" name="filetype.socket_dgram"></a>**`__WASI_FILETYPE_SOCKET_DGRAM`** 1738 1739 The file descriptor or file refers to a datagram 1740 socket. 1741 1742- <a href="#filetype.socket_stream" name="filetype.socket_stream"></a>**`__WASI_FILETYPE_SOCKET_STREAM`** 1743 1744 The file descriptor or file refers to a byte-stream 1745 socket. 1746 1747- <a href="#filetype.symbolic_link" name="filetype.symbolic_link"></a>**`__WASI_FILETYPE_SYMBOLIC_LINK`** 1748 1749 The file refers to a symbolic link inode. 1750 1751### <a href="#fstflags" name="fstflags"></a>`__wasi_fstflags_t` (`uint16_t` bitfield) 1752 1753Which file time attributes to adjust. 1754 1755Used by [`__wasi_fd_filestat_set_times()`](#fd_filestat_set_times) and [`__wasi_path_filestat_set_times()`](#path_filestat_set_times). 1756 1757Possible values: 1758 1759- <a href="#fstflags.atim" name="fstflags.atim"></a>**`__WASI_FILESTAT_SET_ATIM`** 1760 1761 Adjust the last data access timestamp to the value 1762 stored in [`__wasi_filestat_t::st_atim`](#filestat.st_atim). 1763 1764- <a href="#fstflags.atim_now" name="fstflags.atim_now"></a>**`__WASI_FILESTAT_SET_ATIM_NOW`** 1765 1766 Adjust the last data access timestamp to the time 1767 of clock [`__WASI_CLOCK_REALTIME`](#clockid.realtime). 1768 1769- <a href="#fstflags.mtim" name="fstflags.mtim"></a>**`__WASI_FILESTAT_SET_MTIM`** 1770 1771 Adjust the last data modification timestamp to the 1772 value stored in [`__wasi_filestat_t::st_mtim`](#filestat.st_mtim). 1773 1774- <a href="#fstflags.mtim_now" name="fstflags.mtim_now"></a>**`__WASI_FILESTAT_SET_MTIM_NOW`** 1775 1776 Adjust the last data modification timestamp to the 1777 time of clock [`__WASI_CLOCK_REALTIME`](#clockid.realtime). 1778 1779### <a href="#inode" name="inode"></a>`__wasi_inode_t` (`uint64_t`) 1780 1781File serial number that is unique within its file system. 1782 1783Used by [`__wasi_dirent_t`](#dirent) and [`__wasi_filestat_t`](#filestat). 1784 1785### <a href="#iovec" name="iovec"></a>`__wasi_iovec_t` (`struct`) 1786 1787A region of memory for scatter/gather reads. 1788 1789Used by [`__wasi_fd_pread()`](#fd_pread), [`__wasi_fd_read()`](#fd_read), and [`__wasi_sock_recv()`](#sock_recv). 1790 1791Members: 1792 1793- <a href="#iovec.buf" name="iovec.buf"></a><code>void \*<strong>buf</strong></code> and <a href="#iovec.buf_len" name="iovec.buf_len"></a><code>size\_t <strong>buf\_len</strong></code> 1794 1795 The address and length of the buffer to be filled. 1796 1797### <a href="#linkcount" name="linkcount"></a>`__wasi_linkcount_t` (`uint32_t`) 1798 1799Number of hard links to an inode. 1800 1801Used by [`__wasi_filestat_t`](#filestat). 1802 1803### <a href="#lookupflags" name="lookupflags"></a>`__wasi_lookupflags_t` (`uint32_t` bitfield) 1804 1805Flags determining the method of how paths are resolved. 1806 1807Used by [`__wasi_path_filestat_get()`](#path_filestat_get), [`__wasi_path_filestat_set_times()`](#path_filestat_set_times), [`__wasi_path_link()`](#path_link), and [`__wasi_path_open()`](#path_open). 1808 1809Possible values: 1810 1811- <a href="#lookupflags.symlink_follow" name="lookupflags.symlink_follow"></a>**`__WASI_LOOKUP_SYMLINK_FOLLOW`** 1812 1813 As long as the resolved path corresponds to a symbolic 1814 link, it is expanded. 1815 1816### <a href="#oflags" name="oflags"></a>`__wasi_oflags_t` (`uint16_t` bitfield) 1817 1818Open flags used by [`__wasi_path_open()`](#path_open). 1819 1820Used by [`__wasi_path_open()`](#path_open). 1821 1822Possible values: 1823 1824- <a href="#oflags.creat" name="oflags.creat"></a>**`__WASI_O_CREAT`** 1825 1826 Create file if it does not exist. 1827 1828- <a href="#oflags.directory" name="oflags.directory"></a>**`__WASI_O_DIRECTORY`** 1829 1830 Fail if not a directory. 1831 1832- <a href="#oflags.excl" name="oflags.excl"></a>**`__WASI_O_EXCL`** 1833 1834 Fail if file already exists. 1835 1836- <a href="#oflags.trunc" name="oflags.trunc"></a>**`__WASI_O_TRUNC`** 1837 1838 Truncate file to size 0. 1839 1840### <a href="#preopentype" name="preopentype"></a>`__wasi_preopentype_t` (`uint8_t`) 1841 1842Preopened resource type. 1843 1844Used by [`__wasi_prestat_t`](#prestat). 1845 1846Possible values: 1847 1848- <a href="#preopentype.dir" name="preopentype.dir"></a>**`__WASI_PREOPENTYPE_DIR`** 1849 1850 Preopened directory. 1851 1852### <a href="#prestat" name="prestat"></a>`__wasi_prestat_t` (`struct`) 1853 1854Information about a preopened resource. 1855 1856Used by [`__wasi_fd_prestat_get()`](#fd_prestat_get). 1857 1858Members: 1859 1860- <a href="#prestat.pr_type" name="prestat.pr_type"></a><code>[\_\_wasi\_preopentype\_t](#preopentype) <strong>pr\_type</strong></code> 1861 1862 The type of the preopened resource. 1863 1864- When `pr_type` is [`__WASI_PREOPENTYPE_DIR`](#preopentype.dir): 1865 1866 - <a href="#prestat.pr_name_len" name="prestat.pr_name_len"></a><code>size\_t <strong>u.pr\_name\_len</strong></code> 1867 1868 The length of the preopened directory name. 1869 1870### <a href="#riflags" name="riflags"></a>`__wasi_riflags_t` (`uint16_t` bitfield) 1871 1872Flags provided to [`__wasi_sock_recv()`](#sock_recv). 1873 1874Used by [`__wasi_sock_recv()`](#sock_recv). 1875 1876Possible values: 1877 1878- <a href="#riflags.peek" name="riflags.peek"></a>**`__WASI_SOCK_RECV_PEEK`** 1879 1880 Returns the message without removing it from the 1881 socket's receive queue. 1882 1883- <a href="#riflags.waitall" name="riflags.waitall"></a>**`__WASI_SOCK_RECV_WAITALL`** 1884 1885 On byte-stream sockets, block until the full amount 1886 of data can be returned. 1887 1888### <a href="#rights" name="rights"></a>`__wasi_rights_t` (`uint64_t` bitfield) 1889 1890File descriptor rights, determining which actions may be 1891performed. 1892 1893Used by [`__wasi_fdstat_t`](#fdstat), [`__wasi_fd_fdstat_set_rights()`](#fd_fdstat_set_rights), and [`__wasi_path_open()`](#path_open). 1894 1895Possible values: 1896 1897- <a href="#rights.fd_datasync" name="rights.fd_datasync"></a>**`__WASI_RIGHT_FD_DATASYNC`** 1898 1899 The right to invoke [`__wasi_fd_datasync()`](#fd_datasync). 1900 1901 If [`__WASI_RIGHT_PATH_OPEN`](#rights.path_open) is set, includes the right to 1902 invoke [`__wasi_path_open()`](#path_open) with [`__WASI_FDFLAG_DSYNC`](#fdflags.dsync). 1903 1904- <a href="#rights.fd_read" name="rights.fd_read"></a>**`__WASI_RIGHT_FD_READ`** 1905 1906 The right to invoke [`__wasi_fd_read()`](#fd_read) and [`__wasi_sock_recv()`](#sock_recv). 1907 1908 If [`__WASI_RIGHT_FD_SEEK`](#rights.fd_seek) is set, includes the right to invoke 1909 [`__wasi_fd_pread()`](#fd_pread). 1910 1911- <a href="#rights.fd_seek" name="rights.fd_seek"></a>**`__WASI_RIGHT_FD_SEEK`** 1912 1913 The right to invoke [`__wasi_fd_seek()`](#fd_seek). This flag implies 1914 [`__WASI_RIGHT_FD_TELL`](#rights.fd_tell). 1915 1916- <a href="#rights.fd_fdstat_set_flags" name="rights.fd_fdstat_set_flags"></a>**`__WASI_RIGHT_FD_FDSTAT_SET_FLAGS`** 1917 1918 The right to invoke [`__wasi_fd_fdstat_set_flags()`](#fd_fdstat_set_flags). 1919 1920- <a href="#rights.fd_sync" name="rights.fd_sync"></a>**`__WASI_RIGHT_FD_SYNC`** 1921 1922 The right to invoke [`__wasi_fd_sync()`](#fd_sync). 1923 1924 If [`__WASI_RIGHT_PATH_OPEN`](#rights.path_open) is set, includes the right to 1925 invoke [`__wasi_path_open()`](#path_open) with [`__WASI_FDFLAG_RSYNC`](#fdflags.rsync) and 1926 [`__WASI_FDFLAG_DSYNC`](#fdflags.dsync). 1927 1928- <a href="#rights.fd_tell" name="rights.fd_tell"></a>**`__WASI_RIGHT_FD_TELL`** 1929 1930 The right to invoke [`__wasi_fd_seek()`](#fd_seek) in such a way that the 1931 file offset remains unaltered (i.e., [`__WASI_WHENCE_CUR`](#whence.cur) with 1932 offset zero), or to invoke [`__wasi_fd_tell()`](#fd_tell). 1933 1934- <a href="#rights.fd_write" name="rights.fd_write"></a>**`__WASI_RIGHT_FD_WRITE`** 1935 1936 The right to invoke [`__wasi_fd_write()`](#fd_write) and [`__wasi_sock_send()`](#sock_send). 1937 1938 If [`__WASI_RIGHT_FD_SEEK`](#rights.fd_seek) is set, includes the right to 1939 invoke [`__wasi_fd_pwrite()`](#fd_pwrite). 1940 1941- <a href="#rights.fd_advise" name="rights.fd_advise"></a>**`__WASI_RIGHT_FD_ADVISE`** 1942 1943 The right to invoke [`__wasi_fd_advise()`](#fd_advise). 1944 1945- <a href="#rights.fd_allocate" name="rights.fd_allocate"></a>**`__WASI_RIGHT_FD_ALLOCATE`** 1946 1947 The right to invoke [`__wasi_fd_allocate()`](#fd_allocate). 1948 1949- <a href="#rights.path_create_directory" name="rights.path_create_directory"></a>**`__WASI_RIGHT_PATH_CREATE_DIRECTORY`** 1950 1951 The right to invoke [`__wasi_path_create_directory()`](#path_create_directory). 1952 1953- <a href="#rights.path_create_file" name="rights.path_create_file"></a>**`__WASI_RIGHT_PATH_CREATE_FILE`** 1954 1955 If [`__WASI_RIGHT_PATH_OPEN`](#rights.path_open) is set, the right to invoke 1956 [`__wasi_path_open()`](#path_open) with [`__WASI_O_CREAT`](#oflags.creat). 1957 1958- <a href="#rights.path_link_source" name="rights.path_link_source"></a>**`__WASI_RIGHT_PATH_LINK_SOURCE`** 1959 1960 The right to invoke [`__wasi_path_link()`](#path_link) with the file 1961 descriptor as the source directory. 1962 1963- <a href="#rights.path_link_target" name="rights.path_link_target"></a>**`__WASI_RIGHT_PATH_LINK_TARGET`** 1964 1965 The right to invoke [`__wasi_path_link()`](#path_link) with the file 1966 descriptor as the target directory. 1967 1968- <a href="#rights.path_open" name="rights.path_open"></a>**`__WASI_RIGHT_PATH_OPEN`** 1969 1970 The right to invoke [`__wasi_path_open()`](#path_open). 1971 1972- <a href="#rights.fd_readdir" name="rights.fd_readdir"></a>**`__WASI_RIGHT_FD_READDIR`** 1973 1974 The right to invoke [`__wasi_fd_readdir()`](#fd_readdir). 1975 1976- <a href="#rights.path_readlink" name="rights.path_readlink"></a>**`__WASI_RIGHT_PATH_READLINK`** 1977 1978 The right to invoke [`__wasi_path_readlink()`](#path_readlink). 1979 1980- <a href="#rights.path_rename_source" name="rights.path_rename_source"></a>**`__WASI_RIGHT_PATH_RENAME_SOURCE`** 1981 1982 The right to invoke [`__wasi_path_rename()`](#path_rename) with the file 1983 descriptor as the source directory. 1984 1985- <a href="#rights.path_rename_target" name="rights.path_rename_target"></a>**`__WASI_RIGHT_PATH_RENAME_TARGET`** 1986 1987 The right to invoke [`__wasi_path_rename()`](#path_rename) with the file 1988 descriptor as the target directory. 1989 1990- <a href="#rights.path_filestat_get" name="rights.path_filestat_get"></a>**`__WASI_RIGHT_PATH_FILESTAT_GET`** 1991 1992 The right to invoke [`__wasi_path_filestat_get()`](#path_filestat_get). 1993 1994- <a href="#rights.path_filestat_set_size" name="rights.path_filestat_set_size"></a>**`__WASI_RIGHT_PATH_FILESTAT_SET_SIZE`** 1995 1996 The right to change a file's size (there is no `__wasi_path_filestat_set_size()`). 1997 1998 If [`__WASI_RIGHT_PATH_OPEN`](#rights.path_open) is set, includes the right to 1999 invoke [`__wasi_path_open()`](#path_open) with [`__WASI_O_TRUNC`](#oflags.trunc). 2000 2001- <a href="#rights.path_filestat_set_times" name="rights.path_filestat_set_times"></a>**`__WASI_RIGHT_PATH_FILESTAT_SET_TIMES`** 2002 2003 The right to invoke [`__wasi_path_filestat_set_times()`](#path_filestat_set_times). 2004 2005- <a href="#rights.fd_filestat_get" name="rights.fd_filestat_get"></a>**`__WASI_RIGHT_FD_FILESTAT_GET`** 2006 2007 The right to invoke [`__wasi_fd_filestat_get()`](#fd_filestat_get). 2008 2009- <a href="#rights.fd_filestat_set_size" name="rights.fd_filestat_set_size"></a>**`__WASI_RIGHT_FD_FILESTAT_SET_SIZE`** 2010 2011 The right to invoke [`__wasi_fd_filestat_set_size()`](#fd_filestat_set_size). 2012 2013- <a href="#rights.fd_filestat_set_times" name="rights.fd_filestat_set_times"></a>**`__WASI_RIGHT_FD_FILESTAT_SET_TIMES`** 2014 2015 The right to invoke [`__wasi_fd_filestat_set_times()`](#fd_filestat_set_times). 2016 2017- <a href="#rights.path_symlink" name="rights.path_symlink"></a>**`__WASI_RIGHT_PATH_SYMLINK`** 2018 2019 The right to invoke [`__wasi_path_symlink()`](#path_symlink). 2020 2021- <a href="#rights.path_unlink_file" name="rights.path_unlink_file"></a>**`__WASI_RIGHT_PATH_UNLINK_FILE`** 2022 2023 The right to invoke [`__wasi_path_unlink_file()`](#path_unlink_file). 2024 2025- <a href="#rights.path_remove_directory" name="rights.path_remove_directory"></a>**`__WASI_RIGHT_PATH_REMOVE_DIRECTORY`** 2026 2027 The right to invoke [`__wasi_path_remove_directory()`](#path_remove_directory). 2028 2029- <a href="#rights.poll_fd_readwrite" name="rights.poll_fd_readwrite"></a>**`__WASI_RIGHT_POLL_FD_READWRITE`** 2030 2031 If [`__WASI_RIGHT_FD_READ`](#rights.fd_read) is set, includes the right to 2032 invoke [`__wasi_poll_oneoff()`](#poll_oneoff) to subscribe to [`__WASI_EVENTTYPE_FD_READ`](#eventtype.fd_read). 2033 2034 If [`__WASI_RIGHT_FD_WRITE`](#rights.fd_write) is set, includes the right to 2035 invoke [`__wasi_poll_oneoff()`](#poll_oneoff) to subscribe to [`__WASI_EVENTTYPE_FD_WRITE`](#eventtype.fd_write). 2036 2037- <a href="#rights.sock_shutdown" name="rights.sock_shutdown"></a>**`__WASI_RIGHT_SOCK_SHUTDOWN`** 2038 2039 The right to invoke [`__wasi_sock_shutdown()`](#sock_shutdown). 2040 2041### <a href="#roflags" name="roflags"></a>`__wasi_roflags_t` (`uint16_t` bitfield) 2042 2043Flags returned by [`__wasi_sock_recv()`](#sock_recv). 2044 2045Used by [`__wasi_sock_recv()`](#sock_recv). 2046 2047Possible values: 2048 2049- <a href="#roflags.data_truncated" name="roflags.data_truncated"></a>**`__WASI_SOCK_RECV_DATA_TRUNCATED`** 2050 2051 Returned by [`__wasi_sock_recv()`](#sock_recv): Message data has been 2052 truncated. 2053 2054### <a href="#sdflags" name="sdflags"></a>`__wasi_sdflags_t` (`uint8_t` bitfield) 2055 2056Which channels on a socket to shut down. 2057 2058Used by [`__wasi_sock_shutdown()`](#sock_shutdown). 2059 2060Possible values: 2061 2062- <a href="#sdflags.rd" name="sdflags.rd"></a>**`__WASI_SHUT_RD`** 2063 2064 Disables further receive operations. 2065 2066- <a href="#sdflags.wr" name="sdflags.wr"></a>**`__WASI_SHUT_WR`** 2067 2068 Disables further send operations. 2069 2070### <a href="#siflags" name="siflags"></a>`__wasi_siflags_t` (`uint16_t` bitfield) 2071 2072Flags provided to [`__wasi_sock_send()`](#sock_send). As there are currently no flags 2073defined, it must be set to zero. 2074 2075Used by [`__wasi_sock_send()`](#sock_send). 2076 2077### <a href="#signal" name="signal"></a>`__wasi_signal_t` (`uint8_t`) 2078 2079Signal condition. 2080 2081Used by [`__wasi_proc_raise()`](#proc_raise). 2082 2083Possible values: 2084 2085- <a href="#signal.abrt" name="signal.abrt"></a>**`__WASI_SIGABRT`** 2086 2087 Process abort signal. 2088 2089 Action: Terminates the process. 2090 2091- <a href="#signal.alrm" name="signal.alrm"></a>**`__WASI_SIGALRM`** 2092 2093 Alarm clock. 2094 2095 Action: Terminates the process. 2096 2097- <a href="#signal.bus" name="signal.bus"></a>**`__WASI_SIGBUS`** 2098 2099 Access to an undefined portion of a memory object. 2100 2101 Action: Terminates the process. 2102 2103- <a href="#signal.chld" name="signal.chld"></a>**`__WASI_SIGCHLD`** 2104 2105 Child process terminated, stopped, or continued. 2106 2107 Action: Ignored. 2108 2109- <a href="#signal.cont" name="signal.cont"></a>**`__WASI_SIGCONT`** 2110 2111 Continue executing, if stopped. 2112 2113 Action: Continues executing, if stopped. 2114 2115- <a href="#signal.fpe" name="signal.fpe"></a>**`__WASI_SIGFPE`** 2116 2117 Erroneous arithmetic operation. 2118 2119 Action: Terminates the process. 2120 2121- <a href="#signal.hup" name="signal.hup"></a>**`__WASI_SIGHUP`** 2122 2123 Hangup. 2124 2125 Action: Terminates the process. 2126 2127- <a href="#signal.ill" name="signal.ill"></a>**`__WASI_SIGILL`** 2128 2129 Illegal instruction. 2130 2131 Action: Terminates the process. 2132 2133- <a href="#signal.int" name="signal.int"></a>**`__WASI_SIGINT`** 2134 2135 Terminate interrupt signal. 2136 2137 Action: Terminates the process. 2138 2139- <a href="#signal.kill" name="signal.kill"></a>**`__WASI_SIGKILL`** 2140 2141 Kill. 2142 2143 Action: Terminates the process. 2144 2145- <a href="#signal.pipe" name="signal.pipe"></a>**`__WASI_SIGPIPE`** 2146 2147 Write on a pipe with no one to read it. 2148 2149 Action: Ignored. 2150 2151- <a href="#signal.quit" name="signal.quit"></a>**`__WASI_SIGQUIT`** 2152 2153 Terminal quit signal. 2154 2155 Action: Terminates the process. 2156 2157- <a href="#signal.segv" name="signal.segv"></a>**`__WASI_SIGSEGV`** 2158 2159 Invalid memory reference. 2160 2161 Action: Terminates the process. 2162 2163- <a href="#signal.stop" name="signal.stop"></a>**`__WASI_SIGSTOP`** 2164 2165 Stop executing. 2166 2167 Action: Stops executing. 2168 2169- <a href="#signal.sys" name="signal.sys"></a>**`__WASI_SIGSYS`** 2170 2171 Bad system call. 2172 2173 Action: Terminates the process. 2174 2175- <a href="#signal.term" name="signal.term"></a>**`__WASI_SIGTERM`** 2176 2177 Termination signal. 2178 2179 Action: Terminates the process. 2180 2181- <a href="#signal.trap" name="signal.trap"></a>**`__WASI_SIGTRAP`** 2182 2183 Trace/breakpoint trap. 2184 2185 Action: Terminates the process. 2186 2187- <a href="#signal.tstp" name="signal.tstp"></a>**`__WASI_SIGTSTP`** 2188 2189 Terminal stop signal. 2190 2191 Action: Stops executing. 2192 2193- <a href="#signal.ttin" name="signal.ttin"></a>**`__WASI_SIGTTIN`** 2194 2195 Background process attempting read. 2196 2197 Action: Stops executing. 2198 2199- <a href="#signal.ttou" name="signal.ttou"></a>**`__WASI_SIGTTOU`** 2200 2201 Background process attempting write. 2202 2203 Action: Stops executing. 2204 2205- <a href="#signal.urg" name="signal.urg"></a>**`__WASI_SIGURG`** 2206 2207 High bandwidth data is available at a socket. 2208 2209 Action: Ignored. 2210 2211- <a href="#signal.usr1" name="signal.usr1"></a>**`__WASI_SIGUSR1`** 2212 2213 User-defined signal 1. 2214 2215 Action: Terminates the process. 2216 2217- <a href="#signal.usr2" name="signal.usr2"></a>**`__WASI_SIGUSR2`** 2218 2219 User-defined signal 2. 2220 2221 Action: Terminates the process. 2222 2223- <a href="#signal.vtalrm" name="signal.vtalrm"></a>**`__WASI_SIGVTALRM`** 2224 2225 Virtual timer expired. 2226 2227 Action: Terminates the process. 2228 2229- <a href="#signal.xcpu" name="signal.xcpu"></a>**`__WASI_SIGXCPU`** 2230 2231 CPU time limit exceeded. 2232 2233 Action: Terminates the process. 2234 2235- <a href="#signal.xfsz" name="signal.xfsz"></a>**`__WASI_SIGXFSZ`** 2236 2237 File size limit exceeded. 2238 2239 Action: Terminates the process. 2240 2241### <a href="#subclockflags" name="subclockflags"></a>`__wasi_subclockflags_t` (`uint16_t` bitfield) 2242 2243Flags determining how to interpret the timestamp provided in 2244[`__wasi_subscription_t::u.clock.timeout`](#subscription.u.clock.timeout). 2245 2246Used by [`__wasi_subscription_t`](#subscription). 2247 2248Possible values: 2249 2250- <a href="#subclockflags.abstime" name="subclockflags.abstime"></a>**`__WASI_SUBSCRIPTION_CLOCK_ABSTIME`** 2251 2252 If set, treat the timestamp provided in 2253 [`__wasi_subscription_t::u.clock.timeout`](#subscription.u.clock.timeout) as an absolute timestamp 2254 of clock [`__wasi_subscription_t::u.clock.clock_id`](#subscription.u.clock.clock_id). 2255 2256 If clear, treat the timestamp provided in 2257 [`__wasi_subscription_t::u.clock.timeout`](#subscription.u.clock.timeout) relative to the current 2258 time value of clock [`__wasi_subscription_t::u.clock.clock_id`](#subscription.u.clock.clock_id). 2259 2260### <a href="#subscription" name="subscription"></a>`__wasi_subscription_t` (`struct`) 2261 2262Subscription to an event. 2263 2264Used by [`__wasi_poll_oneoff()`](#poll_oneoff). 2265 2266Members: 2267 2268- <a href="#subscription.userdata" name="subscription.userdata"></a><code>[\_\_wasi\_userdata\_t](#userdata) <strong>userdata</strong></code> 2269 2270 User-provided value that is attached to the subscription in the 2271 implementation and returned through 2272 [`__wasi_event_t::userdata`](#event.userdata). 2273 2274- <a href="#subscription.type" name="subscription.type"></a><code>[\_\_wasi\_eventtype\_t](#eventtype) <strong>type</strong></code> 2275 2276 The type of the event to which to subscribe. 2277 2278- When `type` is [`__WASI_EVENTTYPE_CLOCK`](#eventtype.u.clock): 2279 2280 - <a href="#subscription.u.clock" name="subscription.u.clock"></a>**`u.clock`** 2281 2282 - <a href="#subscription.u.clock.identifier" name="subscription.u.clock.identifier"></a><code>[\_\_wasi\_userdata\_t](#userdata) <strong>identifier</strong></code> 2283 2284 The user-defined unique identifier of the clock. 2285 2286 - <a href="#subscription.u.clock.clock_id" name="subscription.u.clock.clock_id"></a><code>[\_\_wasi\_clockid\_t](#clockid) <strong>clock\_id</strong></code> 2287 2288 The clock against which to compare the timestamp. 2289 2290 - <a href="#subscription.u.clock.timeout" name="subscription.u.clock.timeout"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>timeout</strong></code> 2291 2292 The absolute or relative timestamp. 2293 2294 - <a href="#subscription.u.clock.precision" name="subscription.u.clock.precision"></a><code>[\_\_wasi\_timestamp\_t](#timestamp) <strong>precision</strong></code> 2295 2296 The amount of time that the implementation may wait additionally 2297 to coalesce with other events. 2298 2299 - <a href="#subscription.u.clock.flags" name="subscription.u.clock.flags"></a><code>[\_\_wasi\_subclockflags\_t](#subclockflags) <strong>flags</strong></code> 2300 2301 Flags specifying whether the timeout is absolute or relative. 2302 2303- When `type` is [`__WASI_EVENTTYPE_FD_READ`](#eventtype.fd_read) or [`__WASI_EVENTTYPE_FD_WRITE`](#eventtype.fd_write): 2304 2305 - <a href="#subscription.u.fd_readwrite" name="subscription.u.fd_readwrite"></a>**`u.fd_readwrite`** 2306 2307 - <a href="#subscription.u.fd_readwrite.fd" name="subscription.u.fd_readwrite.fd"></a><code>[\_\_wasi\_fd\_t](#fd) <strong>fd</strong></code> 2308 2309 The file descriptor on which to wait for it to become ready 2310 for reading or writing. 2311 2312### <a href="#timestamp" name="timestamp"></a>`__wasi_timestamp_t` (`uint64_t`) 2313 2314Timestamp in nanoseconds. 2315 2316Used by [`__wasi_filestat_t`](#filestat), [`__wasi_subscription_t`](#subscription), [`__wasi_clock_res_get()`](#clock_res_get), [`__wasi_clock_time_get()`](#clock_time_get), [`__wasi_fd_filestat_set_times()`](#fd_filestat_set_times), and [`__wasi_path_filestat_set_times()`](#path_filestat_set_times). 2317 2318### <a href="#userdata" name="userdata"></a>`__wasi_userdata_t` (`uint64_t`) 2319 2320User-provided value that may be attached to objects that is 2321retained when extracted from the implementation. 2322 2323Used by [`__wasi_event_t`](#event) and [`__wasi_subscription_t`](#subscription). 2324 2325### <a href="#whence" name="whence"></a>`__wasi_whence_t` (`uint8_t`) 2326 2327The position relative to which to set the offset of the file descriptor. 2328 2329Used by [`__wasi_fd_seek()`](#fd_seek). 2330 2331Possible values: 2332 2333- <a href="#whence.cur" name="whence.cur"></a>**`__WASI_WHENCE_CUR`** 2334 2335 Seek relative to current position. 2336 2337- <a href="#whence.end" name="whence.end"></a>**`__WASI_WHENCE_END`** 2338 2339 Seek relative to end-of-file. 2340 2341- <a href="#whence.set" name="whence.set"></a>**`__WASI_WHENCE_SET`** 2342 2343 Seek relative to start-of-file. 2344 2345