2 * THIS FILE IS AUTO-GENERATED from the following files:
3 * typenames.witx, wasi_snapshot_preview1.witx
6 * This file describes the [WASI] interface, consisting of functions, types,
7 * and defined values (macros).
9 * The interface described here is greatly inspired by [CloudABI]'s clean,
10 * thoughtfully-designed, capability-oriented, POSIX-style API.
12 * [CloudABI]: https://github.com/NuxiNL/cloudlibc
13 * [WASI]: https://github.com/WebAssembly/WASI/
20 #error <wasi/api.h> is only supported on WASI platforms.
26 _Static_assert(_Alignof(int8_t) == 1, "non-wasi data layout");
27 _Static_assert(_Alignof(uint8_t) == 1, "non-wasi data layout");
28 _Static_assert(_Alignof(int16_t) == 2, "non-wasi data layout");
29 _Static_assert(_Alignof(uint16_t) == 2, "non-wasi data layout");
30 _Static_assert(_Alignof(int32_t) == 4, "non-wasi data layout");
31 _Static_assert(_Alignof(uint32_t) == 4, "non-wasi data layout");
32 _Static_assert(_Alignof(int64_t) == 8, "non-wasi data layout");
33 _Static_assert(_Alignof(uint64_t) == 8, "non-wasi data layout");
39 // TODO: Encoding this in witx.
40 #define __WASI_DIRCOOKIE_START (UINT64_C(0))
41 typedef __SIZE_TYPE__ __wasi_size_t
;
44 * Non-negative file size or length of a region within a file.
46 typedef uint64_t __wasi_filesize_t
;
49 * Timestamp in nanoseconds.
51 typedef uint64_t __wasi_timestamp_t
;
54 * Identifiers for clocks.
56 typedef uint32_t __wasi_clockid_t
;
59 * The clock measuring real time. Time value zero corresponds with
60 * 1970-01-01T00:00:00Z.
62 #define __WASI_CLOCKID_REALTIME (UINT32_C(0))
65 * The store-wide monotonic clock, which is defined as a clock measuring
66 * real time, whose value cannot be adjusted and which cannot have negative
67 * clock jumps. The epoch of this clock is undefined. The absolute time
68 * value of this clock therefore has no meaning.
70 #define __WASI_CLOCKID_MONOTONIC (UINT32_C(1))
73 * The CPU-time clock associated with the current process.
75 #define __WASI_CLOCKID_PROCESS_CPUTIME_ID (UINT32_C(2))
78 * The CPU-time clock associated with the current thread.
80 #define __WASI_CLOCKID_THREAD_CPUTIME_ID (UINT32_C(3))
83 * Error codes returned by functions.
84 * Not all of these error codes are returned by the functions provided by this
85 * API; some are used in higher-level library layers, and others are provided
86 * merely for alignment with POSIX.
88 typedef uint16_t __wasi_errno_t
;
91 * No error occurred. System call completed successfully.
93 #define __WASI_ERRNO_SUCCESS (UINT16_C(0))
96 * Argument list too long.
98 #define __WASI_ERRNO_2BIG (UINT16_C(1))
103 #define __WASI_ERRNO_ACCES (UINT16_C(2))
108 #define __WASI_ERRNO_ADDRINUSE (UINT16_C(3))
111 * Address not available.
113 #define __WASI_ERRNO_ADDRNOTAVAIL (UINT16_C(4))
116 * Address family not supported.
118 #define __WASI_ERRNO_AFNOSUPPORT (UINT16_C(5))
121 * Resource unavailable, or operation would block.
123 #define __WASI_ERRNO_AGAIN (UINT16_C(6))
126 * Connection already in progress.
128 #define __WASI_ERRNO_ALREADY (UINT16_C(7))
131 * Bad file descriptor.
133 #define __WASI_ERRNO_BADF (UINT16_C(8))
138 #define __WASI_ERRNO_BADMSG (UINT16_C(9))
141 * Device or resource busy.
143 #define __WASI_ERRNO_BUSY (UINT16_C(10))
146 * Operation canceled.
148 #define __WASI_ERRNO_CANCELED (UINT16_C(11))
151 * No child processes.
153 #define __WASI_ERRNO_CHILD (UINT16_C(12))
156 * Connection aborted.
158 #define __WASI_ERRNO_CONNABORTED (UINT16_C(13))
161 * Connection refused.
163 #define __WASI_ERRNO_CONNREFUSED (UINT16_C(14))
168 #define __WASI_ERRNO_CONNRESET (UINT16_C(15))
171 * Resource deadlock would occur.
173 #define __WASI_ERRNO_DEADLK (UINT16_C(16))
176 * Destination address required.
178 #define __WASI_ERRNO_DESTADDRREQ (UINT16_C(17))
181 * Mathematics argument out of domain of function.
183 #define __WASI_ERRNO_DOM (UINT16_C(18))
188 #define __WASI_ERRNO_DQUOT (UINT16_C(19))
193 #define __WASI_ERRNO_EXIST (UINT16_C(20))
198 #define __WASI_ERRNO_FAULT (UINT16_C(21))
203 #define __WASI_ERRNO_FBIG (UINT16_C(22))
206 * Host is unreachable.
208 #define __WASI_ERRNO_HOSTUNREACH (UINT16_C(23))
211 * Identifier removed.
213 #define __WASI_ERRNO_IDRM (UINT16_C(24))
216 * Illegal byte sequence.
218 #define __WASI_ERRNO_ILSEQ (UINT16_C(25))
221 * Operation in progress.
223 #define __WASI_ERRNO_INPROGRESS (UINT16_C(26))
226 * Interrupted function.
228 #define __WASI_ERRNO_INTR (UINT16_C(27))
233 #define __WASI_ERRNO_INVAL (UINT16_C(28))
238 #define __WASI_ERRNO_IO (UINT16_C(29))
241 * Socket is connected.
243 #define __WASI_ERRNO_ISCONN (UINT16_C(30))
248 #define __WASI_ERRNO_ISDIR (UINT16_C(31))
251 * Too many levels of symbolic links.
253 #define __WASI_ERRNO_LOOP (UINT16_C(32))
256 * File descriptor value too large.
258 #define __WASI_ERRNO_MFILE (UINT16_C(33))
263 #define __WASI_ERRNO_MLINK (UINT16_C(34))
268 #define __WASI_ERRNO_MSGSIZE (UINT16_C(35))
273 #define __WASI_ERRNO_MULTIHOP (UINT16_C(36))
278 #define __WASI_ERRNO_NAMETOOLONG (UINT16_C(37))
283 #define __WASI_ERRNO_NETDOWN (UINT16_C(38))
286 * Connection aborted by network.
288 #define __WASI_ERRNO_NETRESET (UINT16_C(39))
291 * Network unreachable.
293 #define __WASI_ERRNO_NETUNREACH (UINT16_C(40))
296 * Too many files open in system.
298 #define __WASI_ERRNO_NFILE (UINT16_C(41))
301 * No buffer space available.
303 #define __WASI_ERRNO_NOBUFS (UINT16_C(42))
308 #define __WASI_ERRNO_NODEV (UINT16_C(43))
311 * No such file or directory.
313 #define __WASI_ERRNO_NOENT (UINT16_C(44))
316 * Executable file format error.
318 #define __WASI_ERRNO_NOEXEC (UINT16_C(45))
321 * No locks available.
323 #define __WASI_ERRNO_NOLCK (UINT16_C(46))
328 #define __WASI_ERRNO_NOLINK (UINT16_C(47))
333 #define __WASI_ERRNO_NOMEM (UINT16_C(48))
336 * No message of the desired type.
338 #define __WASI_ERRNO_NOMSG (UINT16_C(49))
341 * Protocol not available.
343 #define __WASI_ERRNO_NOPROTOOPT (UINT16_C(50))
346 * No space left on device.
348 #define __WASI_ERRNO_NOSPC (UINT16_C(51))
351 * Function not supported.
353 #define __WASI_ERRNO_NOSYS (UINT16_C(52))
356 * The socket is not connected.
358 #define __WASI_ERRNO_NOTCONN (UINT16_C(53))
361 * Not a directory or a symbolic link to a directory.
363 #define __WASI_ERRNO_NOTDIR (UINT16_C(54))
366 * Directory not empty.
368 #define __WASI_ERRNO_NOTEMPTY (UINT16_C(55))
371 * State not recoverable.
373 #define __WASI_ERRNO_NOTRECOVERABLE (UINT16_C(56))
378 #define __WASI_ERRNO_NOTSOCK (UINT16_C(57))
381 * Not supported, or operation not supported on socket.
383 #define __WASI_ERRNO_NOTSUP (UINT16_C(58))
386 * Inappropriate I/O control operation.
388 #define __WASI_ERRNO_NOTTY (UINT16_C(59))
391 * No such device or address.
393 #define __WASI_ERRNO_NXIO (UINT16_C(60))
396 * Value too large to be stored in data type.
398 #define __WASI_ERRNO_OVERFLOW (UINT16_C(61))
401 * Previous owner died.
403 #define __WASI_ERRNO_OWNERDEAD (UINT16_C(62))
406 * Operation not permitted.
408 #define __WASI_ERRNO_PERM (UINT16_C(63))
413 #define __WASI_ERRNO_PIPE (UINT16_C(64))
418 #define __WASI_ERRNO_PROTO (UINT16_C(65))
421 * Protocol not supported.
423 #define __WASI_ERRNO_PROTONOSUPPORT (UINT16_C(66))
426 * Protocol wrong type for socket.
428 #define __WASI_ERRNO_PROTOTYPE (UINT16_C(67))
433 #define __WASI_ERRNO_RANGE (UINT16_C(68))
436 * Read-only file system.
438 #define __WASI_ERRNO_ROFS (UINT16_C(69))
443 #define __WASI_ERRNO_SPIPE (UINT16_C(70))
448 #define __WASI_ERRNO_SRCH (UINT16_C(71))
453 #define __WASI_ERRNO_STALE (UINT16_C(72))
456 * Connection timed out.
458 #define __WASI_ERRNO_TIMEDOUT (UINT16_C(73))
463 #define __WASI_ERRNO_TXTBSY (UINT16_C(74))
468 #define __WASI_ERRNO_XDEV (UINT16_C(75))
471 * Extension: Capabilities insufficient.
473 #define __WASI_ERRNO_NOTCAPABLE (UINT16_C(76))
476 * File descriptor rights, determining which actions may be performed.
478 typedef uint64_t __wasi_rights_t
;
481 * The right to invoke `fd_datasync`.
482 * If `path_open` is set, includes the right to invoke
483 * `path_open` with `fdflag::dsync`.
485 #define __WASI_RIGHTS_FD_DATASYNC (UINT64_C(1))
488 * The right to invoke `fd_read` and `sock_recv`.
489 * If `rights::fd_seek` is set, includes the right to invoke `fd_pread`.
491 #define __WASI_RIGHTS_FD_READ (UINT64_C(2))
494 * The right to invoke `fd_seek`. This flag implies `rights::fd_tell`.
496 #define __WASI_RIGHTS_FD_SEEK (UINT64_C(4))
499 * The right to invoke `fd_fdstat_set_flags`.
501 #define __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS (UINT64_C(8))
504 * The right to invoke `fd_sync`.
505 * If `path_open` is set, includes the right to invoke
506 * `path_open` with `fdflag::rsync` and `fdflag::dsync`.
508 #define __WASI_RIGHTS_FD_SYNC (UINT64_C(16))
511 * The right to invoke `fd_seek` in such a way that the file offset
512 * remains unaltered (i.e., `WHENCE_CUR` with offset zero), or to
515 #define __WASI_RIGHTS_FD_TELL (UINT64_C(32))
518 * The right to invoke `fd_write` and `sock_send`.
519 * If `rights::fd_seek` is set, includes the right to invoke `fd_pwrite`.
521 #define __WASI_RIGHTS_FD_WRITE (UINT64_C(64))
524 * The right to invoke `fd_advise`.
526 #define __WASI_RIGHTS_FD_ADVISE (UINT64_C(128))
529 * The right to invoke `fd_allocate`.
531 #define __WASI_RIGHTS_FD_ALLOCATE (UINT64_C(256))
534 * The right to invoke `path_create_directory`.
536 #define __WASI_RIGHTS_PATH_CREATE_DIRECTORY (UINT64_C(512))
539 * If `path_open` is set, the right to invoke `path_open` with `oflags::creat`.
541 #define __WASI_RIGHTS_PATH_CREATE_FILE (UINT64_C(1024))
544 * The right to invoke `path_link` with the file descriptor as the
547 #define __WASI_RIGHTS_PATH_LINK_SOURCE (UINT64_C(2048))
550 * The right to invoke `path_link` with the file descriptor as the
553 #define __WASI_RIGHTS_PATH_LINK_TARGET (UINT64_C(4096))
556 * The right to invoke `path_open`.
558 #define __WASI_RIGHTS_PATH_OPEN (UINT64_C(8192))
561 * The right to invoke `fd_readdir`.
563 #define __WASI_RIGHTS_FD_READDIR (UINT64_C(16384))
566 * The right to invoke `path_readlink`.
568 #define __WASI_RIGHTS_PATH_READLINK (UINT64_C(32768))
571 * The right to invoke `path_rename` with the file descriptor as the source directory.
573 #define __WASI_RIGHTS_PATH_RENAME_SOURCE (UINT64_C(65536))
576 * The right to invoke `path_rename` with the file descriptor as the target directory.
578 #define __WASI_RIGHTS_PATH_RENAME_TARGET (UINT64_C(131072))
581 * The right to invoke `path_filestat_get`.
583 #define __WASI_RIGHTS_PATH_FILESTAT_GET (UINT64_C(262144))
586 * The right to change a file's size (there is no `path_filestat_set_size`).
587 * If `path_open` is set, includes the right to invoke `path_open` with `oflags::trunc`.
589 #define __WASI_RIGHTS_PATH_FILESTAT_SET_SIZE (UINT64_C(524288))
592 * The right to invoke `path_filestat_set_times`.
594 #define __WASI_RIGHTS_PATH_FILESTAT_SET_TIMES (UINT64_C(1048576))
597 * The right to invoke `fd_filestat_get`.
599 #define __WASI_RIGHTS_FD_FILESTAT_GET (UINT64_C(2097152))
602 * The right to invoke `fd_filestat_set_size`.
604 #define __WASI_RIGHTS_FD_FILESTAT_SET_SIZE (UINT64_C(4194304))
607 * The right to invoke `fd_filestat_set_times`.
609 #define __WASI_RIGHTS_FD_FILESTAT_SET_TIMES (UINT64_C(8388608))
612 * The right to invoke `path_symlink`.
614 #define __WASI_RIGHTS_PATH_SYMLINK (UINT64_C(16777216))
617 * The right to invoke `path_remove_directory`.
619 #define __WASI_RIGHTS_PATH_REMOVE_DIRECTORY (UINT64_C(33554432))
622 * The right to invoke `path_unlink_file`.
624 #define __WASI_RIGHTS_PATH_UNLINK_FILE (UINT64_C(67108864))
627 * If `rights::fd_read` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_read`.
628 * If `rights::fd_write` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_write`.
630 #define __WASI_RIGHTS_POLL_FD_READWRITE (UINT64_C(134217728))
633 * The right to invoke `sock_shutdown`.
635 #define __WASI_RIGHTS_SOCK_SHUTDOWN (UINT64_C(268435456))
638 * A file descriptor index.
640 typedef uint32_t __wasi_fd_t
;
643 * A region of memory for scatter/gather reads.
645 typedef struct __wasi_iovec_t
{
647 * The address of the buffer to be filled.
652 * The length of the buffer to be filled.
654 __wasi_size_t buf_len
;
659 * A region of memory for scatter/gather writes.
661 typedef struct __wasi_ciovec_t
{
663 * The address of the buffer to be written.
668 * The length of the buffer to be written.
670 __wasi_size_t buf_len
;
675 * Relative offset within a file.
677 typedef int64_t __wasi_filedelta_t
;
680 * The position relative to which to set the offset of the file descriptor.
682 typedef uint8_t __wasi_whence_t
;
685 * Seek relative to start-of-file.
687 #define __WASI_WHENCE_SET (UINT8_C(0))
690 * Seek relative to current position.
692 #define __WASI_WHENCE_CUR (UINT8_C(1))
695 * Seek relative to end-of-file.
697 #define __WASI_WHENCE_END (UINT8_C(2))
700 * A reference to the offset of a directory entry.
702 * The value 0 signifies the start of the directory.
704 typedef uint64_t __wasi_dircookie_t
;
707 * The type for the $d_namlen field of $dirent.
709 typedef uint32_t __wasi_dirnamlen_t
;
712 * File serial number that is unique within its file system.
714 typedef uint64_t __wasi_inode_t
;
717 * The type of a file descriptor or file.
719 typedef uint8_t __wasi_filetype_t
;
722 * The type of the file descriptor or file is unknown or is different from any of the other types specified.
724 #define __WASI_FILETYPE_UNKNOWN (UINT8_C(0))
727 * The file descriptor or file refers to a block device inode.
729 #define __WASI_FILETYPE_BLOCK_DEVICE (UINT8_C(1))
732 * The file descriptor or file refers to a character device inode.
734 #define __WASI_FILETYPE_CHARACTER_DEVICE (UINT8_C(2))
737 * The file descriptor or file refers to a directory inode.
739 #define __WASI_FILETYPE_DIRECTORY (UINT8_C(3))
742 * The file descriptor or file refers to a regular file inode.
744 #define __WASI_FILETYPE_REGULAR_FILE (UINT8_C(4))
747 * The file descriptor or file refers to a datagram socket.
749 #define __WASI_FILETYPE_SOCKET_DGRAM (UINT8_C(5))
752 * The file descriptor or file refers to a byte-stream socket.
754 #define __WASI_FILETYPE_SOCKET_STREAM (UINT8_C(6))
757 * The file refers to a symbolic link inode.
759 #define __WASI_FILETYPE_SYMBOLIC_LINK (UINT8_C(7))
764 typedef struct __wasi_dirent_t
{
766 * The offset of the next directory entry stored in this directory.
768 __wasi_dircookie_t d_next
;
771 * The serial number of the file referred to by this directory entry.
773 __wasi_inode_t d_ino
;
776 * The length of the name of the directory entry.
778 __wasi_dirnamlen_t d_namlen
;
781 * The type of the file referred to by this directory entry.
783 __wasi_filetype_t d_type
;
788 * File or memory access pattern advisory information.
790 typedef uint8_t __wasi_advice_t
;
793 * The application has no advice to give on its behavior with respect to the specified data.
795 #define __WASI_ADVICE_NORMAL (UINT8_C(0))
798 * The application expects to access the specified data sequentially from lower offsets to higher offsets.
800 #define __WASI_ADVICE_SEQUENTIAL (UINT8_C(1))
803 * The application expects to access the specified data in a random order.
805 #define __WASI_ADVICE_RANDOM (UINT8_C(2))
808 * The application expects to access the specified data in the near future.
810 #define __WASI_ADVICE_WILLNEED (UINT8_C(3))
813 * The application expects that it will not access the specified data in the near future.
815 #define __WASI_ADVICE_DONTNEED (UINT8_C(4))
818 * The application expects to access the specified data once and then not reuse it thereafter.
820 #define __WASI_ADVICE_NOREUSE (UINT8_C(5))
823 * File descriptor flags.
825 typedef uint16_t __wasi_fdflags_t
;
828 * Append mode: Data written to the file is always appended to the file's end.
830 #define __WASI_FDFLAGS_APPEND (UINT16_C(1))
833 * Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
835 #define __WASI_FDFLAGS_DSYNC (UINT16_C(2))
840 #define __WASI_FDFLAGS_NONBLOCK (UINT16_C(4))
843 * Synchronized read I/O operations.
845 #define __WASI_FDFLAGS_RSYNC (UINT16_C(8))
848 * Write according to synchronized I/O file integrity completion. In
849 * addition to synchronizing the data stored in the file, the implementation
850 * may also synchronously update the file's metadata.
852 #define __WASI_FDFLAGS_SYNC (UINT16_C(16))
855 * File descriptor attributes.
857 typedef struct __wasi_fdstat_t
{
861 __wasi_filetype_t fs_filetype
;
864 * File descriptor flags.
866 __wasi_fdflags_t fs_flags
;
869 * Rights that apply to this file descriptor.
871 __wasi_rights_t fs_rights_base
;
874 * Maximum set of rights that may be installed on new file descriptors that
875 * are created through this file descriptor, e.g., through `path_open`.
877 __wasi_rights_t fs_rights_inheriting
;
882 * Identifier for a device containing a file system. Can be used in combination
883 * with `inode` to uniquely identify a file or directory in the filesystem.
885 typedef uint64_t __wasi_device_t
;
888 * Which file time attributes to adjust.
890 typedef uint16_t __wasi_fstflags_t
;
893 * Adjust the last data access timestamp to the value stored in `filestat::st_atim`.
895 #define __WASI_FSTFLAGS_ATIM (UINT16_C(1))
898 * Adjust the last data access timestamp to the time of clock `clock::realtime`.
900 #define __WASI_FSTFLAGS_ATIM_NOW (UINT16_C(2))
903 * Adjust the last data modification timestamp to the value stored in `filestat::st_mtim`.
905 #define __WASI_FSTFLAGS_MTIM (UINT16_C(4))
908 * Adjust the last data modification timestamp to the time of clock `clock::realtime`.
910 #define __WASI_FSTFLAGS_MTIM_NOW (UINT16_C(8))
913 * Flags determining the method of how paths are resolved.
915 typedef uint32_t __wasi_lookupflags_t
;
918 * As long as the resolved path corresponds to a symbolic link, it is expanded.
920 #define __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW (UINT32_C(1))
923 * Open flags used by `path_open`.
925 typedef uint16_t __wasi_oflags_t
;
928 * Create file if it does not exist.
930 #define __WASI_OFLAGS_CREAT (UINT16_C(1))
933 * Fail if not a directory.
935 #define __WASI_OFLAGS_DIRECTORY (UINT16_C(2))
938 * Fail if file already exists.
940 #define __WASI_OFLAGS_EXCL (UINT16_C(4))
943 * Truncate file to size 0.
945 #define __WASI_OFLAGS_TRUNC (UINT16_C(8))
948 * Number of hard links to an inode.
950 typedef uint64_t __wasi_linkcount_t
;
955 typedef struct __wasi_filestat_t
{
957 * Device ID of device containing the file.
962 * File serial number.
969 __wasi_filetype_t filetype
;
972 * Number of hard links to the file.
974 __wasi_linkcount_t nlink
;
977 * For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link.
979 __wasi_filesize_t size
;
982 * Last data access timestamp.
984 __wasi_timestamp_t atim
;
987 * Last data modification timestamp.
989 __wasi_timestamp_t mtim
;
992 * Last file status change timestamp.
994 __wasi_timestamp_t ctim
;
999 * User-provided value that may be attached to objects that is retained when
1000 * extracted from the implementation.
1002 typedef uint64_t __wasi_userdata_t
;
1005 * Type of a subscription to an event or its occurrence.
1007 typedef uint8_t __wasi_eventtype_t
;
1010 * The time value of clock `subscription::u.clock.clock_id` has
1011 * reached timestamp `subscription::u.clock.timeout`.
1013 #define __WASI_EVENTTYPE_CLOCK (UINT8_C(0))
1016 * File descriptor `subscription::u.fd_readwrite.fd` has data
1017 * available for reading. This event always triggers for regular files.
1019 #define __WASI_EVENTTYPE_FD_READ (UINT8_C(1))
1022 * File descriptor `subscription::u.fd_readwrite.fd` has capacity
1023 * available for writing. This event always triggers for regular files.
1025 #define __WASI_EVENTTYPE_FD_WRITE (UINT8_C(2))
1028 * The state of the file descriptor subscribed to with
1029 * `eventtype::fd_read` or `eventtype::fd_write`.
1031 typedef uint16_t __wasi_eventrwflags_t
;
1034 * The peer of this socket has closed or disconnected.
1036 #define __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP (UINT16_C(1))
1039 * The contents of an $event when type is `eventtype::fd_read` or
1040 * `eventtype::fd_write`.
1042 typedef struct __wasi_event_fd_readwrite_t
{
1044 * The number of bytes available for reading or writing.
1046 __wasi_filesize_t nbytes
;
1049 * The state of the file descriptor.
1051 __wasi_eventrwflags_t flags
;
1053 } __wasi_event_fd_readwrite_t
;
1056 * The contents of an $event.
1058 typedef union __wasi_event_u_t
{
1060 * When type is `eventtype::fd_read` or `eventtype::fd_write`:
1062 __wasi_event_fd_readwrite_t fd_readwrite
;
1067 * An event that occurred.
1069 typedef struct __wasi_event_t
{
1071 * User-provided value that got attached to `subscription::userdata`.
1073 __wasi_userdata_t userdata
;
1076 * If non-zero, an error that occurred while processing the subscription request.
1078 __wasi_errno_t error
;
1081 * The type of the event that occurred.
1083 __wasi_eventtype_t type
;
1086 * The contents of the event.
1093 * Flags determining how to interpret the timestamp provided in
1094 * `subscription::u.clock.timeout.`
1096 typedef uint16_t __wasi_subclockflags_t
;
1099 * If set, treat the timestamp provided in
1100 * `subscription::u.clock.timeout` as an absolute timestamp of clock
1101 * `subscription::u.clock.clock_id.` If clear, treat the timestamp
1102 * provided in `subscription::u.clock.timeout` relative to the
1103 * current time value of clock `subscription::u.clock.clock_id.`
1105 #define __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME (UINT16_C(1))
1108 * The contents of a $subscription when type is `eventtype::clock`.
1110 typedef struct __wasi_subscription_clock_t
{
1112 * The clock against which to compare the timestamp.
1114 __wasi_clockid_t id
;
1117 * The absolute or relative timestamp.
1119 __wasi_timestamp_t timeout
;
1122 * The amount of time that the implementation may wait additionally
1123 * to coalesce with other events.
1125 __wasi_timestamp_t precision
;
1128 * Flags specifying whether the timeout is absolute or relative
1130 __wasi_subclockflags_t flags
;
1132 } __wasi_subscription_clock_t
;
1135 * The contents of a $subscription when type is type is
1136 * `eventtype::fd_read` or `eventtype::fd_write`.
1138 typedef struct __wasi_subscription_fd_readwrite_t
{
1140 * The file descriptor on which to wait for it to become ready for reading or writing.
1142 __wasi_fd_t file_descriptor
;
1144 } __wasi_subscription_fd_readwrite_t
;
1147 * The contents of a $subscription.
1149 typedef union __wasi_subscription_u_t
{
1151 * When type is `eventtype::clock`:
1153 __wasi_subscription_clock_t clock
;
1156 * When type is `eventtype::fd_read` or `eventtype::fd_write`:
1158 __wasi_subscription_fd_readwrite_t fd_readwrite
;
1160 } __wasi_subscription_u_t
;
1163 * Subscription to an event.
1165 typedef struct __wasi_subscription_t
{
1167 * User-provided value that is attached to the subscription in the
1168 * implementation and returned through `event::userdata`.
1170 __wasi_userdata_t userdata
;
1173 * The type of the event to which to subscribe.
1175 __wasi_eventtype_t type
;
1178 * The contents of the subscription.
1180 __wasi_subscription_u_t u
;
1182 } __wasi_subscription_t
;
1185 * Exit code generated by a process when exiting.
1187 typedef uint32_t __wasi_exitcode_t
;
1192 typedef uint8_t __wasi_signal_t
;
1195 * No signal. Note that POSIX has special semantics for `kill(pid, 0)`,
1196 * so this value is reserved.
1198 #define __WASI_SIGNAL_NONE (UINT8_C(0))
1202 * Action: Terminates the process.
1204 #define __WASI_SIGNAL_HUP (UINT8_C(1))
1207 * Terminate interrupt signal.
1208 * Action: Terminates the process.
1210 #define __WASI_SIGNAL_INT (UINT8_C(2))
1213 * Terminal quit signal.
1214 * Action: Terminates the process.
1216 #define __WASI_SIGNAL_QUIT (UINT8_C(3))
1219 * Illegal instruction.
1220 * Action: Terminates the process.
1222 #define __WASI_SIGNAL_ILL (UINT8_C(4))
1225 * Trace/breakpoint trap.
1226 * Action: Terminates the process.
1228 #define __WASI_SIGNAL_TRAP (UINT8_C(5))
1231 * Process abort signal.
1232 * Action: Terminates the process.
1234 #define __WASI_SIGNAL_ABRT (UINT8_C(6))
1237 * Access to an undefined portion of a memory object.
1238 * Action: Terminates the process.
1240 #define __WASI_SIGNAL_BUS (UINT8_C(7))
1243 * Erroneous arithmetic operation.
1244 * Action: Terminates the process.
1246 #define __WASI_SIGNAL_FPE (UINT8_C(8))
1250 * Action: Terminates the process.
1252 #define __WASI_SIGNAL_KILL (UINT8_C(9))
1255 * User-defined signal 1.
1256 * Action: Terminates the process.
1258 #define __WASI_SIGNAL_USR1 (UINT8_C(10))
1261 * Invalid memory reference.
1262 * Action: Terminates the process.
1264 #define __WASI_SIGNAL_SEGV (UINT8_C(11))
1267 * User-defined signal 2.
1268 * Action: Terminates the process.
1270 #define __WASI_SIGNAL_USR2 (UINT8_C(12))
1273 * Write on a pipe with no one to read it.
1276 #define __WASI_SIGNAL_PIPE (UINT8_C(13))
1280 * Action: Terminates the process.
1282 #define __WASI_SIGNAL_ALRM (UINT8_C(14))
1285 * Termination signal.
1286 * Action: Terminates the process.
1288 #define __WASI_SIGNAL_TERM (UINT8_C(15))
1291 * Child process terminated, stopped, or continued.
1294 #define __WASI_SIGNAL_CHLD (UINT8_C(16))
1297 * Continue executing, if stopped.
1298 * Action: Continues executing, if stopped.
1300 #define __WASI_SIGNAL_CONT (UINT8_C(17))
1304 * Action: Stops executing.
1306 #define __WASI_SIGNAL_STOP (UINT8_C(18))
1309 * Terminal stop signal.
1310 * Action: Stops executing.
1312 #define __WASI_SIGNAL_TSTP (UINT8_C(19))
1315 * Background process attempting read.
1316 * Action: Stops executing.
1318 #define __WASI_SIGNAL_TTIN (UINT8_C(20))
1321 * Background process attempting write.
1322 * Action: Stops executing.
1324 #define __WASI_SIGNAL_TTOU (UINT8_C(21))
1327 * High bandwidth data is available at a socket.
1330 #define __WASI_SIGNAL_URG (UINT8_C(22))
1333 * CPU time limit exceeded.
1334 * Action: Terminates the process.
1336 #define __WASI_SIGNAL_XCPU (UINT8_C(23))
1339 * File size limit exceeded.
1340 * Action: Terminates the process.
1342 #define __WASI_SIGNAL_XFSZ (UINT8_C(24))
1345 * Virtual timer expired.
1346 * Action: Terminates the process.
1348 #define __WASI_SIGNAL_VTALRM (UINT8_C(25))
1351 * Profiling timer expired.
1352 * Action: Terminates the process.
1354 #define __WASI_SIGNAL_PROF (UINT8_C(26))
1360 #define __WASI_SIGNAL_WINCH (UINT8_C(27))
1364 * Action: Terminates the process.
1366 #define __WASI_SIGNAL_POLL (UINT8_C(28))
1370 * Action: Terminates the process.
1372 #define __WASI_SIGNAL_PWR (UINT8_C(29))
1376 * Action: Terminates the process.
1378 #define __WASI_SIGNAL_SYS (UINT8_C(30))
1381 * Flags provided to `sock_recv`.
1383 typedef uint16_t __wasi_riflags_t
;
1386 * Returns the message without removing it from the socket's receive queue.
1388 #define __WASI_RIFLAGS_RECV_PEEK (UINT16_C(1))
1391 * On byte-stream sockets, block until the full amount of data can be returned.
1393 #define __WASI_RIFLAGS_RECV_WAITALL (UINT16_C(2))
1396 * Flags returned by `sock_recv`.
1398 typedef uint16_t __wasi_roflags_t
;
1401 * Returned by `sock_recv`: Message data has been truncated.
1403 #define __WASI_ROFLAGS_RECV_DATA_TRUNCATED (UINT16_C(1))
1406 * Flags provided to `sock_send`. As there are currently no flags
1407 * defined, it must be set to zero.
1409 typedef uint16_t __wasi_siflags_t
;
1412 * Which channels on a socket to shut down.
1414 typedef uint8_t __wasi_sdflags_t
;
1417 * Disables further receive operations.
1419 #define __WASI_SDFLAGS_RD (UINT8_C(1))
1422 * Disables further send operations.
1424 #define __WASI_SDFLAGS_WR (UINT8_C(2))
1427 * Identifiers for preopened capabilities.
1429 typedef uint8_t __wasi_preopentype_t
;
1432 * A pre-opened directory.
1434 #define __WASI_PREOPENTYPE_DIR (UINT8_C(0))
1437 * The contents of a $prestat when type is `preopentype::dir`.
1439 typedef struct __wasi_prestat_dir_t
{
1441 * The length of the directory name for use with `fd_prestat_dir_name`.
1443 __wasi_size_t pr_name_len
;
1445 } __wasi_prestat_dir_t
;
1448 * The contents of an $prestat.
1450 typedef union __wasi_prestat_u_t
{
1452 * When type is `preopentype::dir`:
1454 __wasi_prestat_dir_t dir
;
1456 } __wasi_prestat_u_t
;
1459 * Information about a pre-opened capability.
1461 typedef struct __wasi_prestat_t
{
1463 * The type of the pre-opened capability.
1465 __wasi_preopentype_t pr_type
;
1468 * The contents of the information.
1470 __wasi_prestat_u_t u
;
1475 * @defgroup wasi_snapshot_preview1
1480 * Read command-line argument data.
1481 * The size of the array should match that returned by `wasi_args_sizes_get()`
1483 __wasi_errno_t
__wasi_args_get(
1488 __import_module__("wasi_snapshot_preview1"),
1489 __import_name__("args_get"),
1490 __warn_unused_result__
1494 * Return command-line argument data sizes.
1496 __wasi_errno_t
__wasi_args_sizes_get(
1498 * The number of arguments.
1500 __wasi_size_t
*argc
,
1502 * The size of the argument string data.
1504 __wasi_size_t
*argv_buf_size
1506 __import_module__("wasi_snapshot_preview1"),
1507 __import_name__("args_sizes_get"),
1508 __warn_unused_result__
1512 * Read environment variable data.
1513 * The sizes of the buffers should match that returned by `environ.sizes_get()`.
1515 __wasi_errno_t
__wasi_environ_get(
1516 uint8_t * * environ
,
1518 uint8_t * environ_buf
1520 __import_module__("wasi_snapshot_preview1"),
1521 __import_name__("environ_get"),
1522 __warn_unused_result__
1526 * Return command-line argument data sizes.
1528 __wasi_errno_t
__wasi_environ_sizes_get(
1530 * The number of arguments.
1532 __wasi_size_t
*argc
,
1534 * The size of the argument string data.
1536 __wasi_size_t
*argv_buf_size
1538 __import_module__("wasi_snapshot_preview1"),
1539 __import_name__("environ_sizes_get"),
1540 __warn_unused_result__
1544 * Return the resolution of a clock.
1545 * Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks, return `WASI_EINVAL`
1546 * Note: This is similar to `clock_getres` in POSIX.
1548 __wasi_errno_t
__wasi_clock_res_get(
1550 * The clock for which to return the resolution.
1552 __wasi_clockid_t id
,
1555 * The resolution of the clock.
1557 __wasi_timestamp_t
*resolution
1559 __import_module__("wasi_snapshot_preview1"),
1560 __import_name__("clock_res_get"),
1561 __warn_unused_result__
1565 * Return the time value of a clock.
1566 * Note: This is similar to `clock_gettime` in POSIX.
1568 __wasi_errno_t
__wasi_clock_time_get(
1570 * The clock for which to return the time.
1572 __wasi_clockid_t id
,
1575 * The maximum lag (exclusive) that the returned time value may have, compared to its actual value.
1577 __wasi_timestamp_t precision
,
1580 * The time value of the clock.
1582 __wasi_timestamp_t
*time
1584 __import_module__("wasi_snapshot_preview1"),
1585 __import_name__("clock_time_get"),
1586 __warn_unused_result__
1590 * Provide file advisory information on a file descriptor.
1591 * Note: This is similar to `posix_fadvise` in POSIX.
1593 __wasi_errno_t
__wasi_fd_advise(
1597 * The offset within the file to which the advisory applies.
1599 __wasi_filesize_t offset
,
1602 * The length of the region to which the advisory applies.
1604 __wasi_filesize_t len
,
1609 __wasi_advice_t advice
1611 __import_module__("wasi_snapshot_preview1"),
1612 __import_name__("fd_advise"),
1613 __warn_unused_result__
1617 * Force the allocation of space in a file.
1618 * Note: This is similar to `posix_fallocate` in POSIX.
1620 __wasi_errno_t
__wasi_fd_allocate(
1624 * The offset at which to start the allocation.
1626 __wasi_filesize_t offset
,
1629 * The length of the area that is allocated.
1631 __wasi_filesize_t len
1633 __import_module__("wasi_snapshot_preview1"),
1634 __import_name__("fd_allocate"),
1635 __warn_unused_result__
1639 * Close a file descriptor.
1640 * Note: This is similar to `close` in POSIX.
1642 __wasi_errno_t
__wasi_fd_close(
1645 __import_module__("wasi_snapshot_preview1"),
1646 __import_name__("fd_close"),
1647 __warn_unused_result__
1651 * Synchronize the data of a file to disk.
1652 * Note: This is similar to `fdatasync` in POSIX.
1654 __wasi_errno_t
__wasi_fd_datasync(
1657 __import_module__("wasi_snapshot_preview1"),
1658 __import_name__("fd_datasync"),
1659 __warn_unused_result__
1663 * Get the attributes of a file descriptor.
1664 * Note: This returns similar flags to `fsync(fd, F_GETFL)` in POSIX, as well as additional fields.
1666 __wasi_errno_t
__wasi_fd_fdstat_get(
1670 * The buffer where the file descriptor's attributes are stored.
1672 __wasi_fdstat_t
*stat
1674 __import_module__("wasi_snapshot_preview1"),
1675 __import_name__("fd_fdstat_get"),
1676 __warn_unused_result__
1680 * Adjust the flags associated with a file descriptor.
1681 * Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX.
1683 __wasi_errno_t
__wasi_fd_fdstat_set_flags(
1687 * The desired values of the file descriptor flags.
1689 __wasi_fdflags_t flags
1691 __import_module__("wasi_snapshot_preview1"),
1692 __import_name__("fd_fdstat_set_flags"),
1693 __warn_unused_result__
1697 * Adjust the rights associated with a file descriptor.
1698 * This can only be used to remove rights, and returns `ENOTCAPABLE` if called in a way that would attempt to add rights
1700 __wasi_errno_t
__wasi_fd_fdstat_set_rights(
1704 * The desired rights of the file descriptor.
1706 __wasi_rights_t fs_rights_base
,
1708 __wasi_rights_t fs_rights_inheriting
1710 __import_module__("wasi_snapshot_preview1"),
1711 __import_name__("fd_fdstat_set_rights"),
1712 __warn_unused_result__
1716 * Return the attributes of an open file.
1718 __wasi_errno_t
__wasi_fd_filestat_get(
1722 * The buffer where the file's attributes are stored.
1724 __wasi_filestat_t
*buf
1726 __import_module__("wasi_snapshot_preview1"),
1727 __import_name__("fd_filestat_get"),
1728 __warn_unused_result__
1732 * Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.
1733 * Note: This is similar to `ftruncate` in POSIX.
1735 __wasi_errno_t
__wasi_fd_filestat_set_size(
1739 * The desired file size.
1741 __wasi_filesize_t size
1743 __import_module__("wasi_snapshot_preview1"),
1744 __import_name__("fd_filestat_set_size"),
1745 __warn_unused_result__
1749 * Adjust the timestamps of an open file or directory.
1750 * Note: This is similar to `futimens` in POSIX.
1752 __wasi_errno_t
__wasi_fd_filestat_set_times(
1756 * The desired values of the data access timestamp.
1758 __wasi_timestamp_t atim
,
1761 * The desired values of the data modification timestamp.
1763 __wasi_timestamp_t mtim
,
1766 * A bitmask indicating which timestamps to adjust.
1768 __wasi_fstflags_t fst_flags
1770 __import_module__("wasi_snapshot_preview1"),
1771 __import_name__("fd_filestat_set_times"),
1772 __warn_unused_result__
1776 * Read from a file descriptor, without using and updating the file descriptor's offset.
1777 * Note: This is similar to `preadv` in POSIX.
1779 __wasi_errno_t
__wasi_fd_pread(
1783 * List of scatter/gather vectors in which to store data.
1785 const __wasi_iovec_t
*iovs
,
1788 * The length of the array pointed to by `iovs`.
1793 * The offset within the file at which to read.
1795 __wasi_filesize_t offset
,
1798 * The number of bytes read.
1800 __wasi_size_t
*nread
1802 __import_module__("wasi_snapshot_preview1"),
1803 __import_name__("fd_pread"),
1804 __warn_unused_result__
1808 * Return a description of the given preopened file descriptor.
1810 __wasi_errno_t
__wasi_fd_prestat_get(
1814 * The buffer where the description is stored.
1816 __wasi_prestat_t
*buf
1818 __import_module__("wasi_snapshot_preview1"),
1819 __import_name__("fd_prestat_get"),
1820 __warn_unused_result__
1824 * Return a description of the given preopened file descriptor.
1826 __wasi_errno_t
__wasi_fd_prestat_dir_name(
1830 * A buffer into which to write the preopened directory name.
1834 __wasi_size_t path_len
1836 __import_module__("wasi_snapshot_preview1"),
1837 __import_name__("fd_prestat_dir_name"),
1838 __warn_unused_result__
1842 * Write to a file descriptor, without using and updating the file descriptor's offset.
1843 * Note: This is similar to `pwritev` in POSIX.
1845 __wasi_errno_t
__wasi_fd_pwrite(
1849 * List of scatter/gather vectors from which to retrieve data.
1851 const __wasi_ciovec_t
*iovs
,
1854 * The length of the array pointed to by `iovs`.
1859 * The offset within the file at which to write.
1861 __wasi_filesize_t offset
,
1864 * The number of bytes written.
1866 __wasi_size_t
*nwritten
1868 __import_module__("wasi_snapshot_preview1"),
1869 __import_name__("fd_pwrite"),
1870 __warn_unused_result__
1874 * Read from a file descriptor.
1875 * Note: This is similar to `readv` in POSIX.
1877 __wasi_errno_t
__wasi_fd_read(
1881 * List of scatter/gather vectors to which to store data.
1883 const __wasi_iovec_t
*iovs
,
1886 * The length of the array pointed to by `iovs`.
1891 * The number of bytes read.
1893 __wasi_size_t
*nread
1895 __import_module__("wasi_snapshot_preview1"),
1896 __import_name__("fd_read"),
1897 __warn_unused_result__
1901 * Read directory entries from a directory.
1902 * When successful, the contents of the output buffer consist of a sequence of
1903 * directory entries. Each directory entry consists of a dirent_t object,
1904 * followed by dirent_t::d_namlen bytes holding the name of the directory
1906 * This function fills the output buffer as much as possible, potentially
1907 * truncating the last directory entry. This allows the caller to grow its
1908 * read buffer size in case it's too small to fit a single large directory
1909 * entry, or skip the oversized directory entry.
1911 __wasi_errno_t
__wasi_fd_readdir(
1915 * The buffer where directory entries are stored
1919 __wasi_size_t buf_len
,
1922 * The location within the directory to start reading
1924 __wasi_dircookie_t cookie
,
1927 * The number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached.
1929 __wasi_size_t
*bufused
1931 __import_module__("wasi_snapshot_preview1"),
1932 __import_name__("fd_readdir"),
1933 __warn_unused_result__
1937 * Atomically replace a file descriptor by renumbering another file descriptor.
1938 * Due to the strong focus on thread safety, this environment does not provide
1939 * a mechanism to duplicate or renumber a file descriptor to an arbitrary
1940 * number, like `dup2()`. This would be prone to race conditions, as an actual
1941 * file descriptor with the same number could be allocated by a different
1942 * thread at the same time.
1943 * This function provides a way to atomically renumber file descriptors, which
1944 * would disappear if `dup2()` were to be removed entirely.
1946 __wasi_errno_t
__wasi_fd_renumber(
1950 * The file descriptor to overwrite.
1954 __import_module__("wasi_snapshot_preview1"),
1955 __import_name__("fd_renumber"),
1956 __warn_unused_result__
1960 * Move the offset of a file descriptor.
1961 * Note: This is similar to `lseek` in POSIX.
1963 __wasi_errno_t
__wasi_fd_seek(
1967 * The number of bytes to move.
1969 __wasi_filedelta_t offset
,
1972 * The base from which the offset is relative.
1974 __wasi_whence_t whence
,
1977 * The new offset of the file descriptor, relative to the start of the file.
1979 __wasi_filesize_t
*newoffset
1981 __import_module__("wasi_snapshot_preview1"),
1982 __import_name__("fd_seek"),
1983 __warn_unused_result__
1987 * Synchronize the data and metadata of a file to disk.
1988 * Note: This is similar to `fsync` in POSIX.
1990 __wasi_errno_t
__wasi_fd_sync(
1993 __import_module__("wasi_snapshot_preview1"),
1994 __import_name__("fd_sync"),
1995 __warn_unused_result__
1999 * Return the current offset of a file descriptor.
2000 * Note: This is similar to `lseek(fd, 0, SEEK_CUR)` in POSIX.
2002 __wasi_errno_t
__wasi_fd_tell(
2006 * The current offset of the file descriptor, relative to the start of the file.
2008 __wasi_filesize_t
*offset
2010 __import_module__("wasi_snapshot_preview1"),
2011 __import_name__("fd_tell"),
2012 __warn_unused_result__
2016 * Write to a file descriptor.
2017 * Note: This is similar to `writev` in POSIX.
2019 __wasi_errno_t
__wasi_fd_write(
2023 * List of scatter/gather vectors from which to retrieve data.
2025 const __wasi_ciovec_t
*iovs
,
2028 * The length of the array pointed to by `iovs`.
2033 * The number of bytes written.
2035 __wasi_size_t
*nwritten
2037 __import_module__("wasi_snapshot_preview1"),
2038 __import_name__("fd_write"),
2039 __warn_unused_result__
2043 * Create a directory.
2044 * Note: This is similar to `mkdirat` in POSIX.
2046 __wasi_errno_t
__wasi_path_create_directory(
2050 * The path at which to create the directory.
2055 * The length of the buffer pointed to by `path`.
2059 __import_module__("wasi_snapshot_preview1"),
2060 __import_name__("path_create_directory"),
2061 __warn_unused_result__
2065 * Return the attributes of a file or directory.
2066 * Note: This is similar to `stat` in POSIX.
2068 __wasi_errno_t
__wasi_path_filestat_get(
2072 * Flags determining the method of how the path is resolved.
2074 __wasi_lookupflags_t flags
,
2077 * The path of the file or directory to inspect.
2082 * The length of the buffer pointed to by `path`.
2087 * The buffer where the file's attributes are stored.
2089 __wasi_filestat_t
*buf
2091 __import_module__("wasi_snapshot_preview1"),
2092 __import_name__("path_filestat_get"),
2093 __warn_unused_result__
2097 * Adjust the timestamps of a file or directory.
2098 * Note: This is similar to `utimensat` in POSIX.
2100 __wasi_errno_t
__wasi_path_filestat_set_times(
2104 * Flags determining the method of how the path is resolved.
2106 __wasi_lookupflags_t flags
,
2109 * The path of the file or directory to operate on.
2114 * The length of the buffer pointed to by `path`.
2119 * The desired values of the data access timestamp.
2121 __wasi_timestamp_t atim
,
2124 * The desired values of the data modification timestamp.
2126 __wasi_timestamp_t mtim
,
2129 * A bitmask indicating which timestamps to adjust.
2131 __wasi_fstflags_t fst_flags
2133 __import_module__("wasi_snapshot_preview1"),
2134 __import_name__("path_filestat_set_times"),
2135 __warn_unused_result__
2139 * Create a hard link.
2140 * Note: This is similar to `linkat` in POSIX.
2142 __wasi_errno_t
__wasi_path_link(
2146 * Flags determining the method of how the path is resolved.
2148 __wasi_lookupflags_t old_flags
,
2151 * The source path from which to link.
2153 const char *old_path
,
2156 * The length of the buffer pointed to by `old_path`.
2158 size_t old_path_len
,
2161 * The working directory at which the resolution of the new path starts.
2166 * The destination path at which to create the hard link.
2168 const char *new_path
,
2171 * The length of the buffer pointed to by `new_path`.
2175 __import_module__("wasi_snapshot_preview1"),
2176 __import_name__("path_link"),
2177 __warn_unused_result__
2181 * Open a file or directory.
2182 * The returned file descriptor is not guaranteed to be the lowest-numbered
2183 * file descriptor not currently open; it is randomized to prevent
2184 * applications from depending on making assumptions about indexes, since this
2185 * is error-prone in multi-threaded contexts. The returned file descriptor is
2186 * guaranteed to be less than 2**31.
2187 * Note: This is similar to `openat` in POSIX.
2189 __wasi_errno_t
__wasi_path_open(
2193 * Flags determining the method of how the path is resolved.
2195 __wasi_lookupflags_t dirflags
,
2198 * The relative path of the file or directory to open, relative to the
2199 * `dirfd` directory.
2204 * The length of the buffer pointed to by `path`.
2209 * The method by which to open the file.
2211 __wasi_oflags_t oflags
,
2214 * The initial rights of the newly created file descriptor. The
2215 * implementation is allowed to return a file descriptor with fewer rights
2216 * than specified, if and only if those rights do not apply to the type of
2217 * file being opened.
2218 * The *base* rights are rights that will apply to operations using the file
2219 * descriptor itself, while the *inheriting* rights are rights that apply to
2220 * file descriptors derived from it.
2222 __wasi_rights_t fs_rights_base
,
2224 __wasi_rights_t fs_rights_inherting
,
2226 __wasi_fdflags_t fdflags
,
2229 * The file descriptor of the file that has been opened.
2231 __wasi_fd_t
*opened_fd
2233 __import_module__("wasi_snapshot_preview1"),
2234 __import_name__("path_open"),
2235 __warn_unused_result__
2239 * Read the contents of a symbolic link.
2240 * Note: This is similar to `readlinkat` in POSIX.
2242 __wasi_errno_t
__wasi_path_readlink(
2246 * The path of the symbolic link from which to read.
2251 * The length of the buffer pointed to by `path`.
2256 * The buffer to which to write the contents of the symbolic link.
2260 __wasi_size_t buf_len
,
2263 * The number of bytes placed in the buffer.
2265 __wasi_size_t
*bufused
2267 __import_module__("wasi_snapshot_preview1"),
2268 __import_name__("path_readlink"),
2269 __warn_unused_result__
2273 * Remove a directory.
2274 * Return `ENOTEMPTY` if the directory is not empty.
2275 * Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
2277 __wasi_errno_t
__wasi_path_remove_directory(
2281 * The path to a directory to remove.
2286 * The length of the buffer pointed to by `path`.
2290 __import_module__("wasi_snapshot_preview1"),
2291 __import_name__("path_remove_directory"),
2292 __warn_unused_result__
2296 * Rename a file or directory.
2297 * Note: This is similar to `renameat` in POSIX.
2299 __wasi_errno_t
__wasi_path_rename(
2303 * The source path of the file or directory to rename.
2305 const char *old_path
,
2308 * The length of the buffer pointed to by `old_path`.
2310 size_t old_path_len
,
2313 * The working directory at which the resolution of the new path starts.
2318 * The destination path to which to rename the file or directory.
2320 const char *new_path
,
2323 * The length of the buffer pointed to by `new_path`.
2327 __import_module__("wasi_snapshot_preview1"),
2328 __import_name__("path_rename"),
2329 __warn_unused_result__
2333 * Create a symbolic link.
2334 * Note: This is similar to `symlinkat` in POSIX.
2336 __wasi_errno_t
__wasi_path_symlink(
2338 * The contents of the symbolic link.
2340 const char *old_path
,
2343 * The length of the buffer pointed to by `old_path`.
2345 size_t old_path_len
,
2350 * The destination path at which to create the symbolic link.
2352 const char *new_path
,
2355 * The length of the buffer pointed to by `new_path`.
2359 __import_module__("wasi_snapshot_preview1"),
2360 __import_name__("path_symlink"),
2361 __warn_unused_result__
2366 * Return `EISDIR` if the path refers to a directory.
2367 * Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
2369 __wasi_errno_t
__wasi_path_unlink_file(
2373 * The path to a file to unlink.
2378 * The length of the buffer pointed to by `path`.
2382 __import_module__("wasi_snapshot_preview1"),
2383 __import_name__("path_unlink_file"),
2384 __warn_unused_result__
2388 * Concurrently poll for the occurrence of a set of events.
2390 __wasi_errno_t
__wasi_poll_oneoff(
2392 * The events to which to subscribe.
2394 const __wasi_subscription_t
* in
,
2397 * The events that have occurred.
2399 __wasi_event_t
* out
,
2402 * Both the number of subscriptions and events.
2404 __wasi_size_t nsubscriptions
,
2407 * The number of events stored.
2409 __wasi_size_t
*nevents
2411 __import_module__("wasi_snapshot_preview1"),
2412 __import_name__("poll_oneoff"),
2413 __warn_unused_result__
2417 * Terminate the process normally. An exit code of 0 indicates successful
2418 * termination of the program. The meanings of other values is dependent on
2421 _Noreturn
void __wasi_proc_exit(
2423 * The exit code returned by the process.
2425 __wasi_exitcode_t rval
2427 __import_module__("wasi_snapshot_preview1"),
2428 __import_name__("proc_exit")));
2431 * Send a signal to the process of the calling thread.
2432 * Note: This is similar to `raise` in POSIX.
2434 __wasi_errno_t
__wasi_proc_raise(
2436 * The signal condition to trigger.
2440 __import_module__("wasi_snapshot_preview1"),
2441 __import_name__("proc_raise"),
2442 __warn_unused_result__
2446 * Temporarily yield execution of the calling thread.
2447 * Note: This is similar to `sched_yield` in POSIX.
2449 __wasi_errno_t
__wasi_sched_yield(
2452 __import_module__("wasi_snapshot_preview1"),
2453 __import_name__("sched_yield"),
2454 __warn_unused_result__
2458 * Write high-quality random data into a buffer.
2459 * This function blocks when the implementation is unable to immediately
2460 * provide sufficient high-quality random data.
2461 * This function may execute slowly, so when large mounts of random data are
2462 * required, it's advisable to use this function to seed a pseudo-random
2463 * number generator, rather than to provide the random data directly.
2465 __wasi_errno_t
__wasi_random_get(
2467 * The buffer to fill with random data.
2471 __wasi_size_t buf_len
2473 __import_module__("wasi_snapshot_preview1"),
2474 __import_name__("random_get"),
2475 __warn_unused_result__
2479 * Receive a message from a socket.
2480 * Note: This is similar to `recv` in POSIX, though it also supports reading
2481 * the data into multiple buffers in the manner of `readv`.
2483 __wasi_errno_t
__wasi_sock_recv(
2487 * List of scatter/gather vectors to which to store data.
2489 const __wasi_iovec_t
*ri_data
,
2492 * The length of the array pointed to by `ri_data`.
2499 __wasi_riflags_t ri_flags
,
2502 * Number of bytes stored in ri_data.
2504 __wasi_size_t
*ro_datalen
,
2508 __wasi_roflags_t
*ro_flags
2510 __import_module__("wasi_snapshot_preview1"),
2511 __import_name__("sock_recv"),
2512 __warn_unused_result__
2516 * Send a message on a socket.
2517 * Note: This is similar to `send` in POSIX, though it also supports writing
2518 * the data from multiple buffers in the manner of `writev`.
2520 __wasi_errno_t
__wasi_sock_send(
2524 * List of scatter/gather vectors to which to retrieve data
2526 const __wasi_ciovec_t
*si_data
,
2529 * The length of the array pointed to by `si_data`.
2536 __wasi_siflags_t si_flags
,
2539 * Number of bytes transmitted.
2541 __wasi_size_t
*so_datalen
2543 __import_module__("wasi_snapshot_preview1"),
2544 __import_name__("sock_send"),
2545 __warn_unused_result__
2549 * Shut down socket send and receive channels.
2550 * Note: This is similar to `shutdown` in POSIX.
2552 __wasi_errno_t
__wasi_sock_shutdown(
2556 * Which channels on the socket to shut down.
2558 __wasi_sdflags_t how
2560 __import_module__("wasi_snapshot_preview1"),
2561 __import_name__("sock_shutdown"),
2562 __warn_unused_result__