-
Notifications
You must be signed in to change notification settings - Fork 202
/
api.h
2115 lines (1841 loc) · 55.6 KB
/
api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* <wasi/api.h>. This file contains declarations describing the WASI ABI
* as of "snapshot preview1". It was originally auto-generated from
* wasi_snapshot_preview1.witx, however WASI is in the process of
* transitioning to a new IDL and header file generator, and this file
* is temporarily being manually maintained.
*
* @file
* This file describes the [WASI] interface, consisting of functions, types,
* and defined values (macros).
*
* The interface described here is greatly inspired by [CloudABI]'s clean,
* thoughtfully-designed, capability-oriented, POSIX-style API.
*
* [CloudABI]: https://github.com/NuxiNL/cloudlibc
* [WASI]: https://github.com/WebAssembly/WASI/
*/
#ifndef __wasi_api_h
#define __wasi_api_h
#ifndef __wasi__
#error <wasi/api.h> is only supported on WASI platforms.
#endif
#ifndef __wasm32__
#error <wasi/api.h> only supports wasm32; doesn't yet support wasm64
#endif
#include <stddef.h>
#include <stdint.h>
_Static_assert(_Alignof(int8_t) == 1, "non-wasi data layout");
_Static_assert(_Alignof(uint8_t) == 1, "non-wasi data layout");
_Static_assert(_Alignof(int16_t) == 2, "non-wasi data layout");
_Static_assert(_Alignof(uint16_t) == 2, "non-wasi data layout");
_Static_assert(_Alignof(int32_t) == 4, "non-wasi data layout");
_Static_assert(_Alignof(uint32_t) == 4, "non-wasi data layout");
_Static_assert(_Alignof(int64_t) == 8, "non-wasi data layout");
_Static_assert(_Alignof(uint64_t) == 8, "non-wasi data layout");
_Static_assert(_Alignof(void*) == 4, "non-wasi data layout");
#ifdef __cplusplus
extern "C" {
#endif
// TODO: Encoding this in witx.
#define __WASI_DIRCOOKIE_START (UINT64_C(0))
typedef __SIZE_TYPE__ __wasi_size_t;
_Static_assert(sizeof(__wasi_size_t) == 4, "witx calculated size");
_Static_assert(_Alignof(__wasi_size_t) == 4, "witx calculated align");
/**
* Non-negative file size or length of a region within a file.
*/
typedef uint64_t __wasi_filesize_t;
_Static_assert(sizeof(__wasi_filesize_t) == 8, "witx calculated size");
_Static_assert(_Alignof(__wasi_filesize_t) == 8, "witx calculated align");
/**
* Timestamp in nanoseconds.
*/
typedef uint64_t __wasi_timestamp_t;
_Static_assert(sizeof(__wasi_timestamp_t) == 8, "witx calculated size");
_Static_assert(_Alignof(__wasi_timestamp_t) == 8, "witx calculated align");
/**
* Identifiers for clocks.
*/
typedef uint32_t __wasi_clockid_t;
/**
* The clock measuring real time. Time value zero corresponds with
* 1970-01-01T00:00:00Z.
*/
#define __WASI_CLOCKID_REALTIME (UINT32_C(0))
/**
* The store-wide monotonic clock, which is defined as a clock measuring
* real time, whose value cannot be adjusted and which cannot have negative
* clock jumps. The epoch of this clock is undefined. The absolute time
* value of this clock therefore has no meaning.
*/
#define __WASI_CLOCKID_MONOTONIC (UINT32_C(1))
/**
* The CPU-time clock associated with the current process.
*/
#define __WASI_CLOCKID_PROCESS_CPUTIME_ID (UINT32_C(2))
/**
* The CPU-time clock associated with the current thread.
*/
#define __WASI_CLOCKID_THREAD_CPUTIME_ID (UINT32_C(3))
_Static_assert(sizeof(__wasi_clockid_t) == 4, "witx calculated size");
_Static_assert(_Alignof(__wasi_clockid_t) == 4, "witx calculated align");
/**
* Error codes returned by functions.
* Not all of these error codes are returned by the functions provided by this
* API; some are used in higher-level library layers, and others are provided
* merely for alignment with POSIX.
*/
typedef uint16_t __wasi_errno_t;
/**
* No error occurred. System call completed successfully.
*/
#define __WASI_ERRNO_SUCCESS (UINT16_C(0))
/**
* Argument list too long.
*/
#define __WASI_ERRNO_2BIG (UINT16_C(1))
/**
* Permission denied.
*/
#define __WASI_ERRNO_ACCES (UINT16_C(2))
/**
* Address in use.
*/
#define __WASI_ERRNO_ADDRINUSE (UINT16_C(3))
/**
* Address not available.
*/
#define __WASI_ERRNO_ADDRNOTAVAIL (UINT16_C(4))
/**
* Address family not supported.
*/
#define __WASI_ERRNO_AFNOSUPPORT (UINT16_C(5))
/**
* Resource unavailable, or operation would block.
*/
#define __WASI_ERRNO_AGAIN (UINT16_C(6))
/**
* Connection already in progress.
*/
#define __WASI_ERRNO_ALREADY (UINT16_C(7))
/**
* Bad file descriptor.
*/
#define __WASI_ERRNO_BADF (UINT16_C(8))
/**
* Bad message.
*/
#define __WASI_ERRNO_BADMSG (UINT16_C(9))
/**
* Device or resource busy.
*/
#define __WASI_ERRNO_BUSY (UINT16_C(10))
/**
* Operation canceled.
*/
#define __WASI_ERRNO_CANCELED (UINT16_C(11))
/**
* No child processes.
*/
#define __WASI_ERRNO_CHILD (UINT16_C(12))
/**
* Connection aborted.
*/
#define __WASI_ERRNO_CONNABORTED (UINT16_C(13))
/**
* Connection refused.
*/
#define __WASI_ERRNO_CONNREFUSED (UINT16_C(14))
/**
* Connection reset.
*/
#define __WASI_ERRNO_CONNRESET (UINT16_C(15))
/**
* Resource deadlock would occur.
*/
#define __WASI_ERRNO_DEADLK (UINT16_C(16))
/**
* Destination address required.
*/
#define __WASI_ERRNO_DESTADDRREQ (UINT16_C(17))
/**
* Mathematics argument out of domain of function.
*/
#define __WASI_ERRNO_DOM (UINT16_C(18))
/**
* Reserved.
*/
#define __WASI_ERRNO_DQUOT (UINT16_C(19))
/**
* File exists.
*/
#define __WASI_ERRNO_EXIST (UINT16_C(20))
/**
* Bad address.
*/
#define __WASI_ERRNO_FAULT (UINT16_C(21))
/**
* File too large.
*/
#define __WASI_ERRNO_FBIG (UINT16_C(22))
/**
* Host is unreachable.
*/
#define __WASI_ERRNO_HOSTUNREACH (UINT16_C(23))
/**
* Identifier removed.
*/
#define __WASI_ERRNO_IDRM (UINT16_C(24))
/**
* Illegal byte sequence.
*/
#define __WASI_ERRNO_ILSEQ (UINT16_C(25))
/**
* Operation in progress.
*/
#define __WASI_ERRNO_INPROGRESS (UINT16_C(26))
/**
* Interrupted function.
*/
#define __WASI_ERRNO_INTR (UINT16_C(27))
/**
* Invalid argument.
*/
#define __WASI_ERRNO_INVAL (UINT16_C(28))
/**
* I/O error.
*/
#define __WASI_ERRNO_IO (UINT16_C(29))
/**
* Socket is connected.
*/
#define __WASI_ERRNO_ISCONN (UINT16_C(30))
/**
* Is a directory.
*/
#define __WASI_ERRNO_ISDIR (UINT16_C(31))
/**
* Too many levels of symbolic links.
*/
#define __WASI_ERRNO_LOOP (UINT16_C(32))
/**
* File descriptor value too large.
*/
#define __WASI_ERRNO_MFILE (UINT16_C(33))
/**
* Too many links.
*/
#define __WASI_ERRNO_MLINK (UINT16_C(34))
/**
* Message too large.
*/
#define __WASI_ERRNO_MSGSIZE (UINT16_C(35))
/**
* Reserved.
*/
#define __WASI_ERRNO_MULTIHOP (UINT16_C(36))
/**
* Filename too long.
*/
#define __WASI_ERRNO_NAMETOOLONG (UINT16_C(37))
/**
* Network is down.
*/
#define __WASI_ERRNO_NETDOWN (UINT16_C(38))
/**
* Connection aborted by network.
*/
#define __WASI_ERRNO_NETRESET (UINT16_C(39))
/**
* Network unreachable.
*/
#define __WASI_ERRNO_NETUNREACH (UINT16_C(40))
/**
* Too many files open in system.
*/
#define __WASI_ERRNO_NFILE (UINT16_C(41))
/**
* No buffer space available.
*/
#define __WASI_ERRNO_NOBUFS (UINT16_C(42))
/**
* No such device.
*/
#define __WASI_ERRNO_NODEV (UINT16_C(43))
/**
* No such file or directory.
*/
#define __WASI_ERRNO_NOENT (UINT16_C(44))
/**
* Executable file format error.
*/
#define __WASI_ERRNO_NOEXEC (UINT16_C(45))
/**
* No locks available.
*/
#define __WASI_ERRNO_NOLCK (UINT16_C(46))
/**
* Reserved.
*/
#define __WASI_ERRNO_NOLINK (UINT16_C(47))
/**
* Not enough space.
*/
#define __WASI_ERRNO_NOMEM (UINT16_C(48))
/**
* No message of the desired type.
*/
#define __WASI_ERRNO_NOMSG (UINT16_C(49))
/**
* Protocol not available.
*/
#define __WASI_ERRNO_NOPROTOOPT (UINT16_C(50))
/**
* No space left on device.
*/
#define __WASI_ERRNO_NOSPC (UINT16_C(51))
/**
* Function not supported.
*/
#define __WASI_ERRNO_NOSYS (UINT16_C(52))
/**
* The socket is not connected.
*/
#define __WASI_ERRNO_NOTCONN (UINT16_C(53))
/**
* Not a directory or a symbolic link to a directory.
*/
#define __WASI_ERRNO_NOTDIR (UINT16_C(54))
/**
* Directory not empty.
*/
#define __WASI_ERRNO_NOTEMPTY (UINT16_C(55))
/**
* State not recoverable.
*/
#define __WASI_ERRNO_NOTRECOVERABLE (UINT16_C(56))
/**
* Not a socket.
*/
#define __WASI_ERRNO_NOTSOCK (UINT16_C(57))
/**
* Not supported, or operation not supported on socket.
*/
#define __WASI_ERRNO_NOTSUP (UINT16_C(58))
/**
* Inappropriate I/O control operation.
*/
#define __WASI_ERRNO_NOTTY (UINT16_C(59))
/**
* No such device or address.
*/
#define __WASI_ERRNO_NXIO (UINT16_C(60))
/**
* Value too large to be stored in data type.
*/
#define __WASI_ERRNO_OVERFLOW (UINT16_C(61))
/**
* Previous owner died.
*/
#define __WASI_ERRNO_OWNERDEAD (UINT16_C(62))
/**
* Operation not permitted.
*/
#define __WASI_ERRNO_PERM (UINT16_C(63))
/**
* Broken pipe.
*/
#define __WASI_ERRNO_PIPE (UINT16_C(64))
/**
* Protocol error.
*/
#define __WASI_ERRNO_PROTO (UINT16_C(65))
/**
* Protocol not supported.
*/
#define __WASI_ERRNO_PROTONOSUPPORT (UINT16_C(66))
/**
* Protocol wrong type for socket.
*/
#define __WASI_ERRNO_PROTOTYPE (UINT16_C(67))
/**
* Result too large.
*/
#define __WASI_ERRNO_RANGE (UINT16_C(68))
/**
* Read-only file system.
*/
#define __WASI_ERRNO_ROFS (UINT16_C(69))
/**
* Invalid seek.
*/
#define __WASI_ERRNO_SPIPE (UINT16_C(70))
/**
* No such process.
*/
#define __WASI_ERRNO_SRCH (UINT16_C(71))
/**
* Reserved.
*/
#define __WASI_ERRNO_STALE (UINT16_C(72))
/**
* Connection timed out.
*/
#define __WASI_ERRNO_TIMEDOUT (UINT16_C(73))
/**
* Text file busy.
*/
#define __WASI_ERRNO_TXTBSY (UINT16_C(74))
/**
* Cross-device link.
*/
#define __WASI_ERRNO_XDEV (UINT16_C(75))
/**
* Extension: Capabilities insufficient.
*/
#define __WASI_ERRNO_NOTCAPABLE (UINT16_C(76))
_Static_assert(sizeof(__wasi_errno_t) == 2, "witx calculated size");
_Static_assert(_Alignof(__wasi_errno_t) == 2, "witx calculated align");
/**
* File descriptor rights, determining which actions may be performed.
*/
typedef uint64_t __wasi_rights_t;
/**
* The right to invoke `fd_datasync`.
* If `path_open` is set, includes the right to invoke
* `path_open` with `fdflags::dsync`.
*/
#define __WASI_RIGHTS_FD_DATASYNC ((__wasi_rights_t)(1 << 0))
/**
* The right to invoke `fd_read` and `sock_recv`.
* If `rights::fd_seek` is set, includes the right to invoke `fd_pread`.
*/
#define __WASI_RIGHTS_FD_READ ((__wasi_rights_t)(1 << 1))
/**
* The right to invoke `fd_seek`. This flag implies `rights::fd_tell`.
*/
#define __WASI_RIGHTS_FD_SEEK ((__wasi_rights_t)(1 << 2))
/**
* The right to invoke `fd_fdstat_set_flags`.
*/
#define __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS ((__wasi_rights_t)(1 << 3))
/**
* The right to invoke `fd_sync`.
* If `path_open` is set, includes the right to invoke
* `path_open` with `fdflags::rsync` and `fdflags::dsync`.
*/
#define __WASI_RIGHTS_FD_SYNC ((__wasi_rights_t)(1 << 4))
/**
* The right to invoke `fd_seek` in such a way that the file offset
* remains unaltered (i.e., `whence::cur` with offset zero), or to
* invoke `fd_tell`.
*/
#define __WASI_RIGHTS_FD_TELL ((__wasi_rights_t)(1 << 5))
/**
* The right to invoke `fd_write` and `sock_send`.
* If `rights::fd_seek` is set, includes the right to invoke `fd_pwrite`.
*/
#define __WASI_RIGHTS_FD_WRITE ((__wasi_rights_t)(1 << 6))
/**
* The right to invoke `fd_advise`.
*/
#define __WASI_RIGHTS_FD_ADVISE ((__wasi_rights_t)(1 << 7))
/**
* The right to invoke `fd_allocate`.
*/
#define __WASI_RIGHTS_FD_ALLOCATE ((__wasi_rights_t)(1 << 8))
/**
* The right to invoke `path_create_directory`.
*/
#define __WASI_RIGHTS_PATH_CREATE_DIRECTORY ((__wasi_rights_t)(1 << 9))
/**
* If `path_open` is set, the right to invoke `path_open` with `oflags::creat`.
*/
#define __WASI_RIGHTS_PATH_CREATE_FILE ((__wasi_rights_t)(1 << 10))
/**
* The right to invoke `path_link` with the file descriptor as the
* source directory.
*/
#define __WASI_RIGHTS_PATH_LINK_SOURCE ((__wasi_rights_t)(1 << 11))
/**
* The right to invoke `path_link` with the file descriptor as the
* target directory.
*/
#define __WASI_RIGHTS_PATH_LINK_TARGET ((__wasi_rights_t)(1 << 12))
/**
* The right to invoke `path_open`.
*/
#define __WASI_RIGHTS_PATH_OPEN ((__wasi_rights_t)(1 << 13))
/**
* The right to invoke `fd_readdir`.
*/
#define __WASI_RIGHTS_FD_READDIR ((__wasi_rights_t)(1 << 14))
/**
* The right to invoke `path_readlink`.
*/
#define __WASI_RIGHTS_PATH_READLINK ((__wasi_rights_t)(1 << 15))
/**
* The right to invoke `path_rename` with the file descriptor as the source directory.
*/
#define __WASI_RIGHTS_PATH_RENAME_SOURCE ((__wasi_rights_t)(1 << 16))
/**
* The right to invoke `path_rename` with the file descriptor as the target directory.
*/
#define __WASI_RIGHTS_PATH_RENAME_TARGET ((__wasi_rights_t)(1 << 17))
/**
* The right to invoke `path_filestat_get`.
*/
#define __WASI_RIGHTS_PATH_FILESTAT_GET ((__wasi_rights_t)(1 << 18))
/**
* The right to change a file's size (there is no `path_filestat_set_size`).
* If `path_open` is set, includes the right to invoke `path_open` with `oflags::trunc`.
*/
#define __WASI_RIGHTS_PATH_FILESTAT_SET_SIZE ((__wasi_rights_t)(1 << 19))
/**
* The right to invoke `path_filestat_set_times`.
*/
#define __WASI_RIGHTS_PATH_FILESTAT_SET_TIMES ((__wasi_rights_t)(1 << 20))
/**
* The right to invoke `fd_filestat_get`.
*/
#define __WASI_RIGHTS_FD_FILESTAT_GET ((__wasi_rights_t)(1 << 21))
/**
* The right to invoke `fd_filestat_set_size`.
*/
#define __WASI_RIGHTS_FD_FILESTAT_SET_SIZE ((__wasi_rights_t)(1 << 22))
/**
* The right to invoke `fd_filestat_set_times`.
*/
#define __WASI_RIGHTS_FD_FILESTAT_SET_TIMES ((__wasi_rights_t)(1 << 23))
/**
* The right to invoke `path_symlink`.
*/
#define __WASI_RIGHTS_PATH_SYMLINK ((__wasi_rights_t)(1 << 24))
/**
* The right to invoke `path_remove_directory`.
*/
#define __WASI_RIGHTS_PATH_REMOVE_DIRECTORY ((__wasi_rights_t)(1 << 25))
/**
* The right to invoke `path_unlink_file`.
*/
#define __WASI_RIGHTS_PATH_UNLINK_FILE ((__wasi_rights_t)(1 << 26))
/**
* If `rights::fd_read` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_read`.
* If `rights::fd_write` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_write`.
*/
#define __WASI_RIGHTS_POLL_FD_READWRITE ((__wasi_rights_t)(1 << 27))
/**
* The right to invoke `sock_shutdown`.
*/
#define __WASI_RIGHTS_SOCK_SHUTDOWN ((__wasi_rights_t)(1 << 28))
/**
* The right to invoke `sock_accept`.
*/
#define __WASI_RIGHTS_SOCK_ACCEPT ((__wasi_rights_t)(1 << 29))
/**
* A file descriptor handle.
*/
typedef int __wasi_fd_t;
_Static_assert(sizeof(__wasi_fd_t) == 4, "witx calculated size");
_Static_assert(_Alignof(__wasi_fd_t) == 4, "witx calculated align");
/**
* A region of memory for scatter/gather reads.
*/
typedef struct __wasi_iovec_t {
/**
* The address of the buffer to be filled.
*/
uint8_t * buf;
/**
* The length of the buffer to be filled.
*/
__wasi_size_t buf_len;
} __wasi_iovec_t;
_Static_assert(sizeof(__wasi_iovec_t) == 8, "witx calculated size");
_Static_assert(_Alignof(__wasi_iovec_t) == 4, "witx calculated align");
_Static_assert(offsetof(__wasi_iovec_t, buf) == 0, "witx calculated offset");
_Static_assert(offsetof(__wasi_iovec_t, buf_len) == 4, "witx calculated offset");
/**
* A region of memory for scatter/gather writes.
*/
typedef struct __wasi_ciovec_t {
/**
* The address of the buffer to be written.
*/
const uint8_t * buf;
/**
* The length of the buffer to be written.
*/
__wasi_size_t buf_len;
} __wasi_ciovec_t;
_Static_assert(sizeof(__wasi_ciovec_t) == 8, "witx calculated size");
_Static_assert(_Alignof(__wasi_ciovec_t) == 4, "witx calculated align");
_Static_assert(offsetof(__wasi_ciovec_t, buf) == 0, "witx calculated offset");
_Static_assert(offsetof(__wasi_ciovec_t, buf_len) == 4, "witx calculated offset");
/**
* Relative offset within a file.
*/
typedef int64_t __wasi_filedelta_t;
_Static_assert(sizeof(__wasi_filedelta_t) == 8, "witx calculated size");
_Static_assert(_Alignof(__wasi_filedelta_t) == 8, "witx calculated align");
/**
* The position relative to which to set the offset of the file descriptor.
*/
typedef uint8_t __wasi_whence_t;
/**
* Seek relative to start-of-file.
*/
#define __WASI_WHENCE_SET (UINT8_C(0))
/**
* Seek relative to current position.
*/
#define __WASI_WHENCE_CUR (UINT8_C(1))
/**
* Seek relative to end-of-file.
*/
#define __WASI_WHENCE_END (UINT8_C(2))
_Static_assert(sizeof(__wasi_whence_t) == 1, "witx calculated size");
_Static_assert(_Alignof(__wasi_whence_t) == 1, "witx calculated align");
/**
* A reference to the offset of a directory entry.
*
* The value 0 signifies the start of the directory.
*/
typedef uint64_t __wasi_dircookie_t;
_Static_assert(sizeof(__wasi_dircookie_t) == 8, "witx calculated size");
_Static_assert(_Alignof(__wasi_dircookie_t) == 8, "witx calculated align");
/**
* The type for the `dirent::d_namlen` field of `dirent` struct.
*/
typedef uint32_t __wasi_dirnamlen_t;
_Static_assert(sizeof(__wasi_dirnamlen_t) == 4, "witx calculated size");
_Static_assert(_Alignof(__wasi_dirnamlen_t) == 4, "witx calculated align");
/**
* File serial number that is unique within its file system.
*/
typedef uint64_t __wasi_inode_t;
_Static_assert(sizeof(__wasi_inode_t) == 8, "witx calculated size");
_Static_assert(_Alignof(__wasi_inode_t) == 8, "witx calculated align");
/**
* The type of a file descriptor or file.
*/
typedef uint8_t __wasi_filetype_t;
/**
* The type of the file descriptor or file is unknown or is different from any of the other types specified.
*/
#define __WASI_FILETYPE_UNKNOWN (UINT8_C(0))
/**
* The file descriptor or file refers to a block device inode.
*/
#define __WASI_FILETYPE_BLOCK_DEVICE (UINT8_C(1))
/**
* The file descriptor or file refers to a character device inode.
*/
#define __WASI_FILETYPE_CHARACTER_DEVICE (UINT8_C(2))
/**
* The file descriptor or file refers to a directory inode.
*/
#define __WASI_FILETYPE_DIRECTORY (UINT8_C(3))
/**
* The file descriptor or file refers to a regular file inode.
*/
#define __WASI_FILETYPE_REGULAR_FILE (UINT8_C(4))
/**
* The file descriptor or file refers to a datagram socket.
*/
#define __WASI_FILETYPE_SOCKET_DGRAM (UINT8_C(5))
/**
* The file descriptor or file refers to a byte-stream socket.
*/
#define __WASI_FILETYPE_SOCKET_STREAM (UINT8_C(6))
/**
* The file refers to a symbolic link inode.
*/
#define __WASI_FILETYPE_SYMBOLIC_LINK (UINT8_C(7))
_Static_assert(sizeof(__wasi_filetype_t) == 1, "witx calculated size");
_Static_assert(_Alignof(__wasi_filetype_t) == 1, "witx calculated align");
/**
* A directory entry.
*/
typedef struct __wasi_dirent_t {
/**
* The offset of the next directory entry stored in this directory.
*/
__wasi_dircookie_t d_next;
/**
* The serial number of the file referred to by this directory entry.
*/
__wasi_inode_t d_ino;
/**
* The length of the name of the directory entry.
*/
__wasi_dirnamlen_t d_namlen;
/**
* The type of the file referred to by this directory entry.
*/
__wasi_filetype_t d_type;
} __wasi_dirent_t;
_Static_assert(sizeof(__wasi_dirent_t) == 24, "witx calculated size");
_Static_assert(_Alignof(__wasi_dirent_t) == 8, "witx calculated align");
_Static_assert(offsetof(__wasi_dirent_t, d_next) == 0, "witx calculated offset");
_Static_assert(offsetof(__wasi_dirent_t, d_ino) == 8, "witx calculated offset");
_Static_assert(offsetof(__wasi_dirent_t, d_namlen) == 16, "witx calculated offset");
_Static_assert(offsetof(__wasi_dirent_t, d_type) == 20, "witx calculated offset");
/**
* File or memory access pattern advisory information.
*/
typedef uint8_t __wasi_advice_t;
/**
* The application has no advice to give on its behavior with respect to the specified data.
*/
#define __WASI_ADVICE_NORMAL (UINT8_C(0))
/**
* The application expects to access the specified data sequentially from lower offsets to higher offsets.
*/
#define __WASI_ADVICE_SEQUENTIAL (UINT8_C(1))
/**
* The application expects to access the specified data in a random order.
*/
#define __WASI_ADVICE_RANDOM (UINT8_C(2))
/**
* The application expects to access the specified data in the near future.
*/
#define __WASI_ADVICE_WILLNEED (UINT8_C(3))
/**
* The application expects that it will not access the specified data in the near future.
*/
#define __WASI_ADVICE_DONTNEED (UINT8_C(4))
/**
* The application expects to access the specified data once and then not reuse it thereafter.
*/
#define __WASI_ADVICE_NOREUSE (UINT8_C(5))
_Static_assert(sizeof(__wasi_advice_t) == 1, "witx calculated size");
_Static_assert(_Alignof(__wasi_advice_t) == 1, "witx calculated align");
/**
* File descriptor flags.
*/
typedef uint16_t __wasi_fdflags_t;
/**
* Append mode: Data written to the file is always appended to the file's end.
*/
#define __WASI_FDFLAGS_APPEND ((__wasi_fdflags_t)(1 << 0))
/**
* Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
*/
#define __WASI_FDFLAGS_DSYNC ((__wasi_fdflags_t)(1 << 1))
/**
* Non-blocking mode.
*/
#define __WASI_FDFLAGS_NONBLOCK ((__wasi_fdflags_t)(1 << 2))
/**
* Synchronized read I/O operations.
*/
#define __WASI_FDFLAGS_RSYNC ((__wasi_fdflags_t)(1 << 3))
/**
* Write according to synchronized I/O file integrity completion. In
* addition to synchronizing the data stored in the file, the implementation
* may also synchronously update the file's metadata.
*/
#define __WASI_FDFLAGS_SYNC ((__wasi_fdflags_t)(1 << 4))
/**
* File descriptor attributes.
*/
typedef struct __wasi_fdstat_t {
/**
* File type.
*/
__wasi_filetype_t fs_filetype;
/**
* File descriptor flags.
*/
__wasi_fdflags_t fs_flags;
/**
* Rights that apply to this file descriptor.
*/
__wasi_rights_t fs_rights_base;
/**
* Maximum set of rights that may be installed on new file descriptors that
* are created through this file descriptor, e.g., through `path_open`.
*/
__wasi_rights_t fs_rights_inheriting;
} __wasi_fdstat_t;
_Static_assert(sizeof(__wasi_fdstat_t) == 24, "witx calculated size");
_Static_assert(_Alignof(__wasi_fdstat_t) == 8, "witx calculated align");
_Static_assert(offsetof(__wasi_fdstat_t, fs_filetype) == 0, "witx calculated offset");
_Static_assert(offsetof(__wasi_fdstat_t, fs_flags) == 2, "witx calculated offset");
_Static_assert(offsetof(__wasi_fdstat_t, fs_rights_base) == 8, "witx calculated offset");
_Static_assert(offsetof(__wasi_fdstat_t, fs_rights_inheriting) == 16, "witx calculated offset");
/**
* Identifier for a device containing a file system. Can be used in combination
* with `inode` to uniquely identify a file or directory in the filesystem.
*/
typedef uint64_t __wasi_device_t;
_Static_assert(sizeof(__wasi_device_t) == 8, "witx calculated size");
_Static_assert(_Alignof(__wasi_device_t) == 8, "witx calculated align");
/**
* Which file time attributes to adjust.
*/
typedef uint16_t __wasi_fstflags_t;
/**
* Adjust the last data access timestamp to the value stored in `filestat::atim`.
*/
#define __WASI_FSTFLAGS_ATIM ((__wasi_fstflags_t)(1 << 0))
/**
* Adjust the last data access timestamp to the time of clock `clockid::realtime`.
*/
#define __WASI_FSTFLAGS_ATIM_NOW ((__wasi_fstflags_t)(1 << 1))
/**
* Adjust the last data modification timestamp to the value stored in `filestat::mtim`.
*/
#define __WASI_FSTFLAGS_MTIM ((__wasi_fstflags_t)(1 << 2))
/**
* Adjust the last data modification timestamp to the time of clock `clockid::realtime`.
*/
#define __WASI_FSTFLAGS_MTIM_NOW ((__wasi_fstflags_t)(1 << 3))
/**
* Flags determining the method of how paths are resolved.
*/
typedef uint32_t __wasi_lookupflags_t;
/**
* As long as the resolved path corresponds to a symbolic link, it is expanded.
*/
#define __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW ((__wasi_lookupflags_t)(1 << 0))