]> git.proxmox.com Git - wasi-libc.git/blob - libc-bottom-half/headers/public/wasi/api.h
New upstream version 0.0~git20210922.ad51334
[wasi-libc.git] / libc-bottom-half / headers / public / wasi / api.h
1 /**
2 * THIS FILE IS AUTO-GENERATED from the following files:
3 * wasi_snapshot_preview1.witx
4 *
5 * To regenerate this file execute:
6 *
7 * cargo run --manifest-path tools/wasi-headers/Cargo.toml generate-libc
8 *
9 * Modifications to this file will cause CI to fail, the code generator tool
10 * must be modified to change this file.
11 *
12 * @file
13 * This file describes the [WASI] interface, consisting of functions, types,
14 * and defined values (macros).
15 *
16 * The interface described here is greatly inspired by [CloudABI]'s clean,
17 * thoughtfully-designed, capability-oriented, POSIX-style API.
18 *
19 * [CloudABI]: https://github.com/NuxiNL/cloudlibc
20 * [WASI]: https://github.com/WebAssembly/WASI/
21 */
22
23 #ifndef __wasi_api_h
24 #define __wasi_api_h
25
26 #ifndef __wasi__
27 #error <wasi/api.h> is only supported on WASI platforms.
28 #endif
29
30 #ifndef __wasm32__
31 #error <wasi/api.h> only supports wasm32; doesn't yet support wasm64
32 #endif
33
34 #include <stddef.h>
35 #include <stdint.h>
36
37 _Static_assert(_Alignof(int8_t) == 1, "non-wasi data layout");
38 _Static_assert(_Alignof(uint8_t) == 1, "non-wasi data layout");
39 _Static_assert(_Alignof(int16_t) == 2, "non-wasi data layout");
40 _Static_assert(_Alignof(uint16_t) == 2, "non-wasi data layout");
41 _Static_assert(_Alignof(int32_t) == 4, "non-wasi data layout");
42 _Static_assert(_Alignof(uint32_t) == 4, "non-wasi data layout");
43 _Static_assert(_Alignof(int64_t) == 8, "non-wasi data layout");
44 _Static_assert(_Alignof(uint64_t) == 8, "non-wasi data layout");
45 _Static_assert(_Alignof(void*) == 4, "non-wasi data layout");
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 // TODO: Encoding this in witx.
52 #define __WASI_DIRCOOKIE_START (UINT64_C(0))
53 typedef __SIZE_TYPE__ __wasi_size_t;
54
55 _Static_assert(sizeof(__wasi_size_t) == 4, "witx calculated size");
56 _Static_assert(_Alignof(__wasi_size_t) == 4, "witx calculated align");
57
58 /**
59 * Non-negative file size or length of a region within a file.
60 */
61 typedef uint64_t __wasi_filesize_t;
62
63 _Static_assert(sizeof(__wasi_filesize_t) == 8, "witx calculated size");
64 _Static_assert(_Alignof(__wasi_filesize_t) == 8, "witx calculated align");
65
66 /**
67 * Timestamp in nanoseconds.
68 */
69 typedef uint64_t __wasi_timestamp_t;
70
71 _Static_assert(sizeof(__wasi_timestamp_t) == 8, "witx calculated size");
72 _Static_assert(_Alignof(__wasi_timestamp_t) == 8, "witx calculated align");
73
74 /**
75 * Identifiers for clocks.
76 */
77 typedef uint32_t __wasi_clockid_t;
78
79 /**
80 * The clock measuring real time. Time value zero corresponds with
81 * 1970-01-01T00:00:00Z.
82 */
83 #define __WASI_CLOCKID_REALTIME (UINT32_C(0))
84
85 /**
86 * The store-wide monotonic clock, which is defined as a clock measuring
87 * real time, whose value cannot be adjusted and which cannot have negative
88 * clock jumps. The epoch of this clock is undefined. The absolute time
89 * value of this clock therefore has no meaning.
90 */
91 #define __WASI_CLOCKID_MONOTONIC (UINT32_C(1))
92
93 /**
94 * The CPU-time clock associated with the current process.
95 */
96 #define __WASI_CLOCKID_PROCESS_CPUTIME_ID (UINT32_C(2))
97
98 /**
99 * The CPU-time clock associated with the current thread.
100 */
101 #define __WASI_CLOCKID_THREAD_CPUTIME_ID (UINT32_C(3))
102
103 _Static_assert(sizeof(__wasi_clockid_t) == 4, "witx calculated size");
104 _Static_assert(_Alignof(__wasi_clockid_t) == 4, "witx calculated align");
105
106 /**
107 * Error codes returned by functions.
108 * Not all of these error codes are returned by the functions provided by this
109 * API; some are used in higher-level library layers, and others are provided
110 * merely for alignment with POSIX.
111 */
112 typedef uint16_t __wasi_errno_t;
113
114 /**
115 * No error occurred. System call completed successfully.
116 */
117 #define __WASI_ERRNO_SUCCESS (UINT16_C(0))
118
119 /**
120 * Argument list too long.
121 */
122 #define __WASI_ERRNO_2BIG (UINT16_C(1))
123
124 /**
125 * Permission denied.
126 */
127 #define __WASI_ERRNO_ACCES (UINT16_C(2))
128
129 /**
130 * Address in use.
131 */
132 #define __WASI_ERRNO_ADDRINUSE (UINT16_C(3))
133
134 /**
135 * Address not available.
136 */
137 #define __WASI_ERRNO_ADDRNOTAVAIL (UINT16_C(4))
138
139 /**
140 * Address family not supported.
141 */
142 #define __WASI_ERRNO_AFNOSUPPORT (UINT16_C(5))
143
144 /**
145 * Resource unavailable, or operation would block.
146 */
147 #define __WASI_ERRNO_AGAIN (UINT16_C(6))
148
149 /**
150 * Connection already in progress.
151 */
152 #define __WASI_ERRNO_ALREADY (UINT16_C(7))
153
154 /**
155 * Bad file descriptor.
156 */
157 #define __WASI_ERRNO_BADF (UINT16_C(8))
158
159 /**
160 * Bad message.
161 */
162 #define __WASI_ERRNO_BADMSG (UINT16_C(9))
163
164 /**
165 * Device or resource busy.
166 */
167 #define __WASI_ERRNO_BUSY (UINT16_C(10))
168
169 /**
170 * Operation canceled.
171 */
172 #define __WASI_ERRNO_CANCELED (UINT16_C(11))
173
174 /**
175 * No child processes.
176 */
177 #define __WASI_ERRNO_CHILD (UINT16_C(12))
178
179 /**
180 * Connection aborted.
181 */
182 #define __WASI_ERRNO_CONNABORTED (UINT16_C(13))
183
184 /**
185 * Connection refused.
186 */
187 #define __WASI_ERRNO_CONNREFUSED (UINT16_C(14))
188
189 /**
190 * Connection reset.
191 */
192 #define __WASI_ERRNO_CONNRESET (UINT16_C(15))
193
194 /**
195 * Resource deadlock would occur.
196 */
197 #define __WASI_ERRNO_DEADLK (UINT16_C(16))
198
199 /**
200 * Destination address required.
201 */
202 #define __WASI_ERRNO_DESTADDRREQ (UINT16_C(17))
203
204 /**
205 * Mathematics argument out of domain of function.
206 */
207 #define __WASI_ERRNO_DOM (UINT16_C(18))
208
209 /**
210 * Reserved.
211 */
212 #define __WASI_ERRNO_DQUOT (UINT16_C(19))
213
214 /**
215 * File exists.
216 */
217 #define __WASI_ERRNO_EXIST (UINT16_C(20))
218
219 /**
220 * Bad address.
221 */
222 #define __WASI_ERRNO_FAULT (UINT16_C(21))
223
224 /**
225 * File too large.
226 */
227 #define __WASI_ERRNO_FBIG (UINT16_C(22))
228
229 /**
230 * Host is unreachable.
231 */
232 #define __WASI_ERRNO_HOSTUNREACH (UINT16_C(23))
233
234 /**
235 * Identifier removed.
236 */
237 #define __WASI_ERRNO_IDRM (UINT16_C(24))
238
239 /**
240 * Illegal byte sequence.
241 */
242 #define __WASI_ERRNO_ILSEQ (UINT16_C(25))
243
244 /**
245 * Operation in progress.
246 */
247 #define __WASI_ERRNO_INPROGRESS (UINT16_C(26))
248
249 /**
250 * Interrupted function.
251 */
252 #define __WASI_ERRNO_INTR (UINT16_C(27))
253
254 /**
255 * Invalid argument.
256 */
257 #define __WASI_ERRNO_INVAL (UINT16_C(28))
258
259 /**
260 * I/O error.
261 */
262 #define __WASI_ERRNO_IO (UINT16_C(29))
263
264 /**
265 * Socket is connected.
266 */
267 #define __WASI_ERRNO_ISCONN (UINT16_C(30))
268
269 /**
270 * Is a directory.
271 */
272 #define __WASI_ERRNO_ISDIR (UINT16_C(31))
273
274 /**
275 * Too many levels of symbolic links.
276 */
277 #define __WASI_ERRNO_LOOP (UINT16_C(32))
278
279 /**
280 * File descriptor value too large.
281 */
282 #define __WASI_ERRNO_MFILE (UINT16_C(33))
283
284 /**
285 * Too many links.
286 */
287 #define __WASI_ERRNO_MLINK (UINT16_C(34))
288
289 /**
290 * Message too large.
291 */
292 #define __WASI_ERRNO_MSGSIZE (UINT16_C(35))
293
294 /**
295 * Reserved.
296 */
297 #define __WASI_ERRNO_MULTIHOP (UINT16_C(36))
298
299 /**
300 * Filename too long.
301 */
302 #define __WASI_ERRNO_NAMETOOLONG (UINT16_C(37))
303
304 /**
305 * Network is down.
306 */
307 #define __WASI_ERRNO_NETDOWN (UINT16_C(38))
308
309 /**
310 * Connection aborted by network.
311 */
312 #define __WASI_ERRNO_NETRESET (UINT16_C(39))
313
314 /**
315 * Network unreachable.
316 */
317 #define __WASI_ERRNO_NETUNREACH (UINT16_C(40))
318
319 /**
320 * Too many files open in system.
321 */
322 #define __WASI_ERRNO_NFILE (UINT16_C(41))
323
324 /**
325 * No buffer space available.
326 */
327 #define __WASI_ERRNO_NOBUFS (UINT16_C(42))
328
329 /**
330 * No such device.
331 */
332 #define __WASI_ERRNO_NODEV (UINT16_C(43))
333
334 /**
335 * No such file or directory.
336 */
337 #define __WASI_ERRNO_NOENT (UINT16_C(44))
338
339 /**
340 * Executable file format error.
341 */
342 #define __WASI_ERRNO_NOEXEC (UINT16_C(45))
343
344 /**
345 * No locks available.
346 */
347 #define __WASI_ERRNO_NOLCK (UINT16_C(46))
348
349 /**
350 * Reserved.
351 */
352 #define __WASI_ERRNO_NOLINK (UINT16_C(47))
353
354 /**
355 * Not enough space.
356 */
357 #define __WASI_ERRNO_NOMEM (UINT16_C(48))
358
359 /**
360 * No message of the desired type.
361 */
362 #define __WASI_ERRNO_NOMSG (UINT16_C(49))
363
364 /**
365 * Protocol not available.
366 */
367 #define __WASI_ERRNO_NOPROTOOPT (UINT16_C(50))
368
369 /**
370 * No space left on device.
371 */
372 #define __WASI_ERRNO_NOSPC (UINT16_C(51))
373
374 /**
375 * Function not supported.
376 */
377 #define __WASI_ERRNO_NOSYS (UINT16_C(52))
378
379 /**
380 * The socket is not connected.
381 */
382 #define __WASI_ERRNO_NOTCONN (UINT16_C(53))
383
384 /**
385 * Not a directory or a symbolic link to a directory.
386 */
387 #define __WASI_ERRNO_NOTDIR (UINT16_C(54))
388
389 /**
390 * Directory not empty.
391 */
392 #define __WASI_ERRNO_NOTEMPTY (UINT16_C(55))
393
394 /**
395 * State not recoverable.
396 */
397 #define __WASI_ERRNO_NOTRECOVERABLE (UINT16_C(56))
398
399 /**
400 * Not a socket.
401 */
402 #define __WASI_ERRNO_NOTSOCK (UINT16_C(57))
403
404 /**
405 * Not supported, or operation not supported on socket.
406 */
407 #define __WASI_ERRNO_NOTSUP (UINT16_C(58))
408
409 /**
410 * Inappropriate I/O control operation.
411 */
412 #define __WASI_ERRNO_NOTTY (UINT16_C(59))
413
414 /**
415 * No such device or address.
416 */
417 #define __WASI_ERRNO_NXIO (UINT16_C(60))
418
419 /**
420 * Value too large to be stored in data type.
421 */
422 #define __WASI_ERRNO_OVERFLOW (UINT16_C(61))
423
424 /**
425 * Previous owner died.
426 */
427 #define __WASI_ERRNO_OWNERDEAD (UINT16_C(62))
428
429 /**
430 * Operation not permitted.
431 */
432 #define __WASI_ERRNO_PERM (UINT16_C(63))
433
434 /**
435 * Broken pipe.
436 */
437 #define __WASI_ERRNO_PIPE (UINT16_C(64))
438
439 /**
440 * Protocol error.
441 */
442 #define __WASI_ERRNO_PROTO (UINT16_C(65))
443
444 /**
445 * Protocol not supported.
446 */
447 #define __WASI_ERRNO_PROTONOSUPPORT (UINT16_C(66))
448
449 /**
450 * Protocol wrong type for socket.
451 */
452 #define __WASI_ERRNO_PROTOTYPE (UINT16_C(67))
453
454 /**
455 * Result too large.
456 */
457 #define __WASI_ERRNO_RANGE (UINT16_C(68))
458
459 /**
460 * Read-only file system.
461 */
462 #define __WASI_ERRNO_ROFS (UINT16_C(69))
463
464 /**
465 * Invalid seek.
466 */
467 #define __WASI_ERRNO_SPIPE (UINT16_C(70))
468
469 /**
470 * No such process.
471 */
472 #define __WASI_ERRNO_SRCH (UINT16_C(71))
473
474 /**
475 * Reserved.
476 */
477 #define __WASI_ERRNO_STALE (UINT16_C(72))
478
479 /**
480 * Connection timed out.
481 */
482 #define __WASI_ERRNO_TIMEDOUT (UINT16_C(73))
483
484 /**
485 * Text file busy.
486 */
487 #define __WASI_ERRNO_TXTBSY (UINT16_C(74))
488
489 /**
490 * Cross-device link.
491 */
492 #define __WASI_ERRNO_XDEV (UINT16_C(75))
493
494 /**
495 * Extension: Capabilities insufficient.
496 */
497 #define __WASI_ERRNO_NOTCAPABLE (UINT16_C(76))
498
499 _Static_assert(sizeof(__wasi_errno_t) == 2, "witx calculated size");
500 _Static_assert(_Alignof(__wasi_errno_t) == 2, "witx calculated align");
501
502 /**
503 * File descriptor rights, determining which actions may be performed.
504 */
505 typedef uint64_t __wasi_rights_t;
506
507 /**
508 * The right to invoke `fd_datasync`.
509 * If `path_open` is set, includes the right to invoke
510 * `path_open` with `fdflags::dsync`.
511 */
512 #define __WASI_RIGHTS_FD_DATASYNC ((__wasi_rights_t)(1 << 0))
513
514 /**
515 * The right to invoke `fd_read` and `sock_recv`.
516 * If `rights::fd_seek` is set, includes the right to invoke `fd_pread`.
517 */
518 #define __WASI_RIGHTS_FD_READ ((__wasi_rights_t)(1 << 1))
519
520 /**
521 * The right to invoke `fd_seek`. This flag implies `rights::fd_tell`.
522 */
523 #define __WASI_RIGHTS_FD_SEEK ((__wasi_rights_t)(1 << 2))
524
525 /**
526 * The right to invoke `fd_fdstat_set_flags`.
527 */
528 #define __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS ((__wasi_rights_t)(1 << 3))
529
530 /**
531 * The right to invoke `fd_sync`.
532 * If `path_open` is set, includes the right to invoke
533 * `path_open` with `fdflags::rsync` and `fdflags::dsync`.
534 */
535 #define __WASI_RIGHTS_FD_SYNC ((__wasi_rights_t)(1 << 4))
536
537 /**
538 * The right to invoke `fd_seek` in such a way that the file offset
539 * remains unaltered (i.e., `whence::cur` with offset zero), or to
540 * invoke `fd_tell`.
541 */
542 #define __WASI_RIGHTS_FD_TELL ((__wasi_rights_t)(1 << 5))
543
544 /**
545 * The right to invoke `fd_write` and `sock_send`.
546 * If `rights::fd_seek` is set, includes the right to invoke `fd_pwrite`.
547 */
548 #define __WASI_RIGHTS_FD_WRITE ((__wasi_rights_t)(1 << 6))
549
550 /**
551 * The right to invoke `fd_advise`.
552 */
553 #define __WASI_RIGHTS_FD_ADVISE ((__wasi_rights_t)(1 << 7))
554
555 /**
556 * The right to invoke `fd_allocate`.
557 */
558 #define __WASI_RIGHTS_FD_ALLOCATE ((__wasi_rights_t)(1 << 8))
559
560 /**
561 * The right to invoke `path_create_directory`.
562 */
563 #define __WASI_RIGHTS_PATH_CREATE_DIRECTORY ((__wasi_rights_t)(1 << 9))
564
565 /**
566 * If `path_open` is set, the right to invoke `path_open` with `oflags::creat`.
567 */
568 #define __WASI_RIGHTS_PATH_CREATE_FILE ((__wasi_rights_t)(1 << 10))
569
570 /**
571 * The right to invoke `path_link` with the file descriptor as the
572 * source directory.
573 */
574 #define __WASI_RIGHTS_PATH_LINK_SOURCE ((__wasi_rights_t)(1 << 11))
575
576 /**
577 * The right to invoke `path_link` with the file descriptor as the
578 * target directory.
579 */
580 #define __WASI_RIGHTS_PATH_LINK_TARGET ((__wasi_rights_t)(1 << 12))
581
582 /**
583 * The right to invoke `path_open`.
584 */
585 #define __WASI_RIGHTS_PATH_OPEN ((__wasi_rights_t)(1 << 13))
586
587 /**
588 * The right to invoke `fd_readdir`.
589 */
590 #define __WASI_RIGHTS_FD_READDIR ((__wasi_rights_t)(1 << 14))
591
592 /**
593 * The right to invoke `path_readlink`.
594 */
595 #define __WASI_RIGHTS_PATH_READLINK ((__wasi_rights_t)(1 << 15))
596
597 /**
598 * The right to invoke `path_rename` with the file descriptor as the source directory.
599 */
600 #define __WASI_RIGHTS_PATH_RENAME_SOURCE ((__wasi_rights_t)(1 << 16))
601
602 /**
603 * The right to invoke `path_rename` with the file descriptor as the target directory.
604 */
605 #define __WASI_RIGHTS_PATH_RENAME_TARGET ((__wasi_rights_t)(1 << 17))
606
607 /**
608 * The right to invoke `path_filestat_get`.
609 */
610 #define __WASI_RIGHTS_PATH_FILESTAT_GET ((__wasi_rights_t)(1 << 18))
611
612 /**
613 * The right to change a file's size (there is no `path_filestat_set_size`).
614 * If `path_open` is set, includes the right to invoke `path_open` with `oflags::trunc`.
615 */
616 #define __WASI_RIGHTS_PATH_FILESTAT_SET_SIZE ((__wasi_rights_t)(1 << 19))
617
618 /**
619 * The right to invoke `path_filestat_set_times`.
620 */
621 #define __WASI_RIGHTS_PATH_FILESTAT_SET_TIMES ((__wasi_rights_t)(1 << 20))
622
623 /**
624 * The right to invoke `fd_filestat_get`.
625 */
626 #define __WASI_RIGHTS_FD_FILESTAT_GET ((__wasi_rights_t)(1 << 21))
627
628 /**
629 * The right to invoke `fd_filestat_set_size`.
630 */
631 #define __WASI_RIGHTS_FD_FILESTAT_SET_SIZE ((__wasi_rights_t)(1 << 22))
632
633 /**
634 * The right to invoke `fd_filestat_set_times`.
635 */
636 #define __WASI_RIGHTS_FD_FILESTAT_SET_TIMES ((__wasi_rights_t)(1 << 23))
637
638 /**
639 * The right to invoke `path_symlink`.
640 */
641 #define __WASI_RIGHTS_PATH_SYMLINK ((__wasi_rights_t)(1 << 24))
642
643 /**
644 * The right to invoke `path_remove_directory`.
645 */
646 #define __WASI_RIGHTS_PATH_REMOVE_DIRECTORY ((__wasi_rights_t)(1 << 25))
647
648 /**
649 * The right to invoke `path_unlink_file`.
650 */
651 #define __WASI_RIGHTS_PATH_UNLINK_FILE ((__wasi_rights_t)(1 << 26))
652
653 /**
654 * If `rights::fd_read` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_read`.
655 * If `rights::fd_write` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_write`.
656 */
657 #define __WASI_RIGHTS_POLL_FD_READWRITE ((__wasi_rights_t)(1 << 27))
658
659 /**
660 * The right to invoke `sock_shutdown`.
661 */
662 #define __WASI_RIGHTS_SOCK_SHUTDOWN ((__wasi_rights_t)(1 << 28))
663
664 /**
665 * A file descriptor handle.
666 */
667 typedef int __wasi_fd_t;
668
669 _Static_assert(sizeof(__wasi_fd_t) == 4, "witx calculated size");
670 _Static_assert(_Alignof(__wasi_fd_t) == 4, "witx calculated align");
671
672 /**
673 * A region of memory for scatter/gather reads.
674 */
675 typedef struct __wasi_iovec_t {
676 /**
677 * The address of the buffer to be filled.
678 */
679 uint8_t * buf;
680
681 /**
682 * The length of the buffer to be filled.
683 */
684 __wasi_size_t buf_len;
685
686 } __wasi_iovec_t;
687
688 _Static_assert(sizeof(__wasi_iovec_t) == 8, "witx calculated size");
689 _Static_assert(_Alignof(__wasi_iovec_t) == 4, "witx calculated align");
690 _Static_assert(offsetof(__wasi_iovec_t, buf) == 0, "witx calculated offset");
691 _Static_assert(offsetof(__wasi_iovec_t, buf_len) == 4, "witx calculated offset");
692
693 /**
694 * A region of memory for scatter/gather writes.
695 */
696 typedef struct __wasi_ciovec_t {
697 /**
698 * The address of the buffer to be written.
699 */
700 const uint8_t * buf;
701
702 /**
703 * The length of the buffer to be written.
704 */
705 __wasi_size_t buf_len;
706
707 } __wasi_ciovec_t;
708
709 _Static_assert(sizeof(__wasi_ciovec_t) == 8, "witx calculated size");
710 _Static_assert(_Alignof(__wasi_ciovec_t) == 4, "witx calculated align");
711 _Static_assert(offsetof(__wasi_ciovec_t, buf) == 0, "witx calculated offset");
712 _Static_assert(offsetof(__wasi_ciovec_t, buf_len) == 4, "witx calculated offset");
713
714 /**
715 * Relative offset within a file.
716 */
717 typedef int64_t __wasi_filedelta_t;
718
719 _Static_assert(sizeof(__wasi_filedelta_t) == 8, "witx calculated size");
720 _Static_assert(_Alignof(__wasi_filedelta_t) == 8, "witx calculated align");
721
722 /**
723 * The position relative to which to set the offset of the file descriptor.
724 */
725 typedef uint8_t __wasi_whence_t;
726
727 /**
728 * Seek relative to start-of-file.
729 */
730 #define __WASI_WHENCE_SET (UINT8_C(0))
731
732 /**
733 * Seek relative to current position.
734 */
735 #define __WASI_WHENCE_CUR (UINT8_C(1))
736
737 /**
738 * Seek relative to end-of-file.
739 */
740 #define __WASI_WHENCE_END (UINT8_C(2))
741
742 _Static_assert(sizeof(__wasi_whence_t) == 1, "witx calculated size");
743 _Static_assert(_Alignof(__wasi_whence_t) == 1, "witx calculated align");
744
745 /**
746 * A reference to the offset of a directory entry.
747 *
748 * The value 0 signifies the start of the directory.
749 */
750 typedef uint64_t __wasi_dircookie_t;
751
752 _Static_assert(sizeof(__wasi_dircookie_t) == 8, "witx calculated size");
753 _Static_assert(_Alignof(__wasi_dircookie_t) == 8, "witx calculated align");
754
755 /**
756 * The type for the `dirent::d_namlen` field of `dirent` struct.
757 */
758 typedef uint32_t __wasi_dirnamlen_t;
759
760 _Static_assert(sizeof(__wasi_dirnamlen_t) == 4, "witx calculated size");
761 _Static_assert(_Alignof(__wasi_dirnamlen_t) == 4, "witx calculated align");
762
763 /**
764 * File serial number that is unique within its file system.
765 */
766 typedef uint64_t __wasi_inode_t;
767
768 _Static_assert(sizeof(__wasi_inode_t) == 8, "witx calculated size");
769 _Static_assert(_Alignof(__wasi_inode_t) == 8, "witx calculated align");
770
771 /**
772 * The type of a file descriptor or file.
773 */
774 typedef uint8_t __wasi_filetype_t;
775
776 /**
777 * The type of the file descriptor or file is unknown or is different from any of the other types specified.
778 */
779 #define __WASI_FILETYPE_UNKNOWN (UINT8_C(0))
780
781 /**
782 * The file descriptor or file refers to a block device inode.
783 */
784 #define __WASI_FILETYPE_BLOCK_DEVICE (UINT8_C(1))
785
786 /**
787 * The file descriptor or file refers to a character device inode.
788 */
789 #define __WASI_FILETYPE_CHARACTER_DEVICE (UINT8_C(2))
790
791 /**
792 * The file descriptor or file refers to a directory inode.
793 */
794 #define __WASI_FILETYPE_DIRECTORY (UINT8_C(3))
795
796 /**
797 * The file descriptor or file refers to a regular file inode.
798 */
799 #define __WASI_FILETYPE_REGULAR_FILE (UINT8_C(4))
800
801 /**
802 * The file descriptor or file refers to a datagram socket.
803 */
804 #define __WASI_FILETYPE_SOCKET_DGRAM (UINT8_C(5))
805
806 /**
807 * The file descriptor or file refers to a byte-stream socket.
808 */
809 #define __WASI_FILETYPE_SOCKET_STREAM (UINT8_C(6))
810
811 /**
812 * The file refers to a symbolic link inode.
813 */
814 #define __WASI_FILETYPE_SYMBOLIC_LINK (UINT8_C(7))
815
816 _Static_assert(sizeof(__wasi_filetype_t) == 1, "witx calculated size");
817 _Static_assert(_Alignof(__wasi_filetype_t) == 1, "witx calculated align");
818
819 /**
820 * A directory entry.
821 */
822 typedef struct __wasi_dirent_t {
823 /**
824 * The offset of the next directory entry stored in this directory.
825 */
826 __wasi_dircookie_t d_next;
827
828 /**
829 * The serial number of the file referred to by this directory entry.
830 */
831 __wasi_inode_t d_ino;
832
833 /**
834 * The length of the name of the directory entry.
835 */
836 __wasi_dirnamlen_t d_namlen;
837
838 /**
839 * The type of the file referred to by this directory entry.
840 */
841 __wasi_filetype_t d_type;
842
843 } __wasi_dirent_t;
844
845 _Static_assert(sizeof(__wasi_dirent_t) == 24, "witx calculated size");
846 _Static_assert(_Alignof(__wasi_dirent_t) == 8, "witx calculated align");
847 _Static_assert(offsetof(__wasi_dirent_t, d_next) == 0, "witx calculated offset");
848 _Static_assert(offsetof(__wasi_dirent_t, d_ino) == 8, "witx calculated offset");
849 _Static_assert(offsetof(__wasi_dirent_t, d_namlen) == 16, "witx calculated offset");
850 _Static_assert(offsetof(__wasi_dirent_t, d_type) == 20, "witx calculated offset");
851
852 /**
853 * File or memory access pattern advisory information.
854 */
855 typedef uint8_t __wasi_advice_t;
856
857 /**
858 * The application has no advice to give on its behavior with respect to the specified data.
859 */
860 #define __WASI_ADVICE_NORMAL (UINT8_C(0))
861
862 /**
863 * The application expects to access the specified data sequentially from lower offsets to higher offsets.
864 */
865 #define __WASI_ADVICE_SEQUENTIAL (UINT8_C(1))
866
867 /**
868 * The application expects to access the specified data in a random order.
869 */
870 #define __WASI_ADVICE_RANDOM (UINT8_C(2))
871
872 /**
873 * The application expects to access the specified data in the near future.
874 */
875 #define __WASI_ADVICE_WILLNEED (UINT8_C(3))
876
877 /**
878 * The application expects that it will not access the specified data in the near future.
879 */
880 #define __WASI_ADVICE_DONTNEED (UINT8_C(4))
881
882 /**
883 * The application expects to access the specified data once and then not reuse it thereafter.
884 */
885 #define __WASI_ADVICE_NOREUSE (UINT8_C(5))
886
887 _Static_assert(sizeof(__wasi_advice_t) == 1, "witx calculated size");
888 _Static_assert(_Alignof(__wasi_advice_t) == 1, "witx calculated align");
889
890 /**
891 * File descriptor flags.
892 */
893 typedef uint16_t __wasi_fdflags_t;
894
895 /**
896 * Append mode: Data written to the file is always appended to the file's end.
897 */
898 #define __WASI_FDFLAGS_APPEND ((__wasi_fdflags_t)(1 << 0))
899
900 /**
901 * Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
902 */
903 #define __WASI_FDFLAGS_DSYNC ((__wasi_fdflags_t)(1 << 1))
904
905 /**
906 * Non-blocking mode.
907 */
908 #define __WASI_FDFLAGS_NONBLOCK ((__wasi_fdflags_t)(1 << 2))
909
910 /**
911 * Synchronized read I/O operations.
912 */
913 #define __WASI_FDFLAGS_RSYNC ((__wasi_fdflags_t)(1 << 3))
914
915 /**
916 * Write according to synchronized I/O file integrity completion. In
917 * addition to synchronizing the data stored in the file, the implementation
918 * may also synchronously update the file's metadata.
919 */
920 #define __WASI_FDFLAGS_SYNC ((__wasi_fdflags_t)(1 << 4))
921
922 /**
923 * File descriptor attributes.
924 */
925 typedef struct __wasi_fdstat_t {
926 /**
927 * File type.
928 */
929 __wasi_filetype_t fs_filetype;
930
931 /**
932 * File descriptor flags.
933 */
934 __wasi_fdflags_t fs_flags;
935
936 /**
937 * Rights that apply to this file descriptor.
938 */
939 __wasi_rights_t fs_rights_base;
940
941 /**
942 * Maximum set of rights that may be installed on new file descriptors that
943 * are created through this file descriptor, e.g., through `path_open`.
944 */
945 __wasi_rights_t fs_rights_inheriting;
946
947 } __wasi_fdstat_t;
948
949 _Static_assert(sizeof(__wasi_fdstat_t) == 24, "witx calculated size");
950 _Static_assert(_Alignof(__wasi_fdstat_t) == 8, "witx calculated align");
951 _Static_assert(offsetof(__wasi_fdstat_t, fs_filetype) == 0, "witx calculated offset");
952 _Static_assert(offsetof(__wasi_fdstat_t, fs_flags) == 2, "witx calculated offset");
953 _Static_assert(offsetof(__wasi_fdstat_t, fs_rights_base) == 8, "witx calculated offset");
954 _Static_assert(offsetof(__wasi_fdstat_t, fs_rights_inheriting) == 16, "witx calculated offset");
955
956 /**
957 * Identifier for a device containing a file system. Can be used in combination
958 * with `inode` to uniquely identify a file or directory in the filesystem.
959 */
960 typedef uint64_t __wasi_device_t;
961
962 _Static_assert(sizeof(__wasi_device_t) == 8, "witx calculated size");
963 _Static_assert(_Alignof(__wasi_device_t) == 8, "witx calculated align");
964
965 /**
966 * Which file time attributes to adjust.
967 */
968 typedef uint16_t __wasi_fstflags_t;
969
970 /**
971 * Adjust the last data access timestamp to the value stored in `filestat::atim`.
972 */
973 #define __WASI_FSTFLAGS_ATIM ((__wasi_fstflags_t)(1 << 0))
974
975 /**
976 * Adjust the last data access timestamp to the time of clock `clockid::realtime`.
977 */
978 #define __WASI_FSTFLAGS_ATIM_NOW ((__wasi_fstflags_t)(1 << 1))
979
980 /**
981 * Adjust the last data modification timestamp to the value stored in `filestat::mtim`.
982 */
983 #define __WASI_FSTFLAGS_MTIM ((__wasi_fstflags_t)(1 << 2))
984
985 /**
986 * Adjust the last data modification timestamp to the time of clock `clockid::realtime`.
987 */
988 #define __WASI_FSTFLAGS_MTIM_NOW ((__wasi_fstflags_t)(1 << 3))
989
990 /**
991 * Flags determining the method of how paths are resolved.
992 */
993 typedef uint32_t __wasi_lookupflags_t;
994
995 /**
996 * As long as the resolved path corresponds to a symbolic link, it is expanded.
997 */
998 #define __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW ((__wasi_lookupflags_t)(1 << 0))
999
1000 /**
1001 * Open flags used by `path_open`.
1002 */
1003 typedef uint16_t __wasi_oflags_t;
1004
1005 /**
1006 * Create file if it does not exist.
1007 */
1008 #define __WASI_OFLAGS_CREAT ((__wasi_oflags_t)(1 << 0))
1009
1010 /**
1011 * Fail if not a directory.
1012 */
1013 #define __WASI_OFLAGS_DIRECTORY ((__wasi_oflags_t)(1 << 1))
1014
1015 /**
1016 * Fail if file already exists.
1017 */
1018 #define __WASI_OFLAGS_EXCL ((__wasi_oflags_t)(1 << 2))
1019
1020 /**
1021 * Truncate file to size 0.
1022 */
1023 #define __WASI_OFLAGS_TRUNC ((__wasi_oflags_t)(1 << 3))
1024
1025 /**
1026 * Number of hard links to an inode.
1027 */
1028 typedef uint64_t __wasi_linkcount_t;
1029
1030 _Static_assert(sizeof(__wasi_linkcount_t) == 8, "witx calculated size");
1031 _Static_assert(_Alignof(__wasi_linkcount_t) == 8, "witx calculated align");
1032
1033 /**
1034 * File attributes.
1035 */
1036 typedef struct __wasi_filestat_t {
1037 /**
1038 * Device ID of device containing the file.
1039 */
1040 __wasi_device_t dev;
1041
1042 /**
1043 * File serial number.
1044 */
1045 __wasi_inode_t ino;
1046
1047 /**
1048 * File type.
1049 */
1050 __wasi_filetype_t filetype;
1051
1052 /**
1053 * Number of hard links to the file.
1054 */
1055 __wasi_linkcount_t nlink;
1056
1057 /**
1058 * For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link.
1059 */
1060 __wasi_filesize_t size;
1061
1062 /**
1063 * Last data access timestamp.
1064 */
1065 __wasi_timestamp_t atim;
1066
1067 /**
1068 * Last data modification timestamp.
1069 */
1070 __wasi_timestamp_t mtim;
1071
1072 /**
1073 * Last file status change timestamp.
1074 */
1075 __wasi_timestamp_t ctim;
1076
1077 } __wasi_filestat_t;
1078
1079 _Static_assert(sizeof(__wasi_filestat_t) == 64, "witx calculated size");
1080 _Static_assert(_Alignof(__wasi_filestat_t) == 8, "witx calculated align");
1081 _Static_assert(offsetof(__wasi_filestat_t, dev) == 0, "witx calculated offset");
1082 _Static_assert(offsetof(__wasi_filestat_t, ino) == 8, "witx calculated offset");
1083 _Static_assert(offsetof(__wasi_filestat_t, filetype) == 16, "witx calculated offset");
1084 _Static_assert(offsetof(__wasi_filestat_t, nlink) == 24, "witx calculated offset");
1085 _Static_assert(offsetof(__wasi_filestat_t, size) == 32, "witx calculated offset");
1086 _Static_assert(offsetof(__wasi_filestat_t, atim) == 40, "witx calculated offset");
1087 _Static_assert(offsetof(__wasi_filestat_t, mtim) == 48, "witx calculated offset");
1088 _Static_assert(offsetof(__wasi_filestat_t, ctim) == 56, "witx calculated offset");
1089
1090 /**
1091 * User-provided value that may be attached to objects that is retained when
1092 * extracted from the implementation.
1093 */
1094 typedef uint64_t __wasi_userdata_t;
1095
1096 _Static_assert(sizeof(__wasi_userdata_t) == 8, "witx calculated size");
1097 _Static_assert(_Alignof(__wasi_userdata_t) == 8, "witx calculated align");
1098
1099 /**
1100 * Type of a subscription to an event or its occurrence.
1101 */
1102 typedef uint8_t __wasi_eventtype_t;
1103
1104 /**
1105 * The time value of clock `subscription_clock::id` has
1106 * reached timestamp `subscription_clock::timeout`.
1107 */
1108 #define __WASI_EVENTTYPE_CLOCK (UINT8_C(0))
1109
1110 /**
1111 * File descriptor `subscription_fd_readwrite::file_descriptor` has data
1112 * available for reading. This event always triggers for regular files.
1113 */
1114 #define __WASI_EVENTTYPE_FD_READ (UINT8_C(1))
1115
1116 /**
1117 * File descriptor `subscription_fd_readwrite::file_descriptor` has capacity
1118 * available for writing. This event always triggers for regular files.
1119 */
1120 #define __WASI_EVENTTYPE_FD_WRITE (UINT8_C(2))
1121
1122 _Static_assert(sizeof(__wasi_eventtype_t) == 1, "witx calculated size");
1123 _Static_assert(_Alignof(__wasi_eventtype_t) == 1, "witx calculated align");
1124
1125 /**
1126 * The state of the file descriptor subscribed to with
1127 * `eventtype::fd_read` or `eventtype::fd_write`.
1128 */
1129 typedef uint16_t __wasi_eventrwflags_t;
1130
1131 /**
1132 * The peer of this socket has closed or disconnected.
1133 */
1134 #define __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP ((__wasi_eventrwflags_t)(1 << 0))
1135
1136 /**
1137 * The contents of an `event` when type is `eventtype::fd_read` or
1138 * `eventtype::fd_write`.
1139 */
1140 typedef struct __wasi_event_fd_readwrite_t {
1141 /**
1142 * The number of bytes available for reading or writing.
1143 */
1144 __wasi_filesize_t nbytes;
1145
1146 /**
1147 * The state of the file descriptor.
1148 */
1149 __wasi_eventrwflags_t flags;
1150
1151 } __wasi_event_fd_readwrite_t;
1152
1153 _Static_assert(sizeof(__wasi_event_fd_readwrite_t) == 16, "witx calculated size");
1154 _Static_assert(_Alignof(__wasi_event_fd_readwrite_t) == 8, "witx calculated align");
1155 _Static_assert(offsetof(__wasi_event_fd_readwrite_t, nbytes) == 0, "witx calculated offset");
1156 _Static_assert(offsetof(__wasi_event_fd_readwrite_t, flags) == 8, "witx calculated offset");
1157
1158 /**
1159 * An event that occurred.
1160 */
1161 typedef struct __wasi_event_t {
1162 /**
1163 * User-provided value that got attached to `subscription::userdata`.
1164 */
1165 __wasi_userdata_t userdata;
1166
1167 /**
1168 * If non-zero, an error that occurred while processing the subscription request.
1169 */
1170 __wasi_errno_t error;
1171
1172 /**
1173 * The type of event that occured
1174 */
1175 __wasi_eventtype_t type;
1176
1177 /**
1178 * The contents of the event, if it is an `eventtype::fd_read` or
1179 * `eventtype::fd_write`. `eventtype::clock` events ignore this field.
1180 */
1181 __wasi_event_fd_readwrite_t fd_readwrite;
1182
1183 } __wasi_event_t;
1184
1185 _Static_assert(sizeof(__wasi_event_t) == 32, "witx calculated size");
1186 _Static_assert(_Alignof(__wasi_event_t) == 8, "witx calculated align");
1187 _Static_assert(offsetof(__wasi_event_t, userdata) == 0, "witx calculated offset");
1188 _Static_assert(offsetof(__wasi_event_t, error) == 8, "witx calculated offset");
1189 _Static_assert(offsetof(__wasi_event_t, type) == 10, "witx calculated offset");
1190 _Static_assert(offsetof(__wasi_event_t, fd_readwrite) == 16, "witx calculated offset");
1191
1192 /**
1193 * Flags determining how to interpret the timestamp provided in
1194 * `subscription_clock::timeout`.
1195 */
1196 typedef uint16_t __wasi_subclockflags_t;
1197
1198 /**
1199 * If set, treat the timestamp provided in
1200 * `subscription_clock::timeout` as an absolute timestamp of clock
1201 * `subscription_clock::id`. If clear, treat the timestamp
1202 * provided in `subscription_clock::timeout` relative to the
1203 * current time value of clock `subscription_clock::id`.
1204 */
1205 #define __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME ((__wasi_subclockflags_t)(1 << 0))
1206
1207 /**
1208 * The contents of a `subscription` when type is `eventtype::clock`.
1209 */
1210 typedef struct __wasi_subscription_clock_t {
1211 /**
1212 * The clock against which to compare the timestamp.
1213 */
1214 __wasi_clockid_t id;
1215
1216 /**
1217 * The absolute or relative timestamp.
1218 */
1219 __wasi_timestamp_t timeout;
1220
1221 /**
1222 * The amount of time that the implementation may wait additionally
1223 * to coalesce with other events.
1224 */
1225 __wasi_timestamp_t precision;
1226
1227 /**
1228 * Flags specifying whether the timeout is absolute or relative
1229 */
1230 __wasi_subclockflags_t flags;
1231
1232 } __wasi_subscription_clock_t;
1233
1234 _Static_assert(sizeof(__wasi_subscription_clock_t) == 32, "witx calculated size");
1235 _Static_assert(_Alignof(__wasi_subscription_clock_t) == 8, "witx calculated align");
1236 _Static_assert(offsetof(__wasi_subscription_clock_t, id) == 0, "witx calculated offset");
1237 _Static_assert(offsetof(__wasi_subscription_clock_t, timeout) == 8, "witx calculated offset");
1238 _Static_assert(offsetof(__wasi_subscription_clock_t, precision) == 16, "witx calculated offset");
1239 _Static_assert(offsetof(__wasi_subscription_clock_t, flags) == 24, "witx calculated offset");
1240
1241 /**
1242 * The contents of a `subscription` when type is type is
1243 * `eventtype::fd_read` or `eventtype::fd_write`.
1244 */
1245 typedef struct __wasi_subscription_fd_readwrite_t {
1246 /**
1247 * The file descriptor on which to wait for it to become ready for reading or writing.
1248 */
1249 __wasi_fd_t file_descriptor;
1250
1251 } __wasi_subscription_fd_readwrite_t;
1252
1253 _Static_assert(sizeof(__wasi_subscription_fd_readwrite_t) == 4, "witx calculated size");
1254 _Static_assert(_Alignof(__wasi_subscription_fd_readwrite_t) == 4, "witx calculated align");
1255 _Static_assert(offsetof(__wasi_subscription_fd_readwrite_t, file_descriptor) == 0, "witx calculated offset");
1256
1257 /**
1258 * The contents of a `subscription`.
1259 */
1260 typedef union __wasi_subscription_u_u_t {
1261 __wasi_subscription_clock_t clock;
1262 __wasi_subscription_fd_readwrite_t fd_read;
1263 __wasi_subscription_fd_readwrite_t fd_write;
1264 } __wasi_subscription_u_u_t;
1265 typedef struct __wasi_subscription_u_t {
1266 uint8_t tag;
1267 __wasi_subscription_u_u_t u;
1268 } __wasi_subscription_u_t;
1269
1270 _Static_assert(sizeof(__wasi_subscription_u_t) == 40, "witx calculated size");
1271 _Static_assert(_Alignof(__wasi_subscription_u_t) == 8, "witx calculated align");
1272
1273 /**
1274 * Subscription to an event.
1275 */
1276 typedef struct __wasi_subscription_t {
1277 /**
1278 * User-provided value that is attached to the subscription in the
1279 * implementation and returned through `event::userdata`.
1280 */
1281 __wasi_userdata_t userdata;
1282
1283 /**
1284 * The type of the event to which to subscribe, and its contents
1285 */
1286 __wasi_subscription_u_t u;
1287
1288 } __wasi_subscription_t;
1289
1290 _Static_assert(sizeof(__wasi_subscription_t) == 48, "witx calculated size");
1291 _Static_assert(_Alignof(__wasi_subscription_t) == 8, "witx calculated align");
1292 _Static_assert(offsetof(__wasi_subscription_t, userdata) == 0, "witx calculated offset");
1293 _Static_assert(offsetof(__wasi_subscription_t, u) == 8, "witx calculated offset");
1294
1295 /**
1296 * Exit code generated by a process when exiting.
1297 */
1298 typedef uint32_t __wasi_exitcode_t;
1299
1300 _Static_assert(sizeof(__wasi_exitcode_t) == 4, "witx calculated size");
1301 _Static_assert(_Alignof(__wasi_exitcode_t) == 4, "witx calculated align");
1302
1303 /**
1304 * Signal condition.
1305 */
1306 typedef uint8_t __wasi_signal_t;
1307
1308 /**
1309 * No signal. Note that POSIX has special semantics for `kill(pid, 0)`,
1310 * so this value is reserved.
1311 */
1312 #define __WASI_SIGNAL_NONE (UINT8_C(0))
1313
1314 /**
1315 * Hangup.
1316 * Action: Terminates the process.
1317 */
1318 #define __WASI_SIGNAL_HUP (UINT8_C(1))
1319
1320 /**
1321 * Terminate interrupt signal.
1322 * Action: Terminates the process.
1323 */
1324 #define __WASI_SIGNAL_INT (UINT8_C(2))
1325
1326 /**
1327 * Terminal quit signal.
1328 * Action: Terminates the process.
1329 */
1330 #define __WASI_SIGNAL_QUIT (UINT8_C(3))
1331
1332 /**
1333 * Illegal instruction.
1334 * Action: Terminates the process.
1335 */
1336 #define __WASI_SIGNAL_ILL (UINT8_C(4))
1337
1338 /**
1339 * Trace/breakpoint trap.
1340 * Action: Terminates the process.
1341 */
1342 #define __WASI_SIGNAL_TRAP (UINT8_C(5))
1343
1344 /**
1345 * Process abort signal.
1346 * Action: Terminates the process.
1347 */
1348 #define __WASI_SIGNAL_ABRT (UINT8_C(6))
1349
1350 /**
1351 * Access to an undefined portion of a memory object.
1352 * Action: Terminates the process.
1353 */
1354 #define __WASI_SIGNAL_BUS (UINT8_C(7))
1355
1356 /**
1357 * Erroneous arithmetic operation.
1358 * Action: Terminates the process.
1359 */
1360 #define __WASI_SIGNAL_FPE (UINT8_C(8))
1361
1362 /**
1363 * Kill.
1364 * Action: Terminates the process.
1365 */
1366 #define __WASI_SIGNAL_KILL (UINT8_C(9))
1367
1368 /**
1369 * User-defined signal 1.
1370 * Action: Terminates the process.
1371 */
1372 #define __WASI_SIGNAL_USR1 (UINT8_C(10))
1373
1374 /**
1375 * Invalid memory reference.
1376 * Action: Terminates the process.
1377 */
1378 #define __WASI_SIGNAL_SEGV (UINT8_C(11))
1379
1380 /**
1381 * User-defined signal 2.
1382 * Action: Terminates the process.
1383 */
1384 #define __WASI_SIGNAL_USR2 (UINT8_C(12))
1385
1386 /**
1387 * Write on a pipe with no one to read it.
1388 * Action: Ignored.
1389 */
1390 #define __WASI_SIGNAL_PIPE (UINT8_C(13))
1391
1392 /**
1393 * Alarm clock.
1394 * Action: Terminates the process.
1395 */
1396 #define __WASI_SIGNAL_ALRM (UINT8_C(14))
1397
1398 /**
1399 * Termination signal.
1400 * Action: Terminates the process.
1401 */
1402 #define __WASI_SIGNAL_TERM (UINT8_C(15))
1403
1404 /**
1405 * Child process terminated, stopped, or continued.
1406 * Action: Ignored.
1407 */
1408 #define __WASI_SIGNAL_CHLD (UINT8_C(16))
1409
1410 /**
1411 * Continue executing, if stopped.
1412 * Action: Continues executing, if stopped.
1413 */
1414 #define __WASI_SIGNAL_CONT (UINT8_C(17))
1415
1416 /**
1417 * Stop executing.
1418 * Action: Stops executing.
1419 */
1420 #define __WASI_SIGNAL_STOP (UINT8_C(18))
1421
1422 /**
1423 * Terminal stop signal.
1424 * Action: Stops executing.
1425 */
1426 #define __WASI_SIGNAL_TSTP (UINT8_C(19))
1427
1428 /**
1429 * Background process attempting read.
1430 * Action: Stops executing.
1431 */
1432 #define __WASI_SIGNAL_TTIN (UINT8_C(20))
1433
1434 /**
1435 * Background process attempting write.
1436 * Action: Stops executing.
1437 */
1438 #define __WASI_SIGNAL_TTOU (UINT8_C(21))
1439
1440 /**
1441 * High bandwidth data is available at a socket.
1442 * Action: Ignored.
1443 */
1444 #define __WASI_SIGNAL_URG (UINT8_C(22))
1445
1446 /**
1447 * CPU time limit exceeded.
1448 * Action: Terminates the process.
1449 */
1450 #define __WASI_SIGNAL_XCPU (UINT8_C(23))
1451
1452 /**
1453 * File size limit exceeded.
1454 * Action: Terminates the process.
1455 */
1456 #define __WASI_SIGNAL_XFSZ (UINT8_C(24))
1457
1458 /**
1459 * Virtual timer expired.
1460 * Action: Terminates the process.
1461 */
1462 #define __WASI_SIGNAL_VTALRM (UINT8_C(25))
1463
1464 /**
1465 * Profiling timer expired.
1466 * Action: Terminates the process.
1467 */
1468 #define __WASI_SIGNAL_PROF (UINT8_C(26))
1469
1470 /**
1471 * Window changed.
1472 * Action: Ignored.
1473 */
1474 #define __WASI_SIGNAL_WINCH (UINT8_C(27))
1475
1476 /**
1477 * I/O possible.
1478 * Action: Terminates the process.
1479 */
1480 #define __WASI_SIGNAL_POLL (UINT8_C(28))
1481
1482 /**
1483 * Power failure.
1484 * Action: Terminates the process.
1485 */
1486 #define __WASI_SIGNAL_PWR (UINT8_C(29))
1487
1488 /**
1489 * Bad system call.
1490 * Action: Terminates the process.
1491 */
1492 #define __WASI_SIGNAL_SYS (UINT8_C(30))
1493
1494 _Static_assert(sizeof(__wasi_signal_t) == 1, "witx calculated size");
1495 _Static_assert(_Alignof(__wasi_signal_t) == 1, "witx calculated align");
1496
1497 /**
1498 * Flags provided to `sock_recv`.
1499 */
1500 typedef uint16_t __wasi_riflags_t;
1501
1502 /**
1503 * Returns the message without removing it from the socket's receive queue.
1504 */
1505 #define __WASI_RIFLAGS_RECV_PEEK ((__wasi_riflags_t)(1 << 0))
1506
1507 /**
1508 * On byte-stream sockets, block until the full amount of data can be returned.
1509 */
1510 #define __WASI_RIFLAGS_RECV_WAITALL ((__wasi_riflags_t)(1 << 1))
1511
1512 /**
1513 * Flags returned by `sock_recv`.
1514 */
1515 typedef uint16_t __wasi_roflags_t;
1516
1517 /**
1518 * Returned by `sock_recv`: Message data has been truncated.
1519 */
1520 #define __WASI_ROFLAGS_RECV_DATA_TRUNCATED ((__wasi_roflags_t)(1 << 0))
1521
1522 /**
1523 * Flags provided to `sock_send`. As there are currently no flags
1524 * defined, it must be set to zero.
1525 */
1526 typedef uint16_t __wasi_siflags_t;
1527
1528 _Static_assert(sizeof(__wasi_siflags_t) == 2, "witx calculated size");
1529 _Static_assert(_Alignof(__wasi_siflags_t) == 2, "witx calculated align");
1530
1531 /**
1532 * Which channels on a socket to shut down.
1533 */
1534 typedef uint8_t __wasi_sdflags_t;
1535
1536 /**
1537 * Disables further receive operations.
1538 */
1539 #define __WASI_SDFLAGS_RD ((__wasi_sdflags_t)(1 << 0))
1540
1541 /**
1542 * Disables further send operations.
1543 */
1544 #define __WASI_SDFLAGS_WR ((__wasi_sdflags_t)(1 << 1))
1545
1546 /**
1547 * Identifiers for preopened capabilities.
1548 */
1549 typedef uint8_t __wasi_preopentype_t;
1550
1551 /**
1552 * A pre-opened directory.
1553 */
1554 #define __WASI_PREOPENTYPE_DIR (UINT8_C(0))
1555
1556 _Static_assert(sizeof(__wasi_preopentype_t) == 1, "witx calculated size");
1557 _Static_assert(_Alignof(__wasi_preopentype_t) == 1, "witx calculated align");
1558
1559 /**
1560 * The contents of a $prestat when type is `preopentype::dir`.
1561 */
1562 typedef struct __wasi_prestat_dir_t {
1563 /**
1564 * The length of the directory name for use with `fd_prestat_dir_name`.
1565 */
1566 __wasi_size_t pr_name_len;
1567
1568 } __wasi_prestat_dir_t;
1569
1570 _Static_assert(sizeof(__wasi_prestat_dir_t) == 4, "witx calculated size");
1571 _Static_assert(_Alignof(__wasi_prestat_dir_t) == 4, "witx calculated align");
1572 _Static_assert(offsetof(__wasi_prestat_dir_t, pr_name_len) == 0, "witx calculated offset");
1573
1574 /**
1575 * Information about a pre-opened capability.
1576 */
1577 typedef union __wasi_prestat_u_t {
1578 __wasi_prestat_dir_t dir;
1579 } __wasi_prestat_u_t;
1580 typedef struct __wasi_prestat_t {
1581 uint8_t tag;
1582 __wasi_prestat_u_t u;
1583 } __wasi_prestat_t;
1584
1585 _Static_assert(sizeof(__wasi_prestat_t) == 8, "witx calculated size");
1586 _Static_assert(_Alignof(__wasi_prestat_t) == 4, "witx calculated align");
1587
1588 /**
1589 * @defgroup wasi_snapshot_preview1
1590 * @{
1591 */
1592
1593 /**
1594 * Read command-line argument data.
1595 * The size of the array should match that returned by `args_sizes_get`
1596 */
1597 __wasi_errno_t __wasi_args_get(
1598 uint8_t * * argv,
1599 uint8_t * argv_buf
1600 ) __attribute__((__warn_unused_result__));
1601 /**
1602 * Return command-line argument data sizes.
1603 * @return
1604 * Returns the number of arguments and the size of the argument string
1605 * data, or an error.
1606 */
1607 __wasi_errno_t __wasi_args_sizes_get(
1608 __wasi_size_t *retptr0,
1609 __wasi_size_t *retptr1
1610 ) __attribute__((__warn_unused_result__));
1611 /**
1612 * Read environment variable data.
1613 * The sizes of the buffers should match that returned by `environ_sizes_get`.
1614 */
1615 __wasi_errno_t __wasi_environ_get(
1616 uint8_t * * environ,
1617 uint8_t * environ_buf
1618 ) __attribute__((__warn_unused_result__));
1619 /**
1620 * Return environment variable data sizes.
1621 * @return
1622 * Returns the number of environment variable arguments and the size of the
1623 * environment variable data.
1624 */
1625 __wasi_errno_t __wasi_environ_sizes_get(
1626 __wasi_size_t *retptr0,
1627 __wasi_size_t *retptr1
1628 ) __attribute__((__warn_unused_result__));
1629 /**
1630 * Return the resolution of a clock.
1631 * Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks,
1632 * return `errno::inval`.
1633 * Note: This is similar to `clock_getres` in POSIX.
1634 * @return
1635 * The resolution of the clock, or an error if one happened.
1636 */
1637 __wasi_errno_t __wasi_clock_res_get(
1638 /**
1639 * The clock for which to return the resolution.
1640 */
1641 __wasi_clockid_t id,
1642 __wasi_timestamp_t *retptr0
1643 ) __attribute__((__warn_unused_result__));
1644 /**
1645 * Return the time value of a clock.
1646 * Note: This is similar to `clock_gettime` in POSIX.
1647 * @return
1648 * The time value of the clock.
1649 */
1650 __wasi_errno_t __wasi_clock_time_get(
1651 /**
1652 * The clock for which to return the time.
1653 */
1654 __wasi_clockid_t id,
1655 /**
1656 * The maximum lag (exclusive) that the returned time value may have, compared to its actual value.
1657 */
1658 __wasi_timestamp_t precision,
1659 __wasi_timestamp_t *retptr0
1660 ) __attribute__((__warn_unused_result__));
1661 /**
1662 * Provide file advisory information on a file descriptor.
1663 * Note: This is similar to `posix_fadvise` in POSIX.
1664 */
1665 __wasi_errno_t __wasi_fd_advise(
1666 __wasi_fd_t fd,
1667 /**
1668 * The offset within the file to which the advisory applies.
1669 */
1670 __wasi_filesize_t offset,
1671 /**
1672 * The length of the region to which the advisory applies.
1673 */
1674 __wasi_filesize_t len,
1675 /**
1676 * The advice.
1677 */
1678 __wasi_advice_t advice
1679 ) __attribute__((__warn_unused_result__));
1680 /**
1681 * Force the allocation of space in a file.
1682 * Note: This is similar to `posix_fallocate` in POSIX.
1683 */
1684 __wasi_errno_t __wasi_fd_allocate(
1685 __wasi_fd_t fd,
1686 /**
1687 * The offset at which to start the allocation.
1688 */
1689 __wasi_filesize_t offset,
1690 /**
1691 * The length of the area that is allocated.
1692 */
1693 __wasi_filesize_t len
1694 ) __attribute__((__warn_unused_result__));
1695 /**
1696 * Close a file descriptor.
1697 * Note: This is similar to `close` in POSIX.
1698 */
1699 __wasi_errno_t __wasi_fd_close(
1700 __wasi_fd_t fd
1701 ) __attribute__((__warn_unused_result__));
1702 /**
1703 * Synchronize the data of a file to disk.
1704 * Note: This is similar to `fdatasync` in POSIX.
1705 */
1706 __wasi_errno_t __wasi_fd_datasync(
1707 __wasi_fd_t fd
1708 ) __attribute__((__warn_unused_result__));
1709 /**
1710 * Get the attributes of a file descriptor.
1711 * Note: This returns similar flags to `fsync(fd, F_GETFL)` in POSIX, as well as additional fields.
1712 * @return
1713 * The buffer where the file descriptor's attributes are stored.
1714 */
1715 __wasi_errno_t __wasi_fd_fdstat_get(
1716 __wasi_fd_t fd,
1717 __wasi_fdstat_t *retptr0
1718 ) __attribute__((__warn_unused_result__));
1719 /**
1720 * Adjust the flags associated with a file descriptor.
1721 * Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX.
1722 */
1723 __wasi_errno_t __wasi_fd_fdstat_set_flags(
1724 __wasi_fd_t fd,
1725 /**
1726 * The desired values of the file descriptor flags.
1727 */
1728 __wasi_fdflags_t flags
1729 ) __attribute__((__warn_unused_result__));
1730 /**
1731 * Adjust the rights associated with a file descriptor.
1732 * This can only be used to remove rights, and returns `errno::notcapable` if called in a way that would attempt to add rights
1733 */
1734 __wasi_errno_t __wasi_fd_fdstat_set_rights(
1735 __wasi_fd_t fd,
1736 /**
1737 * The desired rights of the file descriptor.
1738 */
1739 __wasi_rights_t fs_rights_base,
1740 __wasi_rights_t fs_rights_inheriting
1741 ) __attribute__((__warn_unused_result__));
1742 /**
1743 * Return the attributes of an open file.
1744 * @return
1745 * The buffer where the file's attributes are stored.
1746 */
1747 __wasi_errno_t __wasi_fd_filestat_get(
1748 __wasi_fd_t fd,
1749 __wasi_filestat_t *retptr0
1750 ) __attribute__((__warn_unused_result__));
1751 /**
1752 * Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.
1753 * Note: This is similar to `ftruncate` in POSIX.
1754 */
1755 __wasi_errno_t __wasi_fd_filestat_set_size(
1756 __wasi_fd_t fd,
1757 /**
1758 * The desired file size.
1759 */
1760 __wasi_filesize_t size
1761 ) __attribute__((__warn_unused_result__));
1762 /**
1763 * Adjust the timestamps of an open file or directory.
1764 * Note: This is similar to `futimens` in POSIX.
1765 */
1766 __wasi_errno_t __wasi_fd_filestat_set_times(
1767 __wasi_fd_t fd,
1768 /**
1769 * The desired values of the data access timestamp.
1770 */
1771 __wasi_timestamp_t atim,
1772 /**
1773 * The desired values of the data modification timestamp.
1774 */
1775 __wasi_timestamp_t mtim,
1776 /**
1777 * A bitmask indicating which timestamps to adjust.
1778 */
1779 __wasi_fstflags_t fst_flags
1780 ) __attribute__((__warn_unused_result__));
1781 /**
1782 * Read from a file descriptor, without using and updating the file descriptor's offset.
1783 * Note: This is similar to `preadv` in POSIX.
1784 * @return
1785 * The number of bytes read.
1786 */
1787 __wasi_errno_t __wasi_fd_pread(
1788 __wasi_fd_t fd,
1789 /**
1790 * List of scatter/gather vectors in which to store data.
1791 */
1792 const __wasi_iovec_t *iovs,
1793 /**
1794 * The length of the array pointed to by `iovs`.
1795 */
1796 size_t iovs_len,
1797 /**
1798 * The offset within the file at which to read.
1799 */
1800 __wasi_filesize_t offset,
1801 __wasi_size_t *retptr0
1802 ) __attribute__((__warn_unused_result__));
1803 /**
1804 * Return a description of the given preopened file descriptor.
1805 * @return
1806 * The buffer where the description is stored.
1807 */
1808 __wasi_errno_t __wasi_fd_prestat_get(
1809 __wasi_fd_t fd,
1810 __wasi_prestat_t *retptr0
1811 ) __attribute__((__warn_unused_result__));
1812 /**
1813 * Return a description of the given preopened file descriptor.
1814 */
1815 __wasi_errno_t __wasi_fd_prestat_dir_name(
1816 __wasi_fd_t fd,
1817 /**
1818 * A buffer into which to write the preopened directory name.
1819 */
1820 uint8_t * path,
1821 __wasi_size_t path_len
1822 ) __attribute__((__warn_unused_result__));
1823 /**
1824 * Write to a file descriptor, without using and updating the file descriptor's offset.
1825 * Note: This is similar to `pwritev` in POSIX.
1826 * @return
1827 * The number of bytes written.
1828 */
1829 __wasi_errno_t __wasi_fd_pwrite(
1830 __wasi_fd_t fd,
1831 /**
1832 * List of scatter/gather vectors from which to retrieve data.
1833 */
1834 const __wasi_ciovec_t *iovs,
1835 /**
1836 * The length of the array pointed to by `iovs`.
1837 */
1838 size_t iovs_len,
1839 /**
1840 * The offset within the file at which to write.
1841 */
1842 __wasi_filesize_t offset,
1843 __wasi_size_t *retptr0
1844 ) __attribute__((__warn_unused_result__));
1845 /**
1846 * Read from a file descriptor.
1847 * Note: This is similar to `readv` in POSIX.
1848 * @return
1849 * The number of bytes read.
1850 */
1851 __wasi_errno_t __wasi_fd_read(
1852 __wasi_fd_t fd,
1853 /**
1854 * List of scatter/gather vectors to which to store data.
1855 */
1856 const __wasi_iovec_t *iovs,
1857 /**
1858 * The length of the array pointed to by `iovs`.
1859 */
1860 size_t iovs_len,
1861 __wasi_size_t *retptr0
1862 ) __attribute__((__warn_unused_result__));
1863 /**
1864 * Read directory entries from a directory.
1865 * When successful, the contents of the output buffer consist of a sequence of
1866 * directory entries. Each directory entry consists of a `dirent` object,
1867 * followed by `dirent::d_namlen` bytes holding the name of the directory
1868 * entry.
1869 * This function fills the output buffer as much as possible, potentially
1870 * truncating the last directory entry. This allows the caller to grow its
1871 * read buffer size in case it's too small to fit a single large directory
1872 * entry, or skip the oversized directory entry.
1873 * @return
1874 * 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.
1875 */
1876 __wasi_errno_t __wasi_fd_readdir(
1877 __wasi_fd_t fd,
1878 /**
1879 * The buffer where directory entries are stored
1880 */
1881 uint8_t * buf,
1882 __wasi_size_t buf_len,
1883 /**
1884 * The location within the directory to start reading
1885 */
1886 __wasi_dircookie_t cookie,
1887 __wasi_size_t *retptr0
1888 ) __attribute__((__warn_unused_result__));
1889 /**
1890 * Atomically replace a file descriptor by renumbering another file descriptor.
1891 * Due to the strong focus on thread safety, this environment does not provide
1892 * a mechanism to duplicate or renumber a file descriptor to an arbitrary
1893 * number, like `dup2()`. This would be prone to race conditions, as an actual
1894 * file descriptor with the same number could be allocated by a different
1895 * thread at the same time.
1896 * This function provides a way to atomically renumber file descriptors, which
1897 * would disappear if `dup2()` were to be removed entirely.
1898 */
1899 __wasi_errno_t __wasi_fd_renumber(
1900 __wasi_fd_t fd,
1901 /**
1902 * The file descriptor to overwrite.
1903 */
1904 __wasi_fd_t to
1905 ) __attribute__((__warn_unused_result__));
1906 /**
1907 * Move the offset of a file descriptor.
1908 * Note: This is similar to `lseek` in POSIX.
1909 * @return
1910 * The new offset of the file descriptor, relative to the start of the file.
1911 */
1912 __wasi_errno_t __wasi_fd_seek(
1913 __wasi_fd_t fd,
1914 /**
1915 * The number of bytes to move.
1916 */
1917 __wasi_filedelta_t offset,
1918 /**
1919 * The base from which the offset is relative.
1920 */
1921 __wasi_whence_t whence,
1922 __wasi_filesize_t *retptr0
1923 ) __attribute__((__warn_unused_result__));
1924 /**
1925 * Synchronize the data and metadata of a file to disk.
1926 * Note: This is similar to `fsync` in POSIX.
1927 */
1928 __wasi_errno_t __wasi_fd_sync(
1929 __wasi_fd_t fd
1930 ) __attribute__((__warn_unused_result__));
1931 /**
1932 * Return the current offset of a file descriptor.
1933 * Note: This is similar to `lseek(fd, 0, SEEK_CUR)` in POSIX.
1934 * @return
1935 * The current offset of the file descriptor, relative to the start of the file.
1936 */
1937 __wasi_errno_t __wasi_fd_tell(
1938 __wasi_fd_t fd,
1939 __wasi_filesize_t *retptr0
1940 ) __attribute__((__warn_unused_result__));
1941 /**
1942 * Write to a file descriptor.
1943 * Note: This is similar to `writev` in POSIX.
1944 */
1945 __wasi_errno_t __wasi_fd_write(
1946 __wasi_fd_t fd,
1947 /**
1948 * List of scatter/gather vectors from which to retrieve data.
1949 */
1950 const __wasi_ciovec_t *iovs,
1951 /**
1952 * The length of the array pointed to by `iovs`.
1953 */
1954 size_t iovs_len,
1955 __wasi_size_t *retptr0
1956 ) __attribute__((__warn_unused_result__));
1957 /**
1958 * Create a directory.
1959 * Note: This is similar to `mkdirat` in POSIX.
1960 */
1961 __wasi_errno_t __wasi_path_create_directory(
1962 __wasi_fd_t fd,
1963 /**
1964 * The path at which to create the directory.
1965 */
1966 const char *path
1967 ) __attribute__((__warn_unused_result__));
1968 /**
1969 * Return the attributes of a file or directory.
1970 * Note: This is similar to `stat` in POSIX.
1971 * @return
1972 * The buffer where the file's attributes are stored.
1973 */
1974 __wasi_errno_t __wasi_path_filestat_get(
1975 __wasi_fd_t fd,
1976 /**
1977 * Flags determining the method of how the path is resolved.
1978 */
1979 __wasi_lookupflags_t flags,
1980 /**
1981 * The path of the file or directory to inspect.
1982 */
1983 const char *path,
1984 __wasi_filestat_t *retptr0
1985 ) __attribute__((__warn_unused_result__));
1986 /**
1987 * Adjust the timestamps of a file or directory.
1988 * Note: This is similar to `utimensat` in POSIX.
1989 */
1990 __wasi_errno_t __wasi_path_filestat_set_times(
1991 __wasi_fd_t fd,
1992 /**
1993 * Flags determining the method of how the path is resolved.
1994 */
1995 __wasi_lookupflags_t flags,
1996 /**
1997 * The path of the file or directory to operate on.
1998 */
1999 const char *path,
2000 /**
2001 * The desired values of the data access timestamp.
2002 */
2003 __wasi_timestamp_t atim,
2004 /**
2005 * The desired values of the data modification timestamp.
2006 */
2007 __wasi_timestamp_t mtim,
2008 /**
2009 * A bitmask indicating which timestamps to adjust.
2010 */
2011 __wasi_fstflags_t fst_flags
2012 ) __attribute__((__warn_unused_result__));
2013 /**
2014 * Create a hard link.
2015 * Note: This is similar to `linkat` in POSIX.
2016 */
2017 __wasi_errno_t __wasi_path_link(
2018 __wasi_fd_t old_fd,
2019 /**
2020 * Flags determining the method of how the path is resolved.
2021 */
2022 __wasi_lookupflags_t old_flags,
2023 /**
2024 * The source path from which to link.
2025 */
2026 const char *old_path,
2027 /**
2028 * The working directory at which the resolution of the new path starts.
2029 */
2030 __wasi_fd_t new_fd,
2031 /**
2032 * The destination path at which to create the hard link.
2033 */
2034 const char *new_path
2035 ) __attribute__((__warn_unused_result__));
2036 /**
2037 * Open a file or directory.
2038 * The returned file descriptor is not guaranteed to be the lowest-numbered
2039 * file descriptor not currently open; it is randomized to prevent
2040 * applications from depending on making assumptions about indexes, since this
2041 * is error-prone in multi-threaded contexts. The returned file descriptor is
2042 * guaranteed to be less than 2**31.
2043 * Note: This is similar to `openat` in POSIX.
2044 * @return
2045 * The file descriptor of the file that has been opened.
2046 */
2047 __wasi_errno_t __wasi_path_open(
2048 __wasi_fd_t fd,
2049 /**
2050 * Flags determining the method of how the path is resolved.
2051 */
2052 __wasi_lookupflags_t dirflags,
2053 /**
2054 * The relative path of the file or directory to open, relative to the
2055 * `path_open::fd` directory.
2056 */
2057 const char *path,
2058 /**
2059 * The method by which to open the file.
2060 */
2061 __wasi_oflags_t oflags,
2062 /**
2063 * The initial rights of the newly created file descriptor. The
2064 * implementation is allowed to return a file descriptor with fewer rights
2065 * than specified, if and only if those rights do not apply to the type of
2066 * file being opened.
2067 * The *base* rights are rights that will apply to operations using the file
2068 * descriptor itself, while the *inheriting* rights are rights that apply to
2069 * file descriptors derived from it.
2070 */
2071 __wasi_rights_t fs_rights_base,
2072 __wasi_rights_t fs_rights_inheriting,
2073 __wasi_fdflags_t fdflags,
2074 __wasi_fd_t *retptr0
2075 ) __attribute__((__warn_unused_result__));
2076 /**
2077 * Read the contents of a symbolic link.
2078 * Note: This is similar to `readlinkat` in POSIX.
2079 * @return
2080 * The number of bytes placed in the buffer.
2081 */
2082 __wasi_errno_t __wasi_path_readlink(
2083 __wasi_fd_t fd,
2084 /**
2085 * The path of the symbolic link from which to read.
2086 */
2087 const char *path,
2088 /**
2089 * The buffer to which to write the contents of the symbolic link.
2090 */
2091 uint8_t * buf,
2092 __wasi_size_t buf_len,
2093 __wasi_size_t *retptr0
2094 ) __attribute__((__warn_unused_result__));
2095 /**
2096 * Remove a directory.
2097 * Return `errno::notempty` if the directory is not empty.
2098 * Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
2099 */
2100 __wasi_errno_t __wasi_path_remove_directory(
2101 __wasi_fd_t fd,
2102 /**
2103 * The path to a directory to remove.
2104 */
2105 const char *path
2106 ) __attribute__((__warn_unused_result__));
2107 /**
2108 * Rename a file or directory.
2109 * Note: This is similar to `renameat` in POSIX.
2110 */
2111 __wasi_errno_t __wasi_path_rename(
2112 __wasi_fd_t fd,
2113 /**
2114 * The source path of the file or directory to rename.
2115 */
2116 const char *old_path,
2117 /**
2118 * The working directory at which the resolution of the new path starts.
2119 */
2120 __wasi_fd_t new_fd,
2121 /**
2122 * The destination path to which to rename the file or directory.
2123 */
2124 const char *new_path
2125 ) __attribute__((__warn_unused_result__));
2126 /**
2127 * Create a symbolic link.
2128 * Note: This is similar to `symlinkat` in POSIX.
2129 */
2130 __wasi_errno_t __wasi_path_symlink(
2131 /**
2132 * The contents of the symbolic link.
2133 */
2134 const char *old_path,
2135 __wasi_fd_t fd,
2136 /**
2137 * The destination path at which to create the symbolic link.
2138 */
2139 const char *new_path
2140 ) __attribute__((__warn_unused_result__));
2141 /**
2142 * Unlink a file.
2143 * Return `errno::isdir` if the path refers to a directory.
2144 * Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
2145 */
2146 __wasi_errno_t __wasi_path_unlink_file(
2147 __wasi_fd_t fd,
2148 /**
2149 * The path to a file to unlink.
2150 */
2151 const char *path
2152 ) __attribute__((__warn_unused_result__));
2153 /**
2154 * Concurrently poll for the occurrence of a set of events.
2155 * @return
2156 * The number of events stored.
2157 */
2158 __wasi_errno_t __wasi_poll_oneoff(
2159 /**
2160 * The events to which to subscribe.
2161 */
2162 const __wasi_subscription_t * in,
2163 /**
2164 * The events that have occurred.
2165 */
2166 __wasi_event_t * out,
2167 /**
2168 * Both the number of subscriptions and events.
2169 */
2170 __wasi_size_t nsubscriptions,
2171 __wasi_size_t *retptr0
2172 ) __attribute__((__warn_unused_result__));
2173 /**
2174 * Terminate the process normally. An exit code of 0 indicates successful
2175 * termination of the program. The meanings of other values is dependent on
2176 * the environment.
2177 */
2178 _Noreturn void __wasi_proc_exit(
2179 /**
2180 * The exit code returned by the process.
2181 */
2182 __wasi_exitcode_t rval
2183 );
2184 /**
2185 * Send a signal to the process of the calling thread.
2186 * Note: This is similar to `raise` in POSIX.
2187 */
2188 __wasi_errno_t __wasi_proc_raise(
2189 /**
2190 * The signal condition to trigger.
2191 */
2192 __wasi_signal_t sig
2193 ) __attribute__((__warn_unused_result__));
2194 /**
2195 * Temporarily yield execution of the calling thread.
2196 * Note: This is similar to `sched_yield` in POSIX.
2197 */
2198 __wasi_errno_t __wasi_sched_yield(
2199 void
2200 ) __attribute__((__warn_unused_result__));
2201 /**
2202 * Write high-quality random data into a buffer.
2203 * This function blocks when the implementation is unable to immediately
2204 * provide sufficient high-quality random data.
2205 * This function may execute slowly, so when large mounts of random data are
2206 * required, it's advisable to use this function to seed a pseudo-random
2207 * number generator, rather than to provide the random data directly.
2208 */
2209 __wasi_errno_t __wasi_random_get(
2210 /**
2211 * The buffer to fill with random data.
2212 */
2213 uint8_t * buf,
2214 __wasi_size_t buf_len
2215 ) __attribute__((__warn_unused_result__));
2216 /**
2217 * Receive a message from a socket.
2218 * Note: This is similar to `recv` in POSIX, though it also supports reading
2219 * the data into multiple buffers in the manner of `readv`.
2220 * @return
2221 * Number of bytes stored in ri_data and message flags.
2222 */
2223 __wasi_errno_t __wasi_sock_recv(
2224 __wasi_fd_t fd,
2225 /**
2226 * List of scatter/gather vectors to which to store data.
2227 */
2228 const __wasi_iovec_t *ri_data,
2229 /**
2230 * The length of the array pointed to by `ri_data`.
2231 */
2232 size_t ri_data_len,
2233 /**
2234 * Message flags.
2235 */
2236 __wasi_riflags_t ri_flags,
2237 __wasi_size_t *retptr0,
2238 __wasi_roflags_t *retptr1
2239 ) __attribute__((__warn_unused_result__));
2240 /**
2241 * Send a message on a socket.
2242 * Note: This is similar to `send` in POSIX, though it also supports writing
2243 * the data from multiple buffers in the manner of `writev`.
2244 * @return
2245 * Number of bytes transmitted.
2246 */
2247 __wasi_errno_t __wasi_sock_send(
2248 __wasi_fd_t fd,
2249 /**
2250 * List of scatter/gather vectors to which to retrieve data
2251 */
2252 const __wasi_ciovec_t *si_data,
2253 /**
2254 * The length of the array pointed to by `si_data`.
2255 */
2256 size_t si_data_len,
2257 /**
2258 * Message flags.
2259 */
2260 __wasi_siflags_t si_flags,
2261 __wasi_size_t *retptr0
2262 ) __attribute__((__warn_unused_result__));
2263 /**
2264 * Shut down socket send and receive channels.
2265 * Note: This is similar to `shutdown` in POSIX.
2266 */
2267 __wasi_errno_t __wasi_sock_shutdown(
2268 __wasi_fd_t fd,
2269 /**
2270 * Which channels on the socket to shut down.
2271 */
2272 __wasi_sdflags_t how
2273 ) __attribute__((__warn_unused_result__));
2274 /** @} */
2275
2276 #ifdef __cplusplus
2277 }
2278 #endif
2279
2280 #endif