/src/WasmEdge/thirdparty/wasi/api.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: 2019-2024 Second State INC |
3 | | |
4 | | /** |
5 | | * THIS FILE IS AUTO-GENERATED from the following files: |
6 | | * typenames.witx |
7 | | * |
8 | | * @file |
9 | | * This file describes the [WASI] interface, consisting of functions, types, |
10 | | * and defined values (macros). |
11 | | * |
12 | | * The interface described here is greatly inspired by [CloudABI]'s clean, |
13 | | * thoughtfully-designed, capability-oriented, POSIX-style API. |
14 | | * |
15 | | * [CloudABI]: https://github.com/NuxiNL/cloudlibc |
16 | | * [WASI]: https://github.com/WebAssembly/WASI/ |
17 | | */ |
18 | | |
19 | | #pragma once |
20 | | |
21 | | #include <cstddef> |
22 | | #include <cstdint> |
23 | | #include <type_traits> |
24 | | |
25 | | using const_uint8_t_ptr = uint32_t; |
26 | | using uint8_t_ptr = uint32_t; |
27 | | |
28 | | #define DEFINE_ENUM_OPERATORS(type) \ |
29 | 0 | inline constexpr type operator~(type a) noexcept { \ |
30 | 0 | return static_cast<type>(~static_cast<std::underlying_type_t<type>>(a)); \ |
31 | 0 | } \ Unexecuted instantiation: operator~(__wasi_rights_t) Unexecuted instantiation: operator~(__wasi_fdflags_t) Unexecuted instantiation: operator~(__wasi_fstflags_t) Unexecuted instantiation: operator~(__wasi_lookupflags_t) Unexecuted instantiation: operator~(__wasi_oflags_t) Unexecuted instantiation: operator~(__wasi_eventrwflags_t) Unexecuted instantiation: operator~(__wasi_subclockflags_t) Unexecuted instantiation: operator~(__wasi_aiflags_t) Unexecuted instantiation: operator~(__wasi_riflags_t) Unexecuted instantiation: operator~(__wasi_roflags_t) Unexecuted instantiation: operator~(__wasi_sdflags_t) Unexecuted instantiation: WasmEdge::Host::WASI::operator~(WasmEdge::Host::WASI::VFS::Flags) |
32 | 0 | inline constexpr type operator|(type a, type b) noexcept { \ |
33 | 0 | return static_cast<type>(static_cast<std::underlying_type_t<type>>(a) | \ |
34 | 0 | static_cast<std::underlying_type_t<type>>(b)); \ |
35 | 0 | } \ Unexecuted instantiation: operator|(__wasi_rights_t, __wasi_rights_t) Unexecuted instantiation: operator|(__wasi_fdflags_t, __wasi_fdflags_t) Unexecuted instantiation: operator|(__wasi_fstflags_t, __wasi_fstflags_t) Unexecuted instantiation: operator|(__wasi_lookupflags_t, __wasi_lookupflags_t) Unexecuted instantiation: operator|(__wasi_oflags_t, __wasi_oflags_t) Unexecuted instantiation: operator|(__wasi_eventrwflags_t, __wasi_eventrwflags_t) Unexecuted instantiation: operator|(__wasi_subclockflags_t, __wasi_subclockflags_t) Unexecuted instantiation: operator|(__wasi_aiflags_t, __wasi_aiflags_t) Unexecuted instantiation: operator|(__wasi_riflags_t, __wasi_riflags_t) Unexecuted instantiation: operator|(__wasi_roflags_t, __wasi_roflags_t) Unexecuted instantiation: operator|(__wasi_sdflags_t, __wasi_sdflags_t) Unexecuted instantiation: WasmEdge::Host::WASI::operator|(WasmEdge::Host::WASI::VFS::Flags, WasmEdge::Host::WASI::VFS::Flags) |
36 | 0 | inline constexpr type &operator|=(type &a, type b) noexcept { \ |
37 | 0 | a = a | b; \ |
38 | 0 | return a; \ |
39 | 0 | } \ Unexecuted instantiation: operator|=(__wasi_rights_t&, __wasi_rights_t) Unexecuted instantiation: operator|=(__wasi_fdflags_t&, __wasi_fdflags_t) Unexecuted instantiation: operator|=(__wasi_fstflags_t&, __wasi_fstflags_t) Unexecuted instantiation: operator|=(__wasi_lookupflags_t&, __wasi_lookupflags_t) Unexecuted instantiation: operator|=(__wasi_oflags_t&, __wasi_oflags_t) Unexecuted instantiation: operator|=(__wasi_eventrwflags_t&, __wasi_eventrwflags_t) Unexecuted instantiation: operator|=(__wasi_subclockflags_t&, __wasi_subclockflags_t) Unexecuted instantiation: operator|=(__wasi_aiflags_t&, __wasi_aiflags_t) Unexecuted instantiation: operator|=(__wasi_riflags_t&, __wasi_riflags_t) Unexecuted instantiation: operator|=(__wasi_roflags_t&, __wasi_roflags_t) Unexecuted instantiation: operator|=(__wasi_sdflags_t&, __wasi_sdflags_t) Unexecuted instantiation: WasmEdge::Host::WASI::operator|=(WasmEdge::Host::WASI::VFS::Flags&, WasmEdge::Host::WASI::VFS::Flags) |
40 | 0 | inline constexpr type operator&(type a, type b) noexcept { \ |
41 | 0 | return static_cast<type>(static_cast<std::underlying_type_t<type>>(a) & \ |
42 | 0 | static_cast<std::underlying_type_t<type>>(b)); \ |
43 | 0 | } \ Unexecuted instantiation: operator&(__wasi_rights_t, __wasi_rights_t) Unexecuted instantiation: operator&(__wasi_fdflags_t, __wasi_fdflags_t) Unexecuted instantiation: operator&(__wasi_fstflags_t, __wasi_fstflags_t) Unexecuted instantiation: operator&(__wasi_lookupflags_t, __wasi_lookupflags_t) Unexecuted instantiation: operator&(__wasi_oflags_t, __wasi_oflags_t) Unexecuted instantiation: operator&(__wasi_eventrwflags_t, __wasi_eventrwflags_t) Unexecuted instantiation: operator&(__wasi_subclockflags_t, __wasi_subclockflags_t) Unexecuted instantiation: operator&(__wasi_aiflags_t, __wasi_aiflags_t) Unexecuted instantiation: operator&(__wasi_riflags_t, __wasi_riflags_t) Unexecuted instantiation: operator&(__wasi_roflags_t, __wasi_roflags_t) Unexecuted instantiation: operator&(__wasi_sdflags_t, __wasi_sdflags_t) Unexecuted instantiation: WasmEdge::Host::WASI::operator&(WasmEdge::Host::WASI::VFS::Flags, WasmEdge::Host::WASI::VFS::Flags) |
44 | 0 | inline constexpr type &operator&=(type &a, type b) noexcept { \ |
45 | 0 | a = a & b; \ |
46 | 0 | return a; \ |
47 | 0 | } Unexecuted instantiation: operator&=(__wasi_rights_t&, __wasi_rights_t) Unexecuted instantiation: operator&=(__wasi_fdflags_t&, __wasi_fdflags_t) Unexecuted instantiation: operator&=(__wasi_fstflags_t&, __wasi_fstflags_t) Unexecuted instantiation: operator&=(__wasi_lookupflags_t&, __wasi_lookupflags_t) Unexecuted instantiation: operator&=(__wasi_oflags_t&, __wasi_oflags_t) Unexecuted instantiation: operator&=(__wasi_eventrwflags_t&, __wasi_eventrwflags_t) Unexecuted instantiation: operator&=(__wasi_subclockflags_t&, __wasi_subclockflags_t) Unexecuted instantiation: operator&=(__wasi_aiflags_t&, __wasi_aiflags_t) Unexecuted instantiation: operator&=(__wasi_riflags_t&, __wasi_riflags_t) Unexecuted instantiation: operator&=(__wasi_roflags_t&, __wasi_roflags_t) Unexecuted instantiation: operator&=(__wasi_sdflags_t&, __wasi_sdflags_t) Unexecuted instantiation: WasmEdge::Host::WASI::operator&=(WasmEdge::Host::WASI::VFS::Flags&, WasmEdge::Host::WASI::VFS::Flags) |
48 | | |
49 | | static_assert(alignof(int8_t) == 1, "non-wasi data layout"); |
50 | | static_assert(alignof(uint8_t) == 1, "non-wasi data layout"); |
51 | | static_assert(alignof(int16_t) == 2, "non-wasi data layout"); |
52 | | static_assert(alignof(uint16_t) == 2, "non-wasi data layout"); |
53 | | static_assert(alignof(int32_t) == 4, "non-wasi data layout"); |
54 | | static_assert(alignof(uint32_t) == 4, "non-wasi data layout"); |
55 | | static_assert(alignof(int64_t) == 8, "non-wasi data layout"); |
56 | | static_assert(alignof(uint64_t) == 8, "non-wasi data layout"); |
57 | | static_assert(alignof(const_uint8_t_ptr) == 4, "non-wasi data layout"); |
58 | | static_assert(alignof(uint8_t_ptr) == 4, "non-wasi data layout"); |
59 | | |
60 | | using __wasi_size_t = uint32_t; |
61 | | |
62 | | static_assert(sizeof(__wasi_size_t) == 4, "witx calculated size"); |
63 | | static_assert(alignof(__wasi_size_t) == 4, "witx calculated align"); |
64 | | |
65 | | /** |
66 | | * Non-negative file size or length of a region within a file. |
67 | | */ |
68 | | using __wasi_filesize_t = uint64_t; |
69 | | |
70 | | static_assert(sizeof(__wasi_filesize_t) == 8, "witx calculated size"); |
71 | | static_assert(alignof(__wasi_filesize_t) == 8, "witx calculated align"); |
72 | | |
73 | | /** |
74 | | * Timestamp in nanoseconds. |
75 | | */ |
76 | | using __wasi_timestamp_t = uint64_t; |
77 | | |
78 | | static_assert(sizeof(__wasi_timestamp_t) == 8, "witx calculated size"); |
79 | | static_assert(alignof(__wasi_timestamp_t) == 8, "witx calculated align"); |
80 | | |
81 | | /** |
82 | | * Identifiers for clocks. |
83 | | */ |
84 | | enum __wasi_clockid_t : uint32_t { |
85 | | /** |
86 | | * The clock measuring real time. Time value zero corresponds with |
87 | | * 1970-01-01T00:00:00Z. |
88 | | */ |
89 | | __WASI_CLOCKID_REALTIME = 0, |
90 | | |
91 | | /** |
92 | | * The store-wide monotonic clock, which is defined as a clock measuring |
93 | | * real time, whose value cannot be adjusted and which cannot have negative |
94 | | * clock jumps. The epoch of this clock is undefined. The absolute time |
95 | | * value of this clock therefore has no meaning. |
96 | | */ |
97 | | __WASI_CLOCKID_MONOTONIC = 1, |
98 | | |
99 | | /** |
100 | | * The CPU-time clock associated with the current process. |
101 | | */ |
102 | | __WASI_CLOCKID_PROCESS_CPUTIME_ID = 2, |
103 | | |
104 | | /** |
105 | | * The CPU-time clock associated with the current thread. |
106 | | */ |
107 | | __WASI_CLOCKID_THREAD_CPUTIME_ID = 3, |
108 | | |
109 | | }; |
110 | | static_assert(sizeof(__wasi_clockid_t) == 4, "witx calculated size"); |
111 | | static_assert(alignof(__wasi_clockid_t) == 4, "witx calculated align"); |
112 | | |
113 | | /** |
114 | | * Error codes returned by functions. |
115 | | * Not all of these error codes are returned by the functions provided by this |
116 | | * API; some are used in higher-level library layers, and others are provided |
117 | | * merely for alignment with POSIX. |
118 | | */ |
119 | | enum __wasi_errno_t : uint16_t { |
120 | | /** |
121 | | * No error occurred. System call completed successfully. |
122 | | */ |
123 | | __WASI_ERRNO_SUCCESS = 0, |
124 | | |
125 | | /** |
126 | | * Argument list too long. |
127 | | */ |
128 | | __WASI_ERRNO_2BIG = 1, |
129 | | |
130 | | /** |
131 | | * Permission denied. |
132 | | */ |
133 | | __WASI_ERRNO_ACCES = 2, |
134 | | |
135 | | /** |
136 | | * Address in use. |
137 | | */ |
138 | | __WASI_ERRNO_ADDRINUSE = 3, |
139 | | |
140 | | /** |
141 | | * Address not available. |
142 | | */ |
143 | | __WASI_ERRNO_ADDRNOTAVAIL = 4, |
144 | | |
145 | | /** |
146 | | * Address family not supported. |
147 | | */ |
148 | | __WASI_ERRNO_AFNOSUPPORT = 5, |
149 | | |
150 | | /** |
151 | | * Resource unavailable, or operation would block. |
152 | | */ |
153 | | __WASI_ERRNO_AGAIN = 6, |
154 | | |
155 | | /** |
156 | | * Connection already in progress. |
157 | | */ |
158 | | __WASI_ERRNO_ALREADY = 7, |
159 | | |
160 | | /** |
161 | | * Bad file descriptor. |
162 | | */ |
163 | | __WASI_ERRNO_BADF = 8, |
164 | | |
165 | | /** |
166 | | * Bad message. |
167 | | */ |
168 | | __WASI_ERRNO_BADMSG = 9, |
169 | | |
170 | | /** |
171 | | * Device or resource busy. |
172 | | */ |
173 | | __WASI_ERRNO_BUSY = 10, |
174 | | |
175 | | /** |
176 | | * Operation canceled. |
177 | | */ |
178 | | __WASI_ERRNO_CANCELED = 11, |
179 | | |
180 | | /** |
181 | | * No child processes. |
182 | | */ |
183 | | __WASI_ERRNO_CHILD = 12, |
184 | | |
185 | | /** |
186 | | * Connection aborted. |
187 | | */ |
188 | | __WASI_ERRNO_CONNABORTED = 13, |
189 | | |
190 | | /** |
191 | | * Connection refused. |
192 | | */ |
193 | | __WASI_ERRNO_CONNREFUSED = 14, |
194 | | |
195 | | /** |
196 | | * Connection reset. |
197 | | */ |
198 | | __WASI_ERRNO_CONNRESET = 15, |
199 | | |
200 | | /** |
201 | | * Resource deadlock would occur. |
202 | | */ |
203 | | __WASI_ERRNO_DEADLK = 16, |
204 | | |
205 | | /** |
206 | | * Destination address required. |
207 | | */ |
208 | | __WASI_ERRNO_DESTADDRREQ = 17, |
209 | | |
210 | | /** |
211 | | * Mathematics argument out of domain of function. |
212 | | */ |
213 | | __WASI_ERRNO_DOM = 18, |
214 | | |
215 | | /** |
216 | | * Reserved. |
217 | | */ |
218 | | __WASI_ERRNO_DQUOT = 19, |
219 | | |
220 | | /** |
221 | | * File exists. |
222 | | */ |
223 | | __WASI_ERRNO_EXIST = 20, |
224 | | |
225 | | /** |
226 | | * Bad address. |
227 | | */ |
228 | | __WASI_ERRNO_FAULT = 21, |
229 | | |
230 | | /** |
231 | | * File too large. |
232 | | */ |
233 | | __WASI_ERRNO_FBIG = 22, |
234 | | |
235 | | /** |
236 | | * Host is unreachable. |
237 | | */ |
238 | | __WASI_ERRNO_HOSTUNREACH = 23, |
239 | | |
240 | | /** |
241 | | * Identifier removed. |
242 | | */ |
243 | | __WASI_ERRNO_IDRM = 24, |
244 | | |
245 | | /** |
246 | | * Illegal byte sequence. |
247 | | */ |
248 | | __WASI_ERRNO_ILSEQ = 25, |
249 | | |
250 | | /** |
251 | | * Operation in progress. |
252 | | */ |
253 | | __WASI_ERRNO_INPROGRESS = 26, |
254 | | |
255 | | /** |
256 | | * Interrupted function. |
257 | | */ |
258 | | __WASI_ERRNO_INTR = 27, |
259 | | |
260 | | /** |
261 | | * Invalid argument. |
262 | | */ |
263 | | __WASI_ERRNO_INVAL = 28, |
264 | | |
265 | | /** |
266 | | * I/O error. |
267 | | */ |
268 | | __WASI_ERRNO_IO = 29, |
269 | | |
270 | | /** |
271 | | * Socket is connected. |
272 | | */ |
273 | | __WASI_ERRNO_ISCONN = 30, |
274 | | |
275 | | /** |
276 | | * Is a directory. |
277 | | */ |
278 | | __WASI_ERRNO_ISDIR = 31, |
279 | | |
280 | | /** |
281 | | * Too many levels of symbolic links. |
282 | | */ |
283 | | __WASI_ERRNO_LOOP = 32, |
284 | | |
285 | | /** |
286 | | * File descriptor value too large. |
287 | | */ |
288 | | __WASI_ERRNO_MFILE = 33, |
289 | | |
290 | | /** |
291 | | * Too many links. |
292 | | */ |
293 | | __WASI_ERRNO_MLINK = 34, |
294 | | |
295 | | /** |
296 | | * Message too large. |
297 | | */ |
298 | | __WASI_ERRNO_MSGSIZE = 35, |
299 | | |
300 | | /** |
301 | | * Reserved. |
302 | | */ |
303 | | __WASI_ERRNO_MULTIHOP = 36, |
304 | | |
305 | | /** |
306 | | * Filename too long. |
307 | | */ |
308 | | __WASI_ERRNO_NAMETOOLONG = 37, |
309 | | |
310 | | /** |
311 | | * Network is down. |
312 | | */ |
313 | | __WASI_ERRNO_NETDOWN = 38, |
314 | | |
315 | | /** |
316 | | * Connection aborted by network. |
317 | | */ |
318 | | __WASI_ERRNO_NETRESET = 39, |
319 | | |
320 | | /** |
321 | | * Network unreachable. |
322 | | */ |
323 | | __WASI_ERRNO_NETUNREACH = 40, |
324 | | |
325 | | /** |
326 | | * Too many files open in system. |
327 | | */ |
328 | | __WASI_ERRNO_NFILE = 41, |
329 | | |
330 | | /** |
331 | | * No buffer space available. |
332 | | */ |
333 | | __WASI_ERRNO_NOBUFS = 42, |
334 | | |
335 | | /** |
336 | | * No such device. |
337 | | */ |
338 | | __WASI_ERRNO_NODEV = 43, |
339 | | |
340 | | /** |
341 | | * No such file or directory. |
342 | | */ |
343 | | __WASI_ERRNO_NOENT = 44, |
344 | | |
345 | | /** |
346 | | * Executable file format error. |
347 | | */ |
348 | | __WASI_ERRNO_NOEXEC = 45, |
349 | | |
350 | | /** |
351 | | * No locks available. |
352 | | */ |
353 | | __WASI_ERRNO_NOLCK = 46, |
354 | | |
355 | | /** |
356 | | * Reserved. |
357 | | */ |
358 | | __WASI_ERRNO_NOLINK = 47, |
359 | | |
360 | | /** |
361 | | * Not enough space. |
362 | | */ |
363 | | __WASI_ERRNO_NOMEM = 48, |
364 | | |
365 | | /** |
366 | | * No message of the desired type. |
367 | | */ |
368 | | __WASI_ERRNO_NOMSG = 49, |
369 | | |
370 | | /** |
371 | | * Protocol not available. |
372 | | */ |
373 | | __WASI_ERRNO_NOPROTOOPT = 50, |
374 | | |
375 | | /** |
376 | | * No space left on device. |
377 | | */ |
378 | | __WASI_ERRNO_NOSPC = 51, |
379 | | |
380 | | /** |
381 | | * Function not supported. |
382 | | */ |
383 | | __WASI_ERRNO_NOSYS = 52, |
384 | | |
385 | | /** |
386 | | * The socket is not connected. |
387 | | */ |
388 | | __WASI_ERRNO_NOTCONN = 53, |
389 | | |
390 | | /** |
391 | | * Not a directory or a symbolic link to a directory. |
392 | | */ |
393 | | __WASI_ERRNO_NOTDIR = 54, |
394 | | |
395 | | /** |
396 | | * Directory not empty. |
397 | | */ |
398 | | __WASI_ERRNO_NOTEMPTY = 55, |
399 | | |
400 | | /** |
401 | | * State not recoverable. |
402 | | */ |
403 | | __WASI_ERRNO_NOTRECOVERABLE = 56, |
404 | | |
405 | | /** |
406 | | * Not a socket. |
407 | | */ |
408 | | __WASI_ERRNO_NOTSOCK = 57, |
409 | | |
410 | | /** |
411 | | * Not supported, or operation not supported on socket. |
412 | | */ |
413 | | __WASI_ERRNO_NOTSUP = 58, |
414 | | |
415 | | /** |
416 | | * Inappropriate I/O control operation. |
417 | | */ |
418 | | __WASI_ERRNO_NOTTY = 59, |
419 | | |
420 | | /** |
421 | | * No such device or address. |
422 | | */ |
423 | | __WASI_ERRNO_NXIO = 60, |
424 | | |
425 | | /** |
426 | | * Value too large to be stored in data type. |
427 | | */ |
428 | | __WASI_ERRNO_OVERFLOW = 61, |
429 | | |
430 | | /** |
431 | | * Previous owner died. |
432 | | */ |
433 | | __WASI_ERRNO_OWNERDEAD = 62, |
434 | | |
435 | | /** |
436 | | * Operation not permitted. |
437 | | */ |
438 | | __WASI_ERRNO_PERM = 63, |
439 | | |
440 | | /** |
441 | | * Broken pipe. |
442 | | */ |
443 | | __WASI_ERRNO_PIPE = 64, |
444 | | |
445 | | /** |
446 | | * Protocol error. |
447 | | */ |
448 | | __WASI_ERRNO_PROTO = 65, |
449 | | |
450 | | /** |
451 | | * Protocol not supported. |
452 | | */ |
453 | | __WASI_ERRNO_PROTONOSUPPORT = 66, |
454 | | |
455 | | /** |
456 | | * Protocol wrong type for socket. |
457 | | */ |
458 | | __WASI_ERRNO_PROTOTYPE = 67, |
459 | | |
460 | | /** |
461 | | * Result too large. |
462 | | */ |
463 | | __WASI_ERRNO_RANGE = 68, |
464 | | |
465 | | /** |
466 | | * Read-only file system. |
467 | | */ |
468 | | __WASI_ERRNO_ROFS = 69, |
469 | | |
470 | | /** |
471 | | * Invalid seek. |
472 | | */ |
473 | | __WASI_ERRNO_SPIPE = 70, |
474 | | |
475 | | /** |
476 | | * No such process. |
477 | | */ |
478 | | __WASI_ERRNO_SRCH = 71, |
479 | | |
480 | | /** |
481 | | * Reserved. |
482 | | */ |
483 | | __WASI_ERRNO_STALE = 72, |
484 | | |
485 | | /** |
486 | | * Connection timed out. |
487 | | */ |
488 | | __WASI_ERRNO_TIMEDOUT = 73, |
489 | | |
490 | | /** |
491 | | * Text file busy. |
492 | | */ |
493 | | __WASI_ERRNO_TXTBSY = 74, |
494 | | |
495 | | /** |
496 | | * Cross-device link. |
497 | | */ |
498 | | __WASI_ERRNO_XDEV = 75, |
499 | | |
500 | | /** |
501 | | * Extension: Capabilities insufficient. |
502 | | */ |
503 | | __WASI_ERRNO_NOTCAPABLE = 76, |
504 | | |
505 | | /** |
506 | | * The specified network host does not have any network addresses in the |
507 | | * requested address family. |
508 | | */ |
509 | | __WASI_ERRNO_AIADDRFAMILY = 77, |
510 | | |
511 | | /** |
512 | | * Try again later. |
513 | | */ |
514 | | __WASI_ERRNO_AIAGAIN = 78, |
515 | | |
516 | | /** |
517 | | * Hints.ai_flags contains invalid flags |
518 | | */ |
519 | | __WASI_ERRNO_AIBADFLAG = 79, |
520 | | |
521 | | /** |
522 | | * The name server returned a permanent failure indication. |
523 | | */ |
524 | | __WASI_ERRNO_AIFAIL = 80, |
525 | | |
526 | | /** |
527 | | * The requested address family is not supported. |
528 | | */ |
529 | | __WASI_ERRNO_AIFAMILY = 81, |
530 | | |
531 | | /** |
532 | | * Addrinfo out of memory. |
533 | | */ |
534 | | __WASI_ERRNO_AIMEMORY = 82, |
535 | | |
536 | | /** |
537 | | * Network host exists, but does not have any network addresses defined. |
538 | | */ |
539 | | __WASI_ERRNO_AINODATA = 83, |
540 | | |
541 | | /** |
542 | | * Node or service is not known; or both node and service are NULL |
543 | | */ |
544 | | __WASI_ERRNO_AINONAME = 84, |
545 | | |
546 | | /** |
547 | | * Service is not available for the requested socket type. |
548 | | */ |
549 | | __WASI_ERRNO_AISERVICE = 85, |
550 | | |
551 | | /** |
552 | | * The requested socket type is not supported. |
553 | | */ |
554 | | __WASI_ERRNO_AISOCKTYPE = 86, |
555 | | |
556 | | /** |
557 | | * Other system error; |
558 | | */ |
559 | | __WASI_ERRNO_AISYSTEM = 87, |
560 | | |
561 | | }; |
562 | | static_assert(sizeof(__wasi_errno_t) == 2, "witx calculated size"); |
563 | | static_assert(alignof(__wasi_errno_t) == 2, "witx calculated align"); |
564 | | |
565 | | /** |
566 | | * File descriptor rights, determining which actions may be performed. |
567 | | */ |
568 | | enum __wasi_rights_t : uint64_t { |
569 | | |
570 | | /** |
571 | | * The right to invoke `fd_datasync`. |
572 | | * If `path_open` is set, includes the right to invoke |
573 | | * `path_open` with `fdflags::dsync`. |
574 | | */ |
575 | | __WASI_RIGHTS_FD_DATASYNC = 1ULL << 0, |
576 | | |
577 | | /** |
578 | | * The right to invoke `fd_read` and `sock_recv`. |
579 | | * If `rights::fd_seek` is set, includes the right to invoke `fd_pread`. |
580 | | */ |
581 | | __WASI_RIGHTS_FD_READ = 1ULL << 1, |
582 | | |
583 | | /** |
584 | | * The right to invoke `fd_seek`. This flag implies `rights::fd_tell`. |
585 | | */ |
586 | | __WASI_RIGHTS_FD_SEEK = 1ULL << 2, |
587 | | |
588 | | /** |
589 | | * The right to invoke `fd_fdstat_set_flags`. |
590 | | */ |
591 | | __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS = 1ULL << 3, |
592 | | |
593 | | /** |
594 | | * The right to invoke `fd_sync`. |
595 | | * If `path_open` is set, includes the right to invoke |
596 | | * `path_open` with `fdflags::rsync` and `fdflags::dsync`. |
597 | | */ |
598 | | __WASI_RIGHTS_FD_SYNC = 1ULL << 4, |
599 | | |
600 | | /** |
601 | | * The right to invoke `fd_seek` in such a way that the file offset |
602 | | * remains unaltered (i.e., `whence::cur` with offset zero), or to |
603 | | * invoke `fd_tell`. |
604 | | */ |
605 | | __WASI_RIGHTS_FD_TELL = 1ULL << 5, |
606 | | |
607 | | /** |
608 | | * The right to invoke `fd_write` and `sock_send`. |
609 | | * If `rights::fd_seek` is set, includes the right to invoke `fd_pwrite`. |
610 | | */ |
611 | | __WASI_RIGHTS_FD_WRITE = 1ULL << 6, |
612 | | |
613 | | /** |
614 | | * The right to invoke `fd_advise`. |
615 | | */ |
616 | | __WASI_RIGHTS_FD_ADVISE = 1ULL << 7, |
617 | | |
618 | | /** |
619 | | * The right to invoke `fd_allocate`. |
620 | | */ |
621 | | __WASI_RIGHTS_FD_ALLOCATE = 1ULL << 8, |
622 | | |
623 | | /** |
624 | | * The right to invoke `path_create_directory`. |
625 | | */ |
626 | | __WASI_RIGHTS_PATH_CREATE_DIRECTORY = 1ULL << 9, |
627 | | |
628 | | /** |
629 | | * If `path_open` is set, the right to invoke `path_open` with |
630 | | * `oflags::creat`. |
631 | | */ |
632 | | __WASI_RIGHTS_PATH_CREATE_FILE = 1ULL << 10, |
633 | | |
634 | | /** |
635 | | * The right to invoke `path_link` with the file descriptor as the |
636 | | * source directory. |
637 | | */ |
638 | | __WASI_RIGHTS_PATH_LINK_SOURCE = 1ULL << 11, |
639 | | |
640 | | /** |
641 | | * The right to invoke `path_link` with the file descriptor as the |
642 | | * target directory. |
643 | | */ |
644 | | __WASI_RIGHTS_PATH_LINK_TARGET = 1ULL << 12, |
645 | | |
646 | | /** |
647 | | * The right to invoke `path_open`. |
648 | | */ |
649 | | __WASI_RIGHTS_PATH_OPEN = 1ULL << 13, |
650 | | |
651 | | /** |
652 | | * The right to invoke `fd_readdir`. |
653 | | */ |
654 | | __WASI_RIGHTS_FD_READDIR = 1ULL << 14, |
655 | | |
656 | | /** |
657 | | * The right to invoke `path_readlink`. |
658 | | */ |
659 | | __WASI_RIGHTS_PATH_READLINK = 1ULL << 15, |
660 | | |
661 | | /** |
662 | | * The right to invoke `path_rename` with the file descriptor as the source |
663 | | * directory. |
664 | | */ |
665 | | __WASI_RIGHTS_PATH_RENAME_SOURCE = 1ULL << 16, |
666 | | |
667 | | /** |
668 | | * The right to invoke `path_rename` with the file descriptor as the target |
669 | | * directory. |
670 | | */ |
671 | | __WASI_RIGHTS_PATH_RENAME_TARGET = 1ULL << 17, |
672 | | |
673 | | /** |
674 | | * The right to invoke `path_filestat_get`. |
675 | | */ |
676 | | __WASI_RIGHTS_PATH_FILESTAT_GET = 1ULL << 18, |
677 | | |
678 | | /** |
679 | | * The right to change a file's size (there is no `path_filestat_set_size`). |
680 | | * If `path_open` is set, includes the right to invoke `path_open` with |
681 | | * `oflags::trunc`. |
682 | | */ |
683 | | __WASI_RIGHTS_PATH_FILESTAT_SET_SIZE = 1ULL << 19, |
684 | | |
685 | | /** |
686 | | * The right to invoke `path_filestat_set_times`. |
687 | | */ |
688 | | __WASI_RIGHTS_PATH_FILESTAT_SET_TIMES = 1ULL << 20, |
689 | | |
690 | | /** |
691 | | * The right to invoke `fd_filestat_get`. |
692 | | */ |
693 | | __WASI_RIGHTS_FD_FILESTAT_GET = 1ULL << 21, |
694 | | |
695 | | /** |
696 | | * The right to invoke `fd_filestat_set_size`. |
697 | | */ |
698 | | __WASI_RIGHTS_FD_FILESTAT_SET_SIZE = 1ULL << 22, |
699 | | |
700 | | /** |
701 | | * The right to invoke `fd_filestat_set_times`. |
702 | | */ |
703 | | __WASI_RIGHTS_FD_FILESTAT_SET_TIMES = 1ULL << 23, |
704 | | |
705 | | /** |
706 | | * The right to invoke `path_symlink`. |
707 | | */ |
708 | | __WASI_RIGHTS_PATH_SYMLINK = 1ULL << 24, |
709 | | |
710 | | /** |
711 | | * The right to invoke `path_remove_directory`. |
712 | | */ |
713 | | __WASI_RIGHTS_PATH_REMOVE_DIRECTORY = 1ULL << 25, |
714 | | |
715 | | /** |
716 | | * The right to invoke `path_unlink_file`. |
717 | | */ |
718 | | __WASI_RIGHTS_PATH_UNLINK_FILE = 1ULL << 26, |
719 | | |
720 | | /** |
721 | | * If `rights::fd_read` is set, includes the right to invoke `poll_oneoff` to |
722 | | * subscribe to `eventtype::fd_read`. If `rights::fd_write` is set, includes |
723 | | * the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_write`. |
724 | | */ |
725 | | __WASI_RIGHTS_POLL_FD_READWRITE = 1ULL << 27, |
726 | | |
727 | | /** |
728 | | * The right to invoke `sock_shutdown`. |
729 | | */ |
730 | | __WASI_RIGHTS_SOCK_SHUTDOWN = 1ULL << 28, |
731 | | |
732 | | /** |
733 | | * The right to invoke `sock_open`. |
734 | | */ |
735 | | __WASI_RIGHTS_SOCK_OPEN = 1ULL << 29, |
736 | | |
737 | | /** |
738 | | * The right to invoke `sock_close`. |
739 | | */ |
740 | | __WASI_RIGHTS_SOCK_CLOSE = 1ULL << 30, |
741 | | |
742 | | /** |
743 | | * The right to invoke `sock_bind`. |
744 | | */ |
745 | | __WASI_RIGHTS_SOCK_BIND = 1ULL << 31, |
746 | | |
747 | | /** |
748 | | * The right to invoke `sock_recv`. |
749 | | */ |
750 | | __WASI_RIGHTS_SOCK_RECV = 1ULL << 32, |
751 | | |
752 | | /** |
753 | | * The right to invoke `sock_recv_from`. |
754 | | */ |
755 | | __WASI_RIGHTS_SOCK_RECV_FROM = 1ULL << 33, |
756 | | |
757 | | /** |
758 | | * The right to invoke `sock_send`. |
759 | | */ |
760 | | __WASI_RIGHTS_SOCK_SEND = 1ULL << 34, |
761 | | |
762 | | /** |
763 | | * The right to invoke `sock_send_to`. |
764 | | */ |
765 | | __WASI_RIGHTS_SOCK_SEND_TO = 1ULL << 35, |
766 | | |
767 | | }; |
768 | | DEFINE_ENUM_OPERATORS(__wasi_rights_t) |
769 | | |
770 | | static_assert(sizeof(__wasi_rights_t) == 8, "witx calculated size"); |
771 | | static_assert(alignof(__wasi_rights_t) == 8, "witx calculated align"); |
772 | | |
773 | | /** |
774 | | * A file descriptor handle. |
775 | | */ |
776 | | using __wasi_fd_t = int32_t; |
777 | | |
778 | | static_assert(sizeof(__wasi_fd_t) == 4, "witx calculated size"); |
779 | | static_assert(alignof(__wasi_fd_t) == 4, "witx calculated align"); |
780 | | |
781 | | /** |
782 | | * A socket descriptor is currently an alias type of a typical file descriptor. |
783 | | */ |
784 | | using __wasi_sock_d_t = __wasi_fd_t; |
785 | | |
786 | | static_assert(sizeof(__wasi_sock_d_t) == 4, "witx calculated size"); |
787 | | static_assert(alignof(__wasi_sock_d_t) == 4, "witx calculated align"); |
788 | | |
789 | | /** |
790 | | * A region of memory for scatter/gather reads. |
791 | | */ |
792 | | struct __wasi_iovec_t { |
793 | | /** |
794 | | * The address of the buffer to be filled. |
795 | | */ |
796 | | uint8_t_ptr buf; |
797 | | |
798 | | /** |
799 | | * The length of the buffer to be filled. |
800 | | */ |
801 | | __wasi_size_t buf_len; |
802 | | }; |
803 | | |
804 | | static_assert(sizeof(__wasi_iovec_t) == 8, "witx calculated size"); |
805 | | static_assert(alignof(__wasi_iovec_t) == 4, "witx calculated align"); |
806 | | static_assert(offsetof(__wasi_iovec_t, buf) == 0, "witx calculated offset"); |
807 | | static_assert(offsetof(__wasi_iovec_t, buf_len) == 4, "witx calculated offset"); |
808 | | |
809 | | /** |
810 | | * A region of memory for scatter/gather writes. |
811 | | */ |
812 | | struct __wasi_ciovec_t { |
813 | | /** |
814 | | * The address of the buffer to be written. |
815 | | */ |
816 | | const_uint8_t_ptr buf; |
817 | | |
818 | | /** |
819 | | * The length of the buffer to be written. |
820 | | */ |
821 | | __wasi_size_t buf_len; |
822 | | }; |
823 | | |
824 | | static_assert(sizeof(__wasi_ciovec_t) == 8, "witx calculated size"); |
825 | | static_assert(alignof(__wasi_ciovec_t) == 4, "witx calculated align"); |
826 | | static_assert(offsetof(__wasi_ciovec_t, buf) == 0, "witx calculated offset"); |
827 | | static_assert(offsetof(__wasi_ciovec_t, buf_len) == 4, |
828 | | "witx calculated offset"); |
829 | | |
830 | | /** |
831 | | * Relative offset within a file. |
832 | | */ |
833 | | using __wasi_filedelta_t = int64_t; |
834 | | |
835 | | static_assert(sizeof(__wasi_filedelta_t) == 8, "witx calculated size"); |
836 | | static_assert(alignof(__wasi_filedelta_t) == 8, "witx calculated align"); |
837 | | |
838 | | /** |
839 | | * The position relative to which to set the offset of the file descriptor. |
840 | | */ |
841 | | enum __wasi_whence_t : uint8_t { |
842 | | /** |
843 | | * Seek relative to start-of-file. |
844 | | */ |
845 | | __WASI_WHENCE_SET = 0, |
846 | | |
847 | | /** |
848 | | * Seek relative to current position. |
849 | | */ |
850 | | __WASI_WHENCE_CUR = 1, |
851 | | |
852 | | /** |
853 | | * Seek relative to end-of-file. |
854 | | */ |
855 | | __WASI_WHENCE_END = 2, |
856 | | |
857 | | }; |
858 | | static_assert(sizeof(__wasi_whence_t) == 1, "witx calculated size"); |
859 | | static_assert(alignof(__wasi_whence_t) == 1, "witx calculated align"); |
860 | | |
861 | | /** |
862 | | * A reference to the offset of a directory entry. |
863 | | * |
864 | | * The value 0 signifies the start of the directory. |
865 | | */ |
866 | | using __wasi_dircookie_t = uint64_t; |
867 | | |
868 | | static_assert(sizeof(__wasi_dircookie_t) == 8, "witx calculated size"); |
869 | | static_assert(alignof(__wasi_dircookie_t) == 8, "witx calculated align"); |
870 | | |
871 | | /** |
872 | | * The type for the `dirent::d_namlen` field of `dirent` struct. |
873 | | */ |
874 | | using __wasi_dirnamlen_t = uint32_t; |
875 | | |
876 | | static_assert(sizeof(__wasi_dirnamlen_t) == 4, "witx calculated size"); |
877 | | static_assert(alignof(__wasi_dirnamlen_t) == 4, "witx calculated align"); |
878 | | |
879 | | /** |
880 | | * File serial number that is unique within its file system. |
881 | | */ |
882 | | using __wasi_inode_t = uint64_t; |
883 | | |
884 | | static_assert(sizeof(__wasi_inode_t) == 8, "witx calculated size"); |
885 | | static_assert(alignof(__wasi_inode_t) == 8, "witx calculated align"); |
886 | | |
887 | | /** |
888 | | * The type of a file descriptor or file. |
889 | | */ |
890 | | enum __wasi_filetype_t : uint8_t { |
891 | | /** |
892 | | * The type of the file descriptor or file is unknown or is different from any |
893 | | * of the other types specified. |
894 | | */ |
895 | | __WASI_FILETYPE_UNKNOWN = 0, |
896 | | |
897 | | /** |
898 | | * The file descriptor or file refers to a block device inode. |
899 | | */ |
900 | | __WASI_FILETYPE_BLOCK_DEVICE = 1, |
901 | | |
902 | | /** |
903 | | * The file descriptor or file refers to a character device inode. |
904 | | */ |
905 | | __WASI_FILETYPE_CHARACTER_DEVICE = 2, |
906 | | |
907 | | /** |
908 | | * The file descriptor or file refers to a directory inode. |
909 | | */ |
910 | | __WASI_FILETYPE_DIRECTORY = 3, |
911 | | |
912 | | /** |
913 | | * The file descriptor or file refers to a regular file inode. |
914 | | */ |
915 | | __WASI_FILETYPE_REGULAR_FILE = 4, |
916 | | |
917 | | /** |
918 | | * The file descriptor or file refers to a datagram socket. |
919 | | */ |
920 | | __WASI_FILETYPE_SOCKET_DGRAM = 5, |
921 | | |
922 | | /** |
923 | | * The file descriptor or file refers to a byte-stream socket. |
924 | | */ |
925 | | __WASI_FILETYPE_SOCKET_STREAM = 6, |
926 | | |
927 | | /** |
928 | | * The file refers to a symbolic link inode. |
929 | | */ |
930 | | __WASI_FILETYPE_SYMBOLIC_LINK = 7, |
931 | | |
932 | | }; |
933 | | static_assert(sizeof(__wasi_filetype_t) == 1, "witx calculated size"); |
934 | | static_assert(alignof(__wasi_filetype_t) == 1, "witx calculated align"); |
935 | | |
936 | | /** |
937 | | * A directory entry. |
938 | | */ |
939 | | struct __wasi_dirent_t { |
940 | | /** |
941 | | * The offset of the next directory entry stored in this directory. |
942 | | */ |
943 | | __wasi_dircookie_t d_next; |
944 | | |
945 | | /** |
946 | | * The serial number of the file referred to by this directory entry. |
947 | | */ |
948 | | __wasi_inode_t d_ino; |
949 | | |
950 | | /** |
951 | | * The length of the name of the directory entry. |
952 | | */ |
953 | | __wasi_dirnamlen_t d_namlen; |
954 | | |
955 | | /** |
956 | | * The type of the file referred to by this directory entry. |
957 | | */ |
958 | | __wasi_filetype_t d_type; |
959 | | }; |
960 | | |
961 | | static_assert(sizeof(__wasi_dirent_t) == 24, "witx calculated size"); |
962 | | static_assert(alignof(__wasi_dirent_t) == 8, "witx calculated align"); |
963 | | static_assert(offsetof(__wasi_dirent_t, d_next) == 0, "witx calculated offset"); |
964 | | static_assert(offsetof(__wasi_dirent_t, d_ino) == 8, "witx calculated offset"); |
965 | | static_assert(offsetof(__wasi_dirent_t, d_namlen) == 16, |
966 | | "witx calculated offset"); |
967 | | static_assert(offsetof(__wasi_dirent_t, d_type) == 20, |
968 | | "witx calculated offset"); |
969 | | |
970 | | /** |
971 | | * File or memory access pattern advisory information. |
972 | | */ |
973 | | enum __wasi_advice_t : uint8_t { |
974 | | /** |
975 | | * The application has no advice to give on its behavior with respect to the |
976 | | * specified data. |
977 | | */ |
978 | | __WASI_ADVICE_NORMAL = 0, |
979 | | |
980 | | /** |
981 | | * The application expects to access the specified data sequentially from |
982 | | * lower offsets to higher offsets. |
983 | | */ |
984 | | __WASI_ADVICE_SEQUENTIAL = 1, |
985 | | |
986 | | /** |
987 | | * The application expects to access the specified data in a random order. |
988 | | */ |
989 | | __WASI_ADVICE_RANDOM = 2, |
990 | | |
991 | | /** |
992 | | * The application expects to access the specified data in the near future. |
993 | | */ |
994 | | __WASI_ADVICE_WILLNEED = 3, |
995 | | |
996 | | /** |
997 | | * The application expects that it will not access the specified data in the |
998 | | * near future. |
999 | | */ |
1000 | | __WASI_ADVICE_DONTNEED = 4, |
1001 | | |
1002 | | /** |
1003 | | * The application expects to access the specified data once and then not |
1004 | | * reuse it thereafter. |
1005 | | */ |
1006 | | __WASI_ADVICE_NOREUSE = 5, |
1007 | | |
1008 | | }; |
1009 | | static_assert(sizeof(__wasi_advice_t) == 1, "witx calculated size"); |
1010 | | static_assert(alignof(__wasi_advice_t) == 1, "witx calculated align"); |
1011 | | |
1012 | | /** |
1013 | | * File descriptor flags. |
1014 | | */ |
1015 | | enum __wasi_fdflags_t : uint16_t { |
1016 | | |
1017 | | /** |
1018 | | * Append mode: Data written to the file is always appended to the file's end. |
1019 | | */ |
1020 | | __WASI_FDFLAGS_APPEND = 1ULL << 0, |
1021 | | |
1022 | | /** |
1023 | | * Write according to synchronized I/O data integrity completion. Only the |
1024 | | * data stored in the file is synchronized. |
1025 | | */ |
1026 | | __WASI_FDFLAGS_DSYNC = 1ULL << 1, |
1027 | | |
1028 | | /** |
1029 | | * Non-blocking mode. |
1030 | | */ |
1031 | | __WASI_FDFLAGS_NONBLOCK = 1ULL << 2, |
1032 | | |
1033 | | /** |
1034 | | * Synchronized read I/O operations. |
1035 | | */ |
1036 | | __WASI_FDFLAGS_RSYNC = 1ULL << 3, |
1037 | | |
1038 | | /** |
1039 | | * Write according to synchronized I/O file integrity completion. In |
1040 | | * addition to synchronizing the data stored in the file, the implementation |
1041 | | * may also synchronously update the file's metadata. |
1042 | | */ |
1043 | | __WASI_FDFLAGS_SYNC = 1ULL << 4, |
1044 | | |
1045 | | }; |
1046 | | DEFINE_ENUM_OPERATORS(__wasi_fdflags_t) |
1047 | | |
1048 | | static_assert(sizeof(__wasi_fdflags_t) == 2, "witx calculated size"); |
1049 | | static_assert(alignof(__wasi_fdflags_t) == 2, "witx calculated align"); |
1050 | | |
1051 | | /** |
1052 | | * File descriptor attributes. |
1053 | | */ |
1054 | | struct __wasi_fdstat_t { |
1055 | | /** |
1056 | | * File type. |
1057 | | */ |
1058 | | __wasi_filetype_t fs_filetype; |
1059 | | |
1060 | | /** |
1061 | | * File descriptor flags. |
1062 | | */ |
1063 | | __wasi_fdflags_t fs_flags; |
1064 | | |
1065 | | /** |
1066 | | * Rights that apply to this file descriptor. |
1067 | | */ |
1068 | | __wasi_rights_t fs_rights_base; |
1069 | | |
1070 | | /** |
1071 | | * Maximum set of rights that may be installed on new file descriptors that |
1072 | | * are created through this file descriptor, e.g., through `path_open`. |
1073 | | */ |
1074 | | __wasi_rights_t fs_rights_inheriting; |
1075 | | }; |
1076 | | |
1077 | | static_assert(sizeof(__wasi_fdstat_t) == 24, "witx calculated size"); |
1078 | | static_assert(alignof(__wasi_fdstat_t) == 8, "witx calculated align"); |
1079 | | static_assert(offsetof(__wasi_fdstat_t, fs_filetype) == 0, |
1080 | | "witx calculated offset"); |
1081 | | static_assert(offsetof(__wasi_fdstat_t, fs_flags) == 2, |
1082 | | "witx calculated offset"); |
1083 | | static_assert(offsetof(__wasi_fdstat_t, fs_rights_base) == 8, |
1084 | | "witx calculated offset"); |
1085 | | static_assert(offsetof(__wasi_fdstat_t, fs_rights_inheriting) == 16, |
1086 | | "witx calculated offset"); |
1087 | | |
1088 | | /** |
1089 | | * Identifier for a device containing a file system. Can be used in combination |
1090 | | * with `inode` to uniquely identify a file or directory in the filesystem. |
1091 | | */ |
1092 | | using __wasi_device_t = uint64_t; |
1093 | | |
1094 | | static_assert(sizeof(__wasi_device_t) == 8, "witx calculated size"); |
1095 | | static_assert(alignof(__wasi_device_t) == 8, "witx calculated align"); |
1096 | | |
1097 | | /** |
1098 | | * Which file time attributes to adjust. |
1099 | | */ |
1100 | | enum __wasi_fstflags_t : uint16_t { |
1101 | | |
1102 | | /** |
1103 | | * Adjust the last data access timestamp to the value stored in |
1104 | | * `filestat::atim`. |
1105 | | */ |
1106 | | __WASI_FSTFLAGS_ATIM = 1ULL << 0, |
1107 | | |
1108 | | /** |
1109 | | * Adjust the last data access timestamp to the time of clock |
1110 | | * `clockid::realtime`. |
1111 | | */ |
1112 | | __WASI_FSTFLAGS_ATIM_NOW = 1ULL << 1, |
1113 | | |
1114 | | /** |
1115 | | * Adjust the last data modification timestamp to the value stored in |
1116 | | * `filestat::mtim`. |
1117 | | */ |
1118 | | __WASI_FSTFLAGS_MTIM = 1ULL << 2, |
1119 | | |
1120 | | /** |
1121 | | * Adjust the last data modification timestamp to the time of clock |
1122 | | * `clockid::realtime`. |
1123 | | */ |
1124 | | __WASI_FSTFLAGS_MTIM_NOW = 1ULL << 3, |
1125 | | |
1126 | | }; |
1127 | | DEFINE_ENUM_OPERATORS(__wasi_fstflags_t) |
1128 | | |
1129 | | static_assert(sizeof(__wasi_fstflags_t) == 2, "witx calculated size"); |
1130 | | static_assert(alignof(__wasi_fstflags_t) == 2, "witx calculated align"); |
1131 | | |
1132 | | /** |
1133 | | * Flags determining the method of how paths are resolved. |
1134 | | */ |
1135 | | enum __wasi_lookupflags_t : uint32_t { |
1136 | | |
1137 | | /** |
1138 | | * As long as the resolved path corresponds to a symbolic link, it is |
1139 | | * expanded. |
1140 | | */ |
1141 | | __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW = 1ULL << 0, |
1142 | | |
1143 | | }; |
1144 | | DEFINE_ENUM_OPERATORS(__wasi_lookupflags_t) |
1145 | | |
1146 | | static_assert(sizeof(__wasi_lookupflags_t) == 4, "witx calculated size"); |
1147 | | static_assert(alignof(__wasi_lookupflags_t) == 4, "witx calculated align"); |
1148 | | |
1149 | | /** |
1150 | | * Open flags used by `path_open`. |
1151 | | */ |
1152 | | enum __wasi_oflags_t : uint16_t { |
1153 | | |
1154 | | /** |
1155 | | * Create file if it does not exist. |
1156 | | */ |
1157 | | __WASI_OFLAGS_CREAT = 1ULL << 0, |
1158 | | |
1159 | | /** |
1160 | | * Fail if not a directory. |
1161 | | */ |
1162 | | __WASI_OFLAGS_DIRECTORY = 1ULL << 1, |
1163 | | |
1164 | | /** |
1165 | | * Fail if file already exists. |
1166 | | */ |
1167 | | __WASI_OFLAGS_EXCL = 1ULL << 2, |
1168 | | |
1169 | | /** |
1170 | | * Truncate file to size 0. |
1171 | | */ |
1172 | | __WASI_OFLAGS_TRUNC = 1ULL << 3, |
1173 | | |
1174 | | }; |
1175 | | DEFINE_ENUM_OPERATORS(__wasi_oflags_t) |
1176 | | |
1177 | | static_assert(sizeof(__wasi_oflags_t) == 2, "witx calculated size"); |
1178 | | static_assert(alignof(__wasi_oflags_t) == 2, "witx calculated align"); |
1179 | | |
1180 | | /** |
1181 | | * Number of hard links to an inode. |
1182 | | */ |
1183 | | using __wasi_linkcount_t = uint64_t; |
1184 | | |
1185 | | static_assert(sizeof(__wasi_linkcount_t) == 8, "witx calculated size"); |
1186 | | static_assert(alignof(__wasi_linkcount_t) == 8, "witx calculated align"); |
1187 | | |
1188 | | /** |
1189 | | * File attributes. |
1190 | | */ |
1191 | | struct __wasi_filestat_t { |
1192 | | /** |
1193 | | * Device ID of device containing the file. |
1194 | | */ |
1195 | | __wasi_device_t dev; |
1196 | | |
1197 | | /** |
1198 | | * File serial number. |
1199 | | */ |
1200 | | __wasi_inode_t ino; |
1201 | | |
1202 | | /** |
1203 | | * File type. |
1204 | | */ |
1205 | | __wasi_filetype_t filetype; |
1206 | | |
1207 | | /** |
1208 | | * Number of hard links to the file. |
1209 | | */ |
1210 | | __wasi_linkcount_t nlink; |
1211 | | |
1212 | | /** |
1213 | | * For regular files, the file size in bytes. For symbolic links, the length |
1214 | | * in bytes of the pathname contained in the symbolic link. |
1215 | | */ |
1216 | | __wasi_filesize_t size; |
1217 | | |
1218 | | /** |
1219 | | * Last data access timestamp. |
1220 | | */ |
1221 | | __wasi_timestamp_t atim; |
1222 | | |
1223 | | /** |
1224 | | * Last data modification timestamp. |
1225 | | */ |
1226 | | __wasi_timestamp_t mtim; |
1227 | | |
1228 | | /** |
1229 | | * Last file status change timestamp. |
1230 | | */ |
1231 | | __wasi_timestamp_t ctim; |
1232 | | }; |
1233 | | |
1234 | | static_assert(sizeof(__wasi_filestat_t) == 64, "witx calculated size"); |
1235 | | static_assert(alignof(__wasi_filestat_t) == 8, "witx calculated align"); |
1236 | | static_assert(offsetof(__wasi_filestat_t, dev) == 0, "witx calculated offset"); |
1237 | | static_assert(offsetof(__wasi_filestat_t, ino) == 8, "witx calculated offset"); |
1238 | | static_assert(offsetof(__wasi_filestat_t, filetype) == 16, |
1239 | | "witx calculated offset"); |
1240 | | static_assert(offsetof(__wasi_filestat_t, nlink) == 24, |
1241 | | "witx calculated offset"); |
1242 | | static_assert(offsetof(__wasi_filestat_t, size) == 32, |
1243 | | "witx calculated offset"); |
1244 | | static_assert(offsetof(__wasi_filestat_t, atim) == 40, |
1245 | | "witx calculated offset"); |
1246 | | static_assert(offsetof(__wasi_filestat_t, mtim) == 48, |
1247 | | "witx calculated offset"); |
1248 | | static_assert(offsetof(__wasi_filestat_t, ctim) == 56, |
1249 | | "witx calculated offset"); |
1250 | | |
1251 | | /** |
1252 | | * User-provided value that may be attached to objects that is retained when |
1253 | | * extracted from the implementation. |
1254 | | */ |
1255 | | using __wasi_userdata_t = uint64_t; |
1256 | | |
1257 | | static_assert(sizeof(__wasi_userdata_t) == 8, "witx calculated size"); |
1258 | | static_assert(alignof(__wasi_userdata_t) == 8, "witx calculated align"); |
1259 | | |
1260 | | /** |
1261 | | * Type of a subscription to an event or its occurrence. |
1262 | | */ |
1263 | | enum __wasi_eventtype_t : uint8_t { |
1264 | | /** |
1265 | | * The time value of clock `subscription_clock::id` has |
1266 | | * reached timestamp `subscription_clock::timeout`. |
1267 | | */ |
1268 | | __WASI_EVENTTYPE_CLOCK = 0, |
1269 | | |
1270 | | /** |
1271 | | * File descriptor `subscription_fd_readwrite::file_descriptor` has data |
1272 | | * available for reading. This event always triggers for regular files. |
1273 | | */ |
1274 | | __WASI_EVENTTYPE_FD_READ = 1, |
1275 | | |
1276 | | /** |
1277 | | * File descriptor `subscription_fd_readwrite::file_descriptor` has capacity |
1278 | | * available for writing. This event always triggers for regular files. |
1279 | | */ |
1280 | | __WASI_EVENTTYPE_FD_WRITE = 2, |
1281 | | |
1282 | | }; |
1283 | | static_assert(sizeof(__wasi_eventtype_t) == 1, "witx calculated size"); |
1284 | | static_assert(alignof(__wasi_eventtype_t) == 1, "witx calculated align"); |
1285 | | |
1286 | | /** |
1287 | | * The state of the file descriptor subscribed to with |
1288 | | * `eventtype::fd_read` or `eventtype::fd_write`. |
1289 | | */ |
1290 | | enum __wasi_eventrwflags_t : uint16_t { |
1291 | | |
1292 | | /** |
1293 | | * The peer of this socket has closed or disconnected. |
1294 | | */ |
1295 | | __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP = 1ULL << 0, |
1296 | | |
1297 | | }; |
1298 | | DEFINE_ENUM_OPERATORS(__wasi_eventrwflags_t) |
1299 | | |
1300 | | static_assert(sizeof(__wasi_eventrwflags_t) == 2, "witx calculated size"); |
1301 | | static_assert(alignof(__wasi_eventrwflags_t) == 2, "witx calculated align"); |
1302 | | |
1303 | | /** |
1304 | | * The contents of an `event` when type is `eventtype::fd_read` or |
1305 | | * `eventtype::fd_write`. |
1306 | | */ |
1307 | | struct __wasi_event_fd_readwrite_t { |
1308 | | /** |
1309 | | * The number of bytes available for reading or writing. |
1310 | | */ |
1311 | | __wasi_filesize_t nbytes; |
1312 | | |
1313 | | /** |
1314 | | * The state of the file descriptor. |
1315 | | */ |
1316 | | __wasi_eventrwflags_t flags; |
1317 | | }; |
1318 | | |
1319 | | static_assert(sizeof(__wasi_event_fd_readwrite_t) == 16, |
1320 | | "witx calculated size"); |
1321 | | static_assert(alignof(__wasi_event_fd_readwrite_t) == 8, |
1322 | | "witx calculated align"); |
1323 | | static_assert(offsetof(__wasi_event_fd_readwrite_t, nbytes) == 0, |
1324 | | "witx calculated offset"); |
1325 | | static_assert(offsetof(__wasi_event_fd_readwrite_t, flags) == 8, |
1326 | | "witx calculated offset"); |
1327 | | |
1328 | | /** |
1329 | | * An event that occurred. |
1330 | | */ |
1331 | | struct __wasi_event_t { |
1332 | | /** |
1333 | | * User-provided value that got attached to `subscription::userdata`. |
1334 | | */ |
1335 | | __wasi_userdata_t userdata; |
1336 | | |
1337 | | /** |
1338 | | * If non-zero, an error that occurred while processing the subscription |
1339 | | * request. |
1340 | | */ |
1341 | | __wasi_errno_t error; |
1342 | | |
1343 | | /** |
1344 | | * The type of event that occured |
1345 | | */ |
1346 | | __wasi_eventtype_t type; |
1347 | | |
1348 | | /** |
1349 | | * The contents of the event, if it is an `eventtype::fd_read` or |
1350 | | * `eventtype::fd_write`. `eventtype::clock` events ignore this field. |
1351 | | */ |
1352 | | __wasi_event_fd_readwrite_t fd_readwrite; |
1353 | | }; |
1354 | | |
1355 | | static_assert(sizeof(__wasi_event_t) == 32, "witx calculated size"); |
1356 | | static_assert(alignof(__wasi_event_t) == 8, "witx calculated align"); |
1357 | | static_assert(offsetof(__wasi_event_t, userdata) == 0, |
1358 | | "witx calculated offset"); |
1359 | | static_assert(offsetof(__wasi_event_t, error) == 8, "witx calculated offset"); |
1360 | | static_assert(offsetof(__wasi_event_t, type) == 10, "witx calculated offset"); |
1361 | | static_assert(offsetof(__wasi_event_t, fd_readwrite) == 16, |
1362 | | "witx calculated offset"); |
1363 | | |
1364 | | /** |
1365 | | * Flags determining how to interpret the timestamp provided in |
1366 | | * `subscription_clock::timeout`. |
1367 | | */ |
1368 | | enum __wasi_subclockflags_t : uint16_t { |
1369 | | |
1370 | | /** |
1371 | | * If set, treat the timestamp provided in |
1372 | | * `subscription_clock::timeout` as an absolute timestamp of clock |
1373 | | * `subscription_clock::id`. If clear, treat the timestamp |
1374 | | * provided in `subscription_clock::timeout` relative to the |
1375 | | * current time value of clock `subscription_clock::id`. |
1376 | | */ |
1377 | | __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME = 1ULL << 0, |
1378 | | |
1379 | | }; |
1380 | | DEFINE_ENUM_OPERATORS(__wasi_subclockflags_t) |
1381 | | |
1382 | | static_assert(sizeof(__wasi_subclockflags_t) == 2, "witx calculated size"); |
1383 | | static_assert(alignof(__wasi_subclockflags_t) == 2, "witx calculated align"); |
1384 | | |
1385 | | /** |
1386 | | * The contents of a `subscription` when type is `eventtype::clock`. |
1387 | | */ |
1388 | | struct __wasi_subscription_clock_t { |
1389 | | /** |
1390 | | * The clock against which to compare the timestamp. |
1391 | | */ |
1392 | | __wasi_clockid_t id; |
1393 | | |
1394 | | /** |
1395 | | * The absolute or relative timestamp. |
1396 | | */ |
1397 | | __wasi_timestamp_t timeout; |
1398 | | |
1399 | | /** |
1400 | | * The amount of time that the implementation may wait additionally |
1401 | | * to coalesce with other events. |
1402 | | */ |
1403 | | __wasi_timestamp_t precision; |
1404 | | |
1405 | | /** |
1406 | | * Flags specifying whether the timeout is absolute or relative |
1407 | | */ |
1408 | | __wasi_subclockflags_t flags; |
1409 | | }; |
1410 | | |
1411 | | static_assert(sizeof(__wasi_subscription_clock_t) == 32, |
1412 | | "witx calculated size"); |
1413 | | static_assert(alignof(__wasi_subscription_clock_t) == 8, |
1414 | | "witx calculated align"); |
1415 | | static_assert(offsetof(__wasi_subscription_clock_t, id) == 0, |
1416 | | "witx calculated offset"); |
1417 | | static_assert(offsetof(__wasi_subscription_clock_t, timeout) == 8, |
1418 | | "witx calculated offset"); |
1419 | | static_assert(offsetof(__wasi_subscription_clock_t, precision) == 16, |
1420 | | "witx calculated offset"); |
1421 | | static_assert(offsetof(__wasi_subscription_clock_t, flags) == 24, |
1422 | | "witx calculated offset"); |
1423 | | |
1424 | | /** |
1425 | | * The contents of a `subscription` when type is type is |
1426 | | * `eventtype::fd_read` or `eventtype::fd_write`. |
1427 | | */ |
1428 | | struct __wasi_subscription_fd_readwrite_t { |
1429 | | /** |
1430 | | * The file descriptor on which to wait for it to become ready for reading or |
1431 | | * writing. |
1432 | | */ |
1433 | | __wasi_fd_t file_descriptor; |
1434 | | }; |
1435 | | |
1436 | | static_assert(sizeof(__wasi_subscription_fd_readwrite_t) == 4, |
1437 | | "witx calculated size"); |
1438 | | static_assert(alignof(__wasi_subscription_fd_readwrite_t) == 4, |
1439 | | "witx calculated align"); |
1440 | | static_assert(offsetof(__wasi_subscription_fd_readwrite_t, file_descriptor) == |
1441 | | 0, |
1442 | | "witx calculated offset"); |
1443 | | |
1444 | | /** |
1445 | | * The contents of a `subscription`. |
1446 | | */ |
1447 | | union __wasi_subscription_u_u_t { |
1448 | | __wasi_subscription_clock_t clock; |
1449 | | __wasi_subscription_fd_readwrite_t fd_read; |
1450 | | __wasi_subscription_fd_readwrite_t fd_write; |
1451 | | }; |
1452 | | struct __wasi_subscription_u_t { |
1453 | | __wasi_eventtype_t tag; |
1454 | | __wasi_subscription_u_u_t u; |
1455 | | }; |
1456 | | |
1457 | | static_assert(sizeof(__wasi_subscription_u_t) == 40, "witx calculated size"); |
1458 | | static_assert(alignof(__wasi_subscription_u_t) == 8, "witx calculated align"); |
1459 | | static_assert(offsetof(__wasi_subscription_u_t, u) == 8, |
1460 | | "witx calculated union offset"); |
1461 | | |
1462 | | /** |
1463 | | * Subscription to an event. |
1464 | | */ |
1465 | | struct __wasi_subscription_t { |
1466 | | /** |
1467 | | * User-provided value that is attached to the subscription in the |
1468 | | * implementation and returned through `event::userdata`. |
1469 | | */ |
1470 | | __wasi_userdata_t userdata; |
1471 | | |
1472 | | /** |
1473 | | * The type of the event to which to subscribe, and its contents |
1474 | | */ |
1475 | | __wasi_subscription_u_t u; |
1476 | | }; |
1477 | | |
1478 | | static_assert(sizeof(__wasi_subscription_t) == 48, "witx calculated size"); |
1479 | | static_assert(alignof(__wasi_subscription_t) == 8, "witx calculated align"); |
1480 | | static_assert(offsetof(__wasi_subscription_t, userdata) == 0, |
1481 | | "witx calculated offset"); |
1482 | | static_assert(offsetof(__wasi_subscription_t, u) == 8, |
1483 | | "witx calculated offset"); |
1484 | | |
1485 | | /** |
1486 | | * Exit code generated by a process when exiting. |
1487 | | */ |
1488 | | using __wasi_exitcode_t = uint32_t; |
1489 | | |
1490 | | static_assert(sizeof(__wasi_exitcode_t) == 4, "witx calculated size"); |
1491 | | static_assert(alignof(__wasi_exitcode_t) == 4, "witx calculated align"); |
1492 | | |
1493 | | /** |
1494 | | * Signal condition. |
1495 | | */ |
1496 | | enum __wasi_signal_t : uint8_t { |
1497 | | /** |
1498 | | * No signal. Note that POSIX has special semantics for `kill(pid, 0)`, |
1499 | | * so this value is reserved. |
1500 | | */ |
1501 | | __WASI_SIGNAL_NONE = 0, |
1502 | | |
1503 | | /** |
1504 | | * Hangup. |
1505 | | * Action: Terminates the process. |
1506 | | */ |
1507 | | __WASI_SIGNAL_HUP = 1, |
1508 | | |
1509 | | /** |
1510 | | * Terminate interrupt signal. |
1511 | | * Action: Terminates the process. |
1512 | | */ |
1513 | | __WASI_SIGNAL_INT = 2, |
1514 | | |
1515 | | /** |
1516 | | * Terminal quit signal. |
1517 | | * Action: Terminates the process. |
1518 | | */ |
1519 | | __WASI_SIGNAL_QUIT = 3, |
1520 | | |
1521 | | /** |
1522 | | * Illegal instruction. |
1523 | | * Action: Terminates the process. |
1524 | | */ |
1525 | | __WASI_SIGNAL_ILL = 4, |
1526 | | |
1527 | | /** |
1528 | | * Trace/breakpoint trap. |
1529 | | * Action: Terminates the process. |
1530 | | */ |
1531 | | __WASI_SIGNAL_TRAP = 5, |
1532 | | |
1533 | | /** |
1534 | | * Process abort signal. |
1535 | | * Action: Terminates the process. |
1536 | | */ |
1537 | | __WASI_SIGNAL_ABRT = 6, |
1538 | | |
1539 | | /** |
1540 | | * Access to an undefined portion of a memory object. |
1541 | | * Action: Terminates the process. |
1542 | | */ |
1543 | | __WASI_SIGNAL_BUS = 7, |
1544 | | |
1545 | | /** |
1546 | | * Erroneous arithmetic operation. |
1547 | | * Action: Terminates the process. |
1548 | | */ |
1549 | | __WASI_SIGNAL_FPE = 8, |
1550 | | |
1551 | | /** |
1552 | | * Kill. |
1553 | | * Action: Terminates the process. |
1554 | | */ |
1555 | | __WASI_SIGNAL_KILL = 9, |
1556 | | |
1557 | | /** |
1558 | | * User-defined signal 1. |
1559 | | * Action: Terminates the process. |
1560 | | */ |
1561 | | __WASI_SIGNAL_USR1 = 10, |
1562 | | |
1563 | | /** |
1564 | | * Invalid memory reference. |
1565 | | * Action: Terminates the process. |
1566 | | */ |
1567 | | __WASI_SIGNAL_SEGV = 11, |
1568 | | |
1569 | | /** |
1570 | | * User-defined signal 2. |
1571 | | * Action: Terminates the process. |
1572 | | */ |
1573 | | __WASI_SIGNAL_USR2 = 12, |
1574 | | |
1575 | | /** |
1576 | | * Write on a pipe with no one to read it. |
1577 | | * Action: Ignored. |
1578 | | */ |
1579 | | __WASI_SIGNAL_PIPE = 13, |
1580 | | |
1581 | | /** |
1582 | | * Alarm clock. |
1583 | | * Action: Terminates the process. |
1584 | | */ |
1585 | | __WASI_SIGNAL_ALRM = 14, |
1586 | | |
1587 | | /** |
1588 | | * Termination signal. |
1589 | | * Action: Terminates the process. |
1590 | | */ |
1591 | | __WASI_SIGNAL_TERM = 15, |
1592 | | |
1593 | | /** |
1594 | | * Child process terminated, stopped, or continued. |
1595 | | * Action: Ignored. |
1596 | | */ |
1597 | | __WASI_SIGNAL_CHLD = 16, |
1598 | | |
1599 | | /** |
1600 | | * Continue executing, if stopped. |
1601 | | * Action: Continues executing, if stopped. |
1602 | | */ |
1603 | | __WASI_SIGNAL_CONT = 17, |
1604 | | |
1605 | | /** |
1606 | | * Stop executing. |
1607 | | * Action: Stops executing. |
1608 | | */ |
1609 | | __WASI_SIGNAL_STOP = 18, |
1610 | | |
1611 | | /** |
1612 | | * Terminal stop signal. |
1613 | | * Action: Stops executing. |
1614 | | */ |
1615 | | __WASI_SIGNAL_TSTP = 19, |
1616 | | |
1617 | | /** |
1618 | | * Background process attempting read. |
1619 | | * Action: Stops executing. |
1620 | | */ |
1621 | | __WASI_SIGNAL_TTIN = 20, |
1622 | | |
1623 | | /** |
1624 | | * Background process attempting write. |
1625 | | * Action: Stops executing. |
1626 | | */ |
1627 | | __WASI_SIGNAL_TTOU = 21, |
1628 | | |
1629 | | /** |
1630 | | * High bandwidth data is available at a socket. |
1631 | | * Action: Ignored. |
1632 | | */ |
1633 | | __WASI_SIGNAL_URG = 22, |
1634 | | |
1635 | | /** |
1636 | | * CPU time limit exceeded. |
1637 | | * Action: Terminates the process. |
1638 | | */ |
1639 | | __WASI_SIGNAL_XCPU = 23, |
1640 | | |
1641 | | /** |
1642 | | * File size limit exceeded. |
1643 | | * Action: Terminates the process. |
1644 | | */ |
1645 | | __WASI_SIGNAL_XFSZ = 24, |
1646 | | |
1647 | | /** |
1648 | | * Virtual timer expired. |
1649 | | * Action: Terminates the process. |
1650 | | */ |
1651 | | __WASI_SIGNAL_VTALRM = 25, |
1652 | | |
1653 | | /** |
1654 | | * Profiling timer expired. |
1655 | | * Action: Terminates the process. |
1656 | | */ |
1657 | | __WASI_SIGNAL_PROF = 26, |
1658 | | |
1659 | | /** |
1660 | | * Window changed. |
1661 | | * Action: Ignored. |
1662 | | */ |
1663 | | __WASI_SIGNAL_WINCH = 27, |
1664 | | |
1665 | | /** |
1666 | | * I/O possible. |
1667 | | * Action: Terminates the process. |
1668 | | */ |
1669 | | __WASI_SIGNAL_POLL = 28, |
1670 | | |
1671 | | /** |
1672 | | * Power failure. |
1673 | | * Action: Terminates the process. |
1674 | | */ |
1675 | | __WASI_SIGNAL_PWR = 29, |
1676 | | |
1677 | | /** |
1678 | | * Bad system call. |
1679 | | * Action: Terminates the process. |
1680 | | */ |
1681 | | __WASI_SIGNAL_SYS = 30, |
1682 | | |
1683 | | }; |
1684 | | static_assert(sizeof(__wasi_signal_t) == 1, "witx calculated size"); |
1685 | | static_assert(alignof(__wasi_signal_t) == 1, "witx calculated align"); |
1686 | | |
1687 | | /** |
1688 | | * Socket address family |
1689 | | */ |
1690 | | enum __wasi_address_family_t : uint8_t { |
1691 | | __WASI_ADDRESS_FAMILY_UNSPEC = 0, |
1692 | | |
1693 | | __WASI_ADDRESS_FAMILY_INET4 = 1, |
1694 | | |
1695 | | __WASI_ADDRESS_FAMILY_INET6 = 2, |
1696 | | |
1697 | | __WASI_ADDRESS_FAMILY_AF_UNIX = 3 |
1698 | | }; |
1699 | | static_assert(sizeof(__wasi_address_family_t) == 1, "witx calculated size"); |
1700 | | static_assert(alignof(__wasi_address_family_t) == 1, "witx calculated align"); |
1701 | | |
1702 | | /** |
1703 | | * Socket address |
1704 | | */ |
1705 | | struct __wasi_address_t { |
1706 | | uint8_t_ptr buf; |
1707 | | |
1708 | | __wasi_size_t buf_len; |
1709 | | }; |
1710 | | |
1711 | | static_assert(sizeof(__wasi_address_t) == 8, "witx calculated size"); |
1712 | | static_assert(alignof(__wasi_address_t) == 4, "witx calculated align"); |
1713 | | static_assert(offsetof(__wasi_address_t, buf) == 0, "witx calculated offset"); |
1714 | | static_assert(offsetof(__wasi_address_t, buf_len) == 4, |
1715 | | "witx calculated offset"); |
1716 | | |
1717 | | enum __wasi_sock_opt_level_t : uint32_t { |
1718 | | __WASI_SOCK_OPT_LEVEL_SOL_SOCKET = 0, |
1719 | | |
1720 | | }; |
1721 | | static_assert(sizeof(__wasi_sock_opt_level_t) == 4, "witx calculated size"); |
1722 | | static_assert(alignof(__wasi_sock_opt_level_t) == 4, "witx calculated align"); |
1723 | | |
1724 | | enum __wasi_sock_opt_so_t : uint32_t { |
1725 | | __WASI_SOCK_OPT_SO_REUSEADDR = 0, |
1726 | | |
1727 | | __WASI_SOCK_OPT_SO_TYPE = 1, |
1728 | | |
1729 | | __WASI_SOCK_OPT_SO_ERROR = 2, |
1730 | | |
1731 | | __WASI_SOCK_OPT_SO_DONTROUTE = 3, |
1732 | | |
1733 | | __WASI_SOCK_OPT_SO_BROADCAST = 4, |
1734 | | |
1735 | | __WASI_SOCK_OPT_SO_SNDBUF = 5, |
1736 | | |
1737 | | __WASI_SOCK_OPT_SO_RCVBUF = 6, |
1738 | | |
1739 | | __WASI_SOCK_OPT_SO_KEEPALIVE = 7, |
1740 | | |
1741 | | __WASI_SOCK_OPT_SO_OOBINLINE = 8, |
1742 | | |
1743 | | __WASI_SOCK_OPT_SO_LINGER = 9, |
1744 | | |
1745 | | __WASI_SOCK_OPT_SO_RCVLOWAT = 10, |
1746 | | |
1747 | | __WASI_SOCK_OPT_SO_RCVTIMEO = 11, |
1748 | | |
1749 | | __WASI_SOCK_OPT_SO_SNDTIMEO = 12, |
1750 | | |
1751 | | __WASI_SOCK_OPT_SO_ACCEPTCONN = 13, |
1752 | | |
1753 | | __WASI_SOCK_OPT_SO_BINDTODEVICE = 14, |
1754 | | |
1755 | | }; |
1756 | | static_assert(sizeof(__wasi_sock_opt_so_t) == 4, "witx calculated size"); |
1757 | | static_assert(alignof(__wasi_sock_opt_so_t) == 4, "witx calculated align"); |
1758 | | |
1759 | | /** |
1760 | | * Flags provided to `getaddrinfo`. |
1761 | | */ |
1762 | | enum __wasi_aiflags_t : uint16_t { |
1763 | | |
1764 | | /** |
1765 | | * Socket address is intended for bind() |
1766 | | */ |
1767 | | __WASI_AIFLAGS_AI_PASSIVE = 1ULL << 0, |
1768 | | |
1769 | | /** |
1770 | | * Request for canonical name. |
1771 | | */ |
1772 | | __WASI_AIFLAGS_AI_CANONNAME = 1ULL << 1, |
1773 | | |
1774 | | /** |
1775 | | * Return numeric host address as name. |
1776 | | */ |
1777 | | __WASI_AIFLAGS_AI_NUMERICHOST = 1ULL << 2, |
1778 | | |
1779 | | /** |
1780 | | * Inhibit service name resolution. |
1781 | | */ |
1782 | | __WASI_AIFLAGS_AI_NUMERICSERV = 1ULL << 3, |
1783 | | |
1784 | | /** |
1785 | | * If no IPv6 addresses are found, query for IPv4 addresses and return them to |
1786 | | * the caller as IPv4-mapped IPv6 addresses. |
1787 | | */ |
1788 | | __WASI_AIFLAGS_AI_V4MAPPED = 1ULL << 4, |
1789 | | |
1790 | | /** |
1791 | | * Query for both IPv4 and IPv6 addresses. |
1792 | | */ |
1793 | | __WASI_AIFLAGS_AI_ALL = 1ULL << 5, |
1794 | | |
1795 | | /** |
1796 | | * Query for IPv4 addresses only when an IPv4 address is configured; query for |
1797 | | * IPv6 addresses only when an IPv6 address is configured. |
1798 | | */ |
1799 | | __WASI_AIFLAGS_AI_ADDRCONFIG = 1ULL << 6, |
1800 | | |
1801 | | }; |
1802 | | DEFINE_ENUM_OPERATORS(__wasi_aiflags_t) |
1803 | | |
1804 | | static_assert(sizeof(__wasi_aiflags_t) == 2, "witx calculated size"); |
1805 | | static_assert(alignof(__wasi_aiflags_t) == 2, "witx calculated align"); |
1806 | | |
1807 | | /** |
1808 | | * Socket type |
1809 | | */ |
1810 | | enum __wasi_sock_type_t : uint8_t { |
1811 | | __WASI_SOCK_TYPE_SOCK_ANY = 0, |
1812 | | |
1813 | | __WASI_SOCK_TYPE_SOCK_DGRAM = 1, |
1814 | | |
1815 | | __WASI_SOCK_TYPE_SOCK_STREAM = 2, |
1816 | | |
1817 | | }; |
1818 | | static_assert(sizeof(__wasi_sock_type_t) == 1, "witx calculated size"); |
1819 | | static_assert(alignof(__wasi_sock_type_t) == 1, "witx calculated align"); |
1820 | | |
1821 | | /** |
1822 | | * Protocol |
1823 | | */ |
1824 | | enum __wasi_protocol_t : uint8_t { |
1825 | | __WASI_PROTOCOL_IPPROTO_IP = 0, |
1826 | | |
1827 | | __WASI_PROTOCOL_IPPROTO_TCP = 1, |
1828 | | |
1829 | | __WASI_PROTOCOL_IPPROTO_UDP = 2, |
1830 | | |
1831 | | }; |
1832 | | static_assert(sizeof(__wasi_protocol_t) == 1, "witx calculated size"); |
1833 | | static_assert(alignof(__wasi_protocol_t) == 1, "witx calculated align"); |
1834 | | |
1835 | | /** |
1836 | | * Socket address_in provided for getaddrinfo |
1837 | | */ |
1838 | | struct __wasi_sockaddr_in_t { |
1839 | | __wasi_address_family_t sin_family; |
1840 | | |
1841 | | uint16_t sin_port; |
1842 | | |
1843 | | __wasi_address_t sin_addr; |
1844 | | |
1845 | | __wasi_size_t sin_zero_len; |
1846 | | |
1847 | | uint8_t_ptr sin_zero; |
1848 | | }; |
1849 | | |
1850 | | static_assert(sizeof(__wasi_sockaddr_in_t) == 20, "witx calculated size"); |
1851 | | static_assert(alignof(__wasi_sockaddr_in_t) == 4, "witx calculated align"); |
1852 | | static_assert(offsetof(__wasi_sockaddr_in_t, sin_family) == 0, |
1853 | | "witx calculated offset"); |
1854 | | static_assert(offsetof(__wasi_sockaddr_in_t, sin_port) == 2, |
1855 | | "witx calculated offset"); |
1856 | | static_assert(offsetof(__wasi_sockaddr_in_t, sin_addr) == 4, |
1857 | | "witx calculated offset"); |
1858 | | static_assert(offsetof(__wasi_sockaddr_in_t, sin_zero_len) == 12, |
1859 | | "witx calculated offset"); |
1860 | | static_assert(offsetof(__wasi_sockaddr_in_t, sin_zero) == 16, |
1861 | | "witx calculated offset"); |
1862 | | |
1863 | | /** |
1864 | | * Socket address provided for getaddrinfo |
1865 | | */ |
1866 | | struct __wasi_sockaddr_t { |
1867 | | __wasi_address_family_t sa_family; |
1868 | | |
1869 | | __wasi_size_t sa_data_len; |
1870 | | |
1871 | | uint8_t_ptr sa_data; |
1872 | | }; |
1873 | | |
1874 | | static_assert(sizeof(__wasi_sockaddr_t) == 12, "witx calculated size"); |
1875 | | static_assert(alignof(__wasi_sockaddr_t) == 4, "witx calculated align"); |
1876 | | static_assert(offsetof(__wasi_sockaddr_t, sa_family) == 0, |
1877 | | "witx calculated offset"); |
1878 | | static_assert(offsetof(__wasi_sockaddr_t, sa_data_len) == 4, |
1879 | | "witx calculated offset"); |
1880 | | static_assert(offsetof(__wasi_sockaddr_t, sa_data) == 8, |
1881 | | "witx calculated offset"); |
1882 | | |
1883 | | /** |
1884 | | * Address information |
1885 | | */ |
1886 | | struct __wasi_addrinfo_t { |
1887 | | __wasi_aiflags_t ai_flags; |
1888 | | |
1889 | | __wasi_address_family_t ai_family; |
1890 | | |
1891 | | __wasi_sock_type_t ai_socktype; |
1892 | | |
1893 | | __wasi_protocol_t ai_protocol; |
1894 | | |
1895 | | __wasi_size_t ai_addrlen; |
1896 | | |
1897 | | uint8_t_ptr ai_addr; |
1898 | | |
1899 | | uint8_t_ptr ai_canonname; |
1900 | | |
1901 | | __wasi_size_t ai_canonname_len; |
1902 | | |
1903 | | uint8_t_ptr ai_next; |
1904 | | }; |
1905 | | |
1906 | | static_assert(sizeof(__wasi_addrinfo_t) == 28, "witx calculated size"); |
1907 | | static_assert(alignof(__wasi_addrinfo_t) == 4, "witx calculated align"); |
1908 | | static_assert(offsetof(__wasi_addrinfo_t, ai_flags) == 0, |
1909 | | "witx calculated offset"); |
1910 | | static_assert(offsetof(__wasi_addrinfo_t, ai_family) == 2, |
1911 | | "witx calculated offset"); |
1912 | | static_assert(offsetof(__wasi_addrinfo_t, ai_socktype) == 3, |
1913 | | "witx calculated offset"); |
1914 | | static_assert(offsetof(__wasi_addrinfo_t, ai_protocol) == 4, |
1915 | | "witx calculated offset"); |
1916 | | static_assert(offsetof(__wasi_addrinfo_t, ai_addrlen) == 8, |
1917 | | "witx calculated offset"); |
1918 | | static_assert(offsetof(__wasi_addrinfo_t, ai_addr) == 12, |
1919 | | "witx calculated offset"); |
1920 | | static_assert(offsetof(__wasi_addrinfo_t, ai_canonname) == 16, |
1921 | | "witx calculated offset"); |
1922 | | static_assert(offsetof(__wasi_addrinfo_t, ai_canonname_len) == 20, |
1923 | | "witx calculated offset"); |
1924 | | static_assert(offsetof(__wasi_addrinfo_t, ai_next) == 24, |
1925 | | "witx calculated offset"); |
1926 | | |
1927 | | /** |
1928 | | * Flags provided to `sock_recv`. |
1929 | | */ |
1930 | | enum __wasi_riflags_t : uint16_t { |
1931 | | |
1932 | | /** |
1933 | | * Returns the message without removing it from the socket's receive queue. |
1934 | | */ |
1935 | | __WASI_RIFLAGS_RECV_PEEK = 1ULL << 0, |
1936 | | |
1937 | | /** |
1938 | | * On byte-stream sockets, block until the full amount of data can be |
1939 | | * returned. |
1940 | | */ |
1941 | | __WASI_RIFLAGS_RECV_WAITALL = 1ULL << 1, |
1942 | | |
1943 | | }; |
1944 | | DEFINE_ENUM_OPERATORS(__wasi_riflags_t) |
1945 | | |
1946 | | static_assert(sizeof(__wasi_riflags_t) == 2, "witx calculated size"); |
1947 | | static_assert(alignof(__wasi_riflags_t) == 2, "witx calculated align"); |
1948 | | |
1949 | | /** |
1950 | | * Flags returned by `sock_recv`. |
1951 | | */ |
1952 | | enum __wasi_roflags_t : uint16_t { |
1953 | | |
1954 | | /** |
1955 | | * Returned by `sock_recv`: Message data has been truncated. |
1956 | | */ |
1957 | | __WASI_ROFLAGS_RECV_DATA_TRUNCATED = 1ULL << 0, |
1958 | | |
1959 | | }; |
1960 | | DEFINE_ENUM_OPERATORS(__wasi_roflags_t) |
1961 | | |
1962 | | static_assert(sizeof(__wasi_roflags_t) == 2, "witx calculated size"); |
1963 | | static_assert(alignof(__wasi_roflags_t) == 2, "witx calculated align"); |
1964 | | |
1965 | | /** |
1966 | | * Flags provided to `sock_send`. As there are currently no flags |
1967 | | * defined, it must be set to zero. |
1968 | | */ |
1969 | | using __wasi_siflags_t = uint16_t; |
1970 | | |
1971 | | static_assert(sizeof(__wasi_siflags_t) == 2, "witx calculated size"); |
1972 | | static_assert(alignof(__wasi_siflags_t) == 2, "witx calculated align"); |
1973 | | |
1974 | | /** |
1975 | | * Which channels on a socket to shut down. |
1976 | | */ |
1977 | | enum __wasi_sdflags_t : uint8_t { |
1978 | | |
1979 | | /** |
1980 | | * Disables further receive operations. |
1981 | | */ |
1982 | | __WASI_SDFLAGS_RD = 1ULL << 0, |
1983 | | |
1984 | | /** |
1985 | | * Disables further send operations. |
1986 | | */ |
1987 | | __WASI_SDFLAGS_WR = 1ULL << 1, |
1988 | | |
1989 | | }; |
1990 | | DEFINE_ENUM_OPERATORS(__wasi_sdflags_t) |
1991 | | |
1992 | | static_assert(sizeof(__wasi_sdflags_t) == 1, "witx calculated size"); |
1993 | | static_assert(alignof(__wasi_sdflags_t) == 1, "witx calculated align"); |
1994 | | |
1995 | | /** |
1996 | | * Identifiers for preopened capabilities. |
1997 | | */ |
1998 | | enum __wasi_preopentype_t : uint8_t { |
1999 | | /** |
2000 | | * A pre-opened directory. |
2001 | | */ |
2002 | | __WASI_PREOPENTYPE_DIR = 0, |
2003 | | |
2004 | | }; |
2005 | | static_assert(sizeof(__wasi_preopentype_t) == 1, "witx calculated size"); |
2006 | | static_assert(alignof(__wasi_preopentype_t) == 1, "witx calculated align"); |
2007 | | |
2008 | | /** |
2009 | | * The contents of a $prestat when type is `preopentype::dir`. |
2010 | | */ |
2011 | | struct __wasi_prestat_dir_t { |
2012 | | /** |
2013 | | * The length of the directory name for use with `fd_prestat_dir_name`. |
2014 | | */ |
2015 | | __wasi_size_t pr_name_len; |
2016 | | }; |
2017 | | |
2018 | | static_assert(sizeof(__wasi_prestat_dir_t) == 4, "witx calculated size"); |
2019 | | static_assert(alignof(__wasi_prestat_dir_t) == 4, "witx calculated align"); |
2020 | | static_assert(offsetof(__wasi_prestat_dir_t, pr_name_len) == 0, |
2021 | | "witx calculated offset"); |
2022 | | |
2023 | | /** |
2024 | | * Information about a pre-opened capability. |
2025 | | */ |
2026 | | union __wasi_prestat_u_t { |
2027 | | __wasi_prestat_dir_t dir; |
2028 | | }; |
2029 | | struct __wasi_prestat_t { |
2030 | | __wasi_preopentype_t tag; |
2031 | | __wasi_prestat_u_t u; |
2032 | | }; |
2033 | | |
2034 | | static_assert(sizeof(__wasi_prestat_t) == 8, "witx calculated size"); |
2035 | | static_assert(alignof(__wasi_prestat_t) == 4, "witx calculated align"); |
2036 | | static_assert(offsetof(__wasi_prestat_t, u) == 4, |
2037 | | "witx calculated union offset"); |