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