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