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