authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-05-18 16:00:06+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-05-20 16:54:00+02:00
log7b74de7d717e2167337ba8a23e73baf99239529f
tree2eb631f92e8df09ab388b3d3ea226f07f224d69e
parent782cfedaf6452b00df948132284da65fa3ac8fdd

wasi,cc: fix naming and add stubs for building

Rename include dir to match the convention: from `wasm32-wasi` to `wasm-wasi-musl` Add building stubs which will be used to build and cache WASI libc sysroot.

394 files changed, 14285 insertions(+), 14250 deletions(-)

CMakeLists.txt+1
......@@ -593,6 +593,7 @@ set(ZIG_STAGE2_SOURCES
593593 "${CMAKE_SOURCE_DIR}/src/translate_c/ast.zig"
594594 "${CMAKE_SOURCE_DIR}/src/type.zig"
595595 "${CMAKE_SOURCE_DIR}/src/value.zig"
596 "${CMAKE_SOURCE_DIR}/src/wasi_libc.zig"
596597 "${CMAKE_SOURCE_DIR}/src/windows_sdk.zig"
597598 "${CMAKE_SOURCE_DIR}/src/Zir.zig"
598599 "${CMAKE_SOURCE_DIR}/src/Sema.zig"
lib/libc/include/wasm-wasi-musl/__errno.h created+20
......@@ -0,0 +1,20 @@
1#ifndef __wasilibc___errno_h
2#define __wasilibc___errno_h
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#ifdef __cplusplus
9extern thread_local int errno;
10#else
11extern _Thread_local int errno;
12#endif
13
14#define errno errno
15
16#ifdef __cplusplus
17}
18#endif
19
20#endif
lib/libc/include/wasm-wasi-musl/__errno_values.h created+86
......@@ -0,0 +1,86 @@
1#ifndef __wasilibc___errno_values_h
2#define __wasilibc___errno_values_h
3
4#include <wasi/api.h>
5
6#define E2BIG __WASI_ERRNO_2BIG
7#define EACCES __WASI_ERRNO_ACCES
8#define EADDRINUSE __WASI_ERRNO_ADDRINUSE
9#define EADDRNOTAVAIL __WASI_ERRNO_ADDRNOTAVAIL
10#define EAFNOSUPPORT __WASI_ERRNO_AFNOSUPPORT
11#define EAGAIN __WASI_ERRNO_AGAIN
12#define EALREADY __WASI_ERRNO_ALREADY
13#define EBADF __WASI_ERRNO_BADF
14#define EBADMSG __WASI_ERRNO_BADMSG
15#define EBUSY __WASI_ERRNO_BUSY
16#define ECANCELED __WASI_ERRNO_CANCELED
17#define ECHILD __WASI_ERRNO_CHILD
18#define ECONNABORTED __WASI_ERRNO_CONNABORTED
19#define ECONNREFUSED __WASI_ERRNO_CONNREFUSED
20#define ECONNRESET __WASI_ERRNO_CONNRESET
21#define EDEADLK __WASI_ERRNO_DEADLK
22#define EDESTADDRREQ __WASI_ERRNO_DESTADDRREQ
23#define EDOM __WASI_ERRNO_DOM
24#define EDQUOT __WASI_ERRNO_DQUOT
25#define EEXIST __WASI_ERRNO_EXIST
26#define EFAULT __WASI_ERRNO_FAULT
27#define EFBIG __WASI_ERRNO_FBIG
28#define EHOSTUNREACH __WASI_ERRNO_HOSTUNREACH
29#define EIDRM __WASI_ERRNO_IDRM
30#define EILSEQ __WASI_ERRNO_ILSEQ
31#define EINPROGRESS __WASI_ERRNO_INPROGRESS
32#define EINTR __WASI_ERRNO_INTR
33#define EINVAL __WASI_ERRNO_INVAL
34#define EIO __WASI_ERRNO_IO
35#define EISCONN __WASI_ERRNO_ISCONN
36#define EISDIR __WASI_ERRNO_ISDIR
37#define ELOOP __WASI_ERRNO_LOOP
38#define EMFILE __WASI_ERRNO_MFILE
39#define EMLINK __WASI_ERRNO_MLINK
40#define EMSGSIZE __WASI_ERRNO_MSGSIZE
41#define EMULTIHOP __WASI_ERRNO_MULTIHOP
42#define ENAMETOOLONG __WASI_ERRNO_NAMETOOLONG
43#define ENETDOWN __WASI_ERRNO_NETDOWN
44#define ENETRESET __WASI_ERRNO_NETRESET
45#define ENETUNREACH __WASI_ERRNO_NETUNREACH
46#define ENFILE __WASI_ERRNO_NFILE
47#define ENOBUFS __WASI_ERRNO_NOBUFS
48#define ENODEV __WASI_ERRNO_NODEV
49#define ENOENT __WASI_ERRNO_NOENT
50#define ENOEXEC __WASI_ERRNO_NOEXEC
51#define ENOLCK __WASI_ERRNO_NOLCK
52#define ENOLINK __WASI_ERRNO_NOLINK
53#define ENOMEM __WASI_ERRNO_NOMEM
54#define ENOMSG __WASI_ERRNO_NOMSG
55#define ENOPROTOOPT __WASI_ERRNO_NOPROTOOPT
56#define ENOSPC __WASI_ERRNO_NOSPC
57#define ENOSYS __WASI_ERRNO_NOSYS
58#define ENOTCONN __WASI_ERRNO_NOTCONN
59#define ENOTDIR __WASI_ERRNO_NOTDIR
60#define ENOTEMPTY __WASI_ERRNO_NOTEMPTY
61#define ENOTRECOVERABLE __WASI_ERRNO_NOTRECOVERABLE
62#define ENOTSOCK __WASI_ERRNO_NOTSOCK
63#define ENOTSUP __WASI_ERRNO_NOTSUP
64#define ENOTTY __WASI_ERRNO_NOTTY
65#define ENXIO __WASI_ERRNO_NXIO
66#define EOVERFLOW __WASI_ERRNO_OVERFLOW
67#define EOWNERDEAD __WASI_ERRNO_OWNERDEAD
68#define EPERM __WASI_ERRNO_PERM
69#define EPIPE __WASI_ERRNO_PIPE
70#define EPROTO __WASI_ERRNO_PROTO
71#define EPROTONOSUPPORT __WASI_ERRNO_PROTONOSUPPORT
72#define EPROTOTYPE __WASI_ERRNO_PROTOTYPE
73#define ERANGE __WASI_ERRNO_RANGE
74#define EROFS __WASI_ERRNO_ROFS
75#define ESPIPE __WASI_ERRNO_SPIPE
76#define ESRCH __WASI_ERRNO_SRCH
77#define ESTALE __WASI_ERRNO_STALE
78#define ETIMEDOUT __WASI_ERRNO_TIMEDOUT
79#define ETXTBSY __WASI_ERRNO_TXTBSY
80#define EXDEV __WASI_ERRNO_XDEV
81#define ENOTCAPABLE __WASI_ERRNO_NOTCAPABLE
82
83#define EOPNOTSUPP ENOTSUP
84#define EWOULDBLOCK EAGAIN
85
86#endif
lib/libc/include/wasm-wasi-musl/__fd_set.h created+76
......@@ -0,0 +1,76 @@
1#ifndef __wasilibc___fd_set_h
2#define __wasilibc___fd_set_h
3
4#include <__typedef_fd_set.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10static __inline void FD_CLR(int __fd, fd_set *__set) {
11 size_t __n = __set->__nfds;
12 for (int *__p = __set->__fds, *__e = __p + __n;
13 __p < __e; ++__p)
14 {
15 if (*__p == __fd) {
16 *__p = __e[-1];
17 __set->__nfds = __n - 1;
18 return;
19 }
20 }
21}
22
23static __inline
24#ifdef __cplusplus
25bool
26#else
27_Bool
28#endif
29FD_ISSET(int __fd, const fd_set *__set)
30{
31 size_t __n = __set->__nfds;
32 for (const int *__p = __set->__fds, *__e = __p + __n;
33 __p < __e; ++__p)
34 {
35 if (*__p == __fd) {
36 return 1;
37 }
38 }
39 return 0;
40}
41
42static __inline void FD_SET(int __fd, fd_set *__set) {
43 size_t __n = __set->__nfds;
44 for (const int *__p = __set->__fds, *__e = __p + __n;
45 __p < __e; ++__p)
46 {
47 if (*__p == __fd) {
48 return;
49 }
50 }
51 __set->__nfds = __n + 1;
52 __set->__fds[__n] = __fd;
53}
54
55static __inline void FD_ZERO(fd_set *__set) {
56 __set->__nfds = 0;
57}
58
59static __inline void FD_COPY(const fd_set *__restrict __from,
60 fd_set *__restrict __to) {
61 size_t __n = __from->__nfds;
62 __to->__nfds = __n;
63 __builtin_memcpy(__to->__fds, __from->__fds, __n * sizeof(int));
64}
65
66#define FD_CLR(fd, set) (FD_CLR((fd), (set)))
67#define FD_ISSET(fd, set) (FD_ISSET((fd), (set)))
68#define FD_SET(fd, set) (FD_SET((fd), (set)))
69#define FD_ZERO(set) (FD_ZERO((set)))
70#define FD_COPY(from, to) (FD_COPY((from), (to)))
71
72#ifdef __cplusplus
73}
74#endif
75
76#endif
lib/libc/include/wasm-wasi-musl/__function___isatty.h created+14
......@@ -0,0 +1,14 @@
1#ifndef __wasilibc___function___isatty_h
2#define __wasilibc___function___isatty_h
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8int __isatty(int fd);
9
10#ifdef __cplusplus
11}
12#endif
13
14#endif
lib/libc/include/wasm-wasi-musl/__functions_malloc.h created+26
......@@ -0,0 +1,26 @@
1#ifndef __wasilibc___functions_malloc_h
2#define __wasilibc___functions_malloc_h
3
4#define __need_size_t
5#define __need_wchar_t
6#define __need_NULL
7#include <stddef.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13void *malloc(size_t __size) __attribute__((__malloc__, __warn_unused_result__));
14void free(void *__ptr);
15void *calloc(size_t __nmemb, size_t __size) __attribute__((__malloc__, __warn_unused_result__));
16void *realloc(void *__ptr, size_t __size) __attribute__((__warn_unused_result__));
17
18#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
19void *reallocarray(void *__ptr, size_t __nmemb, size_t __size) __attribute__((__warn_unused_result__));
20#endif
21
22#ifdef __cplusplus
23}
24#endif
25
26#endif
lib/libc/include/wasm-wasi-musl/__functions_memcpy.h created+20
......@@ -0,0 +1,20 @@
1#ifndef __wasilibc___functions_memcpy_h
2#define __wasilibc___functions_memcpy_h
3
4#define __need_size_t
5#define __need_NULL
6#include <stddef.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12void *memcpy(void *__restrict__ __dst, const void *__restrict__ __src, size_t __n) __attribute__((__nothrow__, __leaf__, __nonnull__(1, 2)));
13void *memmove(void *__dst, const void *__src, size_t __n) __attribute__((__nothrow__, __leaf__, __nonnull__(1, 2)));
14void *memset(void *__dst, int __c, size_t __n) __attribute__((__nothrow__, __leaf__, __nonnull__(1)));
15
16#ifdef __cplusplus
17}
18#endif
19
20#endif
lib/libc/include/wasm-wasi-musl/__header_dirent.h created+39
......@@ -0,0 +1,39 @@
1#ifndef __wasilibc___header_dirent_h
2#define __wasilibc___header_dirent_h
3
4#include <wasi/api.h>
5
6#define DT_BLK __WASI_FILETYPE_BLOCK_DEVICE
7#define DT_CHR __WASI_FILETYPE_CHARACTER_DEVICE
8#define DT_DIR __WASI_FILETYPE_DIRECTORY
9#define DT_FIFO __WASI_FILETYPE_SOCKET_STREAM
10#define DT_LNK __WASI_FILETYPE_SYMBOLIC_LINK
11#define DT_REG __WASI_FILETYPE_REGULAR_FILE
12#define DT_UNKNOWN __WASI_FILETYPE_UNKNOWN
13
14#include <__struct_dirent.h>
15#include <__typedef_DIR.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21int closedir(DIR *);
22DIR *opendir(const char *);
23DIR *fdopendir(int);
24int fdclosedir(DIR *);
25struct dirent *readdir(DIR *);
26void rewinddir(DIR *);
27void seekdir(DIR *, long);
28long telldir(DIR *);
29DIR *opendirat(int, const char *);
30void rewinddir(DIR *);
31int scandirat(int, const char *, struct dirent ***,
32 int (*)(const struct dirent *),
33 int (*)(const struct dirent **, const struct dirent **));
34
35#ifdef __cplusplus
36}
37#endif
38
39#endif
lib/libc/include/wasm-wasi-musl/__header_fcntl.h created+61
......@@ -0,0 +1,61 @@
1#ifndef __wasilibc___header_fcntl_h
2#define __wasilibc___header_fcntl_h
3
4#include <wasi/api.h>
5#include <__seek.h>
6#include <__mode_t.h>
7
8#define O_APPEND __WASI_FDFLAGS_APPEND
9#define O_DSYNC __WASI_FDFLAGS_DSYNC
10#define O_NONBLOCK __WASI_FDFLAGS_NONBLOCK
11#define O_RSYNC __WASI_FDFLAGS_RSYNC
12#define O_SYNC __WASI_FDFLAGS_SYNC
13#define O_CREAT (__WASI_OFLAGS_CREAT << 12)
14#define O_DIRECTORY (__WASI_OFLAGS_DIRECTORY << 12)
15#define O_EXCL (__WASI_OFLAGS_EXCL << 12)
16#define O_TRUNC (__WASI_OFLAGS_TRUNC << 12)
17
18#define O_NOFOLLOW (0x01000000)
19#define O_EXEC (0x02000000)
20#define O_RDONLY (0x04000000)
21#define O_SEARCH (0x08000000)
22#define O_WRONLY (0x10000000)
23
24/*
25 * O_CLOEXEC is defined to be zero, as WASI has no exec-style functions.
26 */
27#define O_CLOEXEC (0)
28
29/*
30 * O_TTY_INIT is defined to be zero, meaning that WASI implementations are
31 * expected to always initialize a terminal the first time it's opened.
32 */
33#define O_TTY_INIT (0)
34
35#define O_NOCTTY (0)
36
37#define O_RDWR (O_RDONLY | O_WRONLY)
38#define O_ACCMODE (O_EXEC | O_RDWR | O_SEARCH)
39
40#define POSIX_FADV_DONTNEED __WASI_ADVICE_DONTNEED
41#define POSIX_FADV_NOREUSE __WASI_ADVICE_NOREUSE
42#define POSIX_FADV_NORMAL __WASI_ADVICE_NORMAL
43#define POSIX_FADV_RANDOM __WASI_ADVICE_RANDOM
44#define POSIX_FADV_SEQUENTIAL __WASI_ADVICE_SEQUENTIAL
45#define POSIX_FADV_WILLNEED __WASI_ADVICE_WILLNEED
46
47#define F_GETFD (1)
48#define F_SETFD (2)
49#define F_GETFL (3)
50#define F_SETFL (4)
51
52#define FD_CLOEXEC (1)
53
54#define AT_EACCESS (0x0)
55#define AT_SYMLINK_NOFOLLOW (0x1)
56#define AT_SYMLINK_FOLLOW (0x2)
57#define AT_REMOVEDIR (0x4)
58
59#define AT_FDCWD (-2)
60
61#endif
lib/libc/include/wasm-wasi-musl/__header_inttypes.h created+182
......@@ -0,0 +1,182 @@
1#ifndef __wasilibc___include_inttypes_h
2#define __wasilibc___include_inttypes_h
3
4#include <stdint.h>
5
6#define __need_wchar_t
7#include <stddef.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13typedef struct { intmax_t quot, rem; } imaxdiv_t;
14
15intmax_t imaxabs(intmax_t);
16imaxdiv_t imaxdiv(intmax_t, intmax_t);
17intmax_t strtoimax(const char *__restrict, char **__restrict, int);
18uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
19intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
20uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
21
22#define PRId16 __INT16_FMTd__
23#define PRIi16 __INT16_FMTi__
24#define PRId32 __INT32_FMTd__
25#define PRIi32 __INT32_FMTi__
26#define PRId64 __INT64_FMTd__
27#define PRIi64 __INT64_FMTi__
28#define PRId8 __INT8_FMTd__
29#define PRIi8 __INT8_FMTi__
30#define PRIdMAX __INTMAX_FMTd__
31#define PRIiMAX __INTMAX_FMTi__
32#define PRIdPTR __INTPTR_FMTd__
33#define PRIiPTR __INTPTR_FMTi__
34#define PRIdFAST16 __INT_FAST16_FMTd__
35#define PRIiFAST16 __INT_FAST16_FMTi__
36#define PRIdFAST32 __INT_FAST32_FMTd__
37#define PRIiFAST32 __INT_FAST32_FMTi__
38#define PRIdFAST64 __INT_FAST64_FMTd__
39#define PRIiFAST64 __INT_FAST64_FMTi__
40#define PRIdFAST8 __INT_FAST8_FMTd__
41#define PRIiFAST8 __INT_FAST8_FMTi__
42#define PRIdLEAST16 __INT_LEAST16_FMTd__
43#define PRIiLEAST16 __INT_LEAST16_FMTi__
44#define PRIdLEAST32 __INT_LEAST32_FMTd__
45#define PRIiLEAST32 __INT_LEAST32_FMTi__
46#define PRIdLEAST64 __INT_LEAST64_FMTd__
47#define PRIiLEAST64 __INT_LEAST64_FMTi__
48#define PRIdLEAST8 __INT_LEAST8_FMTd__
49#define PRIiLEAST8 __INT_LEAST8_FMTi__
50#define PRIX16 __UINT16_FMTX__
51#define PRIo16 __UINT16_FMTo__
52#define PRIu16 __UINT16_FMTu__
53#define PRIx16 __UINT16_FMTx__
54#define PRIX32 __UINT32_FMTX__
55#define PRIo32 __UINT32_FMTo__
56#define PRIu32 __UINT32_FMTu__
57#define PRIx32 __UINT32_FMTx__
58#define PRIX64 __UINT64_FMTX__
59#define PRIo64 __UINT64_FMTo__
60#define PRIu64 __UINT64_FMTu__
61#define PRIx64 __UINT64_FMTx__
62#define PRIX8 __UINT8_FMTX__
63#define PRIo8 __UINT8_FMTo__
64#define PRIu8 __UINT8_FMTu__
65#define PRIx8 __UINT8_FMTx__
66#define PRIXMAX __UINTMAX_FMTX__
67#define PRIoMAX __UINTMAX_FMTo__
68#define PRIuMAX __UINTMAX_FMTu__
69#define PRIxMAX __UINTMAX_FMTx__
70#define PRIXPTR __UINTPTR_FMTX__
71#define PRIoPTR __UINTPTR_FMTo__
72#define PRIuPTR __UINTPTR_FMTu__
73#define PRIxPTR __UINTPTR_FMTx__
74#define PRIXFAST16 __UINT_FAST16_FMTX__
75#define PRIoFAST16 __UINT_FAST16_FMTo__
76#define PRIuFAST16 __UINT_FAST16_FMTu__
77#define PRIxFAST16 __UINT_FAST16_FMTx__
78#define PRIXFAST32 __UINT_FAST32_FMTX__
79#define PRIoFAST32 __UINT_FAST32_FMTo__
80#define PRIuFAST32 __UINT_FAST32_FMTu__
81#define PRIxFAST32 __UINT_FAST32_FMTx__
82#define PRIXFAST64 __UINT_FAST64_FMTX__
83#define PRIoFAST64 __UINT_FAST64_FMTo__
84#define PRIuFAST64 __UINT_FAST64_FMTu__
85#define PRIxFAST64 __UINT_FAST64_FMTx__
86#define PRIXFAST8 __UINT_FAST8_FMTX__
87#define PRIoFAST8 __UINT_FAST8_FMTo__
88#define PRIuFAST8 __UINT_FAST8_FMTu__
89#define PRIxFAST8 __UINT_FAST8_FMTx__
90#define PRIXLEAST16 __UINT_LEAST16_FMTX__
91#define PRIoLEAST16 __UINT_LEAST16_FMTo__
92#define PRIuLEAST16 __UINT_LEAST16_FMTu__
93#define PRIxLEAST16 __UINT_LEAST16_FMTx__
94#define PRIXLEAST32 __UINT_LEAST32_FMTX__
95#define PRIoLEAST32 __UINT_LEAST32_FMTo__
96#define PRIuLEAST32 __UINT_LEAST32_FMTu__
97#define PRIxLEAST32 __UINT_LEAST32_FMTx__
98#define PRIXLEAST64 __UINT_LEAST64_FMTX__
99#define PRIoLEAST64 __UINT_LEAST64_FMTo__
100#define PRIuLEAST64 __UINT_LEAST64_FMTu__
101#define PRIxLEAST64 __UINT_LEAST64_FMTx__
102#define PRIXLEAST8 __UINT_LEAST8_FMTX__
103#define PRIoLEAST8 __UINT_LEAST8_FMTo__
104#define PRIuLEAST8 __UINT_LEAST8_FMTu__
105#define PRIxLEAST8 __UINT_LEAST8_FMTx__
106
107#define SCNd16 __INT16_FMTd__
108#define SCNi16 __INT16_FMTi__
109#define SCNd32 __INT32_FMTd__
110#define SCNi32 __INT32_FMTi__
111#define SCNd64 __INT64_FMTd__
112#define SCNi64 __INT64_FMTi__
113#define SCNd8 __INT8_FMTd__
114#define SCNi8 __INT8_FMTi__
115#define SCNdMAX __INTMAX_FMTd__
116#define SCNiMAX __INTMAX_FMTi__
117#define SCNdPTR __INTPTR_FMTd__
118#define SCNiPTR __INTPTR_FMTi__
119#define SCNdFAST16 __INT_FAST16_FMTd__
120#define SCNiFAST16 __INT_FAST16_FMTi__
121#define SCNdFAST32 __INT_FAST32_FMTd__
122#define SCNiFAST32 __INT_FAST32_FMTi__
123#define SCNdFAST64 __INT_FAST64_FMTd__
124#define SCNiFAST64 __INT_FAST64_FMTi__
125#define SCNdFAST8 __INT_FAST8_FMTd__
126#define SCNiFAST8 __INT_FAST8_FMTi__
127#define SCNdLEAST16 __INT_LEAST16_FMTd__
128#define SCNiLEAST16 __INT_LEAST16_FMTi__
129#define SCNdLEAST32 __INT_LEAST32_FMTd__
130#define SCNiLEAST32 __INT_LEAST32_FMTi__
131#define SCNdLEAST64 __INT_LEAST64_FMTd__
132#define SCNiLEAST64 __INT_LEAST64_FMTi__
133#define SCNdLEAST8 __INT_LEAST8_FMTd__
134#define SCNiLEAST8 __INT_LEAST8_FMTi__
135#define SCNo16 __UINT16_FMTo__
136#define SCNu16 __UINT16_FMTu__
137#define SCNx16 __UINT16_FMTx__
138#define SCNo32 __UINT32_FMTo__
139#define SCNu32 __UINT32_FMTu__
140#define SCNx32 __UINT32_FMTx__
141#define SCNo64 __UINT64_FMTo__
142#define SCNu64 __UINT64_FMTu__
143#define SCNx64 __UINT64_FMTx__
144#define SCNo8 __UINT8_FMTo__
145#define SCNu8 __UINT8_FMTu__
146#define SCNx8 __UINT8_FMTx__
147#define SCNoMAX __UINTMAX_FMTo__
148#define SCNuMAX __UINTMAX_FMTu__
149#define SCNxMAX __UINTMAX_FMTx__
150#define SCNoPTR __UINTPTR_FMTo__
151#define SCNuPTR __UINTPTR_FMTu__
152#define SCNxPTR __UINTPTR_FMTx__
153#define SCNoFAST16 __UINT_FAST16_FMTo__
154#define SCNuFAST16 __UINT_FAST16_FMTu__
155#define SCNxFAST16 __UINT_FAST16_FMTx__
156#define SCNoFAST32 __UINT_FAST32_FMTo__
157#define SCNuFAST32 __UINT_FAST32_FMTu__
158#define SCNxFAST32 __UINT_FAST32_FMTx__
159#define SCNoFAST64 __UINT_FAST64_FMTo__
160#define SCNuFAST64 __UINT_FAST64_FMTu__
161#define SCNxFAST64 __UINT_FAST64_FMTx__
162#define SCNoFAST8 __UINT_FAST8_FMTo__
163#define SCNuFAST8 __UINT_FAST8_FMTu__
164#define SCNxFAST8 __UINT_FAST8_FMTx__
165#define SCNoLEAST16 __UINT_LEAST16_FMTo__
166#define SCNuLEAST16 __UINT_LEAST16_FMTu__
167#define SCNxLEAST16 __UINT_LEAST16_FMTx__
168#define SCNoLEAST32 __UINT_LEAST32_FMTo__
169#define SCNuLEAST32 __UINT_LEAST32_FMTu__
170#define SCNxLEAST32 __UINT_LEAST32_FMTx__
171#define SCNoLEAST64 __UINT_LEAST64_FMTo__
172#define SCNuLEAST64 __UINT_LEAST64_FMTu__
173#define SCNxLEAST64 __UINT_LEAST64_FMTx__
174#define SCNoLEAST8 __UINT_LEAST8_FMTo__
175#define SCNuLEAST8 __UINT_LEAST8_FMTu__
176#define SCNxLEAST8 __UINT_LEAST8_FMTx__
177
178#ifdef __cplusplus
179}
180#endif
181
182#endif
lib/libc/include/wasm-wasi-musl/__header_netinet_in.h created+30
......@@ -0,0 +1,30 @@
1#ifndef __wasilibc___header_netinet_in_h
2#define __wasilibc___header_netinet_in_h
3
4#include <__struct_in_addr.h>
5#include <__struct_in6_addr.h>
6#include <__struct_sockaddr_in.h>
7#include <__struct_sockaddr_in6.h>
8
9#define IPPROTO_IP 0
10#define IPPROTO_ICMP 1
11#define IPPROTO_TCP 6
12#define IPPROTO_UDP 17
13#define IPPROTO_IPV6 41
14#define IPPROTO_RAW 255
15
16#define IN6ADDR_ANY_INIT { { \
17 0x00, 0x00, 0x00, 0x00, \
18 0x00, 0x00, 0x00, 0x00, \
19 0x00, 0x00, 0x00, 0x00, \
20 0x00, 0x00, 0x00, 0x00 \
21} }
22
23#define IN6ADDR_LOOPBACK_INIT { { \
24 0x00, 0x00, 0x00, 0x00, \
25 0x00, 0x00, 0x00, 0x00, \
26 0x00, 0x00, 0x00, 0x00, \
27 0x00, 0x00, 0x00, 0x01 \
28} }
29
30#endif
lib/libc/include/wasm-wasi-musl/__header_poll.h created+27
......@@ -0,0 +1,27 @@
1#ifndef __wasilibc___header_poll_h
2#define __wasilibc___header_poll_h
3
4#include <__struct_pollfd.h>
5#include <__typedef_nfds_t.h>
6
7#define POLLRDNORM 0x1
8#define POLLWRNORM 0x2
9
10#define POLLIN POLLRDNORM
11#define POLLOUT POLLWRNORM
12
13#define POLLERR 0x1000
14#define POLLHUP 0x2000
15#define POLLNVAL 0x4000
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21int poll(struct pollfd[], nfds_t, int);
22
23#ifdef __cplusplus
24}
25#endif
26
27#endif
lib/libc/include/wasm-wasi-musl/__header_stdlib.h created+21
......@@ -0,0 +1,21 @@
1#ifndef __wasilibc___header_stdlib_h
2#define __wasilibc___header_stdlib_h
3
4#define __need_size_t
5#include <stddef.h>
6
7#include <__functions_malloc.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13void abort(void) __attribute__((__noreturn__));
14void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
15void _Exit(int) __attribute__((__noreturn__));
16
17#ifdef __cplusplus
18}
19#endif
20
21#endif
lib/libc/include/wasm-wasi-musl/__header_string.h created+23
......@@ -0,0 +1,23 @@
1#ifndef __wasilibc___header_string_h
2#define __wasilibc___header_string_h
3
4#define __need_size_t
5#define __need_NULL
6#include <stddef.h>
7
8#include <__functions_memcpy.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14size_t strlen(const char *) __attribute__((__nothrow__, __leaf__, __pure__, __nonnull__(1)));
15char *strdup(const char *) __attribute__((__nothrow__, __nonnull__(1)));
16int strcmp(const char *, const char *) __attribute__((__nothrow__, __pure__, __nonnull__(1, 2)));
17void *memchr(const void *, int, size_t) __attribute__((__nothrow__, __pure__, __nonnull__(1)));
18
19#ifdef __cplusplus
20}
21#endif
22
23#endif
lib/libc/include/wasm-wasi-musl/__header_sys_ioctl.h created+17
......@@ -0,0 +1,17 @@
1#ifndef __wasilibc___header_sys_ioctl_h
2#define __wasilibc___header_sys_ioctl_h
3
4#define FIONREAD 1
5#define FIONBIO 2
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11int ioctl(int, int, ...);
12
13#ifdef __cplusplus
14}
15#endif
16
17#endif
lib/libc/include/wasm-wasi-musl/__header_sys_resource.h created+19
......@@ -0,0 +1,19 @@
1#ifndef __wasilibc___header_sys_resource_h
2#define __wasilibc___header_sys_resource_h
3
4#include <__struct_rusage.h>
5
6#define RUSAGE_SELF 1
7#define RUSAGE_CHILDREN 2
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13int getrusage(int who, struct rusage *usage);
14
15#ifdef __cplusplus
16}
17#endif
18
19#endif
lib/libc/include/wasm-wasi-musl/__header_sys_socket.h created+41
......@@ -0,0 +1,41 @@
1#ifndef __wasilibc___header_sys_socket_h
2#define __wasilibc___header_sys_socket_h
3
4#include <__struct_msghdr.h>
5#include <__struct_sockaddr.h>
6#include <__struct_sockaddr_storage.h>
7
8#include <wasi/api.h>
9
10#define SHUT_RD __WASI_SDFLAGS_RD
11#define SHUT_WR __WASI_SDFLAGS_WR
12#define SHUT_RDWR (SHUT_RD | SHUT_WR)
13
14#define MSG_PEEK __WASI_RIFLAGS_RECV_PEEK
15#define MSG_WAITALL __WASI_RIFLAGS_RECV_WAITALL
16#define MSG_TRUNC __WASI_RIFLAGS_RECV_DATA_TRUNCATED
17
18#define SOCK_DGRAM __WASI_FILETYPE_SOCKET_DGRAM
19#define SOCK_STREAM __WASI_FILETYPE_SOCKET_STREAM
20
21#define SOCK_NONBLOCK (0x00004000)
22#define SOCK_CLOEXEC (0x00002000)
23
24#define SOL_SOCKET 0x7fffffff
25
26#define SO_TYPE 3
27
28#define AF_UNSPEC 0
29#define AF_INET 1
30#define AF_INET6 2
31#define AF_UNIX 3
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#ifdef __cplusplus
38}
39#endif
40
41#endif
lib/libc/include/wasm-wasi-musl/__header_sys_stat.h created+15
......@@ -0,0 +1,15 @@
1#ifndef __wasilibc___header_sys_stat_h
2#define __wasilibc___header_sys_stat_h
3
4#include <__struct_stat.h>
5
6#define st_atime st_atim.tv_sec
7#define st_mtime st_mtim.tv_sec
8#define st_ctime st_ctim.tv_sec
9
10#include <__mode_t.h>
11
12#define UTIME_NOW (-1)
13#define UTIME_OMIT (-2)
14
15#endif
lib/libc/include/wasm-wasi-musl/__header_time.h created+37
......@@ -0,0 +1,37 @@
1#ifndef __wasilibc___header_time_h
2#define __wasilibc___header_time_h
3
4#define __need_size_t
5#define __need_NULL
6#include <stddef.h>
7
8#include <__typedef_time_t.h>
9#include <__struct_timespec.h>
10#include <__struct_tm.h>
11#include <__typedef_clockid_t.h>
12
13#include <wasi/api.h>
14
15#define TIMER_ABSTIME __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME
16
17extern const struct __clockid _CLOCK_MONOTONIC;
18#define CLOCK_MONOTONIC (&_CLOCK_MONOTONIC)
19extern const struct __clockid _CLOCK_PROCESS_CPUTIME_ID;
20#define CLOCK_PROCESS_CPUTIME_ID (&_CLOCK_PROCESS_CPUTIME_ID)
21extern const struct __clockid _CLOCK_REALTIME;
22#define CLOCK_REALTIME (&_CLOCK_REALTIME)
23extern const struct __clockid _CLOCK_THREAD_CPUTIME_ID;
24#define CLOCK_THREAD_CPUTIME_ID (&_CLOCK_THREAD_CPUTIME_ID)
25
26/*
27 * TIME_UTC is the only standardized time base value.
28 */
29#define TIME_UTC 1
30
31/*
32 * Note that XSI specifies CLOCKS_PER_SEC to be 1000000, rather than
33 * 1000000000; the clock API is providing more precision than XSI specifies.
34 */
35#define CLOCKS_PER_SEC ((clock_t)1000000000)
36
37#endif
lib/libc/include/wasm-wasi-musl/__header_unistd.h created+28
......@@ -0,0 +1,28 @@
1#ifndef __wasilibc___header_unistd_h
2#define __wasilibc___header_unistd_h
3
4struct stat;
5
6#include <__seek.h>
7
8#define F_OK (0)
9#define X_OK (1)
10#define W_OK (2)
11#define R_OK (4)
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17int close(int fd);
18int faccessat(int, const char *, int, int);
19int fstatat(int, const char *__restrict, struct stat *__restrict, int);
20int renameat(int, const char *, int, const char *);
21int openat(int, const char *, int, ...);
22void *sbrk(intptr_t increment);
23
24#ifdef __cplusplus
25}
26#endif
27
28#endif
lib/libc/include/wasm-wasi-musl/__macro_FD_SETSIZE.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___macro_FD_SETSIZE_h
2#define __wasilibc___macro_FD_SETSIZE_h
3
4#define FD_SETSIZE 1024
5
6#endif
lib/libc/include/wasm-wasi-musl/__macro_PAGESIZE.h created+11
......@@ -0,0 +1,11 @@
1#ifndef __wasilibc___macro_PAGESIZE_h
2#define __wasilibc___macro_PAGESIZE_h
3
4/*
5 * The page size in WebAssembly is fixed at 64 KiB. If this ever changes,
6 * it's expected that applications will need to opt in, so we can change
7 * this.
8 */
9#define PAGESIZE (0x10000)
10
11#endif
lib/libc/include/wasm-wasi-musl/__mode_t.h created+38
......@@ -0,0 +1,38 @@
1#ifndef __wasilibc___mode_t_h
2#define __wasilibc___mode_t_h
3
4#define S_IFMT \
5 (S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK)
6#define S_IFBLK (0x6000)
7#define S_IFCHR (0x2000)
8#define S_IFDIR (0x4000)
9#define S_IFLNK (0xa000)
10#define S_IFREG (0x8000)
11#define S_IFSOCK (0xc000)
12#define S_IFIFO (0xc000)
13
14#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK)
15#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR)
16#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
17#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO)
18#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK)
19#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
20#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK)
21
22#define S_IXOTH (0x1)
23#define S_IWOTH (0x2)
24#define S_IROTH (0x4)
25#define S_IRWXO (S_IXOTH | S_IWOTH | S_IROTH)
26#define S_IXGRP (0x8)
27#define S_IWGRP (0x10)
28#define S_IRGRP (0x20)
29#define S_IRWXG (S_IXGRP | S_IWGRP | S_IRGRP)
30#define S_IXUSR (0x40)
31#define S_IWUSR (0x80)
32#define S_IRUSR (0x100)
33#define S_IRWXU (S_IXUSR | S_IWUSR | S_IRUSR)
34#define S_ISVTX (0x200)
35#define S_ISGID (0x400)
36#define S_ISUID (0x800)
37
38#endif
lib/libc/include/wasm-wasi-musl/__seek.h created+10
......@@ -0,0 +1,10 @@
1#ifndef __wasilibc___seek_h
2#define __wasilibc___seek_h
3
4#include <wasi/api.h>
5
6#define SEEK_CUR __WASI_WHENCE_CUR
7#define SEEK_END __WASI_WHENCE_END
8#define SEEK_SET __WASI_WHENCE_SET
9
10#endif
lib/libc/include/wasm-wasi-musl/__struct_dirent.h created+14
......@@ -0,0 +1,14 @@
1#ifndef __wasilibc___struct_dirent_h
2#define __wasilibc___struct_dirent_h
3
4#include <__typedef_ino_t.h>
5
6#define _DIRENT_HAVE_D_TYPE
7
8struct dirent {
9 ino_t d_ino;
10 unsigned char d_type;
11 char d_name[];
12};
13
14#endif
lib/libc/include/wasm-wasi-musl/__struct_in6_addr.h created+8
......@@ -0,0 +1,8 @@
1#ifndef __wasilibc___struct_in6_addr_h
2#define __wasilibc___struct_in6_addr_h
3
4struct in6_addr {
5 _Alignas(int32_t) unsigned char s6_addr[16];
6};
7
8#endif
lib/libc/include/wasm-wasi-musl/__struct_in_addr.h created+10
......@@ -0,0 +1,10 @@
1#ifndef __wasilibc___struct_in_addr_h
2#define __wasilibc___struct_in_addr_h
3
4#include <__typedef_in_addr_t.h>
5
6struct in_addr {
7 in_addr_t s_addr;
8};
9
10#endif
lib/libc/include/wasm-wasi-musl/__struct_iovec.h created+12
......@@ -0,0 +1,12 @@
1#ifndef __wasilibc___struct_iovec_h
2#define __wasilibc___struct_iovec_h
3
4#define __need_size_t
5#include <stddef.h>
6
7struct iovec {
8 void *iov_base;
9 size_t iov_len;
10};
11
12#endif
lib/libc/include/wasm-wasi-musl/__struct_msghdr.h created+16
......@@ -0,0 +1,16 @@
1#ifndef __wasilibc___struct_msghdr_h
2#define __wasilibc___struct_msghdr_h
3
4#include <__typedef_socklen_t.h>
5
6struct msghdr {
7 void *msg_name;
8 socklen_t msg_namelen;
9 struct iovec *msg_iov;
10 int msg_iovlen;
11 void *msg_control;
12 socklen_t msg_controllen;
13 int msg_flags;
14};
15
16#endif
lib/libc/include/wasm-wasi-musl/__struct_pollfd.h created+10
......@@ -0,0 +1,10 @@
1#ifndef __wasilibc___struct_pollfd_h
2#define __wasilibc___struct_pollfd_h
3
4struct pollfd {
5 int fd;
6 short events;
7 short revents;
8};
9
10#endif
lib/libc/include/wasm-wasi-musl/__struct_rusage.h created+12
......@@ -0,0 +1,12 @@
1#ifndef __wasilibc___struct_rusage_h
2#define __wasilibc___struct_rusage_h
3
4#include <__struct_timeval.h>
5
6/* TODO: Add more features here. */
7struct rusage {
8 struct timeval ru_utime;
9 struct timeval ru_stime;
10};
11
12#endif
lib/libc/include/wasm-wasi-musl/__struct_sockaddr.h created+14
......@@ -0,0 +1,14 @@
1#ifndef __wasilibc___struct_sockaddr_h
2#define __wasilibc___struct_sockaddr_h
3
4#define __need_STDDEF_H_misc
5#include <stddef.h>
6
7#include <__typedef_sa_family_t.h>
8
9struct sockaddr {
10 _Alignas(max_align_t) sa_family_t sa_family;
11 char sa_data[0];
12};
13
14#endif
lib/libc/include/wasm-wasi-musl/__struct_sockaddr_in.h created+17
......@@ -0,0 +1,17 @@
1#ifndef __wasilibc___struct_sockaddr_in_h
2#define __wasilibc___struct_sockaddr_in_h
3
4#define __need_STDDEF_H_misc
5#include <stddef.h>
6
7#include <__typedef_sa_family_t.h>
8#include <__typedef_in_port_t.h>
9#include <__struct_in_addr.h>
10
11struct sockaddr_in {
12 _Alignas(max_align_t) sa_family_t sin_family;
13 in_port_t sin_port;
14 struct in_addr sin_addr;
15};
16
17#endif
lib/libc/include/wasm-wasi-musl/__struct_sockaddr_in6.h created+19
......@@ -0,0 +1,19 @@
1#ifndef __wasilibc___struct_sockaddr_in6_h
2#define __wasilibc___struct_sockaddr_in6_h
3
4#define __need_STDDEF_H_misc
5#include <stddef.h>
6
7#include <__typedef_sa_family_t.h>
8#include <__typedef_in_port_t.h>
9#include <__struct_in6_addr.h>
10
11struct sockaddr_in6 {
12 _Alignas(max_align_t) sa_family_t sin6_family;
13 in_port_t sin6_port;
14 unsigned sin6_flowinfo;
15 struct in6_addr sin6_addr;
16 unsigned sin6_scope_id;
17};
18
19#endif
lib/libc/include/wasm-wasi-musl/__struct_sockaddr_storage.h created+14
......@@ -0,0 +1,14 @@
1#ifndef __wasilibc___struct_sockaddr_storage_h
2#define __wasilibc___struct_sockaddr_storage_h
3
4#define __need_STDDEF_H_misc
5#include <stddef.h>
6
7#include <__typedef_sa_family_t.h>
8
9struct sockaddr_storage {
10 _Alignas(max_align_t) sa_family_t ss_family;
11 char __ss_data[32];
12};
13
14#endif
lib/libc/include/wasm-wasi-musl/__struct_sockaddr_un.h created+13
......@@ -0,0 +1,13 @@
1#ifndef __wasilibc___struct_sockaddr_un_h
2#define __wasilibc___struct_sockaddr_un_h
3
4#define __need_STDDEF_H_misc
5#include <stddef.h>
6
7#include <__typedef_sa_family_t.h>
8
9struct sockaddr_un {
10 _Alignas(max_align_t) sa_family_t sun_family;
11};
12
13#endif
lib/libc/include/wasm-wasi-musl/__struct_stat.h created+35
......@@ -0,0 +1,35 @@
1#ifndef __wasilibc___struct_stat_h
2#define __wasilibc___struct_stat_h
3
4#include <__typedef_dev_t.h>
5#include <__typedef_ino_t.h>
6#include <__typedef_nlink_t.h>
7#include <__typedef_mode_t.h>
8#include <__typedef_uid_t.h>
9#include <__typedef_gid_t.h>
10#include <__typedef_off_t.h>
11#include <__typedef_blksize_t.h>
12#include <__typedef_blkcnt_t.h>
13#include <__struct_timespec.h>
14
15struct stat {
16 dev_t st_dev;
17 ino_t st_ino;
18 nlink_t st_nlink;
19
20 mode_t st_mode;
21 uid_t st_uid;
22 gid_t st_gid;
23 unsigned int __pad0;
24 dev_t st_rdev;
25 off_t st_size;
26 blksize_t st_blksize;
27 blkcnt_t st_blocks;
28
29 struct timespec st_atim;
30 struct timespec st_mtim;
31 struct timespec st_ctim;
32 long long __reserved[3];
33};
34
35#endif
lib/libc/include/wasm-wasi-musl/__struct_timespec.h created+12
......@@ -0,0 +1,12 @@
1#ifndef __wasilibc___struct_timespec_h
2#define __wasilibc___struct_timespec_h
3
4#include <__typedef_time_t.h>
5
6/* As specified in POSIX. */
7struct timespec {
8 time_t tv_sec;
9 long tv_nsec;
10};
11
12#endif
lib/libc/include/wasm-wasi-musl/__struct_timeval.h created+13
......@@ -0,0 +1,13 @@
1#ifndef __wasilibc___struct_timeval_h
2#define __wasilibc___struct_timeval_h
3
4#include <__typedef_time_t.h>
5#include <__typedef_suseconds_t.h>
6
7/* As specified in POSIX. */
8struct timeval {
9 time_t tv_sec;
10 suseconds_t tv_usec;
11};
12
13#endif
lib/libc/include/wasm-wasi-musl/__struct_tm.h created+19
......@@ -0,0 +1,19 @@
1#ifndef __wasilibc___struct_tm_h
2#define __wasilibc___struct_tm_h
3
4struct tm {
5 int tm_sec;
6 int tm_min;
7 int tm_hour;
8 int tm_mday;
9 int tm_mon;
10 int tm_year;
11 int tm_wday;
12 int tm_yday;
13 int tm_isdst;
14 int __tm_gmtoff;
15 const char *__tm_zone;
16 int __tm_nsec;
17};
18
19#endif
lib/libc/include/wasm-wasi-musl/__struct_tms.h created+13
......@@ -0,0 +1,13 @@
1#ifndef __wasilibc___struct_tms_h
2#define __wasilibc___struct_tms_h
3
4#include <__typedef_clock_t.h>
5
6struct tms {
7 clock_t tms_utime;
8 clock_t tms_stime;
9 clock_t tms_cutime;
10 clock_t tms_cstime;
11};
12
13#endif
lib/libc/include/wasm-wasi-musl/__typedef_DIR.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___typedef_DIR_h
2#define __wasilibc___typedef_DIR_h
3
4typedef struct _DIR DIR;
5
6#endif
lib/libc/include/wasm-wasi-musl/__typedef_blkcnt_t.h created+7
......@@ -0,0 +1,7 @@
1#ifndef __wasilibc___typedef_blkcnt_t_h
2#define __wasilibc___typedef_blkcnt_t_h
3
4/* Define these as 64-bit signed integers to support files larger than 2 GiB. */
5typedef long long blkcnt_t;
6
7#endif
lib/libc/include/wasm-wasi-musl/__typedef_blksize_t.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___typedef_blksize_t_h
2#define __wasilibc___typedef_blksize_t_h
3
4typedef long blksize_t;
5
6#endif
lib/libc/include/wasm-wasi-musl/__typedef_clock_t.h created+7
......@@ -0,0 +1,7 @@
1#ifndef __wasilibc___typedef_clock_t_h
2#define __wasilibc___typedef_clock_t_h
3
4/* Define this as a 64-bit signed integer to avoid wraparounds. */
5typedef long long clock_t;
6
7#endif
lib/libc/include/wasm-wasi-musl/__typedef_clockid_t.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___typedef_clockid_t_h
2#define __wasilibc___typedef_clockid_t_h
3
4typedef const struct __clockid *clockid_t;
5
6#endif
lib/libc/include/wasm-wasi-musl/__typedef_dev_t.h created+7
......@@ -0,0 +1,7 @@
1#ifndef __wasilibc___typedef_dev_t_h
2#define __wasilibc___typedef_dev_t_h
3
4/* Define these as 64-bit integers to support billions of devices. */
5typedef unsigned long long dev_t;
6
7#endif
lib/libc/include/wasm-wasi-musl/__typedef_fd_set.h created+14
......@@ -0,0 +1,14 @@
1#ifndef __wasilibc___typedef_fd_set_h
2#define __wasilibc___typedef_fd_set_h
3
4#define __need_size_t
5#include <stddef.h>
6
7#include <__macro_FD_SETSIZE.h>
8
9typedef struct {
10 size_t __nfds;
11 int __fds[FD_SETSIZE];
12} fd_set;
13
14#endif
lib/libc/include/wasm-wasi-musl/__typedef_gid_t.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___typedef_gid_t_h
2#define __wasilibc___typedef_gid_t_h
3
4typedef unsigned gid_t;
5
6#endif
lib/libc/include/wasm-wasi-musl/__typedef_in_addr_t.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___typedef_in_addr_t_h
2#define __wasilibc___typedef_in_addr_t_h
3
4typedef unsigned in_addr_t;
5
6#endif
lib/libc/include/wasm-wasi-musl/__typedef_in_port_t.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___typedef_in_port_t_h
2#define __wasilibc___typedef_in_port_t_h
3
4typedef unsigned short in_port_t;
5
6#endif
lib/libc/include/wasm-wasi-musl/__typedef_ino_t.h created+7
......@@ -0,0 +1,7 @@
1#ifndef __wasilibc___typedef_ino_t_h
2#define __wasilibc___typedef_ino_t_h
3
4/* Define these as 64-bit integers to support billions of inodes. */
5typedef unsigned long long ino_t;
6
7#endif
lib/libc/include/wasm-wasi-musl/__typedef_mode_t.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___typedef_mode_t_h
2#define __wasilibc___typedef_mode_t_h
3
4typedef unsigned mode_t;
5
6#endif
lib/libc/include/wasm-wasi-musl/__typedef_nfds_t.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___typedef_nfds_t_h
2#define __wasilibc___typedef_nfds_t_h
3
4typedef unsigned long nfds_t;
5
6#endif
lib/libc/include/wasm-wasi-musl/__typedef_nlink_t.h created+7
......@@ -0,0 +1,7 @@
1#ifndef __wasilibc___typedef_nlink_t_h
2#define __wasilibc___typedef_nlink_t_h
3
4/* Define these as 64-bit unsigned integers to support billions of links. */
5typedef unsigned long long nlink_t;
6
7#endif
lib/libc/include/wasm-wasi-musl/__typedef_off_t.h created+7
......@@ -0,0 +1,7 @@
1#ifndef __wasilibc___typedef_off_t_h
2#define __wasilibc___typedef_off_t_h
3
4/* Define these as 64-bit signed integers to support files larger than 2 GiB. */
5typedef long long off_t;
6
7#endif
lib/libc/include/wasm-wasi-musl/__typedef_sa_family_t.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___typedef_sa_family_t_h
2#define __wasilibc___typedef_sa_family_t_h
3
4typedef unsigned short sa_family_t;
5
6#endif
lib/libc/include/wasm-wasi-musl/__typedef_sigset_t.h created+7
......@@ -0,0 +1,7 @@
1#ifndef __wasilibc___typedef_sigset_t_h
2#define __wasilibc___typedef_sigset_t_h
3
4/* TODO: This is just a placeholder for now. Keep this in sync with musl. */
5typedef unsigned char sigset_t;
6
7#endif
lib/libc/include/wasm-wasi-musl/__typedef_socklen_t.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___typedef_socklen_t_h
2#define __wasilibc___typedef_socklen_t_h
3
4typedef unsigned socklen_t;
5
6#endif
lib/libc/include/wasm-wasi-musl/__typedef_ssize_t.h created+7
......@@ -0,0 +1,7 @@
1#ifndef __wasilibc___typedef_ssize_t_h
2#define __wasilibc___typedef_ssize_t_h
3
4/* This is defined to be the same size as size_t. */
5typedef long ssize_t;
6
7#endif
lib/libc/include/wasm-wasi-musl/__typedef_suseconds_t.h created+8
......@@ -0,0 +1,8 @@
1#ifndef __wasilibc___typedef_suseconds_t_h
2#define __wasilibc___typedef_suseconds_t_h
3
4/* Define this to be 64-bit as its main use is in struct timeval where the
5 extra space would otherwise be padding. */
6typedef long long suseconds_t;
7
8#endif
lib/libc/include/wasm-wasi-musl/__typedef_time_t.h created+7
......@@ -0,0 +1,7 @@
1#ifndef __wasilibc___typedef_time_t_h
2#define __wasilibc___typedef_time_t_h
3
4/* Define this as a 64-bit signed integer to avoid the 2038 bug. */
5typedef long long time_t;
6
7#endif
lib/libc/include/wasm-wasi-musl/__typedef_uid_t.h created+6
......@@ -0,0 +1,6 @@
1#ifndef __wasilibc___typedef_uid_t_h
2#define __wasilibc___typedef_uid_t_h
3
4typedef unsigned uid_t;
5
6#endif
lib/libc/include/wasm-wasi-musl/alloca.h created+19
......@@ -0,0 +1,19 @@
1#ifndef _ALLOCA_H
2#define _ALLOCA_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_size_t
9#include <bits/alltypes.h>
10
11void *alloca(size_t);
12
13#define alloca __builtin_alloca
14
15#ifdef __cplusplus
16}
17#endif
18
19#endif
lib/libc/include/wasm-wasi-musl/ar.h created+25
......@@ -0,0 +1,25 @@
1#ifndef _AR_H
2#define _AR_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define ARMAG "!<arch>\n"
9#define SARMAG 8
10#define ARFMAG "`\n"
11
12struct ar_hdr {
13 char ar_name[16];
14 char ar_date[12];
15 char ar_uid[6], ar_gid[6];
16 char ar_mode[8];
17 char ar_size[10];
18 char ar_fmag[2];
19};
20
21#ifdef __cplusplus
22}
23#endif
24
25#endif
lib/libc/include/wasm-wasi-musl/arpa/ftp.h created+35
......@@ -0,0 +1,35 @@
1#ifndef _ARPA_FTP_H
2#define _ARPA_FTP_H
3#define PRELIM 1
4#define COMPLETE 2
5#define CONTINUE 3
6#define TRANSIENT 4
7#define ERROR 5
8#define TYPE_A 1
9#define TYPE_E 2
10#define TYPE_I 3
11#define TYPE_L 4
12#define FORM_N 1
13#define FORM_T 2
14#define FORM_C 3
15#define STRU_F 1
16#define STRU_R 2
17#define STRU_P 3
18#define MODE_S 1
19#define MODE_B 2
20#define MODE_C 3
21#define REC_ESC '\377'
22#define REC_EOR '\001'
23#define REC_EOF '\002'
24#define BLK_EOR 0x80
25#define BLK_EOF 0x40
26#define BLK_ERRORS 0x20
27#define BLK_RESTART 0x10
28#define BLK_BYTECOUNT 2
29#ifdef FTP_NAMES
30char *modenames[] = {"0", "Stream", "Block", "Compressed" };
31char *strunames[] = {"0", "File", "Record", "Page" };
32char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" };
33char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" };
34#endif
35#endif
lib/libc/include/wasm-wasi-musl/arpa/inet.h created+35
......@@ -0,0 +1,35 @@
1#ifndef _ARPA_INET_H
2#define _ARPA_INET_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <netinet/in.h>
10
11uint32_t htonl(uint32_t);
12uint16_t htons(uint16_t);
13uint32_t ntohl(uint32_t);
14uint16_t ntohs(uint16_t);
15
16#ifdef __wasilibc_unmodified_upstream /* WASI has no inet_addr */
17in_addr_t inet_addr (const char *);
18in_addr_t inet_network (const char *);
19char *inet_ntoa (struct in_addr);
20#endif
21int inet_pton (int, const char *__restrict, void *__restrict);
22const char *inet_ntop (int, const void *__restrict, char *__restrict, socklen_t);
23
24int inet_aton (const char *, struct in_addr *);
25#ifdef __wasilibc_unmodified_upstream /* WASI has no inet_makeaddr */
26struct in_addr inet_makeaddr(in_addr_t, in_addr_t);
27in_addr_t inet_lnaof(struct in_addr);
28in_addr_t inet_netof(struct in_addr);
29#endif
30
31#ifdef __cplusplus
32}
33#endif
34
35#endif
lib/libc/include/wasm-wasi-musl/arpa/nameser.h created+455
......@@ -0,0 +1,455 @@
1#ifndef _ARPA_NAMESER_H
2#define _ARPA_NAMESER_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stddef.h>
9#include <stdint.h>
10
11#define __NAMESER 19991006
12#define NS_PACKETSZ 512
13#define NS_MAXDNAME 1025
14#define NS_MAXMSG 65535
15#define NS_MAXCDNAME 255
16#define NS_MAXLABEL 63
17#define NS_HFIXEDSZ 12
18#define NS_QFIXEDSZ 4
19#define NS_RRFIXEDSZ 10
20#define NS_INT32SZ 4
21#define NS_INT16SZ 2
22#define NS_INT8SZ 1
23#define NS_INADDRSZ 4
24#define NS_IN6ADDRSZ 16
25#define NS_CMPRSFLGS 0xc0
26#define NS_DEFAULTPORT 53
27
28typedef enum __ns_sect {
29 ns_s_qd = 0,
30 ns_s_zn = 0,
31 ns_s_an = 1,
32 ns_s_pr = 1,
33 ns_s_ns = 2,
34 ns_s_ud = 2,
35 ns_s_ar = 3,
36 ns_s_max = 4
37} ns_sect;
38
39typedef struct __ns_msg {
40 const unsigned char *_msg, *_eom;
41 uint16_t _id, _flags, _counts[ns_s_max];
42 const unsigned char *_sections[ns_s_max];
43 ns_sect _sect;
44 int _rrnum;
45 const unsigned char *_msg_ptr;
46} ns_msg;
47
48struct _ns_flagdata { int mask, shift; };
49extern const struct _ns_flagdata _ns_flagdata[];
50
51#define ns_msg_id(handle) ((handle)._id + 0)
52#define ns_msg_base(handle) ((handle)._msg + 0)
53#define ns_msg_end(handle) ((handle)._eom + 0)
54#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
55#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
56#define ns_msg_getflag(handle, flag) \
57 (((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift)
58
59typedef struct __ns_rr {
60 char name[NS_MAXDNAME];
61 uint16_t type;
62 uint16_t rr_class;
63 uint32_t ttl;
64 uint16_t rdlength;
65 const unsigned char *rdata;
66} ns_rr;
67
68#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
69#define ns_rr_type(rr) ((ns_type)((rr).type + 0))
70#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
71#define ns_rr_ttl(rr) ((rr).ttl + 0)
72#define ns_rr_rdlen(rr) ((rr).rdlength + 0)
73#define ns_rr_rdata(rr) ((rr).rdata + 0)
74
75typedef enum __ns_flag {
76 ns_f_qr,
77 ns_f_opcode,
78 ns_f_aa,
79 ns_f_tc,
80 ns_f_rd,
81 ns_f_ra,
82 ns_f_z,
83 ns_f_ad,
84 ns_f_cd,
85 ns_f_rcode,
86 ns_f_max
87} ns_flag;
88
89typedef enum __ns_opcode {
90 ns_o_query = 0,
91 ns_o_iquery = 1,
92 ns_o_status = 2,
93 ns_o_notify = 4,
94 ns_o_update = 5,
95 ns_o_max = 6
96} ns_opcode;
97
98typedef enum __ns_rcode {
99 ns_r_noerror = 0,
100 ns_r_formerr = 1,
101 ns_r_servfail = 2,
102 ns_r_nxdomain = 3,
103 ns_r_notimpl = 4,
104 ns_r_refused = 5,
105 ns_r_yxdomain = 6,
106 ns_r_yxrrset = 7,
107 ns_r_nxrrset = 8,
108 ns_r_notauth = 9,
109 ns_r_notzone = 10,
110 ns_r_max = 11,
111 ns_r_badvers = 16,
112 ns_r_badsig = 16,
113 ns_r_badkey = 17,
114 ns_r_badtime = 18
115} ns_rcode;
116
117typedef enum __ns_update_operation {
118 ns_uop_delete = 0,
119 ns_uop_add = 1,
120 ns_uop_max = 2
121} ns_update_operation;
122
123struct ns_tsig_key {
124 char name[NS_MAXDNAME], alg[NS_MAXDNAME];
125 unsigned char *data;
126 int len;
127};
128typedef struct ns_tsig_key ns_tsig_key;
129
130struct ns_tcp_tsig_state {
131 int counter;
132 struct dst_key *key;
133 void *ctx;
134 unsigned char sig[NS_PACKETSZ];
135 int siglen;
136};
137typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
138
139#define NS_TSIG_FUDGE 300
140#define NS_TSIG_TCP_COUNT 100
141#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
142
143#define NS_TSIG_ERROR_NO_TSIG -10
144#define NS_TSIG_ERROR_NO_SPACE -11
145#define NS_TSIG_ERROR_FORMERR -12
146
147typedef enum __ns_type {
148 ns_t_invalid = 0,
149 ns_t_a = 1,
150 ns_t_ns = 2,
151 ns_t_md = 3,
152 ns_t_mf = 4,
153 ns_t_cname = 5,
154 ns_t_soa = 6,
155 ns_t_mb = 7,
156 ns_t_mg = 8,
157 ns_t_mr = 9,
158 ns_t_null = 10,
159 ns_t_wks = 11,
160 ns_t_ptr = 12,
161 ns_t_hinfo = 13,
162 ns_t_minfo = 14,
163 ns_t_mx = 15,
164 ns_t_txt = 16,
165 ns_t_rp = 17,
166 ns_t_afsdb = 18,
167 ns_t_x25 = 19,
168 ns_t_isdn = 20,
169 ns_t_rt = 21,
170 ns_t_nsap = 22,
171 ns_t_nsap_ptr = 23,
172 ns_t_sig = 24,
173 ns_t_key = 25,
174 ns_t_px = 26,
175 ns_t_gpos = 27,
176 ns_t_aaaa = 28,
177 ns_t_loc = 29,
178 ns_t_nxt = 30,
179 ns_t_eid = 31,
180 ns_t_nimloc = 32,
181 ns_t_srv = 33,
182 ns_t_atma = 34,
183 ns_t_naptr = 35,
184 ns_t_kx = 36,
185 ns_t_cert = 37,
186 ns_t_a6 = 38,
187 ns_t_dname = 39,
188 ns_t_sink = 40,
189 ns_t_opt = 41,
190 ns_t_apl = 42,
191 ns_t_tkey = 249,
192 ns_t_tsig = 250,
193 ns_t_ixfr = 251,
194 ns_t_axfr = 252,
195 ns_t_mailb = 253,
196 ns_t_maila = 254,
197 ns_t_any = 255,
198 ns_t_zxfr = 256,
199 ns_t_max = 65536
200} ns_type;
201
202#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
203 (t) == ns_t_mailb || (t) == ns_t_maila)
204#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
205#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
206#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
207#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
208 (t) == ns_t_zxfr)
209
210typedef enum __ns_class {
211 ns_c_invalid = 0,
212 ns_c_in = 1,
213 ns_c_2 = 2,
214 ns_c_chaos = 3,
215 ns_c_hs = 4,
216 ns_c_none = 254,
217 ns_c_any = 255,
218 ns_c_max = 65536
219} ns_class;
220
221typedef enum __ns_key_types {
222 ns_kt_rsa = 1,
223 ns_kt_dh = 2,
224 ns_kt_dsa = 3,
225 ns_kt_private = 254
226} ns_key_types;
227
228typedef enum __ns_cert_types {
229 cert_t_pkix = 1,
230 cert_t_spki = 2,
231 cert_t_pgp = 3,
232 cert_t_url = 253,
233 cert_t_oid = 254
234} ns_cert_types;
235
236#define NS_KEY_TYPEMASK 0xC000
237#define NS_KEY_TYPE_AUTH_CONF 0x0000
238#define NS_KEY_TYPE_CONF_ONLY 0x8000
239#define NS_KEY_TYPE_AUTH_ONLY 0x4000
240#define NS_KEY_TYPE_NO_KEY 0xC000
241#define NS_KEY_NO_AUTH 0x8000
242#define NS_KEY_NO_CONF 0x4000
243#define NS_KEY_RESERVED2 0x2000
244#define NS_KEY_EXTENDED_FLAGS 0x1000
245#define NS_KEY_RESERVED4 0x0800
246#define NS_KEY_RESERVED5 0x0400
247#define NS_KEY_NAME_TYPE 0x0300
248#define NS_KEY_NAME_USER 0x0000
249#define NS_KEY_NAME_ENTITY 0x0200
250#define NS_KEY_NAME_ZONE 0x0100
251#define NS_KEY_NAME_RESERVED 0x0300
252#define NS_KEY_RESERVED8 0x0080
253#define NS_KEY_RESERVED9 0x0040
254#define NS_KEY_RESERVED10 0x0020
255#define NS_KEY_RESERVED11 0x0010
256#define NS_KEY_SIGNATORYMASK 0x000F
257#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
258 NS_KEY_RESERVED4 | \
259 NS_KEY_RESERVED5 | \
260 NS_KEY_RESERVED8 | \
261 NS_KEY_RESERVED9 | \
262 NS_KEY_RESERVED10 | \
263 NS_KEY_RESERVED11 )
264#define NS_KEY_RESERVED_BITMASK2 0xFFFF
265#define NS_ALG_MD5RSA 1
266#define NS_ALG_DH 2
267#define NS_ALG_DSA 3
268#define NS_ALG_DSS NS_ALG_DSA
269#define NS_ALG_EXPIRE_ONLY 253
270#define NS_ALG_PRIVATE_OID 254
271
272#define NS_KEY_PROT_TLS 1
273#define NS_KEY_PROT_EMAIL 2
274#define NS_KEY_PROT_DNSSEC 3
275#define NS_KEY_PROT_IPSEC 4
276#define NS_KEY_PROT_ANY 255
277
278#define NS_MD5RSA_MIN_BITS 512
279#define NS_MD5RSA_MAX_BITS 4096
280#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
281#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4)
282#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8)
283#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8)
284
285#define NS_DSA_SIG_SIZE 41
286#define NS_DSA_MIN_SIZE 213
287#define NS_DSA_MAX_BYTES 405
288
289#define NS_SIG_TYPE 0
290#define NS_SIG_ALG 2
291#define NS_SIG_LABELS 3
292#define NS_SIG_OTTL 4
293#define NS_SIG_EXPIR 8
294#define NS_SIG_SIGNED 12
295#define NS_SIG_FOOT 16
296#define NS_SIG_SIGNER 18
297#define NS_NXT_BITS 8
298#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS)))
299#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
300#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS)))
301#define NS_NXT_MAX 127
302
303#define NS_OPT_DNSSEC_OK 0x8000U
304#define NS_OPT_NSID 3
305
306#define NS_GET16(s, cp) (void)((s) = ns_get16(((cp)+=2)-2))
307#define NS_GET32(l, cp) (void)((l) = ns_get32(((cp)+=4)-4))
308#define NS_PUT16(s, cp) ns_put16((s), ((cp)+=2)-2)
309#define NS_PUT32(l, cp) ns_put32((l), ((cp)+=4)-4)
310
311unsigned ns_get16(const unsigned char *);
312unsigned long ns_get32(const unsigned char *);
313void ns_put16(unsigned, unsigned char *);
314void ns_put32(unsigned long, unsigned char *);
315
316int ns_initparse(const unsigned char *, int, ns_msg *);
317int ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
318int ns_skiprr(const unsigned char *, const unsigned char *, ns_sect, int);
319int ns_name_uncompress(const unsigned char *, const unsigned char *, const unsigned char *, char *, size_t);
320
321
322#define __BIND 19950621
323
324typedef struct {
325 unsigned id :16;
326#if __BYTE_ORDER == __BIG_ENDIAN
327 unsigned qr: 1;
328 unsigned opcode: 4;
329 unsigned aa: 1;
330 unsigned tc: 1;
331 unsigned rd: 1;
332 unsigned ra: 1;
333 unsigned unused :1;
334 unsigned ad: 1;
335 unsigned cd: 1;
336 unsigned rcode :4;
337#else
338 unsigned rd :1;
339 unsigned tc :1;
340 unsigned aa :1;
341 unsigned opcode :4;
342 unsigned qr :1;
343 unsigned rcode :4;
344 unsigned cd: 1;
345 unsigned ad: 1;
346 unsigned unused :1;
347 unsigned ra :1;
348#endif
349 unsigned qdcount :16;
350 unsigned ancount :16;
351 unsigned nscount :16;
352 unsigned arcount :16;
353} HEADER;
354
355#define PACKETSZ NS_PACKETSZ
356#define MAXDNAME NS_MAXDNAME
357#define MAXCDNAME NS_MAXCDNAME
358#define MAXLABEL NS_MAXLABEL
359#define HFIXEDSZ NS_HFIXEDSZ
360#define QFIXEDSZ NS_QFIXEDSZ
361#define RRFIXEDSZ NS_RRFIXEDSZ
362#define INT32SZ NS_INT32SZ
363#define INT16SZ NS_INT16SZ
364#define INT8SZ NS_INT8SZ
365#define INADDRSZ NS_INADDRSZ
366#define IN6ADDRSZ NS_IN6ADDRSZ
367#define INDIR_MASK NS_CMPRSFLGS
368#define NAMESERVER_PORT NS_DEFAULTPORT
369
370#define S_ZONE ns_s_zn
371#define S_PREREQ ns_s_pr
372#define S_UPDATE ns_s_ud
373#define S_ADDT ns_s_ar
374
375#define QUERY ns_o_query
376#define IQUERY ns_o_iquery
377#define STATUS ns_o_status
378#define NS_NOTIFY_OP ns_o_notify
379#define NS_UPDATE_OP ns_o_update
380
381#define NOERROR ns_r_noerror
382#define FORMERR ns_r_formerr
383#define SERVFAIL ns_r_servfail
384#define NXDOMAIN ns_r_nxdomain
385#define NOTIMP ns_r_notimpl
386#define REFUSED ns_r_refused
387#define YXDOMAIN ns_r_yxdomain
388#define YXRRSET ns_r_yxrrset
389#define NXRRSET ns_r_nxrrset
390#define NOTAUTH ns_r_notauth
391#define NOTZONE ns_r_notzone
392
393#define DELETE ns_uop_delete
394#define ADD ns_uop_add
395
396#define T_A ns_t_a
397#define T_NS ns_t_ns
398#define T_MD ns_t_md
399#define T_MF ns_t_mf
400#define T_CNAME ns_t_cname
401#define T_SOA ns_t_soa
402#define T_MB ns_t_mb
403#define T_MG ns_t_mg
404#define T_MR ns_t_mr
405#define T_NULL ns_t_null
406#define T_WKS ns_t_wks
407#define T_PTR ns_t_ptr
408#define T_HINFO ns_t_hinfo
409#define T_MINFO ns_t_minfo
410#define T_MX ns_t_mx
411#define T_TXT ns_t_txt
412#define T_RP ns_t_rp
413#define T_AFSDB ns_t_afsdb
414#define T_X25 ns_t_x25
415#define T_ISDN ns_t_isdn
416#define T_RT ns_t_rt
417#define T_NSAP ns_t_nsap
418#define T_NSAP_PTR ns_t_nsap_ptr
419#define T_SIG ns_t_sig
420#define T_KEY ns_t_key
421#define T_PX ns_t_px
422#define T_GPOS ns_t_gpos
423#define T_AAAA ns_t_aaaa
424#define T_LOC ns_t_loc
425#define T_NXT ns_t_nxt
426#define T_EID ns_t_eid
427#define T_NIMLOC ns_t_nimloc
428#define T_SRV ns_t_srv
429#define T_ATMA ns_t_atma
430#define T_NAPTR ns_t_naptr
431#define T_A6 ns_t_a6
432#define T_DNAME ns_t_dname
433#define T_TSIG ns_t_tsig
434#define T_IXFR ns_t_ixfr
435#define T_AXFR ns_t_axfr
436#define T_MAILB ns_t_mailb
437#define T_MAILA ns_t_maila
438#define T_ANY ns_t_any
439
440#define C_IN ns_c_in
441#define C_CHAOS ns_c_chaos
442#define C_HS ns_c_hs
443#define C_NONE ns_c_none
444#define C_ANY ns_c_any
445
446#define GETSHORT NS_GET16
447#define GETLONG NS_GET32
448#define PUTSHORT NS_PUT16
449#define PUTLONG NS_PUT32
450
451#ifdef __cplusplus
452}
453#endif
454
455#endif
lib/libc/include/wasm-wasi-musl/arpa/nameser_compat.h created+2
......@@ -0,0 +1,2 @@
1#include <arpa/nameser.h>
2
lib/libc/include/wasm-wasi-musl/arpa/telnet.h created+251
......@@ -0,0 +1,251 @@
1#ifndef _ARPA_TELNET_H
2#define _ARPA_TELNET_H
3
4#define IAC 255
5#define DONT 254
6#define DO 253
7#define WONT 252
8#define WILL 251
9#define SB 250
10#define GA 249
11#define EL 248
12#define EC 247
13#define AYT 246
14#define AO 245
15#define IP 244
16#define BREAK 243
17#define DM 242
18#define NOP 241
19#define SE 240
20#define EOR 239
21#define ABORT 238
22#define SUSP 237
23#define xEOF 236
24
25#define SYNCH 242
26
27#define telcmds ((char [][6]){ "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0 })
28
29#define TELCMD_FIRST xEOF
30#define TELCMD_LAST IAC
31#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
32 (unsigned int)(x) >= TELCMD_FIRST)
33#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
34
35#define TELOPT_BINARY 0
36#define TELOPT_ECHO 1
37#define TELOPT_RCP 2
38#define TELOPT_SGA 3
39#define TELOPT_NAMS 4
40#define TELOPT_STATUS 5
41#define TELOPT_TM 6
42#define TELOPT_RCTE 7
43#define TELOPT_NAOL 8
44#define TELOPT_NAOP 9
45#define TELOPT_NAOCRD 10
46#define TELOPT_NAOHTS 11
47#define TELOPT_NAOHTD 12
48#define TELOPT_NAOFFD 13
49#define TELOPT_NAOVTS 14
50#define TELOPT_NAOVTD 15
51#define TELOPT_NAOLFD 16
52#define TELOPT_XASCII 17
53#define TELOPT_LOGOUT 18
54#define TELOPT_BM 19
55#define TELOPT_DET 20
56#define TELOPT_SUPDUP 21
57#define TELOPT_SUPDUPOUTPUT 22
58#define TELOPT_SNDLOC 23
59#define TELOPT_TTYPE 24
60#define TELOPT_EOR 25
61#define TELOPT_TUID 26
62#define TELOPT_OUTMRK 27
63#define TELOPT_TTYLOC 28
64#define TELOPT_3270REGIME 29
65#define TELOPT_X3PAD 30
66#define TELOPT_NAWS 31
67#define TELOPT_TSPEED 32
68#define TELOPT_LFLOW 33
69#define TELOPT_LINEMODE 34
70#define TELOPT_XDISPLOC 35
71#define TELOPT_OLD_ENVIRON 36
72#define TELOPT_AUTHENTICATION 37/* Authenticate */
73#define TELOPT_ENCRYPT 38
74#define TELOPT_NEW_ENVIRON 39
75#define TELOPT_EXOPL 255
76
77
78#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
79#ifdef TELOPTS
80char *telopts[NTELOPTS+1] = {
81 "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
82 "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
83 "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
84 "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
85 "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
86 "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
87 "TACACS UID", "OUTPUT MARKING", "TTYLOC",
88 "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
89 "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
90 "ENCRYPT", "NEW-ENVIRON",
91 0,
92};
93#define TELOPT_FIRST TELOPT_BINARY
94#define TELOPT_LAST TELOPT_NEW_ENVIRON
95#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
96#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
97#endif
98
99#define TELQUAL_IS 0
100#define TELQUAL_SEND 1
101#define TELQUAL_INFO 2
102#define TELQUAL_REPLY 2
103#define TELQUAL_NAME 3
104
105#define LFLOW_OFF 0
106#define LFLOW_ON 1
107#define LFLOW_RESTART_ANY 2
108#define LFLOW_RESTART_XON 3
109
110
111#define LM_MODE 1
112#define LM_FORWARDMASK 2
113#define LM_SLC 3
114
115#define MODE_EDIT 0x01
116#define MODE_TRAPSIG 0x02
117#define MODE_ACK 0x04
118#define MODE_SOFT_TAB 0x08
119#define MODE_LIT_ECHO 0x10
120
121#define MODE_MASK 0x1f
122
123#define MODE_FLOW 0x0100
124#define MODE_ECHO 0x0200
125#define MODE_INBIN 0x0400
126#define MODE_OUTBIN 0x0800
127#define MODE_FORCE 0x1000
128
129#define SLC_SYNCH 1
130#define SLC_BRK 2
131#define SLC_IP 3
132#define SLC_AO 4
133#define SLC_AYT 5
134#define SLC_EOR 6
135#define SLC_ABORT 7
136#define SLC_EOF 8
137#define SLC_SUSP 9
138#define SLC_EC 10
139#define SLC_EL 11
140#define SLC_EW 12
141#define SLC_RP 13
142#define SLC_LNEXT 14
143#define SLC_XON 15
144#define SLC_XOFF 16
145#define SLC_FORW1 17
146#define SLC_FORW2 18
147
148#define NSLC 18
149
150#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
151 "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
152 "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
153#ifdef SLC_NAMES
154char *slc_names[] = {
155 SLC_NAMELIST
156};
157#else
158extern char *slc_names[];
159#define SLC_NAMES SLC_NAMELIST
160#endif
161
162#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
163#define SLC_NAME(x) slc_names[x]
164
165#define SLC_NOSUPPORT 0
166#define SLC_CANTCHANGE 1
167#define SLC_VARIABLE 2
168#define SLC_DEFAULT 3
169#define SLC_LEVELBITS 0x03
170
171#define SLC_FUNC 0
172#define SLC_FLAGS 1
173#define SLC_VALUE 2
174
175#define SLC_ACK 0x80
176#define SLC_FLUSHIN 0x40
177#define SLC_FLUSHOUT 0x20
178
179#define OLD_ENV_VAR 1
180#define OLD_ENV_VALUE 0
181#define NEW_ENV_VAR 0
182#define NEW_ENV_VALUE 1
183#define ENV_ESC 2
184#define ENV_USERVAR 3
185
186#define AUTH_WHO_CLIENT 0
187#define AUTH_WHO_SERVER 1
188#define AUTH_WHO_MASK 1
189
190#define AUTH_HOW_ONE_WAY 0
191#define AUTH_HOW_MUTUAL 2
192#define AUTH_HOW_MASK 2
193
194#define AUTHTYPE_NULL 0
195#define AUTHTYPE_KERBEROS_V4 1
196#define AUTHTYPE_KERBEROS_V5 2
197#define AUTHTYPE_SPX 3
198#define AUTHTYPE_MINK 4
199#define AUTHTYPE_CNT 5
200
201#define AUTHTYPE_TEST 99
202
203#ifdef AUTH_NAMES
204char *authtype_names[] = {
205 "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
206};
207#else
208extern char *authtype_names[];
209#endif
210
211#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
212#define AUTHTYPE_NAME(x) authtype_names[x]
213
214#define ENCRYPT_IS 0
215#define ENCRYPT_SUPPORT 1
216#define ENCRYPT_REPLY 2
217#define ENCRYPT_START 3
218#define ENCRYPT_END 4
219#define ENCRYPT_REQSTART 5
220#define ENCRYPT_REQEND 6
221#define ENCRYPT_ENC_KEYID 7
222#define ENCRYPT_DEC_KEYID 8
223#define ENCRYPT_CNT 9
224
225#define ENCTYPE_ANY 0
226#define ENCTYPE_DES_CFB64 1
227#define ENCTYPE_DES_OFB64 2
228#define ENCTYPE_CNT 3
229
230#ifdef ENCRYPT_NAMES
231char *encrypt_names[] = {
232 "IS", "SUPPORT", "REPLY", "START", "END",
233 "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
234 0,
235};
236char *enctype_names[] = {
237 "ANY", "DES_CFB64", "DES_OFB64", 0,
238};
239#else
240extern char *encrypt_names[];
241extern char *enctype_names[];
242#endif
243
244
245#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
246#define ENCRYPT_NAME(x) encrypt_names[x]
247
248#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
249#define ENCTYPE_NAME(x) enctype_names[x]
250
251#endif
lib/libc/include/wasm-wasi-musl/arpa/tftp.h created+31
......@@ -0,0 +1,31 @@
1#ifndef _ARPA_TFTP_H
2#define _ARPA_TFTP_H
3#define SEGSIZE 512
4#define RRQ 01
5#define WRQ 02
6#define DATA 03
7#define ACK 04
8#define ERROR 05
9struct tftphdr {
10 short th_opcode;
11 union {
12 unsigned short tu_block;
13 short tu_code;
14 char tu_stuff[1];
15 } th_u;
16 char th_data[1];
17};
18#define th_block th_u.tu_block
19#define th_code th_u.tu_code
20#define th_stuff th_u.tu_stuff
21#define th_msg th_data
22#define EUNDEF 0
23#define ENOTFOUND 1
24#define EACCESS 2
25#define ENOSPACE 3
26#define EBADOP 4
27#define EBADID 5
28#define EEXISTS 6
29#define ENOUSER 7
30#endif
31
lib/libc/include/wasm-wasi-musl/assert.h created+23
......@@ -0,0 +1,23 @@
1#include <features.h>
2
3#undef assert
4
5#ifdef NDEBUG
6#define assert(x) (void)0
7#else
8#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
9#endif
10
11#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
12#define static_assert _Static_assert
13#endif
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19_Noreturn void __assert_fail (const char *, const char *, int, const char *);
20
21#ifdef __cplusplus
22}
23#endif
lib/libc/include/wasm-wasi-musl/bits/alltypes.h created+460
......@@ -0,0 +1,460 @@
1#define _Addr long
2#define _Int64 long long
3#define _Reg long long
4
5#define __BYTE_ORDER __BYTE_ORDER__
6
7#define __LONG_MAX __LONG_MAX__
8
9/*
10 * Rather than define everything ourselves here in the musl layer, for
11 * WASI, reference the definitions in the lower layers.
12 */
13
14#if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t)
15#define __need_wchar_t
16#include <stddef.h>
17#define __DEFINED_wchar_t
18#endif
19
20#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t)
21#define __need_wint_t
22#include <stddef.h>
23#define __DEFINED_wint_t
24#endif
25
26#if defined(__NEED_float_t) && !defined(__DEFINED_float_t)
27typedef float float_t;
28#define __DEFINED_float_t
29#endif
30
31#if defined(__NEED_double_t) && !defined(__DEFINED_double_t)
32typedef double double_t;
33#define __DEFINED_double_t
34#endif
35
36
37#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
38#define __need_max_align_t
39#include <stddef.h>
40#define __DEFINED_max_align_t
41#endif
42
43#if defined(__NEED_time_t) && !defined(__DEFINED_time_t)
44#include <__typedef_time_t.h>
45#define __DEFINED_time_t
46#endif
47
48#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
49#include <__typedef_suseconds_t.h>
50#define __DEFINED_suseconds_t
51#endif
52
53#if defined(__NEED_clockid_t) && !defined(__DEFINED_clockid_t)
54#include <__typedef_clockid_t.h>
55#define __DEFINED_clockid_t
56#endif
57
58#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t)
59#include <__typedef_sigset_t.h>
60#define __DEFINED_sigset_t
61#endif
62
63#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t)
64#include <__typedef_clock_t.h>
65#define __DEFINED_clock_t
66#endif
67#define __LITTLE_ENDIAN 1234
68#define __BIG_ENDIAN 4321
69#define __USE_TIME_BITS64 1
70
71#if defined(__NEED_size_t) && !defined(__DEFINED_size_t)
72typedef unsigned _Addr size_t;
73#define __DEFINED_size_t
74#endif
75
76#if defined(__NEED_uintptr_t) && !defined(__DEFINED_uintptr_t)
77typedef unsigned _Addr uintptr_t;
78#define __DEFINED_uintptr_t
79#endif
80
81#if defined(__NEED_ptrdiff_t) && !defined(__DEFINED_ptrdiff_t)
82typedef _Addr ptrdiff_t;
83#define __DEFINED_ptrdiff_t
84#endif
85
86#if defined(__NEED_ssize_t) && !defined(__DEFINED_ssize_t)
87typedef _Addr ssize_t;
88#define __DEFINED_ssize_t
89#endif
90
91#if defined(__NEED_intptr_t) && !defined(__DEFINED_intptr_t)
92typedef _Addr intptr_t;
93#define __DEFINED_intptr_t
94#endif
95
96#if defined(__NEED_regoff_t) && !defined(__DEFINED_regoff_t)
97typedef _Addr regoff_t;
98#define __DEFINED_regoff_t
99#endif
100
101#if defined(__NEED_register_t) && !defined(__DEFINED_register_t)
102typedef _Reg register_t;
103#define __DEFINED_register_t
104#endif
105
106#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
107#if defined(__NEED_time_t) && !defined(__DEFINED_time_t)
108typedef _Int64 time_t;
109#define __DEFINED_time_t
110#endif
111
112#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
113typedef _Int64 suseconds_t;
114#define __DEFINED_suseconds_t
115#endif
116
117#else
118#if defined(__NEED_time_t) && !defined(__DEFINED_time_t)
119#include <__typedef_time_t.h>
120#define __DEFINED_time_t
121#endif
122
123#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
124#include <__typedef_suseconds_t.h>
125#define __DEFINED_suseconds_t
126#endif
127#endif
128
129#if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t)
130typedef signed char int8_t;
131#define __DEFINED_int8_t
132#endif
133
134#if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t)
135typedef signed short int16_t;
136#define __DEFINED_int16_t
137#endif
138
139#if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t)
140typedef signed int int32_t;
141#define __DEFINED_int32_t
142#endif
143
144#if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t)
145typedef signed _Int64 int64_t;
146#define __DEFINED_int64_t
147#endif
148
149#if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t)
150typedef signed _Int64 intmax_t;
151#define __DEFINED_intmax_t
152#endif
153
154#if defined(__NEED_uint8_t) && !defined(__DEFINED_uint8_t)
155typedef unsigned char uint8_t;
156#define __DEFINED_uint8_t
157#endif
158
159#if defined(__NEED_uint16_t) && !defined(__DEFINED_uint16_t)
160typedef unsigned short uint16_t;
161#define __DEFINED_uint16_t
162#endif
163
164#if defined(__NEED_uint32_t) && !defined(__DEFINED_uint32_t)
165typedef unsigned int uint32_t;
166#define __DEFINED_uint32_t
167#endif
168
169#if defined(__NEED_uint64_t) && !defined(__DEFINED_uint64_t)
170typedef unsigned _Int64 uint64_t;
171#define __DEFINED_uint64_t
172#endif
173
174#if defined(__NEED_u_int64_t) && !defined(__DEFINED_u_int64_t)
175typedef unsigned _Int64 u_int64_t;
176#define __DEFINED_u_int64_t
177#endif
178
179#if defined(__NEED_uintmax_t) && !defined(__DEFINED_uintmax_t)
180typedef unsigned _Int64 uintmax_t;
181#define __DEFINED_uintmax_t
182#endif
183
184
185#if defined(__NEED_mode_t) && !defined(__DEFINED_mode_t)
186typedef unsigned mode_t;
187#define __DEFINED_mode_t
188#endif
189
190#if defined(__NEED_nlink_t) && !defined(__DEFINED_nlink_t)
191typedef unsigned _Reg nlink_t;
192#define __DEFINED_nlink_t
193#endif
194
195#if defined(__NEED_off_t) && !defined(__DEFINED_off_t)
196typedef _Int64 off_t;
197#define __DEFINED_off_t
198#endif
199
200#if defined(__NEED_ino_t) && !defined(__DEFINED_ino_t)
201typedef unsigned _Int64 ino_t;
202#define __DEFINED_ino_t
203#endif
204
205#if defined(__NEED_dev_t) && !defined(__DEFINED_dev_t)
206typedef unsigned _Int64 dev_t;
207#define __DEFINED_dev_t
208#endif
209
210#if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t)
211typedef long blksize_t;
212#define __DEFINED_blksize_t
213#endif
214
215#if defined(__NEED_blkcnt_t) && !defined(__DEFINED_blkcnt_t)
216typedef _Int64 blkcnt_t;
217#define __DEFINED_blkcnt_t
218#endif
219
220#if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t)
221typedef unsigned _Int64 fsblkcnt_t;
222#define __DEFINED_fsblkcnt_t
223#endif
224
225#if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t)
226typedef unsigned _Int64 fsfilcnt_t;
227#define __DEFINED_fsfilcnt_t
228#endif
229
230
231#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t)
232typedef unsigned wint_t;
233#define __DEFINED_wint_t
234#endif
235
236#if defined(__NEED_wctype_t) && !defined(__DEFINED_wctype_t)
237typedef unsigned long wctype_t;
238#define __DEFINED_wctype_t
239#endif
240
241
242#if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t)
243typedef void * timer_t;
244#define __DEFINED_timer_t
245#endif
246
247#if defined(__NEED_clockid_t) && !defined(__DEFINED_clockid_t)
248typedef int clockid_t;
249#define __DEFINED_clockid_t
250#endif
251
252#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t)
253typedef long clock_t;
254#define __DEFINED_clock_t
255#endif
256
257#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
258#if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval)
259struct timeval { time_t tv_sec; suseconds_t tv_usec; };
260#define __DEFINED_struct_timeval
261#endif
262
263#if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec)
264struct timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); };
265#define __DEFINED_struct_timespec
266#endif
267
268#else
269#include <__struct_timeval.h>
270#include <__struct_timespec.h>
271#endif
272
273#if defined(__NEED_pid_t) && !defined(__DEFINED_pid_t)
274typedef int pid_t;
275#define __DEFINED_pid_t
276#endif
277
278#if defined(__NEED_id_t) && !defined(__DEFINED_id_t)
279typedef unsigned id_t;
280#define __DEFINED_id_t
281#endif
282
283#if defined(__NEED_uid_t) && !defined(__DEFINED_uid_t)
284typedef unsigned uid_t;
285#define __DEFINED_uid_t
286#endif
287
288#if defined(__NEED_gid_t) && !defined(__DEFINED_gid_t)
289typedef unsigned gid_t;
290#define __DEFINED_gid_t
291#endif
292
293#if defined(__NEED_key_t) && !defined(__DEFINED_key_t)
294typedef int key_t;
295#define __DEFINED_key_t
296#endif
297
298#if defined(__NEED_useconds_t) && !defined(__DEFINED_useconds_t)
299typedef unsigned useconds_t;
300#define __DEFINED_useconds_t
301#endif
302
303
304#ifdef __cplusplus
305#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t)
306typedef unsigned long pthread_t;
307#define __DEFINED_pthread_t
308#endif
309
310#else
311#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t)
312typedef struct __pthread * pthread_t;
313#define __DEFINED_pthread_t
314#endif
315
316#endif
317#if defined(__NEED_pthread_once_t) && !defined(__DEFINED_pthread_once_t)
318typedef int pthread_once_t;
319#define __DEFINED_pthread_once_t
320#endif
321
322#if defined(__NEED_pthread_key_t) && !defined(__DEFINED_pthread_key_t)
323typedef unsigned pthread_key_t;
324#define __DEFINED_pthread_key_t
325#endif
326
327#if defined(__NEED_pthread_spinlock_t) && !defined(__DEFINED_pthread_spinlock_t)
328typedef int pthread_spinlock_t;
329#define __DEFINED_pthread_spinlock_t
330#endif
331
332#if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t)
333typedef struct { unsigned __attr; } pthread_mutexattr_t;
334#define __DEFINED_pthread_mutexattr_t
335#endif
336
337#if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t)
338typedef struct { unsigned __attr; } pthread_condattr_t;
339#define __DEFINED_pthread_condattr_t
340#endif
341
342#if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t)
343typedef struct { unsigned __attr; } pthread_barrierattr_t;
344#define __DEFINED_pthread_barrierattr_t
345#endif
346
347#if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t)
348typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t;
349#define __DEFINED_pthread_rwlockattr_t
350#endif
351
352
353#ifdef __wasilibc_unmodified_upstream /* WASI doesn't need to define FILE as a complete type */
354#if defined(__NEED_struct__IO_FILE) && !defined(__DEFINED_struct__IO_FILE)
355struct _IO_FILE { char __x; };
356#define __DEFINED_struct__IO_FILE
357#endif
358
359#endif
360#if defined(__NEED_FILE) && !defined(__DEFINED_FILE)
361typedef struct _IO_FILE FILE;
362#define __DEFINED_FILE
363#endif
364
365
366#if defined(__NEED_va_list) && !defined(__DEFINED_va_list)
367typedef __builtin_va_list va_list;
368#define __DEFINED_va_list
369#endif
370
371#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list)
372typedef __builtin_va_list __isoc_va_list;
373#define __DEFINED___isoc_va_list
374#endif
375
376
377#if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t)
378typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
379#define __DEFINED_mbstate_t
380#endif
381
382
383#if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t)
384typedef struct __locale_struct * locale_t;
385#define __DEFINED_locale_t
386#endif
387
388
389#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t)
390typedef struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t;
391#define __DEFINED_sigset_t
392#endif
393
394
395#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
396#if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec)
397struct iovec { void *iov_base; size_t iov_len; };
398#define __DEFINED_struct_iovec
399#endif
400
401#else
402#include <__struct_iovec.h>
403#endif
404
405#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize)
406struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; };
407#define __DEFINED_struct_winsize
408#endif
409
410
411#if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t)
412typedef unsigned socklen_t;
413#define __DEFINED_socklen_t
414#endif
415
416#if defined(__NEED_sa_family_t) && !defined(__DEFINED_sa_family_t)
417typedef unsigned short sa_family_t;
418#define __DEFINED_sa_family_t
419#endif
420
421
422#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t)
423typedef struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t;
424#define __DEFINED_pthread_attr_t
425#endif
426
427#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t)
428typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } pthread_mutex_t;
429#define __DEFINED_pthread_mutex_t
430#endif
431
432#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t)
433typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } mtx_t;
434#define __DEFINED_mtx_t
435#endif
436
437#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t)
438typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } pthread_cond_t;
439#define __DEFINED_pthread_cond_t
440#endif
441
442#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t)
443typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } cnd_t;
444#define __DEFINED_cnd_t
445#endif
446
447#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t)
448typedef struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t;
449#define __DEFINED_pthread_rwlock_t
450#endif
451
452#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t)
453typedef struct { union { int __i[sizeof(long)==8?8:5]; volatile int __vi[sizeof(long)==8?8:5]; void *__p[sizeof(long)==8?4:5]; } __u; } pthread_barrier_t;
454#define __DEFINED_pthread_barrier_t
455#endif
456
457
458#undef _Addr
459#undef _Int64
460#undef _Reg
lib/libc/include/wasm-wasi-musl/bits/dirent.h created+1
......@@ -0,0 +1 @@
1#include <__struct_dirent.h>
lib/libc/include/wasm-wasi-musl/bits/fcntl.h created+1
......@@ -0,0 +1 @@
1/* Use the WASI libc fcntl implementation bits. */
lib/libc/include/wasm-wasi-musl/bits/fenv.h created+10
......@@ -0,0 +1,10 @@
1#define FE_ALL_EXCEPT 0
2#define FE_TONEAREST 0
3
4typedef unsigned long fexcept_t;
5
6typedef struct {
7 unsigned long __cw;
8} fenv_t;
9
10#define FE_DFL_ENV ((const fenv_t *) -1)
lib/libc/include/wasm-wasi-musl/bits/float.h created+16
......@@ -0,0 +1,16 @@
1#define FLT_EVAL_METHOD 0
2
3#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
4#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
5#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
6#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
7
8#define LDBL_MANT_DIG 113
9#define LDBL_MIN_EXP (-16381)
10#define LDBL_MAX_EXP 16384
11
12#define LDBL_DIG 33
13#define LDBL_MIN_10_EXP (-4931)
14#define LDBL_MAX_10_EXP 4932
15
16#define DECIMAL_DIG 36
lib/libc/include/wasm-wasi-musl/bits/hwcap.h created
lib/libc/include/wasm-wasi-musl/bits/io.h created
lib/libc/include/wasm-wasi-musl/bits/ioctl.h created+1
......@@ -0,0 +1 @@
1/* Use the WASI libc ioctl implementation bits. */
lib/libc/include/wasm-wasi-musl/bits/ioctl_fix.h created
lib/libc/include/wasm-wasi-musl/bits/ipcstat.h created+1
......@@ -0,0 +1 @@
1#define IPC_STAT 2
lib/libc/include/wasm-wasi-musl/bits/limits.h created+1
......@@ -0,0 +1 @@
1#include <__macro_PAGESIZE.h>
lib/libc/include/wasm-wasi-musl/bits/mman.h created
lib/libc/include/wasm-wasi-musl/bits/poll.h created
lib/libc/include/wasm-wasi-musl/bits/posix.h created+2
......@@ -0,0 +1,2 @@
1#define _POSIX_V6_ILP32_OFFBIG (1)
2#define _POSIX_V7_ILP32_OFFBIG (1)
lib/libc/include/wasm-wasi-musl/bits/reg.h created+2
......@@ -0,0 +1,2 @@
1#undef __WORDSIZE
2#define __WORDSIZE 64
lib/libc/include/wasm-wasi-musl/bits/resource.h created
lib/libc/include/wasm-wasi-musl/bits/signal.h created+40
......@@ -0,0 +1,40 @@
1#ifdef _WASI_EMULATED_SIGNAL
2
3#define SIGHUP 1
4#define SIGINT 2
5#define SIGQUIT 3
6#define SIGILL 4
7#define SIGTRAP 5
8#define SIGABRT 6
9#define SIGIOT SIGABRT
10#define SIGBUS 7
11#define SIGFPE 8
12#define SIGKILL 9
13#define SIGUSR1 10
14#define SIGSEGV 11
15#define SIGUSR2 12
16#define SIGPIPE 13
17#define SIGALRM 14
18#define SIGTERM 15
19#define SIGSTKFLT 16
20#define SIGCHLD 17
21#define SIGCONT 18
22#define SIGSTOP 19
23#define SIGTSTP 20
24#define SIGTTIN 21
25#define SIGTTOU 22
26#define SIGURG 23
27#define SIGXCPU 24
28#define SIGXFSZ 25
29#define SIGVTALRM 26
30#define SIGPROF 27
31#define SIGWINCH 28
32#define SIGIO 29
33#define SIGPOLL 29
34#define SIGPWR 30
35#define SIGSYS 31
36#define SIGUNUSED SIGSYS
37
38#define _NSIG 65
39
40#endif
lib/libc/include/wasm-wasi-musl/bits/socket.h created
lib/libc/include/wasm-wasi-musl/bits/stat.h created+1
......@@ -0,0 +1 @@
1#include <__struct_stat.h>
lib/libc/include/wasm-wasi-musl/bits/stdint.h created+20
......@@ -0,0 +1,20 @@
1typedef int16_t int_fast16_t;
2typedef int32_t int_fast32_t;
3typedef uint16_t uint_fast16_t;
4typedef uint32_t uint_fast32_t;
5
6#define INT_FAST16_MIN INT16_MIN
7#define INT_FAST32_MIN INT32_MIN
8
9#define INT_FAST16_MAX INT16_MAX
10#define INT_FAST32_MAX INT32_MAX
11
12#define UINT_FAST16_MAX UINT16_MAX
13#define UINT_FAST32_MAX UINT32_MAX
14
15#define INTPTR_MIN INT32_MIN
16#define INTPTR_MAX INT32_MAX
17#define UINTPTR_MAX UINT32_MAX
18#define PTRDIFF_MIN INT32_MIN
19#define PTRDIFF_MAX INT32_MAX
20#define SIZE_MAX UINT32_MAX
lib/libc/include/wasm-wasi-musl/byteswap.h created+26
......@@ -0,0 +1,26 @@
1#ifndef _BYTESWAP_H
2#define _BYTESWAP_H
3
4#include <features.h>
5#include <stdint.h>
6
7static __inline uint16_t __bswap_16(uint16_t __x)
8{
9 return __x<<8 | __x>>8;
10}
11
12static __inline uint32_t __bswap_32(uint32_t __x)
13{
14 return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
15}
16
17static __inline uint64_t __bswap_64(uint64_t __x)
18{
19 return __bswap_32(__x)+0ULL<<32 | __bswap_32(__x>>32);
20}
21
22#define bswap_16(x) __bswap_16(x)
23#define bswap_32(x) __bswap_32(x)
24#define bswap_64(x) __bswap_64(x)
25
26#endif
lib/libc/include/wasm-wasi-musl/complex.h created+143
......@@ -0,0 +1,143 @@
1#ifndef _COMPLEX_H
2#define _COMPLEX_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define complex _Complex
9#ifdef __GNUC__
10#define _Complex_I (__extension__ (0.0f+1.0fi))
11#else
12#define _Complex_I (0.0f+1.0fi)
13#endif
14#define I _Complex_I
15
16double complex cacos(double complex);
17float complex cacosf(float complex);
18long double complex cacosl(long double complex);
19
20double complex casin(double complex);
21float complex casinf(float complex);
22long double complex casinl(long double complex);
23
24double complex catan(double complex);
25float complex catanf(float complex);
26long double complex catanl(long double complex);
27
28double complex ccos(double complex);
29float complex ccosf(float complex);
30long double complex ccosl(long double complex);
31
32double complex csin(double complex);
33float complex csinf(float complex);
34long double complex csinl(long double complex);
35
36double complex ctan(double complex);
37float complex ctanf(float complex);
38long double complex ctanl(long double complex);
39
40double complex cacosh(double complex);
41float complex cacoshf(float complex);
42long double complex cacoshl(long double complex);
43
44double complex casinh(double complex);
45float complex casinhf(float complex);
46long double complex casinhl(long double complex);
47
48double complex catanh(double complex);
49float complex catanhf(float complex);
50long double complex catanhl(long double complex);
51
52double complex ccosh(double complex);
53float complex ccoshf(float complex);
54long double complex ccoshl(long double complex);
55
56double complex csinh(double complex);
57float complex csinhf(float complex);
58long double complex csinhl(long double complex);
59
60double complex ctanh(double complex);
61float complex ctanhf(float complex);
62long double complex ctanhl(long double complex);
63
64double complex cexp(double complex);
65float complex cexpf(float complex);
66long double complex cexpl(long double complex);
67
68double complex clog(double complex);
69float complex clogf(float complex);
70long double complex clogl(long double complex);
71
72double cabs(double complex);
73float cabsf(float complex);
74long double cabsl(long double complex);
75
76double complex cpow(double complex, double complex);
77float complex cpowf(float complex, float complex);
78long double complex cpowl(long double complex, long double complex);
79
80double complex csqrt(double complex);
81float complex csqrtf(float complex);
82long double complex csqrtl(long double complex);
83
84double carg(double complex);
85float cargf(float complex);
86long double cargl(long double complex);
87
88double cimag(double complex);
89float cimagf(float complex);
90long double cimagl(long double complex);
91
92double complex conj(double complex);
93float complex conjf(float complex);
94long double complex conjl(long double complex);
95
96double complex cproj(double complex);
97float complex cprojf(float complex);
98long double complex cprojl(long double complex);
99
100double creal(double complex);
101float crealf(float complex);
102long double creall(long double complex);
103
104#ifdef __wasilibc_unmodified_upstream /* Use the compiler's real/imag operators rather than union type punning */
105#ifndef __cplusplus
106#define __CIMAG(x, t) \
107 (+(union { _Complex t __z; t __xy[2]; }){(_Complex t)(x)}.__xy[1])
108
109#define creal(x) ((double)(x))
110#define crealf(x) ((float)(x))
111#define creall(x) ((long double)(x))
112
113#define cimag(x) __CIMAG(x, double)
114#define cimagf(x) __CIMAG(x, float)
115#define cimagl(x) __CIMAG(x, long double)
116#endif
117#else
118#define creal(x) (__builtin_creal(x))
119#define crealf(x) (__builtin_crealf(x))
120#define creall(x) (__builtin_creall(x))
121
122#define cimag(x) (__builtin_cimag(x))
123#define cimagf(x) (__builtin_cimagf(x))
124#define cimagl(x) (__builtin_cimagl(x))
125#endif
126
127#if __STDC_VERSION__ >= 201112L
128#if defined(_Imaginary_I)
129#define __CMPLX(x, y, t) ((t)(x) + _Imaginary_I*(t)(y))
130#elif defined(__clang__)
131#define __CMPLX(x, y, t) (+(_Complex t){ (t)(x), (t)(y) })
132#else
133#define __CMPLX(x, y, t) (__builtin_complex((t)(x), (t)(y)))
134#endif
135#define CMPLX(x, y) __CMPLX(x, y, double)
136#define CMPLXF(x, y) __CMPLX(x, y, float)
137#define CMPLXL(x, y) __CMPLX(x, y, long double)
138#endif
139
140#ifdef __cplusplus
141}
142#endif
143#endif
lib/libc/include/wasm-wasi-musl/cpio.h created+29
......@@ -0,0 +1,29 @@
1#ifndef _CPIO_H
2#define _CPIO_H
3
4#define MAGIC "070707"
5
6#define C_IRUSR 000400
7#define C_IWUSR 000200
8#define C_IXUSR 000100
9#define C_IRGRP 000040
10#define C_IWGRP 000020
11#define C_IXGRP 000010
12#define C_IROTH 000004
13#define C_IWOTH 000002
14#define C_IXOTH 000001
15
16#define C_ISUID 004000
17#define C_ISGID 002000
18#define C_ISVTX 001000
19
20#define C_ISBLK 060000
21#define C_ISCHR 020000
22#define C_ISDIR 040000
23#define C_ISFIFO 010000
24#define C_ISSOCK 0140000
25#define C_ISLNK 0120000
26#define C_ISCTG 0110000
27#define C_ISREG 0100000
28
29#endif
lib/libc/include/wasm-wasi-musl/crypt.h created+20
......@@ -0,0 +1,20 @@
1#ifndef _CRYPT_H
2#define _CRYPT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8struct crypt_data {
9 int initialized;
10 char __buf[256];
11};
12
13char *crypt(const char *, const char *);
14char *crypt_r(const char *, const char *, struct crypt_data *);
15
16#ifdef __cplusplus
17}
18#endif
19
20#endif
lib/libc/include/wasm-wasi-musl/ctype.h created+75
......@@ -0,0 +1,75 @@
1#ifndef _CTYPE_H
2#define _CTYPE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10int isalnum(int);
11int isalpha(int);
12int isblank(int);
13int iscntrl(int);
14int isdigit(int);
15int isgraph(int);
16int islower(int);
17int isprint(int);
18int ispunct(int);
19int isspace(int);
20int isupper(int);
21int isxdigit(int);
22int tolower(int);
23int toupper(int);
24
25#ifndef __cplusplus
26static __inline int __isspace(int _c)
27{
28 return _c == ' ' || (unsigned)_c-'\t' < 5;
29}
30
31#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a)|32)-'a') < 26)
32#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10)
33#define islower(a) (0 ? islower(a) : ((unsigned)(a)-'a') < 26)
34#define isupper(a) (0 ? isupper(a) : ((unsigned)(a)-'A') < 26)
35#define isprint(a) (0 ? isprint(a) : ((unsigned)(a)-0x20) < 0x5f)
36#define isgraph(a) (0 ? isgraph(a) : ((unsigned)(a)-0x21) < 0x5e)
37#define isspace(a) __isspace(a)
38#endif
39
40
41#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
42 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
43 || defined(_BSD_SOURCE)
44
45#define __NEED_locale_t
46#include <bits/alltypes.h>
47
48int isalnum_l(int, locale_t);
49int isalpha_l(int, locale_t);
50int isblank_l(int, locale_t);
51int iscntrl_l(int, locale_t);
52int isdigit_l(int, locale_t);
53int isgraph_l(int, locale_t);
54int islower_l(int, locale_t);
55int isprint_l(int, locale_t);
56int ispunct_l(int, locale_t);
57int isspace_l(int, locale_t);
58int isupper_l(int, locale_t);
59int isxdigit_l(int, locale_t);
60int tolower_l(int, locale_t);
61int toupper_l(int, locale_t);
62
63int isascii(int);
64int toascii(int);
65#define _tolower(a) ((a)|0x20)
66#define _toupper(a) ((a)&0x5f)
67#define isascii(a) (0 ? isascii(a) : (unsigned)(a) < 128)
68
69#endif
70
71#ifdef __cplusplus
72}
73#endif
74
75#endif
lib/libc/include/wasm-wasi-musl/dirent.h created+89
......@@ -0,0 +1,89 @@
1#ifndef _DIRENT_H
2#define _DIRENT_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#else
6#include <__header_dirent.h>
7#endif
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <features.h>
13
14#define __NEED_ino_t
15#define __NEED_off_t
16#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
17#define __NEED_size_t
18#endif
19
20#include <bits/alltypes.h>
21
22#include <bits/dirent.h>
23
24#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
25typedef struct __dirstream DIR;
26#else
27#include <__typedef_DIR.h>
28#endif
29
30#define d_fileno d_ino
31
32int closedir(DIR *);
33DIR *fdopendir(int);
34DIR *opendir(const char *);
35struct dirent *readdir(DIR *);
36#ifdef __wasilibc_unmodified_upstream /* readdir_r is obsolete */
37int readdir_r(DIR *__restrict, struct dirent *__restrict, struct dirent **__restrict);
38#endif
39void rewinddir(DIR *);
40int dirfd(DIR *);
41
42int alphasort(const struct dirent **, const struct dirent **);
43int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
44
45#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
46void seekdir(DIR *, long);
47long telldir(DIR *);
48#endif
49
50#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
51#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
52#define DT_UNKNOWN 0
53#define DT_FIFO 1
54#define DT_CHR 2
55#define DT_DIR 4
56#define DT_BLK 6
57#define DT_REG 8
58#define DT_LNK 10
59#define DT_SOCK 12
60#define DT_WHT 14
61#define IFTODT(x) ((x)>>12 & 017)
62#define DTTOIF(x) ((x)<<12)
63#endif
64int getdents(int, struct dirent *, size_t);
65#endif
66
67#ifdef _GNU_SOURCE
68int versionsort(const struct dirent **, const struct dirent **);
69#endif
70
71#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
72#define dirent64 dirent
73#define readdir64 readdir
74#ifdef __wasilibc_unmodified_upstream /* readdir_r is obsolete */
75#define readdir64_r readdir_r
76#endif
77#define scandir64 scandir
78#define alphasort64 alphasort
79#define versionsort64 versionsort
80#define off64_t off_t
81#define ino64_t ino_t
82#define getdents64 getdents
83#endif
84
85#ifdef __cplusplus
86}
87#endif
88
89#endif
lib/libc/include/wasm-wasi-musl/endian.h created+80
......@@ -0,0 +1,80 @@
1#ifndef _ENDIAN_H
2#define _ENDIAN_H
3
4#include <features.h>
5
6#define __NEED_uint16_t
7#define __NEED_uint32_t
8#define __NEED_uint64_t
9
10#include <bits/alltypes.h>
11
12#define __PDP_ENDIAN 3412
13
14#define BIG_ENDIAN __BIG_ENDIAN
15#define LITTLE_ENDIAN __LITTLE_ENDIAN
16#define PDP_ENDIAN __PDP_ENDIAN
17#define BYTE_ORDER __BYTE_ORDER
18
19static __inline uint16_t __bswap16(uint16_t __x)
20{
21 return __x<<8 | __x>>8;
22}
23
24static __inline uint32_t __bswap32(uint32_t __x)
25{
26 return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
27}
28
29static __inline uint64_t __bswap64(uint64_t __x)
30{
31 return __bswap32(__x)+0ULL<<32 | __bswap32(__x>>32);
32}
33
34#if __BYTE_ORDER == __LITTLE_ENDIAN
35#define htobe16(x) __bswap16(x)
36#define be16toh(x) __bswap16(x)
37#define htobe32(x) __bswap32(x)
38#define be32toh(x) __bswap32(x)
39#define htobe64(x) __bswap64(x)
40#define be64toh(x) __bswap64(x)
41#define htole16(x) (uint16_t)(x)
42#define le16toh(x) (uint16_t)(x)
43#define htole32(x) (uint32_t)(x)
44#define le32toh(x) (uint32_t)(x)
45#define htole64(x) (uint64_t)(x)
46#define le64toh(x) (uint64_t)(x)
47#else
48#define htobe16(x) (uint16_t)(x)
49#define be16toh(x) (uint16_t)(x)
50#define htobe32(x) (uint32_t)(x)
51#define be32toh(x) (uint32_t)(x)
52#define htobe64(x) (uint64_t)(x)
53#define be64toh(x) (uint64_t)(x)
54#define htole16(x) __bswap16(x)
55#define le16toh(x) __bswap16(x)
56#define htole32(x) __bswap32(x)
57#define le32toh(x) __bswap32(x)
58#define htole64(x) __bswap64(x)
59#define le64toh(x) __bswap64(x)
60#endif
61
62#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
63#if __BYTE_ORDER == __LITTLE_ENDIAN
64#define betoh16(x) __bswap16(x)
65#define betoh32(x) __bswap32(x)
66#define betoh64(x) __bswap64(x)
67#define letoh16(x) (uint16_t)(x)
68#define letoh32(x) (uint32_t)(x)
69#define letoh64(x) (uint64_t)(x)
70#else
71#define betoh16(x) (uint16_t)(x)
72#define betoh32(x) (uint32_t)(x)
73#define betoh64(x) (uint64_t)(x)
74#define letoh16(x) __bswap16(x)
75#define letoh32(x) __bswap32(x)
76#define letoh64(x) __bswap64(x)
77#endif
78#endif
79
80#endif
lib/libc/include/wasm-wasi-musl/err.h created+25
......@@ -0,0 +1,25 @@
1#ifndef _ERR_H
2#define _ERR_H
3
4#include <features.h>
5#include <stdarg.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11void warn(const char *, ...);
12void vwarn(const char *, va_list);
13void warnx(const char *, ...);
14void vwarnx(const char *, va_list);
15
16_Noreturn void err(int, const char *, ...);
17_Noreturn void verr(int, const char *, va_list);
18_Noreturn void errx(int, const char *, ...);
19_Noreturn void verrx(int, const char *, va_list);
20
21#ifdef __cplusplus
22}
23#endif
24
25#endif
lib/libc/include/wasm-wasi-musl/errno.h created+32
......@@ -0,0 +1,32 @@
1#ifndef _ERRNO_H
2#define _ERRNO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
11#include <bits/errno.h>
12
13#ifdef __GNUC__
14__attribute__((const))
15#endif
16int *__errno_location(void);
17#define errno (*__errno_location())
18#else
19#include <__errno.h>
20#include <__errno_values.h>
21#endif
22
23#ifdef _GNU_SOURCE
24extern char *program_invocation_short_name, *program_invocation_name;
25#endif
26
27#ifdef __cplusplus
28}
29#endif
30
31#endif
32
lib/libc/include/wasm-wasi-musl/fcntl.h created+246
......@@ -0,0 +1,246 @@
1#ifndef _FCNTL_H
2#define _FCNTL_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#else
6#include <__header_fcntl.h>
7#endif
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <features.h>
13
14#define __NEED_off_t
15#define __NEED_pid_t
16#define __NEED_mode_t
17
18#ifdef _GNU_SOURCE
19#define __NEED_size_t
20#define __NEED_ssize_t
21#define __NEED_struct_iovec
22#endif
23
24#include <bits/alltypes.h>
25
26#include <bits/fcntl.h>
27
28struct flock {
29 short l_type;
30 short l_whence;
31 off_t l_start;
32 off_t l_len;
33 pid_t l_pid;
34};
35
36int creat(const char *, mode_t);
37int fcntl(int, int, ...);
38int open(const char *, int, ...);
39int openat(int, const char *, int, ...);
40int posix_fadvise(int, off_t, off_t, int);
41int posix_fallocate(int, off_t, off_t);
42
43#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
44#define O_SEARCH O_PATH
45#define O_EXEC O_PATH
46#define O_TTY_INIT 0
47
48#define O_ACCMODE (03|O_SEARCH)
49#define O_RDONLY 00
50#define O_WRONLY 01
51#define O_RDWR 02
52
53#define F_OFD_GETLK 36
54#define F_OFD_SETLK 37
55#define F_OFD_SETLKW 38
56
57#define F_DUPFD_CLOEXEC 1030
58
59#define F_RDLCK 0
60#define F_WRLCK 1
61#define F_UNLCK 2
62
63#define FD_CLOEXEC 1
64
65#define AT_FDCWD (-100)
66#define AT_SYMLINK_NOFOLLOW 0x100
67#define AT_REMOVEDIR 0x200
68#define AT_SYMLINK_FOLLOW 0x400
69#define AT_EACCESS 0x200
70
71#define POSIX_FADV_NORMAL 0
72#define POSIX_FADV_RANDOM 1
73#define POSIX_FADV_SEQUENTIAL 2
74#define POSIX_FADV_WILLNEED 3
75#ifndef POSIX_FADV_DONTNEED
76#define POSIX_FADV_DONTNEED 4
77#define POSIX_FADV_NOREUSE 5
78#endif
79
80#undef SEEK_SET
81#undef SEEK_CUR
82#undef SEEK_END
83#define SEEK_SET 0
84#define SEEK_CUR 1
85#define SEEK_END 2
86
87#ifndef S_IRUSR
88#define S_ISUID 04000
89#define S_ISGID 02000
90#define S_ISVTX 01000
91#define S_IRUSR 0400
92#define S_IWUSR 0200
93#define S_IXUSR 0100
94#define S_IRWXU 0700
95#define S_IRGRP 0040
96#define S_IWGRP 0020
97#define S_IXGRP 0010
98#define S_IRWXG 0070
99#define S_IROTH 0004
100#define S_IWOTH 0002
101#define S_IXOTH 0001
102#define S_IRWXO 0007
103#endif
104
105#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
106#define AT_NO_AUTOMOUNT 0x800
107#define AT_EMPTY_PATH 0x1000
108#define AT_STATX_SYNC_TYPE 0x6000
109#define AT_STATX_SYNC_AS_STAT 0x0000
110#define AT_STATX_FORCE_SYNC 0x2000
111#define AT_STATX_DONT_SYNC 0x4000
112#define AT_RECURSIVE 0x8000
113
114#define FAPPEND O_APPEND
115#define FFSYNC O_SYNC
116#define FASYNC O_ASYNC
117#define FNONBLOCK O_NONBLOCK
118#define FNDELAY O_NDELAY
119
120#define F_OK 0
121#define R_OK 4
122#define W_OK 2
123#define X_OK 1
124#define F_ULOCK 0
125#define F_LOCK 1
126#define F_TLOCK 2
127#define F_TEST 3
128
129#define F_SETLEASE 1024
130#define F_GETLEASE 1025
131#define F_NOTIFY 1026
132#define F_CANCELLK 1029
133#define F_SETPIPE_SZ 1031
134#define F_GETPIPE_SZ 1032
135#define F_ADD_SEALS 1033
136#define F_GET_SEALS 1034
137
138#define F_SEAL_SEAL 0x0001
139#define F_SEAL_SHRINK 0x0002
140#define F_SEAL_GROW 0x0004
141#define F_SEAL_WRITE 0x0008
142#define F_SEAL_FUTURE_WRITE 0x0010
143
144#define F_GET_RW_HINT 1035
145#define F_SET_RW_HINT 1036
146#define F_GET_FILE_RW_HINT 1037
147#define F_SET_FILE_RW_HINT 1038
148
149#define RWF_WRITE_LIFE_NOT_SET 0
150#define RWH_WRITE_LIFE_NONE 1
151#define RWH_WRITE_LIFE_SHORT 2
152#define RWH_WRITE_LIFE_MEDIUM 3
153#define RWH_WRITE_LIFE_LONG 4
154#define RWH_WRITE_LIFE_EXTREME 5
155
156#define DN_ACCESS 0x00000001
157#define DN_MODIFY 0x00000002
158#define DN_CREATE 0x00000004
159#define DN_DELETE 0x00000008
160#define DN_RENAME 0x00000010
161#define DN_ATTRIB 0x00000020
162#define DN_MULTISHOT 0x80000000
163
164int lockf(int, int, off_t);
165#endif
166#endif
167
168#if defined(_GNU_SOURCE)
169#ifdef __wasilibc_unmodified_upstream /* WASI has no name_to_handle_at */
170#define F_OWNER_TID 0
171#define F_OWNER_PID 1
172#define F_OWNER_PGRP 2
173#define F_OWNER_GID 2
174struct file_handle {
175 unsigned handle_bytes;
176 int handle_type;
177 unsigned char f_handle[];
178};
179#endif
180#ifdef __wasilibc_unmodified_upstream /* WASI has no F_GETOWN_EX */
181struct f_owner_ex {
182 int type;
183 pid_t pid;
184};
185#endif
186#ifdef __wasilibc_unmodified_upstream /* WASI has no fallocate */
187#define FALLOC_FL_KEEP_SIZE 1
188#define FALLOC_FL_PUNCH_HOLE 2
189#endif
190#ifdef __wasilibc_unmodified_upstream /* WASI has no name_to_handle_at */
191#define MAX_HANDLE_SZ 128
192#endif
193#ifdef __wasilibc_unmodified_upstream /* WASI has no syc_file_range */
194#define SYNC_FILE_RANGE_WAIT_BEFORE 1
195#define SYNC_FILE_RANGE_WRITE 2
196#define SYNC_FILE_RANGE_WAIT_AFTER 4
197#endif
198#ifdef __wasilibc_unmodified_upstream /* WASI has no splice */
199#define SPLICE_F_MOVE 1
200#define SPLICE_F_NONBLOCK 2
201#define SPLICE_F_MORE 4
202#define SPLICE_F_GIFT 8
203#endif
204#ifdef __wasilibc_unmodified_upstream /* WASI has no fallocate */
205int fallocate(int, int, off_t, off_t);
206#define fallocate64 fallocate
207#endif
208#ifdef __wasilibc_unmodified_upstream /* WASI has no name_to_handle_at */
209int name_to_handle_at(int, const char *, struct file_handle *, int *, int);
210int open_by_handle_at(int, struct file_handle *, int);
211#endif
212#ifdef __wasilibc_unmodified_upstream /* WASI has no readahead */
213ssize_t readahead(int, off_t, size_t);
214#endif
215#ifdef __wasilibc_unmodified_upstream /* WASI has no splice, syc_file_range, or tee */
216int sync_file_range(int, off_t, off_t, unsigned);
217ssize_t vmsplice(int, const struct iovec *, size_t, unsigned);
218ssize_t splice(int, off_t *, int, off_t *, size_t, unsigned);
219ssize_t tee(int, int, size_t, unsigned);
220#endif
221#define loff_t off_t
222#endif
223
224#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
225#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
226#define F_GETLK64 F_GETLK
227#define F_SETLK64 F_SETLK
228#define F_SETLKW64 F_SETLKW
229#define flock64 flock
230#endif
231#define open64 open
232#define openat64 openat
233#define creat64 creat
234#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
235#define lockf64 lockf
236#endif
237#define posix_fadvise64 posix_fadvise
238#define posix_fallocate64 posix_fallocate
239#define off64_t off_t
240#endif
241
242#ifdef __cplusplus
243}
244#endif
245
246#endif
lib/libc/include/wasm-wasi-musl/features.h created+40
......@@ -0,0 +1,40 @@
1#ifndef _FEATURES_H
2#define _FEATURES_H
3
4#if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE)
5#define _GNU_SOURCE 1
6#endif
7
8#if defined(_DEFAULT_SOURCE) && !defined(_BSD_SOURCE)
9#define _BSD_SOURCE 1
10#endif
11
12#if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
13 && !defined(_XOPEN_SOURCE) && !defined(_GNU_SOURCE) \
14 && !defined(_BSD_SOURCE) && !defined(__STRICT_ANSI__)
15#define _BSD_SOURCE 1
16#define _XOPEN_SOURCE 700
17#endif
18
19#if __STDC_VERSION__ >= 199901L
20#define __restrict restrict
21#elif !defined(__GNUC__)
22#define __restrict
23#endif
24
25#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
26#define __inline inline
27#elif !defined(__GNUC__)
28#define __inline
29#endif
30
31#if __STDC_VERSION__ >= 201112L
32#elif defined(__GNUC__)
33#define _Noreturn __attribute__((__noreturn__))
34#else
35#define _Noreturn
36#endif
37
38#define __REDIR(x,y) __typeof__(x) x __asm__(#y)
39
40#endif
lib/libc/include/wasm-wasi-musl/fenv.h created+28
......@@ -0,0 +1,28 @@
1#ifndef _FENV_H
2#define _FENV_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <bits/fenv.h>
9
10int feclearexcept(int);
11int fegetexceptflag(fexcept_t *, int);
12int feraiseexcept(int);
13int fesetexceptflag(const fexcept_t *, int);
14int fetestexcept(int);
15
16int fegetround(void);
17int fesetround(int);
18
19int fegetenv(fenv_t *);
20int feholdexcept(fenv_t *);
21int fesetenv(const fenv_t *);
22int feupdateenv(const fenv_t *);
23
24#ifdef __cplusplus
25}
26#endif
27#endif
28
lib/libc/include/wasm-wasi-musl/float.h created+56
......@@ -0,0 +1,56 @@
1#ifndef _FLOAT_H
2#define _FLOAT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of FLT_ROUNDS */
9int __flt_rounds(void);
10#define FLT_ROUNDS (__flt_rounds())
11#else
12#define FLT_ROUNDS (__builtin_flt_rounds())
13#endif
14
15#define FLT_RADIX 2
16
17#define FLT_TRUE_MIN 1.40129846432481707092e-45F
18#define FLT_MIN 1.17549435082228750797e-38F
19#define FLT_MAX 3.40282346638528859812e+38F
20#define FLT_EPSILON 1.1920928955078125e-07F
21
22#define FLT_MANT_DIG 24
23#define FLT_MIN_EXP (-125)
24#define FLT_MAX_EXP 128
25#define FLT_HAS_SUBNORM 1
26
27#define FLT_DIG 6
28#define FLT_DECIMAL_DIG 9
29#define FLT_MIN_10_EXP (-37)
30#define FLT_MAX_10_EXP 38
31
32#define DBL_TRUE_MIN 4.94065645841246544177e-324
33#define DBL_MIN 2.22507385850720138309e-308
34#define DBL_MAX 1.79769313486231570815e+308
35#define DBL_EPSILON 2.22044604925031308085e-16
36
37#define DBL_MANT_DIG 53
38#define DBL_MIN_EXP (-1021)
39#define DBL_MAX_EXP 1024
40#define DBL_HAS_SUBNORM 1
41
42#define DBL_DIG 15
43#define DBL_DECIMAL_DIG 17
44#define DBL_MIN_10_EXP (-307)
45#define DBL_MAX_10_EXP 308
46
47#define LDBL_HAS_SUBNORM 1
48#define LDBL_DECIMAL_DIG DECIMAL_DIG
49
50#include <bits/float.h>
51
52#ifdef __cplusplus
53}
54#endif
55
56#endif
lib/libc/include/wasm-wasi-musl/fmtmsg.h created+47
......@@ -0,0 +1,47 @@
1#ifndef _FMTMSG_H
2#define _FMTMSG_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define MM_HARD 1
9#define MM_SOFT 2
10#define MM_FIRM 4
11
12#define MM_APPL 8
13#define MM_UTIL 16
14#define MM_OPSYS 32
15
16#define MM_RECOVER 64
17#define MM_NRECOV 128
18
19#define MM_PRINT 256
20#define MM_CONSOLE 512
21
22#define MM_NULLMC 0L
23
24#define MM_HALT 1
25#define MM_ERROR 2
26#define MM_WARNING 3
27#define MM_INFO 4
28#define MM_NOSEV 0
29
30#define MM_OK 0
31#define MM_NOTOK (-1)
32#define MM_NOMSG 1
33#define MM_NOCON 4
34
35#define MM_NULLLBL ((char*)0)
36#define MM_NULLTXT ((char*)0)
37#define MM_NULLACT ((char*)0)
38#define MM_NULLTAG ((char*)0)
39#define MM_NULLSEV 0
40
41int fmtmsg(long, const char *, int, const char *, const char *, const char *);
42
43#ifdef __cplusplus
44}
45#endif
46
47#endif
lib/libc/include/wasm-wasi-musl/fnmatch.h created+24
......@@ -0,0 +1,24 @@
1#ifndef _FNMATCH_H
2#define _FNMATCH_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define FNM_PATHNAME 0x1
9#define FNM_NOESCAPE 0x2
10#define FNM_PERIOD 0x4
11#define FNM_LEADING_DIR 0x8
12#define FNM_CASEFOLD 0x10
13#define FNM_FILE_NAME FNM_PATHNAME
14
15#define FNM_NOMATCH 1
16#define FNM_NOSYS (-1)
17
18int fnmatch(const char *, const char *, int);
19
20#ifdef __cplusplus
21}
22#endif
23
24#endif
lib/libc/include/wasm-wasi-musl/ftw.h created+45
......@@ -0,0 +1,45 @@
1#ifndef _FTW_H
2#define _FTW_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <sys/stat.h>
10
11#define FTW_F 1
12#define FTW_D 2
13#define FTW_DNR 3
14#define FTW_NS 4
15#define FTW_SL 5
16#define FTW_DP 6
17#define FTW_SLN 7
18
19#define FTW_PHYS 1
20#define FTW_MOUNT 2
21#define FTW_CHDIR 4
22#define FTW_DEPTH 8
23
24struct FTW {
25 int base;
26 int level;
27};
28
29#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
30int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
31#endif
32int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *), int, int);
33
34#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
35#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
36#define ftw64 ftw
37#endif
38#define nftw64 nftw
39#endif
40
41#ifdef __cplusplus
42}
43#endif
44
45#endif
lib/libc/include/wasm-wasi-musl/getopt.h created+30
......@@ -0,0 +1,30 @@
1#ifndef _GETOPT_H
2#define _GETOPT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8int getopt(int, char * const [], const char *);
9extern char *optarg;
10extern int optind, opterr, optopt, optreset;
11
12struct option {
13 const char *name;
14 int has_arg;
15 int *flag;
16 int val;
17};
18
19int getopt_long(int, char *const *, const char *, const struct option *, int *);
20int getopt_long_only(int, char *const *, const char *, const struct option *, int *);
21
22#define no_argument 0
23#define required_argument 1
24#define optional_argument 2
25
26#ifdef __cplusplus
27}
28#endif
29
30#endif
lib/libc/include/wasm-wasi-musl/glob.h created+54
......@@ -0,0 +1,54 @@
1#ifndef _GLOB_H
2#define _GLOB_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11
12#include <bits/alltypes.h>
13
14typedef struct {
15 size_t gl_pathc;
16 char **gl_pathv;
17 size_t gl_offs;
18 int __dummy1;
19 void *__dummy2[5];
20} glob_t;
21
22int glob(const char *__restrict, int, int (*)(const char *, int), glob_t *__restrict);
23void globfree(glob_t *);
24
25#define GLOB_ERR 0x01
26#define GLOB_MARK 0x02
27#define GLOB_NOSORT 0x04
28#define GLOB_DOOFFS 0x08
29#define GLOB_NOCHECK 0x10
30#define GLOB_APPEND 0x20
31#define GLOB_NOESCAPE 0x40
32#define GLOB_PERIOD 0x80
33
34#ifdef __wasilibc_unmodified_upstream // WASI has no usernames
35#define GLOB_TILDE 0x1000
36#define GLOB_TILDE_CHECK 0x4000
37#endif
38
39#define GLOB_NOSPACE 1
40#define GLOB_ABORTED 2
41#define GLOB_NOMATCH 3
42#define GLOB_NOSYS 4
43
44#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
45#define glob64 glob
46#define globfree64 globfree
47#define glob64_t glob_t
48#endif
49
50#ifdef __cplusplus
51}
52#endif
53
54#endif
lib/libc/include/wasm-wasi-musl/iconv.h created+24
......@@ -0,0 +1,24 @@
1#ifndef _ICONV_H
2#define _ICONV_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11
12#include <bits/alltypes.h>
13
14typedef void *iconv_t;
15
16iconv_t iconv_open(const char *, const char *);
17size_t iconv(iconv_t, char **__restrict, size_t *__restrict, char **__restrict, size_t *__restrict);
18int iconv_close(iconv_t);
19
20#ifdef __cplusplus
21}
22#endif
23
24#endif
lib/libc/include/wasm-wasi-musl/ifaddrs.h created+35
......@@ -0,0 +1,35 @@
1#ifndef _IFADDRS_H
2#define _IFADDRS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <netinet/in.h>
10#include <sys/socket.h>
11
12struct ifaddrs {
13 struct ifaddrs *ifa_next;
14 char *ifa_name;
15 unsigned ifa_flags;
16 struct sockaddr *ifa_addr;
17 struct sockaddr *ifa_netmask;
18 union {
19 struct sockaddr *ifu_broadaddr;
20 struct sockaddr *ifu_dstaddr;
21 } ifa_ifu;
22 void *ifa_data;
23};
24#define ifa_broadaddr ifa_ifu.ifu_broadaddr
25#define ifa_dstaddr ifa_ifu.ifu_dstaddr
26
27void freeifaddrs(struct ifaddrs *);
28int getifaddrs(struct ifaddrs **);
29
30#ifdef __cplusplus
31}
32#endif
33
34#endif
35
lib/libc/include/wasm-wasi-musl/inttypes.h created+233
......@@ -0,0 +1,233 @@
1#ifndef _INTTYPES_H
2#define _INTTYPES_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9#include <features.h>
10#include <stdint.h>
11
12#define __NEED_wchar_t
13#include <bits/alltypes.h>
14
15typedef struct { intmax_t quot, rem; } imaxdiv_t;
16
17intmax_t imaxabs(intmax_t);
18imaxdiv_t imaxdiv(intmax_t, intmax_t);
19
20intmax_t strtoimax(const char *__restrict, char **__restrict, int);
21uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
22
23intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
24uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
25
26#if UINTPTR_MAX == UINT64_MAX
27#define __PRI64 "l"
28#define __PRIPTR "l"
29#else
30#define __PRI64 "ll"
31#define __PRIPTR ""
32#endif
33
34#define PRId8 "d"
35#define PRId16 "d"
36#define PRId32 "d"
37#define PRId64 __PRI64 "d"
38
39#define PRIdLEAST8 "d"
40#define PRIdLEAST16 "d"
41#define PRIdLEAST32 "d"
42#define PRIdLEAST64 __PRI64 "d"
43
44#define PRIdFAST8 "d"
45#define PRIdFAST16 "d"
46#define PRIdFAST32 "d"
47#define PRIdFAST64 __PRI64 "d"
48
49#define PRIi8 "i"
50#define PRIi16 "i"
51#define PRIi32 "i"
52#define PRIi64 __PRI64 "i"
53
54#define PRIiLEAST8 "i"
55#define PRIiLEAST16 "i"
56#define PRIiLEAST32 "i"
57#define PRIiLEAST64 __PRI64 "i"
58
59#define PRIiFAST8 "i"
60#define PRIiFAST16 "i"
61#define PRIiFAST32 "i"
62#define PRIiFAST64 __PRI64 "i"
63
64#define PRIo8 "o"
65#define PRIo16 "o"
66#define PRIo32 "o"
67#define PRIo64 __PRI64 "o"
68
69#define PRIoLEAST8 "o"
70#define PRIoLEAST16 "o"
71#define PRIoLEAST32 "o"
72#define PRIoLEAST64 __PRI64 "o"
73
74#define PRIoFAST8 "o"
75#define PRIoFAST16 "o"
76#define PRIoFAST32 "o"
77#define PRIoFAST64 __PRI64 "o"
78
79#define PRIu8 "u"
80#define PRIu16 "u"
81#define PRIu32 "u"
82#define PRIu64 __PRI64 "u"
83
84#define PRIuLEAST8 "u"
85#define PRIuLEAST16 "u"
86#define PRIuLEAST32 "u"
87#define PRIuLEAST64 __PRI64 "u"
88
89#define PRIuFAST8 "u"
90#define PRIuFAST16 "u"
91#define PRIuFAST32 "u"
92#define PRIuFAST64 __PRI64 "u"
93
94#define PRIx8 "x"
95#define PRIx16 "x"
96#define PRIx32 "x"
97#define PRIx64 __PRI64 "x"
98
99#define PRIxLEAST8 "x"
100#define PRIxLEAST16 "x"
101#define PRIxLEAST32 "x"
102#define PRIxLEAST64 __PRI64 "x"
103
104#define PRIxFAST8 "x"
105#define PRIxFAST16 "x"
106#define PRIxFAST32 "x"
107#define PRIxFAST64 __PRI64 "x"
108
109#define PRIX8 "X"
110#define PRIX16 "X"
111#define PRIX32 "X"
112#define PRIX64 __PRI64 "X"
113
114#define PRIXLEAST8 "X"
115#define PRIXLEAST16 "X"
116#define PRIXLEAST32 "X"
117#define PRIXLEAST64 __PRI64 "X"
118
119#define PRIXFAST8 "X"
120#define PRIXFAST16 "X"
121#define PRIXFAST32 "X"
122#define PRIXFAST64 __PRI64 "X"
123
124#define PRIdMAX __PRI64 "d"
125#define PRIiMAX __PRI64 "i"
126#define PRIoMAX __PRI64 "o"
127#define PRIuMAX __PRI64 "u"
128#define PRIxMAX __PRI64 "x"
129#define PRIXMAX __PRI64 "X"
130
131#define PRIdPTR __PRIPTR "d"
132#define PRIiPTR __PRIPTR "i"
133#define PRIoPTR __PRIPTR "o"
134#define PRIuPTR __PRIPTR "u"
135#define PRIxPTR __PRIPTR "x"
136#define PRIXPTR __PRIPTR "X"
137
138#define SCNd8 "hhd"
139#define SCNd16 "hd"
140#define SCNd32 "d"
141#define SCNd64 __PRI64 "d"
142
143#define SCNdLEAST8 "hhd"
144#define SCNdLEAST16 "hd"
145#define SCNdLEAST32 "d"
146#define SCNdLEAST64 __PRI64 "d"
147
148#define SCNdFAST8 "hhd"
149#define SCNdFAST16 "d"
150#define SCNdFAST32 "d"
151#define SCNdFAST64 __PRI64 "d"
152
153#define SCNi8 "hhi"
154#define SCNi16 "hi"
155#define SCNi32 "i"
156#define SCNi64 __PRI64 "i"
157
158#define SCNiLEAST8 "hhi"
159#define SCNiLEAST16 "hi"
160#define SCNiLEAST32 "i"
161#define SCNiLEAST64 __PRI64 "i"
162
163#define SCNiFAST8 "hhi"
164#define SCNiFAST16 "i"
165#define SCNiFAST32 "i"
166#define SCNiFAST64 __PRI64 "i"
167
168#define SCNu8 "hhu"
169#define SCNu16 "hu"
170#define SCNu32 "u"
171#define SCNu64 __PRI64 "u"
172
173#define SCNuLEAST8 "hhu"
174#define SCNuLEAST16 "hu"
175#define SCNuLEAST32 "u"
176#define SCNuLEAST64 __PRI64 "u"
177
178#define SCNuFAST8 "hhu"
179#define SCNuFAST16 "u"
180#define SCNuFAST32 "u"
181#define SCNuFAST64 __PRI64 "u"
182
183#define SCNo8 "hho"
184#define SCNo16 "ho"
185#define SCNo32 "o"
186#define SCNo64 __PRI64 "o"
187
188#define SCNoLEAST8 "hho"
189#define SCNoLEAST16 "ho"
190#define SCNoLEAST32 "o"
191#define SCNoLEAST64 __PRI64 "o"
192
193#define SCNoFAST8 "hho"
194#define SCNoFAST16 "o"
195#define SCNoFAST32 "o"
196#define SCNoFAST64 __PRI64 "o"
197
198#define SCNx8 "hhx"
199#define SCNx16 "hx"
200#define SCNx32 "x"
201#define SCNx64 __PRI64 "x"
202
203#define SCNxLEAST8 "hhx"
204#define SCNxLEAST16 "hx"
205#define SCNxLEAST32 "x"
206#define SCNxLEAST64 __PRI64 "x"
207
208#define SCNxFAST8 "hhx"
209#define SCNxFAST16 "x"
210#define SCNxFAST32 "x"
211#define SCNxFAST64 __PRI64 "x"
212
213#define SCNdMAX __PRI64 "d"
214#define SCNiMAX __PRI64 "i"
215#define SCNoMAX __PRI64 "o"
216#define SCNuMAX __PRI64 "u"
217#define SCNxMAX __PRI64 "x"
218
219#define SCNdPTR __PRIPTR "d"
220#define SCNiPTR __PRIPTR "i"
221#define SCNoPTR __PRIPTR "o"
222#define SCNuPTR __PRIPTR "u"
223#define SCNxPTR __PRIPTR "x"
224
225#ifdef __cplusplus
226}
227#endif
228#else
229#include <__header_inttypes.h>
230#endif
231
232#endif
233
lib/libc/include/wasm-wasi-musl/iso646.h created+20
......@@ -0,0 +1,20 @@
1#ifndef _ISO646_H
2#define _ISO646_H
3
4#ifndef __cplusplus
5
6#define and &&
7#define and_eq &=
8#define bitand &
9#define bitor |
10#define compl ~
11#define not !
12#define not_eq !=
13#define or ||
14#define or_eq |=
15#define xor ^
16#define xor_eq ^=
17
18#endif
19
20#endif
lib/libc/include/wasm-wasi-musl/langinfo.h created+98
......@@ -0,0 +1,98 @@
1#ifndef _LANGINFO_H
2#define _LANGINFO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <nl_types.h>
10
11#define __NEED_locale_t
12
13#include <bits/alltypes.h>
14
15#define ABDAY_1 0x20000
16#define ABDAY_2 0x20001
17#define ABDAY_3 0x20002
18#define ABDAY_4 0x20003
19#define ABDAY_5 0x20004
20#define ABDAY_6 0x20005
21#define ABDAY_7 0x20006
22
23#define DAY_1 0x20007
24#define DAY_2 0x20008
25#define DAY_3 0x20009
26#define DAY_4 0x2000A
27#define DAY_5 0x2000B
28#define DAY_6 0x2000C
29#define DAY_7 0x2000D
30
31#define ABMON_1 0x2000E
32#define ABMON_2 0x2000F
33#define ABMON_3 0x20010
34#define ABMON_4 0x20011
35#define ABMON_5 0x20012
36#define ABMON_6 0x20013
37#define ABMON_7 0x20014
38#define ABMON_8 0x20015
39#define ABMON_9 0x20016
40#define ABMON_10 0x20017
41#define ABMON_11 0x20018
42#define ABMON_12 0x20019
43
44#define MON_1 0x2001A
45#define MON_2 0x2001B
46#define MON_3 0x2001C
47#define MON_4 0x2001D
48#define MON_5 0x2001E
49#define MON_6 0x2001F
50#define MON_7 0x20020
51#define MON_8 0x20021
52#define MON_9 0x20022
53#define MON_10 0x20023
54#define MON_11 0x20024
55#define MON_12 0x20025
56
57#define AM_STR 0x20026
58#define PM_STR 0x20027
59
60#define D_T_FMT 0x20028
61#define D_FMT 0x20029
62#define T_FMT 0x2002A
63#define T_FMT_AMPM 0x2002B
64
65#define ERA 0x2002C
66#define ERA_D_FMT 0x2002E
67#define ALT_DIGITS 0x2002F
68#define ERA_D_T_FMT 0x20030
69#define ERA_T_FMT 0x20031
70
71#define CODESET 14
72
73#define CRNCYSTR 0x4000F
74
75#define RADIXCHAR 0x10000
76#define THOUSEP 0x10001
77#define YESEXPR 0x50000
78#define NOEXPR 0x50001
79
80#define _NL_LOCALE_NAME(cat) (((cat)<<16) | 0xffff)
81
82#if defined(_GNU_SOURCE)
83#define NL_LOCALE_NAME(cat) _NL_LOCALE_NAME(cat)
84#endif
85
86#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
87#define YESSTR 0x50002
88#define NOSTR 0x50003
89#endif
90
91char *nl_langinfo(nl_item);
92char *nl_langinfo_l(nl_item, locale_t);
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif
lib/libc/include/wasm-wasi-musl/libgen.h created+15
......@@ -0,0 +1,15 @@
1#ifndef _LIBGEN_H
2#define _LIBGEN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8char *dirname(char *);
9char *basename(char *);
10
11#ifdef __cplusplus
12}
13#endif
14
15#endif
lib/libc/include/wasm-wasi-musl/limits.h created+180
......@@ -0,0 +1,180 @@
1#ifndef _LIMITS_H
2#define _LIMITS_H
3
4#include <features.h>
5
6#include <bits/alltypes.h> /* __LONG_MAX */
7
8/* Support signed or unsigned plain-char */
9
10#if '\xff' > 0
11#define CHAR_MIN 0
12#define CHAR_MAX 255
13#else
14#define CHAR_MIN (-128)
15#define CHAR_MAX 127
16#endif
17
18#define CHAR_BIT 8
19#define SCHAR_MIN (-128)
20#define SCHAR_MAX 127
21#define UCHAR_MAX 255
22#define SHRT_MIN (-1-0x7fff)
23#define SHRT_MAX 0x7fff
24#define USHRT_MAX 0xffff
25#define INT_MIN (-1-0x7fffffff)
26#define INT_MAX 0x7fffffff
27#define UINT_MAX 0xffffffffU
28#define LONG_MIN (-LONG_MAX-1)
29#define LONG_MAX __LONG_MAX
30#define ULONG_MAX (2UL*LONG_MAX+1)
31#define LLONG_MIN (-LLONG_MAX-1)
32#define LLONG_MAX 0x7fffffffffffffffLL
33#define ULLONG_MAX (2ULL*LLONG_MAX+1)
34
35#define MB_LEN_MAX 4
36
37#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
38 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
39
40#include <bits/limits.h>
41
42#ifdef __wasilibc_unmodified_upstream /* WASI has no pipes */
43#define PIPE_BUF 4096
44#endif
45#define FILESIZEBITS 64
46#ifndef NAME_MAX
47#define NAME_MAX 255
48#endif
49#define PATH_MAX 4096
50#define NGROUPS_MAX 32
51#define ARG_MAX 131072
52#define IOV_MAX 1024
53#define SYMLOOP_MAX 40
54#define WORD_BIT 32
55#define SSIZE_MAX LONG_MAX
56#define TZNAME_MAX 6
57#define TTY_NAME_MAX 32
58#define HOST_NAME_MAX 255
59
60#if LONG_MAX == 0x7fffffffL
61#define LONG_BIT 32
62#else
63#define LONG_BIT 64
64#endif
65
66/* Implementation choices... */
67
68#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
69#define PTHREAD_KEYS_MAX 128
70#define PTHREAD_STACK_MIN 2048
71#define PTHREAD_DESTRUCTOR_ITERATIONS 4
72#endif
73#ifdef __wasilibc_unmodified_upstream /* WASI has no semaphores */
74#define SEM_VALUE_MAX 0x7fffffff
75#define SEM_NSEMS_MAX 256
76#endif
77#define DELAYTIMER_MAX 0x7fffffff
78#ifdef __wasilibc_unmodified_upstream /* WASI has no mq */
79#define MQ_PRIO_MAX 32768
80#endif
81#ifdef __wasilibc_unmodified_upstream /* WASI has no usernames */
82#define LOGIN_NAME_MAX 256
83#endif
84
85/* Arbitrary numbers... */
86
87#ifdef __wasilibc_unmodified_upstream /* WASI has no shell commands */
88#define BC_BASE_MAX 99
89#define BC_DIM_MAX 2048
90#define BC_SCALE_MAX 99
91#define BC_STRING_MAX 1000
92#endif
93#define CHARCLASS_NAME_MAX 14
94#define COLL_WEIGHTS_MAX 2
95#ifdef __wasilibc_unmodified_upstream /* WASI has no shell commands */
96#define EXPR_NEST_MAX 32
97#define LINE_MAX 4096
98#endif
99#define RE_DUP_MAX 255
100
101#define NL_ARGMAX 9
102#define NL_MSGMAX 32767
103#define NL_SETMAX 255
104#define NL_TEXTMAX 2048
105
106#endif
107
108#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE)
109
110#ifdef PAGESIZE
111#define PAGE_SIZE PAGESIZE
112#endif
113#define NZERO 20
114#define NL_LANGMAX 32
115
116#endif
117
118#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \
119 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
120
121#define NL_NMAX 16
122
123#endif
124
125/* POSIX/SUS requirements follow. These numbers come directly
126 * from SUS and have nothing to do with the host system. */
127
128#define _POSIX_AIO_LISTIO_MAX 2
129#define _POSIX_AIO_MAX 1
130#define _POSIX_ARG_MAX 4096
131#define _POSIX_CHILD_MAX 25
132#define _POSIX_CLOCKRES_MIN 20000000
133#define _POSIX_DELAYTIMER_MAX 32
134#define _POSIX_HOST_NAME_MAX 255
135#define _POSIX_LINK_MAX 8
136#define _POSIX_LOGIN_NAME_MAX 9
137#define _POSIX_MAX_CANON 255
138#define _POSIX_MAX_INPUT 255
139#define _POSIX_MQ_OPEN_MAX 8
140#define _POSIX_MQ_PRIO_MAX 32
141#define _POSIX_NAME_MAX 14
142#define _POSIX_NGROUPS_MAX 8
143#define _POSIX_OPEN_MAX 20
144#define _POSIX_PATH_MAX 256
145#define _POSIX_PIPE_BUF 512
146#define _POSIX_RE_DUP_MAX 255
147#define _POSIX_RTSIG_MAX 8
148#define _POSIX_SEM_NSEMS_MAX 256
149#define _POSIX_SEM_VALUE_MAX 32767
150#define _POSIX_SIGQUEUE_MAX 32
151#define _POSIX_SSIZE_MAX 32767
152#define _POSIX_STREAM_MAX 8
153#define _POSIX_SS_REPL_MAX 4
154#define _POSIX_SYMLINK_MAX 255
155#define _POSIX_SYMLOOP_MAX 8
156#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
157#define _POSIX_THREAD_KEYS_MAX 128
158#define _POSIX_THREAD_THREADS_MAX 64
159#define _POSIX_TIMER_MAX 32
160#define _POSIX_TRACE_EVENT_NAME_MAX 30
161#define _POSIX_TRACE_NAME_MAX 8
162#define _POSIX_TRACE_SYS_MAX 8
163#define _POSIX_TRACE_USER_EVENT_MAX 32
164#define _POSIX_TTY_NAME_MAX 9
165#define _POSIX_TZNAME_MAX 6
166#define _POSIX2_BC_BASE_MAX 99
167#define _POSIX2_BC_DIM_MAX 2048
168#define _POSIX2_BC_SCALE_MAX 99
169#define _POSIX2_BC_STRING_MAX 1000
170#define _POSIX2_CHARCLASS_NAME_MAX 14
171#define _POSIX2_COLL_WEIGHTS_MAX 2
172#define _POSIX2_EXPR_NEST_MAX 32
173#define _POSIX2_LINE_MAX 2048
174#define _POSIX2_RE_DUP_MAX 255
175
176#define _XOPEN_IOV_MAX 16
177#define _XOPEN_NAME_MAX 255
178#define _XOPEN_PATH_MAX 1024
179
180#endif
lib/libc/include/wasm-wasi-musl/locale.h created+91
......@@ -0,0 +1,91 @@
1#ifndef _LOCALE_H
2#define _LOCALE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
11#ifdef __cplusplus
12#define NULL 0L
13#else
14#define NULL ((void*)0)
15#endif
16#else
17#define __need_NULL
18#include <stddef.h>
19#endif
20
21#define LC_CTYPE 0
22#define LC_NUMERIC 1
23#define LC_TIME 2
24#define LC_COLLATE 3
25#define LC_MONETARY 4
26#define LC_MESSAGES 5
27#define LC_ALL 6
28
29struct lconv {
30 char *decimal_point;
31 char *thousands_sep;
32 char *grouping;
33
34 char *int_curr_symbol;
35 char *currency_symbol;
36 char *mon_decimal_point;
37 char *mon_thousands_sep;
38 char *mon_grouping;
39 char *positive_sign;
40 char *negative_sign;
41 char int_frac_digits;
42 char frac_digits;
43 char p_cs_precedes;
44 char p_sep_by_space;
45 char n_cs_precedes;
46 char n_sep_by_space;
47 char p_sign_posn;
48 char n_sign_posn;
49 char int_p_cs_precedes;
50 char int_p_sep_by_space;
51 char int_n_cs_precedes;
52 char int_n_sep_by_space;
53 char int_p_sign_posn;
54 char int_n_sign_posn;
55};
56
57
58char *setlocale (int, const char *);
59struct lconv *localeconv(void);
60
61
62#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
63 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
64
65#define __NEED_locale_t
66
67#include <bits/alltypes.h>
68
69#define LC_GLOBAL_LOCALE ((locale_t)-1)
70
71#define LC_CTYPE_MASK (1<<LC_CTYPE)
72#define LC_NUMERIC_MASK (1<<LC_NUMERIC)
73#define LC_TIME_MASK (1<<LC_TIME)
74#define LC_COLLATE_MASK (1<<LC_COLLATE)
75#define LC_MONETARY_MASK (1<<LC_MONETARY)
76#define LC_MESSAGES_MASK (1<<LC_MESSAGES)
77#define LC_ALL_MASK 0x7fffffff
78
79locale_t duplocale(locale_t);
80void freelocale(locale_t);
81locale_t newlocale(int, const char *, locale_t);
82locale_t uselocale(locale_t);
83
84#endif
85
86
87#ifdef __cplusplus
88}
89#endif
90
91#endif
lib/libc/include/wasm-wasi-musl/malloc.h created+33
......@@ -0,0 +1,33 @@
1#ifndef _MALLOC_H
2#define _MALLOC_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#else
6#include <__functions_malloc.h>
7#endif
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#define __NEED_size_t
13
14#include <bits/alltypes.h>
15
16#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
17void *malloc (size_t);
18void *calloc (size_t, size_t);
19void *realloc (void *, size_t);
20void free (void *);
21#endif
22#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
23void *valloc (size_t);
24void *memalign(size_t, size_t);
25#endif
26
27size_t malloc_usable_size(void *);
28
29#ifdef __cplusplus
30}
31#endif
32
33#endif
lib/libc/include/wasm-wasi-musl/math.h created+459
......@@ -0,0 +1,459 @@
1#ifndef _MATH_H
2#define _MATH_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_float_t
11#define __NEED_double_t
12#include <bits/alltypes.h>
13
14#if 100*__GNUC__+__GNUC_MINOR__ >= 303
15#define NAN __builtin_nanf("")
16#define INFINITY __builtin_inff()
17#else
18#define NAN (0.0f/0.0f)
19#define INFINITY 1e5000f
20#endif
21
22#define HUGE_VALF INFINITY
23#define HUGE_VAL ((double)INFINITY)
24#define HUGE_VALL ((long double)INFINITY)
25
26#define MATH_ERRNO 1
27#define MATH_ERREXCEPT 2
28#define math_errhandling 2
29
30#define FP_ILOGBNAN (-1-0x7fffffff)
31#define FP_ILOGB0 FP_ILOGBNAN
32
33#define FP_NAN 0
34#define FP_INFINITE 1
35#define FP_ZERO 2
36#define FP_SUBNORMAL 3
37#define FP_NORMAL 4
38
39#ifdef __FP_FAST_FMA
40#define FP_FAST_FMA 1
41#endif
42
43#ifdef __FP_FAST_FMAF
44#define FP_FAST_FMAF 1
45#endif
46
47#ifdef __FP_FAST_FMAL
48#define FP_FAST_FMAL 1
49#endif
50
51#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of the fpclassify-like operations */
52int __fpclassify(double);
53int __fpclassifyf(float);
54int __fpclassifyl(long double);
55
56static __inline unsigned __FLOAT_BITS(float __f)
57{
58 union {float __f; unsigned __i;} __u;
59 __u.__f = __f;
60 return __u.__i;
61}
62static __inline unsigned long long __DOUBLE_BITS(double __f)
63{
64 union {double __f; unsigned long long __i;} __u;
65 __u.__f = __f;
66 return __u.__i;
67}
68
69#define fpclassify(x) ( \
70 sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \
71 sizeof(x) == sizeof(double) ? __fpclassify(x) : \
72 __fpclassifyl(x) )
73
74#define isinf(x) ( \
75 sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 : \
76 sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) == 0x7ffULL<<52 : \
77 __fpclassifyl(x) == FP_INFINITE)
78
79#define isnan(x) ( \
80 sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \
81 sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \
82 __fpclassifyl(x) == FP_NAN)
83
84#define isnormal(x) ( \
85 sizeof(x) == sizeof(float) ? ((__FLOAT_BITS(x)+0x00800000) & 0x7fffffff) >= 0x01000000 : \
86 sizeof(x) == sizeof(double) ? ((__DOUBLE_BITS(x)+(1ULL<<52)) & -1ULL>>1) >= 1ULL<<53 : \
87 __fpclassifyl(x) == FP_NORMAL)
88
89#define isfinite(x) ( \
90 sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000 : \
91 sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) < 0x7ffULL<<52 : \
92 __fpclassifyl(x) > FP_INFINITE)
93
94int __signbit(double);
95int __signbitf(float);
96int __signbitl(long double);
97
98#define signbit(x) ( \
99 sizeof(x) == sizeof(float) ? (int)(__FLOAT_BITS(x)>>31) : \
100 sizeof(x) == sizeof(double) ? (int)(__DOUBLE_BITS(x)>>63) : \
101 __signbitl(x) )
102
103#define isunordered(x,y) (isnan((x)) ? ((void)(y),1) : isnan((y)))
104
105#define __ISREL_DEF(rel, op, type) \
106static __inline int __is##rel(type __x, type __y) \
107{ return !isunordered(__x,__y) && __x op __y; }
108
109__ISREL_DEF(lessf, <, float_t)
110__ISREL_DEF(less, <, double_t)
111__ISREL_DEF(lessl, <, long double)
112__ISREL_DEF(lessequalf, <=, float_t)
113__ISREL_DEF(lessequal, <=, double_t)
114__ISREL_DEF(lessequall, <=, long double)
115__ISREL_DEF(lessgreaterf, !=, float_t)
116__ISREL_DEF(lessgreater, !=, double_t)
117__ISREL_DEF(lessgreaterl, !=, long double)
118__ISREL_DEF(greaterf, >, float_t)
119__ISREL_DEF(greater, >, double_t)
120__ISREL_DEF(greaterl, >, long double)
121__ISREL_DEF(greaterequalf, >=, float_t)
122__ISREL_DEF(greaterequal, >=, double_t)
123__ISREL_DEF(greaterequall, >=, long double)
124
125#define __tg_pred_2(x, y, p) ( \
126 sizeof((x)+(y)) == sizeof(float) ? p##f(x, y) : \
127 sizeof((x)+(y)) == sizeof(double) ? p(x, y) : \
128 p##l(x, y) )
129
130#define isless(x, y) __tg_pred_2(x, y, __isless)
131#define islessequal(x, y) __tg_pred_2(x, y, __islessequal)
132#define islessgreater(x, y) __tg_pred_2(x, y, __islessgreater)
133#define isgreater(x, y) __tg_pred_2(x, y, __isgreater)
134#define isgreaterequal(x, y) __tg_pred_2(x, y, __isgreaterequal)
135#else
136#define fpclassify(x) (__builtin_fpclassify(FP_NAN, FP_INFINITE, \
137 FP_NORMAL, FP_SUBNORMAL, \
138 FP_ZERO, x))
139#define isinf(x) (__builtin_isinf(x))
140#define isnan(x) (__builtin_isnan(x))
141#define isnormal(x) (__builtin_isnormal(x))
142#define isfinite(x) (__builtin_isfinite(x))
143#define signbit(x) (__builtin_signbit(x))
144#define isunordered(x, y) (__builtin_isunordered(x, y))
145#define isless(x, y) (__builtin_isless(x, y))
146#define islessequal(x, y) (__builtin_islessequal(x, y))
147#define islessgreater(x, y) (__builtin_islessgreater(x, y))
148#define isgreater(x, y) (__builtin_isgreater(x, y))
149#define isgreaterequal(x, y) (__builtin_isgreaterequal(x, y))
150#endif
151
152double acos(double);
153float acosf(float);
154long double acosl(long double);
155
156double acosh(double);
157float acoshf(float);
158long double acoshl(long double);
159
160double asin(double);
161float asinf(float);
162long double asinl(long double);
163
164double asinh(double);
165float asinhf(float);
166long double asinhl(long double);
167
168double atan(double);
169float atanf(float);
170long double atanl(long double);
171
172double atan2(double, double);
173float atan2f(float, float);
174long double atan2l(long double, long double);
175
176double atanh(double);
177float atanhf(float);
178long double atanhl(long double);
179
180double cbrt(double);
181float cbrtf(float);
182long double cbrtl(long double);
183
184double ceil(double);
185float ceilf(float);
186long double ceill(long double);
187
188double copysign(double, double);
189float copysignf(float, float);
190long double copysignl(long double, long double);
191
192double cos(double);
193float cosf(float);
194long double cosl(long double);
195
196double cosh(double);
197float coshf(float);
198long double coshl(long double);
199
200double erf(double);
201float erff(float);
202long double erfl(long double);
203
204double erfc(double);
205float erfcf(float);
206long double erfcl(long double);
207
208double exp(double);
209float expf(float);
210long double expl(long double);
211
212double exp2(double);
213float exp2f(float);
214long double exp2l(long double);
215
216double expm1(double);
217float expm1f(float);
218long double expm1l(long double);
219
220double fabs(double);
221float fabsf(float);
222long double fabsl(long double);
223
224double fdim(double, double);
225float fdimf(float, float);
226long double fdiml(long double, long double);
227
228double floor(double);
229float floorf(float);
230long double floorl(long double);
231
232double fma(double, double, double);
233float fmaf(float, float, float);
234long double fmal(long double, long double, long double);
235
236double fmax(double, double);
237float fmaxf(float, float);
238long double fmaxl(long double, long double);
239
240double fmin(double, double);
241float fminf(float, float);
242long double fminl(long double, long double);
243
244double fmod(double, double);
245float fmodf(float, float);
246long double fmodl(long double, long double);
247
248double frexp(double, int *);
249float frexpf(float, int *);
250long double frexpl(long double, int *);
251
252double hypot(double, double);
253float hypotf(float, float);
254long double hypotl(long double, long double);
255
256int ilogb(double);
257int ilogbf(float);
258int ilogbl(long double);
259
260double ldexp(double, int);
261float ldexpf(float, int);
262long double ldexpl(long double, int);
263
264double lgamma(double);
265float lgammaf(float);
266long double lgammal(long double);
267
268long long llrint(double);
269long long llrintf(float);
270long long llrintl(long double);
271
272long long llround(double);
273long long llroundf(float);
274long long llroundl(long double);
275
276double log(double);
277float logf(float);
278long double logl(long double);
279
280double log10(double);
281float log10f(float);
282long double log10l(long double);
283
284double log1p(double);
285float log1pf(float);
286long double log1pl(long double);
287
288double log2(double);
289float log2f(float);
290long double log2l(long double);
291
292double logb(double);
293float logbf(float);
294long double logbl(long double);
295
296long lrint(double);
297long lrintf(float);
298long lrintl(long double);
299
300long lround(double);
301long lroundf(float);
302long lroundl(long double);
303
304double modf(double, double *);
305float modff(float, float *);
306long double modfl(long double, long double *);
307
308double nan(const char *);
309float nanf(const char *);
310long double nanl(const char *);
311
312double nearbyint(double);
313float nearbyintf(float);
314long double nearbyintl(long double);
315
316double nextafter(double, double);
317float nextafterf(float, float);
318long double nextafterl(long double, long double);
319
320double nexttoward(double, long double);
321float nexttowardf(float, long double);
322long double nexttowardl(long double, long double);
323
324double pow(double, double);
325float powf(float, float);
326long double powl(long double, long double);
327
328double remainder(double, double);
329float remainderf(float, float);
330long double remainderl(long double, long double);
331
332double remquo(double, double, int *);
333float remquof(float, float, int *);
334long double remquol(long double, long double, int *);
335
336double rint(double);
337float rintf(float);
338long double rintl(long double);
339
340double round(double);
341float roundf(float);
342long double roundl(long double);
343
344double scalbln(double, long);
345float scalblnf(float, long);
346long double scalblnl(long double, long);
347
348double scalbn(double, int);
349float scalbnf(float, int);
350long double scalbnl(long double, int);
351
352double sin(double);
353float sinf(float);
354long double sinl(long double);
355
356double sinh(double);
357float sinhf(float);
358long double sinhl(long double);
359
360double sqrt(double);
361float sqrtf(float);
362long double sqrtl(long double);
363
364double tan(double);
365float tanf(float);
366long double tanl(long double);
367
368double tanh(double);
369float tanhf(float);
370long double tanhl(long double);
371
372double tgamma(double);
373float tgammaf(float);
374long double tgammal(long double);
375
376double trunc(double);
377float truncf(float);
378long double truncl(long double);
379
380
381#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE)
382#undef MAXFLOAT
383#define MAXFLOAT 3.40282346638528859812e+38F
384#endif
385
386#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
387#define M_E 2.7182818284590452354 /* e */
388#define M_LOG2E 1.4426950408889634074 /* log_2 e */
389#define M_LOG10E 0.43429448190325182765 /* log_10 e */
390#define M_LN2 0.69314718055994530942 /* log_e 2 */
391#define M_LN10 2.30258509299404568402 /* log_e 10 */
392#define M_PI 3.14159265358979323846 /* pi */
393#define M_PI_2 1.57079632679489661923 /* pi/2 */
394#define M_PI_4 0.78539816339744830962 /* pi/4 */
395#define M_1_PI 0.31830988618379067154 /* 1/pi */
396#define M_2_PI 0.63661977236758134308 /* 2/pi */
397#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
398#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
399#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
400
401extern int signgam;
402
403double j0(double);
404double j1(double);
405double jn(int, double);
406
407double y0(double);
408double y1(double);
409double yn(int, double);
410#endif
411
412#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
413#define HUGE 3.40282346638528859812e+38F
414
415double drem(double, double);
416float dremf(float, float);
417
418int finite(double);
419int finitef(float);
420
421double scalb(double, double);
422float scalbf(float, float);
423
424double significand(double);
425float significandf(float);
426
427double lgamma_r(double, int*);
428float lgammaf_r(float, int*);
429
430float j0f(float);
431float j1f(float);
432float jnf(int, float);
433
434float y0f(float);
435float y1f(float);
436float ynf(int, float);
437#endif
438
439#ifdef _GNU_SOURCE
440long double lgammal_r(long double, int*);
441
442void sincos(double, double*, double*);
443void sincosf(float, float*, float*);
444void sincosl(long double, long double*, long double*);
445
446double exp10(double);
447float exp10f(float);
448long double exp10l(long double);
449
450double pow10(double);
451float pow10f(float);
452long double pow10l(long double);
453#endif
454
455#ifdef __cplusplus
456}
457#endif
458
459#endif
lib/libc/include/wasm-wasi-musl/memory.h created+1
......@@ -0,0 +1 @@
1#include <string.h>
lib/libc/include/wasm-wasi-musl/monetary.h created+23
......@@ -0,0 +1,23 @@
1#ifndef _MONETARY_H
2#define _MONETARY_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_ssize_t
11#define __NEED_size_t
12#define __NEED_locale_t
13
14#include <bits/alltypes.h>
15
16ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...);
17ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...);
18
19#ifdef __cplusplus
20}
21#endif
22
23#endif
lib/libc/include/wasm-wasi-musl/mqueue.h created+41
......@@ -0,0 +1,41 @@
1#ifndef _MQUEUE_H
2#define _MQUEUE_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_size_t
10#define __NEED_ssize_t
11#define __NEED_pthread_attr_t
12#define __NEED_time_t
13#define __NEED_struct_timespec
14#include <bits/alltypes.h>
15
16typedef int mqd_t;
17struct mq_attr {
18 long mq_flags, mq_maxmsg, mq_msgsize, mq_curmsgs, __unused[4];
19};
20struct sigevent;
21
22int mq_close(mqd_t);
23int mq_getattr(mqd_t, struct mq_attr *);
24int mq_notify(mqd_t, const struct sigevent *);
25mqd_t mq_open(const char *, int, ...);
26ssize_t mq_receive(mqd_t, char *, size_t, unsigned *);
27int mq_send(mqd_t, const char *, size_t, unsigned);
28int mq_setattr(mqd_t, const struct mq_attr *__restrict, struct mq_attr *__restrict);
29ssize_t mq_timedreceive(mqd_t, char *__restrict, size_t, unsigned *__restrict, const struct timespec *__restrict);
30int mq_timedsend(mqd_t, const char *, size_t, unsigned, const struct timespec *);
31int mq_unlink(const char *);
32
33#if _REDIR_TIME64
34__REDIR(mq_timedreceive, __mq_timedreceive_time64);
35__REDIR(mq_timedsend, __mq_timedsend_time64);
36#endif
37
38#ifdef __cplusplus
39}
40#endif
41#endif
lib/libc/include/wasm-wasi-musl/netinet/icmp6.h created+305
......@@ -0,0 +1,305 @@
1#ifndef _NETINET_ICMP6_H
2#define _NETINET_ICMP6_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <string.h>
10#include <sys/types.h>
11#include <netinet/in.h>
12
13#define ICMP6_FILTER 1
14
15#define ICMP6_FILTER_BLOCK 1
16#define ICMP6_FILTER_PASS 2
17#define ICMP6_FILTER_BLOCKOTHERS 3
18#define ICMP6_FILTER_PASSONLY 4
19
20struct icmp6_filter {
21 uint32_t icmp6_filt[8];
22};
23
24struct icmp6_hdr {
25 uint8_t icmp6_type;
26 uint8_t icmp6_code;
27 uint16_t icmp6_cksum;
28 union {
29 uint32_t icmp6_un_data32[1];
30 uint16_t icmp6_un_data16[2];
31 uint8_t icmp6_un_data8[4];
32 } icmp6_dataun;
33};
34
35#define icmp6_data32 icmp6_dataun.icmp6_un_data32
36#define icmp6_data16 icmp6_dataun.icmp6_un_data16
37#define icmp6_data8 icmp6_dataun.icmp6_un_data8
38#define icmp6_pptr icmp6_data32[0]
39#define icmp6_mtu icmp6_data32[0]
40#define icmp6_id icmp6_data16[0]
41#define icmp6_seq icmp6_data16[1]
42#define icmp6_maxdelay icmp6_data16[0]
43
44#define ICMP6_DST_UNREACH 1
45#define ICMP6_PACKET_TOO_BIG 2
46#define ICMP6_TIME_EXCEEDED 3
47#define ICMP6_PARAM_PROB 4
48
49#define ICMP6_INFOMSG_MASK 0x80
50
51#define ICMP6_ECHO_REQUEST 128
52#define ICMP6_ECHO_REPLY 129
53#define MLD_LISTENER_QUERY 130
54#define MLD_LISTENER_REPORT 131
55#define MLD_LISTENER_REDUCTION 132
56
57#define ICMP6_DST_UNREACH_NOROUTE 0
58#define ICMP6_DST_UNREACH_ADMIN 1
59#define ICMP6_DST_UNREACH_BEYONDSCOPE 2
60#define ICMP6_DST_UNREACH_ADDR 3
61#define ICMP6_DST_UNREACH_NOPORT 4
62
63#define ICMP6_TIME_EXCEED_TRANSIT 0
64#define ICMP6_TIME_EXCEED_REASSEMBLY 1
65
66#define ICMP6_PARAMPROB_HEADER 0
67#define ICMP6_PARAMPROB_NEXTHEADER 1
68#define ICMP6_PARAMPROB_OPTION 2
69
70#define ICMP6_FILTER_WILLPASS(type, filterp) \
71 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
72
73#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
74 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
75
76#define ICMP6_FILTER_SETPASS(type, filterp) \
77 ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
78
79#define ICMP6_FILTER_SETBLOCK(type, filterp) \
80 ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))))
81
82#define ICMP6_FILTER_SETPASSALL(filterp) \
83 memset (filterp, 0, sizeof (struct icmp6_filter));
84
85#define ICMP6_FILTER_SETBLOCKALL(filterp) \
86 memset (filterp, 0xFF, sizeof (struct icmp6_filter));
87
88#define ND_ROUTER_SOLICIT 133
89#define ND_ROUTER_ADVERT 134
90#define ND_NEIGHBOR_SOLICIT 135
91#define ND_NEIGHBOR_ADVERT 136
92#define ND_REDIRECT 137
93
94struct nd_router_solicit {
95 struct icmp6_hdr nd_rs_hdr;
96};
97
98#define nd_rs_type nd_rs_hdr.icmp6_type
99#define nd_rs_code nd_rs_hdr.icmp6_code
100#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
101#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
102
103struct nd_router_advert {
104 struct icmp6_hdr nd_ra_hdr;
105 uint32_t nd_ra_reachable;
106 uint32_t nd_ra_retransmit;
107};
108
109#define nd_ra_type nd_ra_hdr.icmp6_type
110#define nd_ra_code nd_ra_hdr.icmp6_code
111#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
112#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
113#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
114#define ND_RA_FLAG_MANAGED 0x80
115#define ND_RA_FLAG_OTHER 0x40
116#define ND_RA_FLAG_HOME_AGENT 0x20
117#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
118
119struct nd_neighbor_solicit {
120 struct icmp6_hdr nd_ns_hdr;
121 struct in6_addr nd_ns_target;
122};
123
124#define nd_ns_type nd_ns_hdr.icmp6_type
125#define nd_ns_code nd_ns_hdr.icmp6_code
126#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
127#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
128
129struct nd_neighbor_advert {
130 struct icmp6_hdr nd_na_hdr;
131 struct in6_addr nd_na_target;
132};
133
134#define nd_na_type nd_na_hdr.icmp6_type
135#define nd_na_code nd_na_hdr.icmp6_code
136#define nd_na_cksum nd_na_hdr.icmp6_cksum
137#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
138#if __BYTE_ORDER == __BIG_ENDIAN
139#define ND_NA_FLAG_ROUTER 0x80000000
140#define ND_NA_FLAG_SOLICITED 0x40000000
141#define ND_NA_FLAG_OVERRIDE 0x20000000
142#else
143#define ND_NA_FLAG_ROUTER 0x00000080
144#define ND_NA_FLAG_SOLICITED 0x00000040
145#define ND_NA_FLAG_OVERRIDE 0x00000020
146#endif
147
148struct nd_redirect {
149 struct icmp6_hdr nd_rd_hdr;
150 struct in6_addr nd_rd_target;
151 struct in6_addr nd_rd_dst;
152};
153
154#define nd_rd_type nd_rd_hdr.icmp6_type
155#define nd_rd_code nd_rd_hdr.icmp6_code
156#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
157#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
158
159struct nd_opt_hdr {
160 uint8_t nd_opt_type;
161 uint8_t nd_opt_len;
162};
163
164#define ND_OPT_SOURCE_LINKADDR 1
165#define ND_OPT_TARGET_LINKADDR 2
166#define ND_OPT_PREFIX_INFORMATION 3
167#define ND_OPT_REDIRECTED_HEADER 4
168#define ND_OPT_MTU 5
169#define ND_OPT_RTR_ADV_INTERVAL 7
170#define ND_OPT_HOME_AGENT_INFO 8
171
172struct nd_opt_prefix_info {
173 uint8_t nd_opt_pi_type;
174 uint8_t nd_opt_pi_len;
175 uint8_t nd_opt_pi_prefix_len;
176 uint8_t nd_opt_pi_flags_reserved;
177 uint32_t nd_opt_pi_valid_time;
178 uint32_t nd_opt_pi_preferred_time;
179 uint32_t nd_opt_pi_reserved2;
180 struct in6_addr nd_opt_pi_prefix;
181};
182
183#define ND_OPT_PI_FLAG_ONLINK 0x80
184#define ND_OPT_PI_FLAG_AUTO 0x40
185#define ND_OPT_PI_FLAG_RADDR 0x20
186
187struct nd_opt_rd_hdr {
188 uint8_t nd_opt_rh_type;
189 uint8_t nd_opt_rh_len;
190 uint16_t nd_opt_rh_reserved1;
191 uint32_t nd_opt_rh_reserved2;
192};
193
194struct nd_opt_mtu {
195 uint8_t nd_opt_mtu_type;
196 uint8_t nd_opt_mtu_len;
197 uint16_t nd_opt_mtu_reserved;
198 uint32_t nd_opt_mtu_mtu;
199};
200
201struct mld_hdr {
202 struct icmp6_hdr mld_icmp6_hdr;
203 struct in6_addr mld_addr;
204};
205
206#define mld_type mld_icmp6_hdr.icmp6_type
207#define mld_code mld_icmp6_hdr.icmp6_code
208#define mld_cksum mld_icmp6_hdr.icmp6_cksum
209#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
210#define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
211
212#define ICMP6_ROUTER_RENUMBERING 138
213
214struct icmp6_router_renum {
215 struct icmp6_hdr rr_hdr;
216 uint8_t rr_segnum;
217 uint8_t rr_flags;
218 uint16_t rr_maxdelay;
219 uint32_t rr_reserved;
220};
221
222#define rr_type rr_hdr.icmp6_type
223#define rr_code rr_hdr.icmp6_code
224#define rr_cksum rr_hdr.icmp6_cksum
225#define rr_seqnum rr_hdr.icmp6_data32[0]
226
227#define ICMP6_RR_FLAGS_TEST 0x80
228#define ICMP6_RR_FLAGS_REQRESULT 0x40
229#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
230#define ICMP6_RR_FLAGS_SPECSITE 0x10
231#define ICMP6_RR_FLAGS_PREVDONE 0x08
232
233struct rr_pco_match {
234 uint8_t rpm_code;
235 uint8_t rpm_len;
236 uint8_t rpm_ordinal;
237 uint8_t rpm_matchlen;
238 uint8_t rpm_minlen;
239 uint8_t rpm_maxlen;
240 uint16_t rpm_reserved;
241 struct in6_addr rpm_prefix;
242};
243
244#define RPM_PCO_ADD 1
245#define RPM_PCO_CHANGE 2
246#define RPM_PCO_SETGLOBAL 3
247
248struct rr_pco_use {
249 uint8_t rpu_uselen;
250 uint8_t rpu_keeplen;
251 uint8_t rpu_ramask;
252 uint8_t rpu_raflags;
253 uint32_t rpu_vltime;
254 uint32_t rpu_pltime;
255 uint32_t rpu_flags;
256 struct in6_addr rpu_prefix;
257};
258
259#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
260#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10
261
262#if __BYTE_ORDER == __BIG_ENDIAN
263#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
264#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
265#else
266#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
267#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
268#endif
269
270struct rr_result {
271 uint16_t rrr_flags;
272 uint8_t rrr_ordinal;
273 uint8_t rrr_matchedlen;
274 uint32_t rrr_ifid;
275 struct in6_addr rrr_prefix;
276};
277
278#if __BYTE_ORDER == __BIG_ENDIAN
279#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
280#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
281#else
282#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
283#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
284#endif
285
286struct nd_opt_adv_interval {
287 uint8_t nd_opt_adv_interval_type;
288 uint8_t nd_opt_adv_interval_len;
289 uint16_t nd_opt_adv_interval_reserved;
290 uint32_t nd_opt_adv_interval_ival;
291};
292
293struct nd_opt_home_agent_info {
294 uint8_t nd_opt_home_agent_info_type;
295 uint8_t nd_opt_home_agent_info_len;
296 uint16_t nd_opt_home_agent_info_reserved;
297 uint16_t nd_opt_home_agent_info_preference;
298 uint16_t nd_opt_home_agent_info_lifetime;
299};
300
301#ifdef __cplusplus
302}
303#endif
304
305#endif
lib/libc/include/wasm-wasi-musl/netinet/igmp.h created+45
......@@ -0,0 +1,45 @@
1#ifndef _NETINET_IGMP_H
2#define _NETINET_IGMP_H
3
4#include <stdint.h>
5#include <netinet/in.h>
6
7struct igmp {
8 uint8_t igmp_type;
9 uint8_t igmp_code;
10 uint16_t igmp_cksum;
11 struct in_addr igmp_group;
12};
13
14#define IGMP_MINLEN 8
15
16#define IGMP_MEMBERSHIP_QUERY 0x11
17#define IGMP_V1_MEMBERSHIP_REPORT 0x12
18#define IGMP_V2_MEMBERSHIP_REPORT 0x16
19#define IGMP_V2_LEAVE_GROUP 0x17
20
21#define IGMP_DVMRP 0x13
22#define IGMP_PIM 0x14
23#define IGMP_TRACE 0x15
24
25#define IGMP_MTRACE_RESP 0x1e
26#define IGMP_MTRACE 0x1f
27
28#define IGMP_MAX_HOST_REPORT_DELAY 10
29#define IGMP_TIMER_SCALE 10
30
31#define IGMP_DELAYING_MEMBER 1
32#define IGMP_IDLE_MEMBER 2
33#define IGMP_LAZY_MEMBER 3
34#define IGMP_SLEEPING_MEMBER 4
35#define IGMP_AWAKENING_MEMBER 5
36
37#define IGMP_v1_ROUTER 1
38#define IGMP_v2_ROUTER 2
39
40#define IGMP_HOST_MEMBERSHIP_QUERY IGMP_MEMBERSHIP_QUERY
41#define IGMP_HOST_MEMBERSHIP_REPORT IGMP_V1_MEMBERSHIP_REPORT
42#define IGMP_HOST_NEW_MEMBERSHIP_REPORT IGMP_V2_MEMBERSHIP_REPORT
43#define IGMP_HOST_LEAVE_MESSAGE IGMP_V2_LEAVE_GROUP
44
45#endif
lib/libc/include/wasm-wasi-musl/netinet/in.h created+432
......@@ -0,0 +1,432 @@
1#ifndef _NETINET_IN_H
2#define _NETINET_IN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <inttypes.h>
10#include <sys/socket.h>
11#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
12#else
13#include <__header_netinet_in.h>
14#endif
15
16typedef uint16_t in_port_t;
17typedef uint32_t in_addr_t;
18#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
19struct in_addr { in_addr_t s_addr; };
20#endif
21
22#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
23struct sockaddr_in {
24 sa_family_t sin_family;
25 in_port_t sin_port;
26 struct in_addr sin_addr;
27 uint8_t sin_zero[8];
28};
29#endif
30
31#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
32struct in6_addr {
33 union {
34 uint8_t __s6_addr[16];
35 uint16_t __s6_addr16[8];
36 uint32_t __s6_addr32[4];
37 } __in6_union;
38};
39#define s6_addr __in6_union.__s6_addr
40#define s6_addr16 __in6_union.__s6_addr16
41#define s6_addr32 __in6_union.__s6_addr32
42#endif
43
44#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
45struct sockaddr_in6 {
46 sa_family_t sin6_family;
47 in_port_t sin6_port;
48 uint32_t sin6_flowinfo;
49 struct in6_addr sin6_addr;
50 uint32_t sin6_scope_id;
51};
52#endif
53
54struct ipv6_mreq {
55 struct in6_addr ipv6mr_multiaddr;
56 unsigned ipv6mr_interface;
57};
58
59#define INADDR_ANY ((in_addr_t) 0x00000000)
60#define INADDR_BROADCAST ((in_addr_t) 0xffffffff)
61#define INADDR_NONE ((in_addr_t) 0xffffffff)
62#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001)
63
64#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000)
65#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001)
66#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002)
67#define INADDR_ALLSNOOPERS_GROUP ((in_addr_t) 0xe000006a)
68#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff)
69
70#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
71#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
72#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
73#endif
74
75extern const struct in6_addr in6addr_any, in6addr_loopback;
76
77#define INET_ADDRSTRLEN 16
78#define INET6_ADDRSTRLEN 46
79
80uint32_t htonl(uint32_t);
81uint16_t htons(uint16_t);
82uint32_t ntohl(uint32_t);
83uint16_t ntohs(uint16_t);
84
85#define IPPORT_RESERVED 1024
86
87#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
88#define IPPROTO_IP 0
89#define IPPROTO_HOPOPTS 0
90#define IPPROTO_ICMP 1
91#define IPPROTO_IGMP 2
92#define IPPROTO_IPIP 4
93#define IPPROTO_TCP 6
94#define IPPROTO_EGP 8
95#define IPPROTO_PUP 12
96#define IPPROTO_UDP 17
97#define IPPROTO_IDP 22
98#define IPPROTO_TP 29
99#define IPPROTO_DCCP 33
100#define IPPROTO_IPV6 41
101#define IPPROTO_ROUTING 43
102#define IPPROTO_FRAGMENT 44
103#define IPPROTO_RSVP 46
104#define IPPROTO_GRE 47
105#define IPPROTO_ESP 50
106#define IPPROTO_AH 51
107#define IPPROTO_ICMPV6 58
108#define IPPROTO_NONE 59
109#define IPPROTO_DSTOPTS 60
110#define IPPROTO_MTP 92
111#define IPPROTO_BEETPH 94
112#define IPPROTO_ENCAP 98
113#define IPPROTO_PIM 103
114#define IPPROTO_COMP 108
115#define IPPROTO_SCTP 132
116#define IPPROTO_MH 135
117#define IPPROTO_UDPLITE 136
118#define IPPROTO_MPLS 137
119#define IPPROTO_ETHERNET 143
120#define IPPROTO_RAW 255
121#define IPPROTO_MPTCP 262
122#define IPPROTO_MAX 263
123#endif
124
125#define IN6_IS_ADDR_UNSPECIFIED(a) \
126 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
127 ((uint32_t *) (a))[2] == 0 && ((uint32_t *) (a))[3] == 0)
128
129#define IN6_IS_ADDR_LOOPBACK(a) \
130 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
131 ((uint32_t *) (a))[2] == 0 && \
132 ((uint8_t *) (a))[12] == 0 && ((uint8_t *) (a))[13] == 0 && \
133 ((uint8_t *) (a))[14] == 0 && ((uint8_t *) (a))[15] == 1 )
134
135#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
136
137#define IN6_IS_ADDR_LINKLOCAL(a) \
138 ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0x80)
139
140#define IN6_IS_ADDR_SITELOCAL(a) \
141 ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0xc0)
142
143#define IN6_IS_ADDR_V4MAPPED(a) \
144 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
145 ((uint8_t *) (a))[8] == 0 && ((uint8_t *) (a))[9] == 0 && \
146 ((uint8_t *) (a))[10] == 0xff && ((uint8_t *) (a))[11] == 0xff)
147
148#define IN6_IS_ADDR_V4COMPAT(a) \
149 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
150 ((uint32_t *) (a))[2] == 0 && ((uint8_t *) (a))[15] > 1)
151
152#define IN6_IS_ADDR_MC_NODELOCAL(a) \
153 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x1))
154
155#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
156 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x2))
157
158#define IN6_IS_ADDR_MC_SITELOCAL(a) \
159 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x5))
160
161#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
162 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x8))
163
164#define IN6_IS_ADDR_MC_GLOBAL(a) \
165 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0xe))
166
167#define __ARE_4_EQUAL(a,b) \
168 (!( (0[a]-0[b]) | (1[a]-1[b]) | (2[a]-2[b]) | (3[a]-3[b]) ))
169#define IN6_ARE_ADDR_EQUAL(a,b) \
170 __ARE_4_EQUAL((const uint32_t *)(a), (const uint32_t *)(b))
171
172#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0)
173#define IN_CLASSA_NET 0xff000000
174#define IN_CLASSA_NSHIFT 24
175#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
176#define IN_CLASSA_MAX 128
177#define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
178#define IN_CLASSB_NET 0xffff0000
179#define IN_CLASSB_NSHIFT 16
180#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
181#define IN_CLASSB_MAX 65536
182#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
183#define IN_CLASSC_NET 0xffffff00
184#define IN_CLASSC_NSHIFT 8
185#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
186#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
187#define IN_MULTICAST(a) IN_CLASSD(a)
188#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
189#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
190
191#define IN_LOOPBACKNET 127
192
193
194#define IP_TOS 1
195#define IP_TTL 2
196#define IP_HDRINCL 3
197#define IP_OPTIONS 4
198#define IP_ROUTER_ALERT 5
199#define IP_RECVOPTS 6
200#define IP_RETOPTS 7
201#define IP_PKTINFO 8
202#define IP_PKTOPTIONS 9
203#define IP_PMTUDISC 10
204#define IP_MTU_DISCOVER 10
205#define IP_RECVERR 11
206#define IP_RECVTTL 12
207#define IP_RECVTOS 13
208#define IP_MTU 14
209#define IP_FREEBIND 15
210#define IP_IPSEC_POLICY 16
211#define IP_XFRM_POLICY 17
212#define IP_PASSSEC 18
213#define IP_TRANSPARENT 19
214#define IP_ORIGDSTADDR 20
215#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR
216#define IP_MINTTL 21
217#define IP_NODEFRAG 22
218#define IP_CHECKSUM 23
219#define IP_BIND_ADDRESS_NO_PORT 24
220#define IP_RECVFRAGSIZE 25
221#define IP_RECVERR_RFC4884 26
222#define IP_MULTICAST_IF 32
223#define IP_MULTICAST_TTL 33
224#define IP_MULTICAST_LOOP 34
225#define IP_ADD_MEMBERSHIP 35
226#define IP_DROP_MEMBERSHIP 36
227#define IP_UNBLOCK_SOURCE 37
228#define IP_BLOCK_SOURCE 38
229#define IP_ADD_SOURCE_MEMBERSHIP 39
230#define IP_DROP_SOURCE_MEMBERSHIP 40
231#define IP_MSFILTER 41
232#define IP_MULTICAST_ALL 49
233#define IP_UNICAST_IF 50
234
235#define IP_RECVRETOPTS IP_RETOPTS
236
237#define IP_PMTUDISC_DONT 0
238#define IP_PMTUDISC_WANT 1
239#define IP_PMTUDISC_DO 2
240#define IP_PMTUDISC_PROBE 3
241#define IP_PMTUDISC_INTERFACE 4
242#define IP_PMTUDISC_OMIT 5
243
244#define IP_DEFAULT_MULTICAST_TTL 1
245#define IP_DEFAULT_MULTICAST_LOOP 1
246#define IP_MAX_MEMBERSHIPS 20
247
248struct ip_opts {
249 struct in_addr ip_dst;
250 char ip_opts[40];
251};
252
253#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
254
255#define MCAST_JOIN_GROUP 42
256#define MCAST_BLOCK_SOURCE 43
257#define MCAST_UNBLOCK_SOURCE 44
258#define MCAST_LEAVE_GROUP 45
259#define MCAST_JOIN_SOURCE_GROUP 46
260#define MCAST_LEAVE_SOURCE_GROUP 47
261#define MCAST_MSFILTER 48
262
263#define MCAST_EXCLUDE 0
264#define MCAST_INCLUDE 1
265
266struct ip_mreq {
267 struct in_addr imr_multiaddr;
268 struct in_addr imr_interface;
269};
270
271struct ip_mreqn {
272 struct in_addr imr_multiaddr;
273 struct in_addr imr_address;
274 int imr_ifindex;
275};
276
277struct ip_mreq_source {
278 struct in_addr imr_multiaddr;
279 struct in_addr imr_interface;
280 struct in_addr imr_sourceaddr;
281};
282
283struct ip_msfilter {
284 struct in_addr imsf_multiaddr;
285 struct in_addr imsf_interface;
286 uint32_t imsf_fmode;
287 uint32_t imsf_numsrc;
288 struct in_addr imsf_slist[1];
289};
290#define IP_MSFILTER_SIZE(numsrc) \
291 (sizeof(struct ip_msfilter) - sizeof(struct in_addr) \
292 + (numsrc) * sizeof(struct in_addr))
293
294struct group_req {
295 uint32_t gr_interface;
296 struct sockaddr_storage gr_group;
297};
298
299struct group_source_req {
300 uint32_t gsr_interface;
301 struct sockaddr_storage gsr_group;
302 struct sockaddr_storage gsr_source;
303};
304
305struct group_filter {
306 uint32_t gf_interface;
307 struct sockaddr_storage gf_group;
308 uint32_t gf_fmode;
309 uint32_t gf_numsrc;
310 struct sockaddr_storage gf_slist[1];
311};
312#define GROUP_FILTER_SIZE(numsrc) \
313 (sizeof(struct group_filter) - sizeof(struct sockaddr_storage) \
314 + (numsrc) * sizeof(struct sockaddr_storage))
315
316struct in_pktinfo {
317 int ipi_ifindex;
318 struct in_addr ipi_spec_dst;
319 struct in_addr ipi_addr;
320};
321
322struct in6_pktinfo {
323 struct in6_addr ipi6_addr;
324 unsigned ipi6_ifindex;
325};
326
327struct ip6_mtuinfo {
328 struct sockaddr_in6 ip6m_addr;
329 uint32_t ip6m_mtu;
330};
331#endif
332
333#define IPV6_ADDRFORM 1
334#define IPV6_2292PKTINFO 2
335#define IPV6_2292HOPOPTS 3
336#define IPV6_2292DSTOPTS 4
337#define IPV6_2292RTHDR 5
338#define IPV6_2292PKTOPTIONS 6
339#define IPV6_CHECKSUM 7
340#define IPV6_2292HOPLIMIT 8
341#define IPV6_NEXTHOP 9
342#define IPV6_AUTHHDR 10
343#define IPV6_UNICAST_HOPS 16
344#define IPV6_MULTICAST_IF 17
345#define IPV6_MULTICAST_HOPS 18
346#define IPV6_MULTICAST_LOOP 19
347#define IPV6_JOIN_GROUP 20
348#define IPV6_LEAVE_GROUP 21
349#define IPV6_ROUTER_ALERT 22
350#define IPV6_MTU_DISCOVER 23
351#define IPV6_MTU 24
352#define IPV6_RECVERR 25
353#define IPV6_V6ONLY 26
354#define IPV6_JOIN_ANYCAST 27
355#define IPV6_LEAVE_ANYCAST 28
356#define IPV6_MULTICAST_ALL 29
357#define IPV6_ROUTER_ALERT_ISOLATE 30
358#define IPV6_IPSEC_POLICY 34
359#define IPV6_XFRM_POLICY 35
360#define IPV6_HDRINCL 36
361
362#define IPV6_RECVPKTINFO 49
363#define IPV6_PKTINFO 50
364#define IPV6_RECVHOPLIMIT 51
365#define IPV6_HOPLIMIT 52
366#define IPV6_RECVHOPOPTS 53
367#define IPV6_HOPOPTS 54
368#define IPV6_RTHDRDSTOPTS 55
369#define IPV6_RECVRTHDR 56
370#define IPV6_RTHDR 57
371#define IPV6_RECVDSTOPTS 58
372#define IPV6_DSTOPTS 59
373#define IPV6_RECVPATHMTU 60
374#define IPV6_PATHMTU 61
375#define IPV6_DONTFRAG 62
376#define IPV6_RECVTCLASS 66
377#define IPV6_TCLASS 67
378#define IPV6_AUTOFLOWLABEL 70
379#define IPV6_ADDR_PREFERENCES 72
380#define IPV6_MINHOPCOUNT 73
381#define IPV6_ORIGDSTADDR 74
382#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR
383#define IPV6_TRANSPARENT 75
384#define IPV6_UNICAST_IF 76
385#define IPV6_RECVFRAGSIZE 77
386#define IPV6_FREEBIND 78
387
388#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
389#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
390#define IPV6_RXHOPOPTS IPV6_HOPOPTS
391#define IPV6_RXDSTOPTS IPV6_DSTOPTS
392
393#define IPV6_PMTUDISC_DONT 0
394#define IPV6_PMTUDISC_WANT 1
395#define IPV6_PMTUDISC_DO 2
396#define IPV6_PMTUDISC_PROBE 3
397#define IPV6_PMTUDISC_INTERFACE 4
398#define IPV6_PMTUDISC_OMIT 5
399
400#define IPV6_PREFER_SRC_TMP 0x0001
401#define IPV6_PREFER_SRC_PUBLIC 0x0002
402#define IPV6_PREFER_SRC_PUBTMP_DEFAULT 0x0100
403#define IPV6_PREFER_SRC_COA 0x0004
404#define IPV6_PREFER_SRC_HOME 0x0400
405#define IPV6_PREFER_SRC_CGA 0x0008
406#define IPV6_PREFER_SRC_NONCGA 0x0800
407
408#define IPV6_RTHDR_LOOSE 0
409#define IPV6_RTHDR_STRICT 1
410
411#define IPV6_RTHDR_TYPE_0 0
412
413#define __UAPI_DEF_IN_ADDR 0
414#define __UAPI_DEF_IN_IPPROTO 0
415#define __UAPI_DEF_IN_PKTINFO 0
416#define __UAPI_DEF_IP_MREQ 0
417#define __UAPI_DEF_SOCKADDR_IN 0
418#define __UAPI_DEF_IN_CLASS 0
419#define __UAPI_DEF_IN6_ADDR 0
420#define __UAPI_DEF_IN6_ADDR_ALT 0
421#define __UAPI_DEF_SOCKADDR_IN6 0
422#define __UAPI_DEF_IPV6_MREQ 0
423#define __UAPI_DEF_IPPROTO_V6 0
424#define __UAPI_DEF_IPV6_OPTIONS 0
425#define __UAPI_DEF_IN6_PKTINFO 0
426#define __UAPI_DEF_IP6_MTUINFO 0
427
428#ifdef __cplusplus
429}
430#endif
431
432#endif
lib/libc/include/wasm-wasi-musl/netinet/in_systm.h created+9
......@@ -0,0 +1,9 @@
1#ifndef _NETINET_IN_SYSTM_H
2#define _NETINET_IN_SYSTM_H
3
4#include <stdint.h>
5
6typedef uint16_t n_short;
7typedef uint32_t n_long, n_time;
8
9#endif
lib/libc/include/wasm-wasi-musl/netinet/ip.h created+199
......@@ -0,0 +1,199 @@
1#ifndef _NETINET_IP_H
2#define _NETINET_IP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <netinet/in.h>
10
11struct timestamp {
12 uint8_t len;
13 uint8_t ptr;
14#if __BYTE_ORDER == __LITTLE_ENDIAN
15 unsigned int flags:4;
16 unsigned int overflow:4;
17#else
18 unsigned int overflow:4;
19 unsigned int flags:4;
20#endif
21 uint32_t data[9];
22 };
23
24struct iphdr {
25#if __BYTE_ORDER == __LITTLE_ENDIAN
26 unsigned int ihl:4;
27 unsigned int version:4;
28#else
29 unsigned int version:4;
30 unsigned int ihl:4;
31#endif
32 uint8_t tos;
33 uint16_t tot_len;
34 uint16_t id;
35 uint16_t frag_off;
36 uint8_t ttl;
37 uint8_t protocol;
38 uint16_t check;
39 uint32_t saddr;
40 uint32_t daddr;
41};
42
43struct ip {
44#if __BYTE_ORDER == __LITTLE_ENDIAN
45 unsigned int ip_hl:4;
46 unsigned int ip_v:4;
47#else
48 unsigned int ip_v:4;
49 unsigned int ip_hl:4;
50#endif
51 uint8_t ip_tos;
52 uint16_t ip_len;
53 uint16_t ip_id;
54 uint16_t ip_off;
55 uint8_t ip_ttl;
56 uint8_t ip_p;
57 uint16_t ip_sum;
58 struct in_addr ip_src, ip_dst;
59};
60
61#define IP_RF 0x8000
62#define IP_DF 0x4000
63#define IP_MF 0x2000
64#define IP_OFFMASK 0x1fff
65
66struct ip_timestamp {
67 uint8_t ipt_code;
68 uint8_t ipt_len;
69 uint8_t ipt_ptr;
70#if __BYTE_ORDER == __LITTLE_ENDIAN
71 unsigned int ipt_flg:4;
72 unsigned int ipt_oflw:4;
73#else
74 unsigned int ipt_oflw:4;
75 unsigned int ipt_flg:4;
76#endif
77 uint32_t data[9];
78};
79
80#define IPVERSION 4
81#define IP_MAXPACKET 65535
82
83#define IPTOS_ECN_MASK 0x03
84#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
85#define IPTOS_ECN_NOT_ECT 0x00
86#define IPTOS_ECN_ECT1 0x01
87#define IPTOS_ECN_ECT0 0x02
88#define IPTOS_ECN_CE 0x03
89
90#define IPTOS_DSCP_MASK 0xfc
91#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
92#define IPTOS_DSCP_AF11 0x28
93#define IPTOS_DSCP_AF12 0x30
94#define IPTOS_DSCP_AF13 0x38
95#define IPTOS_DSCP_AF21 0x48
96#define IPTOS_DSCP_AF22 0x50
97#define IPTOS_DSCP_AF23 0x58
98#define IPTOS_DSCP_AF31 0x68
99#define IPTOS_DSCP_AF32 0x70
100#define IPTOS_DSCP_AF33 0x78
101#define IPTOS_DSCP_AF41 0x88
102#define IPTOS_DSCP_AF42 0x90
103#define IPTOS_DSCP_AF43 0x98
104#define IPTOS_DSCP_EF 0xb8
105
106#define IPTOS_CLASS_MASK 0xe0
107#define IPTOS_CLASS(x) ((x) & IPTOS_CLASS_MASK)
108#define IPTOS_CLASS_CS0 0x00
109#define IPTOS_CLASS_CS1 0x20
110#define IPTOS_CLASS_CS2 0x40
111#define IPTOS_CLASS_CS3 0x60
112#define IPTOS_CLASS_CS4 0x80
113#define IPTOS_CLASS_CS5 0xa0
114#define IPTOS_CLASS_CS6 0xc0
115#define IPTOS_CLASS_CS7 0xe0
116#define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0
117
118#define IPTOS_TOS_MASK 0x1E
119#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
120#define IPTOS_LOWDELAY 0x10
121#define IPTOS_THROUGHPUT 0x08
122#define IPTOS_RELIABILITY 0x04
123#define IPTOS_LOWCOST 0x02
124#define IPTOS_MINCOST IPTOS_LOWCOST
125
126#define IPTOS_PREC_MASK 0xe0
127#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
128#define IPTOS_PREC_NETCONTROL 0xe0
129#define IPTOS_PREC_INTERNETCONTROL 0xc0
130#define IPTOS_PREC_CRITIC_ECP 0xa0
131#define IPTOS_PREC_FLASHOVERRIDE 0x80
132#define IPTOS_PREC_FLASH 0x60
133#define IPTOS_PREC_IMMEDIATE 0x40
134#define IPTOS_PREC_PRIORITY 0x20
135#define IPTOS_PREC_ROUTINE 0x00
136
137#define IPOPT_COPY 0x80
138#define IPOPT_CLASS_MASK 0x60
139#define IPOPT_NUMBER_MASK 0x1f
140
141#define IPOPT_COPIED(o) ((o) & IPOPT_COPY)
142#define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK)
143#define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK)
144
145#define IPOPT_CONTROL 0x00
146#define IPOPT_RESERVED1 0x20
147#define IPOPT_DEBMEAS 0x40
148#define IPOPT_MEASUREMENT IPOPT_DEBMEAS
149#define IPOPT_RESERVED2 0x60
150
151#define IPOPT_EOL 0
152#define IPOPT_END IPOPT_EOL
153#define IPOPT_NOP 1
154#define IPOPT_NOOP IPOPT_NOP
155
156#define IPOPT_RR 7
157#define IPOPT_TS 68
158#define IPOPT_TIMESTAMP IPOPT_TS
159#define IPOPT_SECURITY 130
160#define IPOPT_SEC IPOPT_SECURITY
161#define IPOPT_LSRR 131
162#define IPOPT_SATID 136
163#define IPOPT_SID IPOPT_SATID
164#define IPOPT_SSRR 137
165#define IPOPT_RA 148
166
167#define IPOPT_OPTVAL 0
168#define IPOPT_OLEN 1
169#define IPOPT_OFFSET 2
170#define IPOPT_MINOFF 4
171
172#define MAX_IPOPTLEN 40
173
174#define IPOPT_TS_TSONLY 0
175#define IPOPT_TS_TSANDADDR 1
176#define IPOPT_TS_PRESPEC 3
177
178#define IPOPT_SECUR_UNCLASS 0x0000
179#define IPOPT_SECUR_CONFID 0xf135
180#define IPOPT_SECUR_EFTO 0x789a
181#define IPOPT_SECUR_MMMM 0xbc4d
182#define IPOPT_SECUR_RESTR 0xaf13
183#define IPOPT_SECUR_SECRET 0xd788
184#define IPOPT_SECUR_TOPSECRET 0x6bc5
185
186#define MAXTTL 255
187#define IPDEFTTL 64
188#define IPFRAGTTL 60
189#define IPTTLDEC 1
190
191#define IP_MSS 576
192
193#define __UAPI_DEF_IPHDR 0
194
195#ifdef __cplusplus
196}
197#endif
198
199#endif
lib/libc/include/wasm-wasi-musl/netinet/ip6.h created+141
......@@ -0,0 +1,141 @@
1#ifndef _NETINET_IP6_H
2#define _NETINET_IP6_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <netinet/in.h>
10
11struct ip6_hdr {
12 union {
13 struct ip6_hdrctl {
14 uint32_t ip6_un1_flow;
15 uint16_t ip6_un1_plen;
16 uint8_t ip6_un1_nxt;
17 uint8_t ip6_un1_hlim;
18 } ip6_un1;
19 uint8_t ip6_un2_vfc;
20 } ip6_ctlun;
21 struct in6_addr ip6_src;
22 struct in6_addr ip6_dst;
23};
24
25#define ip6_vfc ip6_ctlun.ip6_un2_vfc
26#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
27#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
28#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
29#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
30#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
31
32struct ip6_ext {
33 uint8_t ip6e_nxt;
34 uint8_t ip6e_len;
35};
36
37struct ip6_hbh {
38 uint8_t ip6h_nxt;
39 uint8_t ip6h_len;
40};
41
42struct ip6_dest {
43 uint8_t ip6d_nxt;
44 uint8_t ip6d_len;
45};
46
47struct ip6_rthdr {
48 uint8_t ip6r_nxt;
49 uint8_t ip6r_len;
50 uint8_t ip6r_type;
51 uint8_t ip6r_segleft;
52};
53
54struct ip6_rthdr0 {
55 uint8_t ip6r0_nxt;
56 uint8_t ip6r0_len;
57 uint8_t ip6r0_type;
58 uint8_t ip6r0_segleft;
59 uint8_t ip6r0_reserved;
60 uint8_t ip6r0_slmap[3];
61 struct in6_addr ip6r0_addr[];
62};
63
64struct ip6_frag {
65 uint8_t ip6f_nxt;
66 uint8_t ip6f_reserved;
67 uint16_t ip6f_offlg;
68 uint32_t ip6f_ident;
69};
70
71#if __BYTE_ORDER == __BIG_ENDIAN
72#define IP6F_OFF_MASK 0xfff8
73#define IP6F_RESERVED_MASK 0x0006
74#define IP6F_MORE_FRAG 0x0001
75#else
76#define IP6F_OFF_MASK 0xf8ff
77#define IP6F_RESERVED_MASK 0x0600
78#define IP6F_MORE_FRAG 0x0100
79#endif
80
81struct ip6_opt {
82 uint8_t ip6o_type;
83 uint8_t ip6o_len;
84};
85
86#define IP6OPT_TYPE(o) ((o) & 0xc0)
87#define IP6OPT_TYPE_SKIP 0x00
88#define IP6OPT_TYPE_DISCARD 0x40
89#define IP6OPT_TYPE_FORCEICMP 0x80
90#define IP6OPT_TYPE_ICMP 0xc0
91#define IP6OPT_TYPE_MUTABLE 0x20
92
93#define IP6OPT_PAD1 0
94#define IP6OPT_PADN 1
95
96#define IP6OPT_JUMBO 0xc2
97#define IP6OPT_NSAP_ADDR 0xc3
98#define IP6OPT_TUNNEL_LIMIT 0x04
99#define IP6OPT_ROUTER_ALERT 0x05
100
101struct ip6_opt_jumbo {
102 uint8_t ip6oj_type;
103 uint8_t ip6oj_len;
104 uint8_t ip6oj_jumbo_len[4];
105};
106#define IP6OPT_JUMBO_LEN 6
107
108struct ip6_opt_nsap {
109 uint8_t ip6on_type;
110 uint8_t ip6on_len;
111 uint8_t ip6on_src_nsap_len;
112 uint8_t ip6on_dst_nsap_len;
113};
114
115struct ip6_opt_tunnel {
116 uint8_t ip6ot_type;
117 uint8_t ip6ot_len;
118 uint8_t ip6ot_encap_limit;
119};
120
121struct ip6_opt_router {
122 uint8_t ip6or_type;
123 uint8_t ip6or_len;
124 uint8_t ip6or_value[2];
125};
126
127#if __BYTE_ORDER == __BIG_ENDIAN
128#define IP6_ALERT_MLD 0x0000
129#define IP6_ALERT_RSVP 0x0001
130#define IP6_ALERT_AN 0x0002
131#else
132#define IP6_ALERT_MLD 0x0000
133#define IP6_ALERT_RSVP 0x0100
134#define IP6_ALERT_AN 0x0200
135#endif
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif
lib/libc/include/wasm-wasi-musl/netinet/ip_icmp.h created+193
......@@ -0,0 +1,193 @@
1#ifndef _NETINET_IP_ICMP_H
2#define _NETINET_IP_ICMP_H
3
4#include <stdint.h>
5#include <netinet/in.h>
6#include <netinet/ip.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12struct icmphdr {
13 uint8_t type;
14 uint8_t code;
15 uint16_t checksum;
16 union {
17 struct {
18 uint16_t id;
19 uint16_t sequence;
20 } echo;
21 uint32_t gateway;
22 struct {
23 uint16_t __unused;
24 uint16_t mtu;
25 } frag;
26 uint8_t reserved[4];
27 } un;
28};
29
30#define ICMP_ECHOREPLY 0
31#define ICMP_DEST_UNREACH 3
32#define ICMP_SOURCE_QUENCH 4
33#define ICMP_REDIRECT 5
34#define ICMP_ECHO 8
35#define ICMP_TIME_EXCEEDED 11
36#define ICMP_PARAMETERPROB 12
37#define ICMP_TIMESTAMP 13
38#define ICMP_TIMESTAMPREPLY 14
39#define ICMP_INFO_REQUEST 15
40#define ICMP_INFO_REPLY 16
41#define ICMP_ADDRESS 17
42#define ICMP_ADDRESSREPLY 18
43#define NR_ICMP_TYPES 18
44
45
46#define ICMP_NET_UNREACH 0
47#define ICMP_HOST_UNREACH 1
48#define ICMP_PROT_UNREACH 2
49#define ICMP_PORT_UNREACH 3
50#define ICMP_FRAG_NEEDED 4
51#define ICMP_SR_FAILED 5
52#define ICMP_NET_UNKNOWN 6
53#define ICMP_HOST_UNKNOWN 7
54#define ICMP_HOST_ISOLATED 8
55#define ICMP_NET_ANO 9
56#define ICMP_HOST_ANO 10
57#define ICMP_NET_UNR_TOS 11
58#define ICMP_HOST_UNR_TOS 12
59#define ICMP_PKT_FILTERED 13
60#define ICMP_PREC_VIOLATION 14
61#define ICMP_PREC_CUTOFF 15
62#define NR_ICMP_UNREACH 15
63
64#define ICMP_REDIR_NET 0
65#define ICMP_REDIR_HOST 1
66#define ICMP_REDIR_NETTOS 2
67#define ICMP_REDIR_HOSTTOS 3
68
69#define ICMP_EXC_TTL 0
70#define ICMP_EXC_FRAGTIME 1
71
72
73struct icmp_ra_addr {
74 uint32_t ira_addr;
75 uint32_t ira_preference;
76};
77
78struct icmp {
79 uint8_t icmp_type;
80 uint8_t icmp_code;
81 uint16_t icmp_cksum;
82 union {
83 uint8_t ih_pptr;
84 struct in_addr ih_gwaddr;
85 struct ih_idseq {
86 uint16_t icd_id;
87 uint16_t icd_seq;
88 } ih_idseq;
89 uint32_t ih_void;
90
91 struct ih_pmtu {
92 uint16_t ipm_void;
93 uint16_t ipm_nextmtu;
94 } ih_pmtu;
95
96 struct ih_rtradv {
97 uint8_t irt_num_addrs;
98 uint8_t irt_wpa;
99 uint16_t irt_lifetime;
100 } ih_rtradv;
101 } icmp_hun;
102 union {
103 struct {
104 uint32_t its_otime;
105 uint32_t its_rtime;
106 uint32_t its_ttime;
107 } id_ts;
108 struct {
109 struct ip idi_ip;
110 } id_ip;
111 struct icmp_ra_addr id_radv;
112 uint32_t id_mask;
113 uint8_t id_data[1];
114 } icmp_dun;
115};
116
117#define icmp_pptr icmp_hun.ih_pptr
118#define icmp_gwaddr icmp_hun.ih_gwaddr
119#define icmp_id icmp_hun.ih_idseq.icd_id
120#define icmp_seq icmp_hun.ih_idseq.icd_seq
121#define icmp_void icmp_hun.ih_void
122#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
123#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
124#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
125#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
126#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
127#define icmp_otime icmp_dun.id_ts.its_otime
128#define icmp_rtime icmp_dun.id_ts.its_rtime
129#define icmp_ttime icmp_dun.id_ts.its_ttime
130#define icmp_ip icmp_dun.id_ip.idi_ip
131#define icmp_radv icmp_dun.id_radv
132#define icmp_mask icmp_dun.id_mask
133#define icmp_data icmp_dun.id_data
134
135#define ICMP_MINLEN 8
136#define ICMP_TSLEN (8 + 3 * sizeof (n_time))
137#define ICMP_MASKLEN 12
138#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8)
139#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
140
141#define ICMP_UNREACH 3
142#define ICMP_SOURCEQUENCH 4
143#define ICMP_ROUTERADVERT 9
144#define ICMP_ROUTERSOLICIT 10
145#define ICMP_TIMXCEED 11
146#define ICMP_PARAMPROB 12
147#define ICMP_TSTAMP 13
148#define ICMP_TSTAMPREPLY 14
149#define ICMP_IREQ 15
150#define ICMP_IREQREPLY 16
151#define ICMP_MASKREQ 17
152#define ICMP_MASKREPLY 18
153#define ICMP_MAXTYPE 18
154
155#define ICMP_UNREACH_NET 0
156#define ICMP_UNREACH_HOST 1
157#define ICMP_UNREACH_PROTOCOL 2
158#define ICMP_UNREACH_PORT 3
159#define ICMP_UNREACH_NEEDFRAG 4
160#define ICMP_UNREACH_SRCFAIL 5
161#define ICMP_UNREACH_NET_UNKNOWN 6
162#define ICMP_UNREACH_HOST_UNKNOWN 7
163#define ICMP_UNREACH_ISOLATED 8
164#define ICMP_UNREACH_NET_PROHIB 9
165#define ICMP_UNREACH_HOST_PROHIB 10
166#define ICMP_UNREACH_TOSNET 11
167#define ICMP_UNREACH_TOSHOST 12
168#define ICMP_UNREACH_FILTER_PROHIB 13
169#define ICMP_UNREACH_HOST_PRECEDENCE 14
170#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
171
172#define ICMP_REDIRECT_NET 0
173#define ICMP_REDIRECT_HOST 1
174#define ICMP_REDIRECT_TOSNET 2
175#define ICMP_REDIRECT_TOSHOST 3
176
177#define ICMP_TIMXCEED_INTRANS 0
178#define ICMP_TIMXCEED_REASS 1
179
180#define ICMP_PARAMPROB_OPTABSENT 1
181
182#define ICMP_INFOTYPE(type) \
183 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
184 (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
185 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
186 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
187 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
188
189#ifdef __cplusplus
190}
191#endif
192
193#endif
lib/libc/include/wasm-wasi-musl/netinet/tcp.h created+294
......@@ -0,0 +1,294 @@
1#ifndef _NETINET_TCP_H
2#define _NETINET_TCP_H
3
4#include <features.h>
5
6#define TCP_NODELAY 1
7#define TCP_MAXSEG 2
8#define TCP_CORK 3
9#define TCP_KEEPIDLE 4
10#define TCP_KEEPINTVL 5
11#define TCP_KEEPCNT 6
12#define TCP_SYNCNT 7
13#define TCP_LINGER2 8
14#define TCP_DEFER_ACCEPT 9
15#define TCP_WINDOW_CLAMP 10
16#define TCP_INFO 11
17#define TCP_QUICKACK 12
18#define TCP_CONGESTION 13
19#define TCP_MD5SIG 14
20#define TCP_THIN_LINEAR_TIMEOUTS 16
21#define TCP_THIN_DUPACK 17
22#define TCP_USER_TIMEOUT 18
23#define TCP_REPAIR 19
24#define TCP_REPAIR_QUEUE 20
25#define TCP_QUEUE_SEQ 21
26#define TCP_REPAIR_OPTIONS 22
27#define TCP_FASTOPEN 23
28#define TCP_TIMESTAMP 24
29#define TCP_NOTSENT_LOWAT 25
30#define TCP_CC_INFO 26
31#define TCP_SAVE_SYN 27
32#define TCP_SAVED_SYN 28
33#define TCP_REPAIR_WINDOW 29
34#define TCP_FASTOPEN_CONNECT 30
35#define TCP_ULP 31
36#define TCP_MD5SIG_EXT 32
37#define TCP_FASTOPEN_KEY 33
38#define TCP_FASTOPEN_NO_COOKIE 34
39#define TCP_ZEROCOPY_RECEIVE 35
40#define TCP_INQ 36
41#define TCP_TX_DELAY 37
42
43#define TCP_CM_INQ TCP_INQ
44
45#define TCP_ESTABLISHED 1
46#define TCP_SYN_SENT 2
47#define TCP_SYN_RECV 3
48#define TCP_FIN_WAIT1 4
49#define TCP_FIN_WAIT2 5
50#define TCP_TIME_WAIT 6
51#define TCP_CLOSE 7
52#define TCP_CLOSE_WAIT 8
53#define TCP_LAST_ACK 9
54#define TCP_LISTEN 10
55#define TCP_CLOSING 11
56
57enum {
58 TCP_NLA_PAD,
59 TCP_NLA_BUSY,
60 TCP_NLA_RWND_LIMITED,
61 TCP_NLA_SNDBUF_LIMITED,
62 TCP_NLA_DATA_SEGS_OUT,
63 TCP_NLA_TOTAL_RETRANS,
64 TCP_NLA_PACING_RATE,
65 TCP_NLA_DELIVERY_RATE,
66 TCP_NLA_SND_CWND,
67 TCP_NLA_REORDERING,
68 TCP_NLA_MIN_RTT,
69 TCP_NLA_RECUR_RETRANS,
70 TCP_NLA_DELIVERY_RATE_APP_LMT,
71 TCP_NLA_SNDQ_SIZE,
72 TCP_NLA_CA_STATE,
73 TCP_NLA_SND_SSTHRESH,
74 TCP_NLA_DELIVERED,
75 TCP_NLA_DELIVERED_CE,
76 TCP_NLA_BYTES_SENT,
77 TCP_NLA_BYTES_RETRANS,
78 TCP_NLA_DSACK_DUPS,
79 TCP_NLA_REORD_SEEN,
80 TCP_NLA_SRTT,
81 TCP_NLA_TIMEOUT_REHASH,
82 TCP_NLA_BYTES_NOTSENT,
83};
84
85#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
86#define TCPOPT_EOL 0
87#define TCPOPT_NOP 1
88#define TCPOPT_MAXSEG 2
89#define TCPOPT_WINDOW 3
90#define TCPOPT_SACK_PERMITTED 4
91#define TCPOPT_SACK 5
92#define TCPOPT_TIMESTAMP 8
93#define TCPOLEN_SACK_PERMITTED 2
94#define TCPOLEN_WINDOW 3
95#define TCPOLEN_MAXSEG 4
96#define TCPOLEN_TIMESTAMP 10
97
98#define SOL_TCP 6
99
100#include <sys/types.h>
101#include <sys/socket.h>
102#include <stdint.h>
103
104typedef uint32_t tcp_seq;
105
106#define TH_FIN 0x01
107#define TH_SYN 0x02
108#define TH_RST 0x04
109#define TH_PUSH 0x08
110#define TH_ACK 0x10
111#define TH_URG 0x20
112
113struct tcphdr {
114#ifdef _GNU_SOURCE
115#ifdef __GNUC__
116 __extension__
117#endif
118 union { struct {
119
120 uint16_t source;
121 uint16_t dest;
122 uint32_t seq;
123 uint32_t ack_seq;
124#if __BYTE_ORDER == __LITTLE_ENDIAN
125 uint16_t res1:4;
126 uint16_t doff:4;
127 uint16_t fin:1;
128 uint16_t syn:1;
129 uint16_t rst:1;
130 uint16_t psh:1;
131 uint16_t ack:1;
132 uint16_t urg:1;
133 uint16_t res2:2;
134#else
135 uint16_t doff:4;
136 uint16_t res1:4;
137 uint16_t res2:2;
138 uint16_t urg:1;
139 uint16_t ack:1;
140 uint16_t psh:1;
141 uint16_t rst:1;
142 uint16_t syn:1;
143 uint16_t fin:1;
144#endif
145 uint16_t window;
146 uint16_t check;
147 uint16_t urg_ptr;
148
149 }; struct {
150#endif
151
152 uint16_t th_sport;
153 uint16_t th_dport;
154 uint32_t th_seq;
155 uint32_t th_ack;
156#if __BYTE_ORDER == __LITTLE_ENDIAN
157 uint8_t th_x2:4;
158 uint8_t th_off:4;
159#else
160 uint8_t th_off:4;
161 uint8_t th_x2:4;
162#endif
163 uint8_t th_flags;
164 uint16_t th_win;
165 uint16_t th_sum;
166 uint16_t th_urp;
167
168#ifdef _GNU_SOURCE
169 }; };
170#endif
171};
172#endif
173
174#ifdef _GNU_SOURCE
175#define TCPI_OPT_TIMESTAMPS 1
176#define TCPI_OPT_SACK 2
177#define TCPI_OPT_WSCALE 4
178#define TCPI_OPT_ECN 8
179
180#define TCP_CA_Open 0
181#define TCP_CA_Disorder 1
182#define TCP_CA_CWR 2
183#define TCP_CA_Recovery 3
184#define TCP_CA_Loss 4
185
186enum tcp_fastopen_client_fail {
187 TFO_STATUS_UNSPEC,
188 TFO_COOKIE_UNAVAILABLE,
189 TFO_DATA_NOT_ACKED,
190 TFO_SYN_RETRANSMITTED,
191};
192
193struct tcp_info {
194 uint8_t tcpi_state;
195 uint8_t tcpi_ca_state;
196 uint8_t tcpi_retransmits;
197 uint8_t tcpi_probes;
198 uint8_t tcpi_backoff;
199 uint8_t tcpi_options;
200 uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
201 uint8_t tcpi_delivery_rate_app_limited : 1, tcpi_fastopen_client_fail : 2;
202 uint32_t tcpi_rto;
203 uint32_t tcpi_ato;
204 uint32_t tcpi_snd_mss;
205 uint32_t tcpi_rcv_mss;
206 uint32_t tcpi_unacked;
207 uint32_t tcpi_sacked;
208 uint32_t tcpi_lost;
209 uint32_t tcpi_retrans;
210 uint32_t tcpi_fackets;
211 uint32_t tcpi_last_data_sent;
212 uint32_t tcpi_last_ack_sent;
213 uint32_t tcpi_last_data_recv;
214 uint32_t tcpi_last_ack_recv;
215 uint32_t tcpi_pmtu;
216 uint32_t tcpi_rcv_ssthresh;
217 uint32_t tcpi_rtt;
218 uint32_t tcpi_rttvar;
219 uint32_t tcpi_snd_ssthresh;
220 uint32_t tcpi_snd_cwnd;
221 uint32_t tcpi_advmss;
222 uint32_t tcpi_reordering;
223 uint32_t tcpi_rcv_rtt;
224 uint32_t tcpi_rcv_space;
225 uint32_t tcpi_total_retrans;
226 uint64_t tcpi_pacing_rate;
227 uint64_t tcpi_max_pacing_rate;
228 uint64_t tcpi_bytes_acked;
229 uint64_t tcpi_bytes_received;
230 uint32_t tcpi_segs_out;
231 uint32_t tcpi_segs_in;
232 uint32_t tcpi_notsent_bytes;
233 uint32_t tcpi_min_rtt;
234 uint32_t tcpi_data_segs_in;
235 uint32_t tcpi_data_segs_out;
236 uint64_t tcpi_delivery_rate;
237 uint64_t tcpi_busy_time;
238 uint64_t tcpi_rwnd_limited;
239 uint64_t tcpi_sndbuf_limited;
240 uint32_t tcpi_delivered;
241 uint32_t tcpi_delivered_ce;
242 uint64_t tcpi_bytes_sent;
243 uint64_t tcpi_bytes_retrans;
244 uint32_t tcpi_dsack_dups;
245 uint32_t tcpi_reord_seen;
246 uint32_t tcpi_rcv_ooopack;
247 uint32_t tcpi_snd_wnd;
248};
249
250#define TCP_MD5SIG_MAXKEYLEN 80
251
252#define TCP_MD5SIG_FLAG_PREFIX 0x1
253#define TCP_MD5SIG_FLAG_IFINDEX 0x2
254
255struct tcp_md5sig {
256 struct sockaddr_storage tcpm_addr;
257 uint8_t tcpm_flags;
258 uint8_t tcpm_prefixlen;
259 uint16_t tcpm_keylen;
260 int tcpm_ifindex;
261 uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
262};
263
264struct tcp_diag_md5sig {
265 uint8_t tcpm_family;
266 uint8_t tcpm_prefixlen;
267 uint16_t tcpm_keylen;
268 uint32_t tcpm_addr[4];
269 uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
270};
271
272#define TCP_REPAIR_ON 1
273#define TCP_REPAIR_OFF 0
274#define TCP_REPAIR_OFF_NO_WP -1
275
276struct tcp_repair_window {
277 uint32_t snd_wl1;
278 uint32_t snd_wnd;
279 uint32_t max_window;
280 uint32_t rcv_wnd;
281 uint32_t rcv_wup;
282};
283
284struct tcp_zerocopy_receive {
285 uint64_t address;
286 uint32_t length;
287 uint32_t recv_skip_hint;
288 uint32_t inq;
289 int32_t err;
290};
291
292#endif
293
294#endif
lib/libc/include/wasm-wasi-musl/netinet/udp.h created+46
......@@ -0,0 +1,46 @@
1#ifndef _NETINET_UDP_H
2#define _NETINET_UDP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <stdint.h>
10
11#ifdef _GNU_SOURCE
12#define uh_sport source
13#define uh_dport dest
14#define uh_ulen len
15#define uh_sum check
16#endif
17
18struct udphdr {
19 uint16_t uh_sport;
20 uint16_t uh_dport;
21 uint16_t uh_ulen;
22 uint16_t uh_sum;
23};
24
25#define UDP_CORK 1
26#define UDP_ENCAP 100
27#define UDP_NO_CHECK6_TX 101
28#define UDP_NO_CHECK6_RX 102
29#define UDP_SEGMENT 103
30#define UDP_GRO 104
31
32#define UDP_ENCAP_ESPINUDP_NON_IKE 1
33#define UDP_ENCAP_ESPINUDP 2
34#define UDP_ENCAP_L2TPINUDP 3
35#define UDP_ENCAP_GTP0 4
36#define UDP_ENCAP_GTP1U 5
37#define UDP_ENCAP_RXRPC 6
38#define TCP_ENCAP_ESPINTCP 7
39
40#define SOL_UDP 17
41
42#ifdef __cplusplus
43}
44#endif
45
46#endif
lib/libc/include/wasm-wasi-musl/netpacket/packet.h created+62
......@@ -0,0 +1,62 @@
1#ifndef _NETPACKET_PACKET_H
2#define _NETPACKET_PACKET_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8struct sockaddr_ll {
9 unsigned short sll_family, sll_protocol;
10 int sll_ifindex;
11 unsigned short sll_hatype;
12 unsigned char sll_pkttype, sll_halen;
13 unsigned char sll_addr[8];
14};
15
16struct packet_mreq {
17 int mr_ifindex;
18 unsigned short int mr_type, mr_alen;
19 unsigned char mr_address[8];
20};
21
22#define PACKET_HOST 0
23#define PACKET_BROADCAST 1
24#define PACKET_MULTICAST 2
25#define PACKET_OTHERHOST 3
26#define PACKET_OUTGOING 4
27#define PACKET_LOOPBACK 5
28#define PACKET_FASTROUTE 6
29
30#define PACKET_ADD_MEMBERSHIP 1
31#define PACKET_DROP_MEMBERSHIP 2
32#define PACKET_RECV_OUTPUT 3
33#define PACKET_RX_RING 5
34#define PACKET_STATISTICS 6
35#define PACKET_COPY_THRESH 7
36#define PACKET_AUXDATA 8
37#define PACKET_ORIGDEV 9
38#define PACKET_VERSION 10
39#define PACKET_HDRLEN 11
40#define PACKET_RESERVE 12
41#define PACKET_TX_RING 13
42#define PACKET_LOSS 14
43#define PACKET_VNET_HDR 15
44#define PACKET_TX_TIMESTAMP 16
45#define PACKET_TIMESTAMP 17
46#define PACKET_FANOUT 18
47#define PACKET_TX_HAS_OFF 19
48#define PACKET_QDISC_BYPASS 20
49#define PACKET_ROLLOVER_STATS 21
50#define PACKET_FANOUT_DATA 22
51#define PACKET_IGNORE_OUTGOING 23
52
53#define PACKET_MR_MULTICAST 0
54#define PACKET_MR_PROMISC 1
55#define PACKET_MR_ALLMULTI 2
56#define PACKET_MR_UNICAST 3
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif
lib/libc/include/wasm-wasi-musl/nl_types.h created+22
......@@ -0,0 +1,22 @@
1#ifndef _NL_TYPES_H
2#define _NL_TYPES_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define NL_SETD 1
9#define NL_CAT_LOCALE 1
10
11typedef int nl_item;
12typedef void *nl_catd;
13
14nl_catd catopen (const char *, int);
15char *catgets (nl_catd, int, int, const char *);
16int catclose (nl_catd);
17
18#ifdef __cplusplus
19}
20#endif
21
22#endif
lib/libc/include/wasm-wasi-musl/poll.h created+69
......@@ -0,0 +1,69 @@
1#ifndef _POLL_H
2#define _POLL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#include <bits/poll.h>
11
12#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
13#define POLLIN 0x001
14#define POLLPRI 0x002
15#define POLLOUT 0x004
16#define POLLERR 0x008
17#define POLLHUP 0x010
18#define POLLNVAL 0x020
19#define POLLRDNORM 0x040
20#define POLLRDBAND 0x080
21#ifndef POLLWRNORM
22#define POLLWRNORM 0x100
23#define POLLWRBAND 0x200
24#endif
25#ifndef POLLMSG
26#define POLLMSG 0x400
27#define POLLRDHUP 0x2000
28#endif
29#else
30#include <__header_poll.h>
31#endif
32
33#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
34typedef unsigned long nfds_t;
35#else
36#include <__typedef_nfds_t.h>
37#endif
38
39#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
40struct pollfd {
41 int fd;
42 short events;
43 short revents;
44};
45#else
46#include <__struct_pollfd.h>
47#endif
48
49int poll (struct pollfd *, nfds_t, int);
50
51#ifdef _GNU_SOURCE
52#define __NEED_time_t
53#define __NEED_struct_timespec
54#define __NEED_sigset_t
55#include <bits/alltypes.h>
56int ppoll(struct pollfd *, nfds_t, const struct timespec *, const sigset_t *);
57#endif
58
59#if _REDIR_TIME64
60#ifdef _GNU_SOURCE
61__REDIR(ppoll, __ppoll_time64);
62#endif
63#endif
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif
lib/libc/include/wasm-wasi-musl/regex.h created+62
......@@ -0,0 +1,62 @@
1#ifndef _REGEX_H
2#define _REGEX_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_regoff_t
11#define __NEED_size_t
12
13#include <bits/alltypes.h>
14
15typedef struct re_pattern_buffer {
16 size_t re_nsub;
17 void *__opaque, *__padding[4];
18 size_t __nsub2;
19 char __padding2;
20} regex_t;
21
22typedef struct {
23 regoff_t rm_so;
24 regoff_t rm_eo;
25} regmatch_t;
26
27#define REG_EXTENDED 1
28#define REG_ICASE 2
29#define REG_NEWLINE 4
30#define REG_NOSUB 8
31
32#define REG_NOTBOL 1
33#define REG_NOTEOL 2
34
35#define REG_OK 0
36#define REG_NOMATCH 1
37#define REG_BADPAT 2
38#define REG_ECOLLATE 3
39#define REG_ECTYPE 4
40#define REG_EESCAPE 5
41#define REG_ESUBREG 6
42#define REG_EBRACK 7
43#define REG_EPAREN 8
44#define REG_EBRACE 9
45#define REG_BADBR 10
46#define REG_ERANGE 11
47#define REG_ESPACE 12
48#define REG_BADRPT 13
49
50#define REG_ENOSYS -1
51
52int regcomp(regex_t *__restrict, const char *__restrict, int);
53int regexec(const regex_t *__restrict, const char *__restrict, size_t, regmatch_t *__restrict, int);
54void regfree(regex_t *);
55
56size_t regerror(int, const regex_t *__restrict, char *__restrict, size_t);
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif
lib/libc/include/wasm-wasi-musl/sched.h created+152
......@@ -0,0 +1,152 @@
1#ifndef _SCHED_H
2#define _SCHED_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_struct_timespec
10#define __NEED_pid_t
11#define __NEED_time_t
12
13#ifdef _GNU_SOURCE
14#define __NEED_size_t
15#endif
16
17#include <bits/alltypes.h>
18
19#ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */
20struct sched_param {
21 int sched_priority;
22 int __reserved1;
23#if _REDIR_TIME64
24 long __reserved2[4];
25#else
26 struct {
27 time_t __reserved1;
28 long __reserved2;
29 } __reserved2[2];
30#endif
31 int __reserved3;
32};
33
34int sched_get_priority_max(int);
35int sched_get_priority_min(int);
36int sched_getparam(pid_t, struct sched_param *);
37int sched_getscheduler(pid_t);
38int sched_rr_get_interval(pid_t, struct timespec *);
39int sched_setparam(pid_t, const struct sched_param *);
40int sched_setscheduler(pid_t, int, const struct sched_param *);
41#endif
42int sched_yield(void);
43
44#ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */
45#define SCHED_OTHER 0
46#define SCHED_FIFO 1
47#define SCHED_RR 2
48#define SCHED_BATCH 3
49#define SCHED_IDLE 5
50#define SCHED_DEADLINE 6
51#define SCHED_RESET_ON_FORK 0x40000000
52
53#ifdef _GNU_SOURCE
54#define CSIGNAL 0x000000ff
55#define CLONE_NEWTIME 0x00000080
56#define CLONE_VM 0x00000100
57#define CLONE_FS 0x00000200
58#define CLONE_FILES 0x00000400
59#define CLONE_SIGHAND 0x00000800
60#define CLONE_PIDFD 0x00001000
61#define CLONE_PTRACE 0x00002000
62#define CLONE_VFORK 0x00004000
63#define CLONE_PARENT 0x00008000
64#define CLONE_THREAD 0x00010000
65#define CLONE_NEWNS 0x00020000
66#define CLONE_SYSVSEM 0x00040000
67#define CLONE_SETTLS 0x00080000
68#define CLONE_PARENT_SETTID 0x00100000
69#define CLONE_CHILD_CLEARTID 0x00200000
70#define CLONE_DETACHED 0x00400000
71#define CLONE_UNTRACED 0x00800000
72#define CLONE_CHILD_SETTID 0x01000000
73#define CLONE_NEWCGROUP 0x02000000
74#define CLONE_NEWUTS 0x04000000
75#define CLONE_NEWIPC 0x08000000
76#define CLONE_NEWUSER 0x10000000
77#define CLONE_NEWPID 0x20000000
78#define CLONE_NEWNET 0x40000000
79#define CLONE_IO 0x80000000
80int clone (int (*)(void *), void *, int, void *, ...);
81int unshare(int);
82int setns(int, int);
83
84void *memcpy(void *__restrict, const void *__restrict, size_t);
85int memcmp(const void *, const void *, size_t);
86void *memset (void *, int, size_t);
87void *calloc(size_t, size_t);
88void free(void *);
89
90typedef struct cpu_set_t { unsigned long __bits[128/sizeof(long)]; } cpu_set_t;
91int __sched_cpucount(size_t, const cpu_set_t *);
92int sched_getcpu(void);
93int sched_getaffinity(pid_t, size_t, cpu_set_t *);
94int sched_setaffinity(pid_t, size_t, const cpu_set_t *);
95
96#define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \
97 (((unsigned long *)(set))[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) )
98
99#define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=)
100#define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &=~)
101#define CPU_ISSET_S(i, size, set) __CPU_op_S(i, size, set, &)
102
103#define __CPU_op_func_S(func, op) \
104static __inline void __CPU_##func##_S(size_t __size, cpu_set_t *__dest, \
105 const cpu_set_t *__src1, const cpu_set_t *__src2) \
106{ \
107 size_t __i; \
108 for (__i=0; __i<__size/sizeof(long); __i++) \
109 ((unsigned long *)__dest)[__i] = ((unsigned long *)__src1)[__i] \
110 op ((unsigned long *)__src2)[__i] ; \
111}
112
113__CPU_op_func_S(AND, &)
114__CPU_op_func_S(OR, |)
115__CPU_op_func_S(XOR, ^)
116
117#define CPU_AND_S(a,b,c,d) __CPU_AND_S(a,b,c,d)
118#define CPU_OR_S(a,b,c,d) __CPU_OR_S(a,b,c,d)
119#define CPU_XOR_S(a,b,c,d) __CPU_XOR_S(a,b,c,d)
120
121#define CPU_COUNT_S(size,set) __sched_cpucount(size,set)
122#define CPU_ZERO_S(size,set) memset(set,0,size)
123#define CPU_EQUAL_S(size,set1,set2) (!memcmp(set1,set2,size))
124
125#define CPU_ALLOC_SIZE(n) (sizeof(long) * ( (n)/(8*sizeof(long)) \
126 + ((n)%(8*sizeof(long)) + 8*sizeof(long)-1)/(8*sizeof(long)) ) )
127#define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
128#define CPU_FREE(set) free(set)
129
130#define CPU_SETSIZE 128
131
132#define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set)
133#define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set)
134#define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set)
135#define CPU_AND(d,s1,s2) CPU_AND_S(sizeof(cpu_set_t),d,s1,s2)
136#define CPU_OR(d,s1,s2) CPU_OR_S(sizeof(cpu_set_t),d,s1,s2)
137#define CPU_XOR(d,s1,s2) CPU_XOR_S(sizeof(cpu_set_t),d,s1,s2)
138#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t),set)
139#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set)
140#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2)
141
142#endif
143#endif
144
145#if _REDIR_TIME64
146__REDIR(sched_rr_get_interval, __sched_rr_get_interval_time64);
147#endif
148
149#ifdef __cplusplus
150}
151#endif
152#endif
lib/libc/include/wasm-wasi-musl/search.h created+63
......@@ -0,0 +1,63 @@
1#ifndef _SEARCH_H
2#define _SEARCH_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11#include <bits/alltypes.h>
12
13typedef enum { FIND, ENTER } ACTION;
14typedef enum { preorder, postorder, endorder, leaf } VISIT;
15
16typedef struct entry {
17 char *key;
18 void *data;
19} ENTRY;
20
21int hcreate(size_t);
22void hdestroy(void);
23ENTRY *hsearch(ENTRY, ACTION);
24
25#ifdef _GNU_SOURCE
26struct hsearch_data {
27 struct __tab *__tab;
28 unsigned int __unused1;
29 unsigned int __unused2;
30};
31
32int hcreate_r(size_t, struct hsearch_data *);
33void hdestroy_r(struct hsearch_data *);
34int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
35#endif
36
37void insque(void *, void *);
38void remque(void *);
39
40void *lsearch(const void *, void *, size_t *, size_t,
41 int (*)(const void *, const void *));
42void *lfind(const void *, const void *, size_t *, size_t,
43 int (*)(const void *, const void *));
44
45void *tdelete(const void *__restrict, void **__restrict, int(*)(const void *, const void *));
46void *tfind(const void *, void *const *, int(*)(const void *, const void *));
47void *tsearch(const void *, void **, int (*)(const void *, const void *));
48void twalk(const void *, void (*)(const void *, VISIT, int));
49
50#ifdef _GNU_SOURCE
51struct qelem {
52 struct qelem *q_forw, *q_back;
53 char q_data[1];
54};
55
56void tdestroy(void *, void (*)(void *));
57#endif
58
59#ifdef __cplusplus
60}
61#endif
62
63#endif
lib/libc/include/wasm-wasi-musl/semaphore.h created+39
......@@ -0,0 +1,39 @@
1#ifndef _SEMAPHORE_H
2#define _SEMAPHORE_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_time_t
10#define __NEED_struct_timespec
11#include <bits/alltypes.h>
12
13#include <fcntl.h>
14
15#define SEM_FAILED ((sem_t *)0)
16
17typedef struct {
18 volatile int __val[4*sizeof(long)/sizeof(int)];
19} sem_t;
20
21int sem_close(sem_t *);
22int sem_destroy(sem_t *);
23int sem_getvalue(sem_t *__restrict, int *__restrict);
24int sem_init(sem_t *, int, unsigned);
25sem_t *sem_open(const char *, int, ...);
26int sem_post(sem_t *);
27int sem_timedwait(sem_t *__restrict, const struct timespec *__restrict);
28int sem_trywait(sem_t *);
29int sem_unlink(const char *);
30int sem_wait(sem_t *);
31
32#if _REDIR_TIME64
33__REDIR(sem_timedwait, __sem_timedwait_time64);
34#endif
35
36#ifdef __cplusplus
37}
38#endif
39#endif
lib/libc/include/wasm-wasi-musl/signal.h created+331
......@@ -0,0 +1,331 @@
1#ifndef _WASI_EMULATED_SIGNAL
2#error "wasm lacks signal support; to enable minimal signal emulation, \
3compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
4#else
5#ifndef _SIGNAL_H
6#define _SIGNAL_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <features.h>
13
14#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
15 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
16 || defined(_BSD_SOURCE)
17
18#ifdef __wasilibc_unmodified_upstream /* WASI has no ucontext support */
19#ifdef _GNU_SOURCE
20#define __ucontext ucontext
21#endif
22
23#define __NEED_size_t
24#define __NEED_pid_t
25#define __NEED_uid_t
26#define __NEED_struct_timespec
27#define __NEED_pthread_t
28#define __NEED_pthread_attr_t
29#define __NEED_time_t
30#define __NEED_clock_t
31#define __NEED_sigset_t
32
33#include <bits/alltypes.h>
34
35#define SIG_BLOCK 0
36#define SIG_UNBLOCK 1
37#define SIG_SETMASK 2
38
39#define SI_ASYNCNL (-60)
40#define SI_TKILL (-6)
41#define SI_SIGIO (-5)
42#define SI_ASYNCIO (-4)
43#define SI_MESGQ (-3)
44#define SI_TIMER (-2)
45#define SI_QUEUE (-1)
46#define SI_USER 0
47#define SI_KERNEL 128
48
49typedef struct sigaltstack stack_t;
50#endif
51
52#endif
53
54#include <bits/signal.h>
55
56#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
57 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
58 || defined(_BSD_SOURCE)
59
60#ifdef __wasilibc_unmodified_upstream /* WASI has no sigaction */
61#define SIG_HOLD ((void (*)(int)) 2)
62
63#define FPE_INTDIV 1
64#define FPE_INTOVF 2
65#define FPE_FLTDIV 3
66#define FPE_FLTOVF 4
67#define FPE_FLTUND 5
68#define FPE_FLTRES 6
69#define FPE_FLTINV 7
70#define FPE_FLTSUB 8
71
72#define ILL_ILLOPC 1
73#define ILL_ILLOPN 2
74#define ILL_ILLADR 3
75#define ILL_ILLTRP 4
76#define ILL_PRVOPC 5
77#define ILL_PRVREG 6
78#define ILL_COPROC 7
79#define ILL_BADSTK 8
80
81#define SEGV_MAPERR 1
82#define SEGV_ACCERR 2
83#define SEGV_BNDERR 3
84#define SEGV_PKUERR 4
85
86#define BUS_ADRALN 1
87#define BUS_ADRERR 2
88#define BUS_OBJERR 3
89#define BUS_MCEERR_AR 4
90#define BUS_MCEERR_AO 5
91
92#define CLD_EXITED 1
93#define CLD_KILLED 2
94#define CLD_DUMPED 3
95#define CLD_TRAPPED 4
96#define CLD_STOPPED 5
97#define CLD_CONTINUED 6
98
99union sigval {
100 int sival_int;
101 void *sival_ptr;
102};
103
104typedef struct {
105#ifdef __SI_SWAP_ERRNO_CODE
106 int si_signo, si_code, si_errno;
107#else
108 int si_signo, si_errno, si_code;
109#endif
110 union {
111 char __pad[128 - 2*sizeof(int) - sizeof(long)];
112 struct {
113 union {
114 struct {
115 pid_t si_pid;
116 uid_t si_uid;
117 } __piduid;
118 struct {
119 int si_timerid;
120 int si_overrun;
121 } __timer;
122 } __first;
123 union {
124 union sigval si_value;
125 struct {
126 int si_status;
127 clock_t si_utime, si_stime;
128 } __sigchld;
129 } __second;
130 } __si_common;
131 struct {
132 void *si_addr;
133 short si_addr_lsb;
134 union {
135 struct {
136 void *si_lower;
137 void *si_upper;
138 } __addr_bnd;
139 unsigned si_pkey;
140 } __first;
141 } __sigfault;
142 struct {
143 long si_band;
144 int si_fd;
145 } __sigpoll;
146 struct {
147 void *si_call_addr;
148 int si_syscall;
149 unsigned si_arch;
150 } __sigsys;
151 } __si_fields;
152} siginfo_t;
153#define si_pid __si_fields.__si_common.__first.__piduid.si_pid
154#define si_uid __si_fields.__si_common.__first.__piduid.si_uid
155#define si_status __si_fields.__si_common.__second.__sigchld.si_status
156#define si_utime __si_fields.__si_common.__second.__sigchld.si_utime
157#define si_stime __si_fields.__si_common.__second.__sigchld.si_stime
158#define si_value __si_fields.__si_common.__second.si_value
159#define si_addr __si_fields.__sigfault.si_addr
160#define si_addr_lsb __si_fields.__sigfault.si_addr_lsb
161#define si_lower __si_fields.__sigfault.__first.__addr_bnd.si_lower
162#define si_upper __si_fields.__sigfault.__first.__addr_bnd.si_upper
163#define si_pkey __si_fields.__sigfault.__first.si_pkey
164#define si_band __si_fields.__sigpoll.si_band
165#define si_fd __si_fields.__sigpoll.si_fd
166#define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
167#define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
168#define si_ptr si_value.sival_ptr
169#define si_int si_value.sival_int
170#define si_call_addr __si_fields.__sigsys.si_call_addr
171#define si_syscall __si_fields.__sigsys.si_syscall
172#define si_arch __si_fields.__sigsys.si_arch
173
174struct sigaction {
175 union {
176 void (*sa_handler)(int);
177 void (*sa_sigaction)(int, siginfo_t *, void *);
178 } __sa_handler;
179 sigset_t sa_mask;
180 int sa_flags;
181 void (*sa_restorer)(void);
182};
183#define sa_handler __sa_handler.sa_handler
184#define sa_sigaction __sa_handler.sa_sigaction
185
186struct sigevent {
187 union sigval sigev_value;
188 int sigev_signo;
189 int sigev_notify;
190 union {
191 char __pad[64 - 2*sizeof(int) - sizeof(union sigval)];
192 pid_t sigev_notify_thread_id;
193 struct {
194 void (*sigev_notify_function)(union sigval);
195 pthread_attr_t *sigev_notify_attributes;
196 } __sev_thread;
197 } __sev_fields;
198};
199
200#define sigev_notify_thread_id __sev_fields.sigev_notify_thread_id
201#define sigev_notify_function __sev_fields.__sev_thread.sigev_notify_function
202#define sigev_notify_attributes __sev_fields.__sev_thread.sigev_notify_attributes
203
204#define SIGEV_SIGNAL 0
205#define SIGEV_NONE 1
206#define SIGEV_THREAD 2
207#define SIGEV_THREAD_ID 4
208#endif
209
210#ifdef __wasilibc_unmodified_upstream /* WASI has no realtime signals */
211int __libc_current_sigrtmin(void);
212int __libc_current_sigrtmax(void);
213
214#define SIGRTMIN (__libc_current_sigrtmin())
215#define SIGRTMAX (__libc_current_sigrtmax())
216#endif
217
218#ifdef __wasilibc_unmodified_upstream /* WASI has no signals */
219int kill(pid_t, int);
220
221int sigemptyset(sigset_t *);
222int sigfillset(sigset_t *);
223int sigaddset(sigset_t *, int);
224int sigdelset(sigset_t *, int);
225int sigismember(const sigset_t *, int);
226
227int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict);
228int sigsuspend(const sigset_t *);
229int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict);
230int sigpending(sigset_t *);
231int sigwait(const sigset_t *__restrict, int *__restrict);
232int sigwaitinfo(const sigset_t *__restrict, siginfo_t *__restrict);
233int sigtimedwait(const sigset_t *__restrict, siginfo_t *__restrict, const struct timespec *__restrict);
234int sigqueue(pid_t, int, union sigval);
235#endif
236
237#ifdef __wasilibc_unmodified_upstream /* WASI has no threads yet */
238int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict);
239int pthread_kill(pthread_t, int);
240#endif
241
242#ifdef __wasilibc_unmodified_upstream /* WASI has no siginfo */
243void psiginfo(const siginfo_t *, const char *);
244#endif
245void psignal(int, const char *);
246
247#endif
248
249#ifdef __wasilibc_unmodified_upstream /* WASI has no signals */
250#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
251int killpg(pid_t, int);
252int sigaltstack(const stack_t *__restrict, stack_t *__restrict);
253int sighold(int);
254int sigignore(int);
255int siginterrupt(int, int);
256int sigpause(int);
257int sigrelse(int);
258void (*sigset(int, void (*)(int)))(int);
259#define TRAP_BRKPT 1
260#define TRAP_TRACE 2
261#define TRAP_BRANCH 3
262#define TRAP_HWBKPT 4
263#define TRAP_UNK 5
264#define POLL_IN 1
265#define POLL_OUT 2
266#define POLL_MSG 3
267#define POLL_ERR 4
268#define POLL_PRI 5
269#define POLL_HUP 6
270#define SS_ONSTACK 1
271#define SS_DISABLE 2
272#define SS_AUTODISARM (1U << 31)
273#define SS_FLAG_BITS SS_AUTODISARM
274#endif
275#endif
276
277#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
278#define NSIG _NSIG
279typedef void (*sig_t)(int);
280#endif
281
282#ifdef _GNU_SOURCE
283typedef void (*sighandler_t)(int);
284void (*bsd_signal(int, void (*)(int)))(int);
285#ifdef __wasilibc_unmodified_upstream /* WASI has no signal sets */
286int sigisemptyset(const sigset_t *);
287int sigorset (sigset_t *, const sigset_t *, const sigset_t *);
288int sigandset(sigset_t *, const sigset_t *, const sigset_t *);
289
290#define SA_NOMASK SA_NODEFER
291#define SA_ONESHOT SA_RESETHAND
292#endif
293#endif
294
295#ifdef __wasilibc_unmodified_upstream /* 1 is a valid function pointer on wasm */
296#define SIG_ERR ((void (*)(int))-1)
297#define SIG_DFL ((void (*)(int)) 0)
298#define SIG_IGN ((void (*)(int)) 1)
299#else
300void __SIG_ERR(int);
301void __SIG_IGN(int);
302#define SIG_ERR (__SIG_ERR)
303#define SIG_DFL ((void (*)(int)) 0)
304#define SIG_IGN (__SIG_IGN)
305#endif
306
307#ifdef __wasilibc_unmodified_upstream /* Make sig_atomic_t 64-bit on wasm64 */
308typedef int sig_atomic_t;
309#else
310typedef long sig_atomic_t;
311#endif
312
313void (*signal(int, void (*)(int)))(int);
314int raise(int);
315
316#ifdef __wasilibc_unmodified_upstream /* WASI has no sigtimedwait */
317#if _REDIR_TIME64
318#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
319 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
320 || defined(_BSD_SOURCE)
321__REDIR(sigtimedwait, __sigtimedwait_time64);
322#endif
323#endif
324#endif
325
326#ifdef __cplusplus
327}
328#endif
329
330#endif
331#endif
lib/libc/include/wasm-wasi-musl/stdalign.h created+20
......@@ -0,0 +1,20 @@
1#ifndef _STDALIGN_H
2#define _STDALIGN_H
3
4#ifndef __cplusplus
5
6/* this whole header only works in C11 or with compiler extensions */
7#if __STDC_VERSION__ < 201112L && defined( __GNUC__)
8#define _Alignas(t) __attribute__((__aligned__(t)))
9#define _Alignof(t) __alignof__(t)
10#endif
11
12#define alignas _Alignas
13#define alignof _Alignof
14
15#endif
16
17#define __alignas_is_defined 1
18#define __alignof_is_defined 1
19
20#endif
lib/libc/include/wasm-wasi-musl/stdbool.h created+14
......@@ -0,0 +1,14 @@
1#ifndef _STDBOOL_H
2#define _STDBOOL_H
3
4#ifndef __cplusplus
5
6#define true 1
7#define false 0
8#define bool _Bool
9
10#endif
11
12#define __bool_true_false_are_defined 1
13
14#endif
lib/libc/include/wasm-wasi-musl/stdc-predef.h created+10
......@@ -0,0 +1,10 @@
1#ifndef _STDC_PREDEF_H
2#define _STDC_PREDEF_H
3
4#define __STDC_ISO_10646__ 201206L
5
6#if !defined(__GCC_IEC_559) || __GCC_IEC_559 > 0
7#define __STDC_IEC_559__ 1
8#endif
9
10#endif
lib/libc/include/wasm-wasi-musl/stdint.h created+117
......@@ -0,0 +1,117 @@
1#ifndef _STDINT_H
2#define _STDINT_H
3
4#define __NEED_int8_t
5#define __NEED_int16_t
6#define __NEED_int32_t
7#define __NEED_int64_t
8
9#define __NEED_uint8_t
10#define __NEED_uint16_t
11#define __NEED_uint32_t
12#define __NEED_uint64_t
13
14#define __NEED_intptr_t
15#define __NEED_uintptr_t
16
17#define __NEED_intmax_t
18#define __NEED_uintmax_t
19
20#include <bits/alltypes.h>
21
22typedef int8_t int_fast8_t;
23typedef int64_t int_fast64_t;
24
25typedef int8_t int_least8_t;
26typedef int16_t int_least16_t;
27typedef int32_t int_least32_t;
28typedef int64_t int_least64_t;
29
30typedef uint8_t uint_fast8_t;
31typedef uint64_t uint_fast64_t;
32
33typedef uint8_t uint_least8_t;
34typedef uint16_t uint_least16_t;
35typedef uint32_t uint_least32_t;
36typedef uint64_t uint_least64_t;
37
38#define INT8_MIN (-1-0x7f)
39#define INT16_MIN (-1-0x7fff)
40#define INT32_MIN (-1-0x7fffffff)
41#define INT64_MIN (-1-0x7fffffffffffffff)
42
43#define INT8_MAX (0x7f)
44#define INT16_MAX (0x7fff)
45#define INT32_MAX (0x7fffffff)
46#define INT64_MAX (0x7fffffffffffffff)
47
48#define UINT8_MAX (0xff)
49#define UINT16_MAX (0xffff)
50#define UINT32_MAX (0xffffffffu)
51#define UINT64_MAX (0xffffffffffffffffu)
52
53#define INT_FAST8_MIN INT8_MIN
54#define INT_FAST64_MIN INT64_MIN
55
56#define INT_LEAST8_MIN INT8_MIN
57#define INT_LEAST16_MIN INT16_MIN
58#define INT_LEAST32_MIN INT32_MIN
59#define INT_LEAST64_MIN INT64_MIN
60
61#define INT_FAST8_MAX INT8_MAX
62#define INT_FAST64_MAX INT64_MAX
63
64#define INT_LEAST8_MAX INT8_MAX
65#define INT_LEAST16_MAX INT16_MAX
66#define INT_LEAST32_MAX INT32_MAX
67#define INT_LEAST64_MAX INT64_MAX
68
69#define UINT_FAST8_MAX UINT8_MAX
70#define UINT_FAST64_MAX UINT64_MAX
71
72#define UINT_LEAST8_MAX UINT8_MAX
73#define UINT_LEAST16_MAX UINT16_MAX
74#define UINT_LEAST32_MAX UINT32_MAX
75#define UINT_LEAST64_MAX UINT64_MAX
76
77#define INTMAX_MIN INT64_MIN
78#define INTMAX_MAX INT64_MAX
79#define UINTMAX_MAX UINT64_MAX
80
81#define WINT_MIN 0U
82#define WINT_MAX UINT32_MAX
83
84#if L'\0'-1 > 0
85#define WCHAR_MAX (0xffffffffu+L'\0')
86#define WCHAR_MIN (0+L'\0')
87#else
88#define WCHAR_MAX (0x7fffffff+L'\0')
89#define WCHAR_MIN (-1-0x7fffffff+L'\0')
90#endif
91
92#define SIG_ATOMIC_MIN INT32_MIN
93#define SIG_ATOMIC_MAX INT32_MAX
94
95#include <bits/stdint.h>
96
97#define INT8_C(c) c
98#define INT16_C(c) c
99#define INT32_C(c) c
100
101#define UINT8_C(c) c
102#define UINT16_C(c) c
103#define UINT32_C(c) c ## U
104
105#if UINTPTR_MAX == UINT64_MAX
106#define INT64_C(c) c ## L
107#define UINT64_C(c) c ## UL
108#define INTMAX_C(c) c ## L
109#define UINTMAX_C(c) c ## UL
110#else
111#define INT64_C(c) c ## LL
112#define UINT64_C(c) c ## ULL
113#define INTMAX_C(c) c ## LL
114#define UINTMAX_C(c) c ## ULL
115#endif
116
117#endif
lib/libc/include/wasm-wasi-musl/stdio.h created+252
......@@ -0,0 +1,252 @@
1#ifndef _STDIO_H
2#define _STDIO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_FILE
11#define __NEED___isoc_va_list
12#define __NEED_size_t
13
14#ifdef __wasilibc_unmodified_upstream /* WASI doesn't need to define FILE as a complete type */
15#if __STDC_VERSION__ < 201112L
16#define __NEED_struct__IO_FILE
17#endif
18#endif
19
20#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
21 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
22 || defined(_BSD_SOURCE)
23#define __NEED_ssize_t
24#define __NEED_off_t
25#define __NEED_va_list
26#endif
27
28#include <bits/alltypes.h>
29
30#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
31#ifdef __cplusplus
32#define NULL 0L
33#else
34#define NULL ((void*)0)
35#endif
36#else
37#define __need_NULL
38#include <stddef.h>
39#endif
40
41#undef EOF
42#define EOF (-1)
43
44#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
45#undef SEEK_SET
46#undef SEEK_CUR
47#undef SEEK_END
48#define SEEK_SET 0
49#define SEEK_CUR 1
50#define SEEK_END 2
51#else
52#include <__seek.h>
53#endif
54
55#define _IOFBF 0
56#define _IOLBF 1
57#define _IONBF 2
58
59#define BUFSIZ 1024
60#define FILENAME_MAX 4096
61#define FOPEN_MAX 1000
62#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
63#define TMP_MAX 10000
64#define L_tmpnam 20
65#endif
66
67typedef union _G_fpos64_t {
68 char __opaque[16];
69 long long __lldata;
70 double __align;
71} fpos_t;
72
73extern FILE *const stdin;
74extern FILE *const stdout;
75extern FILE *const stderr;
76
77#define stdin (stdin)
78#define stdout (stdout)
79#define stderr (stderr)
80
81FILE *fopen(const char *__restrict, const char *__restrict);
82FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);
83int fclose(FILE *);
84
85int remove(const char *);
86int rename(const char *, const char *);
87
88int feof(FILE *);
89int ferror(FILE *);
90int fflush(FILE *);
91void clearerr(FILE *);
92
93int fseek(FILE *, long, int);
94long ftell(FILE *);
95void rewind(FILE *);
96
97int fgetpos(FILE *__restrict, fpos_t *__restrict);
98int fsetpos(FILE *, const fpos_t *);
99
100size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
101size_t fwrite(const void *__restrict, size_t, size_t, FILE *__restrict);
102
103int fgetc(FILE *);
104int getc(FILE *);
105int getchar(void);
106int ungetc(int, FILE *);
107
108int fputc(int, FILE *);
109int putc(int, FILE *);
110int putchar(int);
111
112char *fgets(char *__restrict, int, FILE *__restrict);
113#if __STDC_VERSION__ < 201112L
114#ifdef __wasilibc_unmodified_upstream /* gets is obsolete */
115char *gets(char *);
116#else
117char *gets(char *) __attribute__((__deprecated__("gets is not defined on WASI")));
118#endif
119#endif
120
121int fputs(const char *__restrict, FILE *__restrict);
122int puts(const char *);
123
124int printf(const char *__restrict, ...);
125int fprintf(FILE *__restrict, const char *__restrict, ...);
126int sprintf(char *__restrict, const char *__restrict, ...);
127int snprintf(char *__restrict, size_t, const char *__restrict, ...);
128
129int vprintf(const char *__restrict, __isoc_va_list);
130int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list);
131int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list);
132int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list);
133
134int scanf(const char *__restrict, ...);
135int fscanf(FILE *__restrict, const char *__restrict, ...);
136int sscanf(const char *__restrict, const char *__restrict, ...);
137int vscanf(const char *__restrict, __isoc_va_list);
138int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list);
139int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list);
140
141void perror(const char *);
142
143int setvbuf(FILE *__restrict, char *__restrict, int, size_t);
144void setbuf(FILE *__restrict, char *__restrict);
145
146#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
147char *tmpnam(char *);
148FILE *tmpfile(void);
149#else
150char *tmpnam(char *) __attribute__((__deprecated__("tmpnam is not defined on WASI")));
151FILE *tmpfile(void) __attribute__((__deprecated__("tmpfile is not defined on WASI")));
152#endif
153
154#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
155 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
156 || defined(_BSD_SOURCE)
157FILE *fmemopen(void *__restrict, size_t, const char *__restrict);
158FILE *open_memstream(char **, size_t *);
159FILE *fdopen(int, const char *);
160#ifdef __wasilibc_unmodified_upstream /* WASI has no popen */
161FILE *popen(const char *, const char *);
162int pclose(FILE *);
163#endif
164int fileno(FILE *);
165int fseeko(FILE *, off_t, int);
166off_t ftello(FILE *);
167int dprintf(int, const char *__restrict, ...);
168int vdprintf(int, const char *__restrict, __isoc_va_list);
169#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
170void flockfile(FILE *);
171int ftrylockfile(FILE *);
172void funlockfile(FILE *);
173#endif
174int getc_unlocked(FILE *);
175int getchar_unlocked(void);
176int putc_unlocked(int, FILE *);
177int putchar_unlocked(int);
178ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict);
179ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict);
180int renameat(int, const char *, int, const char *);
181char *ctermid(char *);
182#define L_ctermid 20
183#endif
184
185
186#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
187#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
188 || defined(_BSD_SOURCE)
189#define P_tmpdir "/tmp"
190char *tempnam(const char *, const char *);
191#endif
192#endif
193
194#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
195#define L_cuserid 20
196char *cuserid(char *);
197void setlinebuf(FILE *);
198void setbuffer(FILE *, char *, size_t);
199int fgetc_unlocked(FILE *);
200int fputc_unlocked(int, FILE *);
201int fflush_unlocked(FILE *);
202size_t fread_unlocked(void *, size_t, size_t, FILE *);
203size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
204void clearerr_unlocked(FILE *);
205int feof_unlocked(FILE *);
206int ferror_unlocked(FILE *);
207int fileno_unlocked(FILE *);
208int getw(FILE *);
209int putw(int, FILE *);
210char *fgetln(FILE *, size_t *);
211int asprintf(char **, const char *, ...);
212int vasprintf(char **, const char *, __isoc_va_list);
213#endif
214
215#ifdef _GNU_SOURCE
216char *fgets_unlocked(char *, int, FILE *);
217int fputs_unlocked(const char *, FILE *);
218
219typedef ssize_t (cookie_read_function_t)(void *, char *, size_t);
220typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t);
221typedef int (cookie_seek_function_t)(void *, off_t *, int);
222typedef int (cookie_close_function_t)(void *);
223
224typedef struct _IO_cookie_io_functions_t {
225 cookie_read_function_t *read;
226 cookie_write_function_t *write;
227 cookie_seek_function_t *seek;
228 cookie_close_function_t *close;
229} cookie_io_functions_t;
230
231FILE *fopencookie(void *, const char *, cookie_io_functions_t);
232#endif
233
234#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
235#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
236#define tmpfile64 tmpfile
237#endif
238#define fopen64 fopen
239#define freopen64 freopen
240#define fseeko64 fseeko
241#define ftello64 ftello
242#define fgetpos64 fgetpos
243#define fsetpos64 fsetpos
244#define fpos64_t fpos_t
245#define off64_t off_t
246#endif
247
248#ifdef __cplusplus
249}
250#endif
251
252#endif
lib/libc/include/wasm-wasi-musl/stdio_ext.h created+34
......@@ -0,0 +1,34 @@
1#ifndef _STDIO_EXT_H
2#define _STDIO_EXT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdio.h>
9
10#define FSETLOCKING_QUERY 0
11#define FSETLOCKING_INTERNAL 1
12#define FSETLOCKING_BYCALLER 2
13
14void _flushlbf(void);
15int __fsetlocking(FILE *, int);
16int __fwriting(FILE *);
17int __freading(FILE *);
18int __freadable(FILE *);
19int __fwritable(FILE *);
20int __flbf(FILE *);
21size_t __fbufsize(FILE *);
22size_t __fpending(FILE *);
23int __fpurge(FILE *);
24
25size_t __freadahead(FILE *);
26const char *__freadptr(FILE *, size_t *);
27void __freadptrinc(FILE *, size_t);
28void __fseterr(FILE *);
29
30#ifdef __cplusplus
31}
32#endif
33
34#endif
lib/libc/include/wasm-wasi-musl/stdlib.h created+216
......@@ -0,0 +1,216 @@
1#ifndef _STDLIB_H
2#define _STDLIB_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#else
6#include <__functions_malloc.h>
7#include <__header_stdlib.h>
8#endif
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#include <features.h>
14
15#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
16#ifdef __cplusplus
17#define NULL 0L
18#else
19#define NULL ((void*)0)
20#endif
21#else
22#define __need_NULL
23#include <stddef.h>
24#endif
25
26#define __NEED_size_t
27#define __NEED_wchar_t
28
29#include <bits/alltypes.h>
30
31int atoi (const char *);
32long atol (const char *);
33long long atoll (const char *);
34double atof (const char *);
35
36float strtof (const char *__restrict, char **__restrict);
37double strtod (const char *__restrict, char **__restrict);
38long double strtold (const char *__restrict, char **__restrict);
39
40long strtol (const char *__restrict, char **__restrict, int);
41unsigned long strtoul (const char *__restrict, char **__restrict, int);
42long long strtoll (const char *__restrict, char **__restrict, int);
43unsigned long long strtoull (const char *__restrict, char **__restrict, int);
44
45int rand (void);
46void srand (unsigned);
47
48#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
49void *malloc (size_t);
50void *calloc (size_t, size_t);
51void *realloc (void *, size_t);
52void free (void *);
53#endif
54void *aligned_alloc(size_t, size_t);
55
56_Noreturn void abort (void);
57int atexit (void (*) (void));
58_Noreturn void exit (int);
59_Noreturn void _Exit (int);
60int at_quick_exit (void (*) (void));
61_Noreturn void quick_exit (int);
62
63char *getenv (const char *);
64
65int system (const char *);
66
67void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
68void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
69
70int abs (int);
71long labs (long);
72long long llabs (long long);
73
74typedef struct { int quot, rem; } div_t;
75typedef struct { long quot, rem; } ldiv_t;
76typedef struct { long long quot, rem; } lldiv_t;
77
78div_t div (int, int);
79ldiv_t ldiv (long, long);
80lldiv_t lldiv (long long, long long);
81
82int mblen (const char *, size_t);
83int mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
84int wctomb (char *, wchar_t);
85size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t);
86size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t);
87
88#define EXIT_FAILURE 1
89#define EXIT_SUCCESS 0
90
91size_t __ctype_get_mb_cur_max(void);
92#define MB_CUR_MAX (__ctype_get_mb_cur_max())
93
94#define RAND_MAX (0x7fffffff)
95
96
97#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
98 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
99 || defined(_BSD_SOURCE)
100
101#ifdef __wasilibc_unmodified_upstream /* WASI has no wait */
102#define WNOHANG 1
103#define WUNTRACED 2
104
105#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
106#define WTERMSIG(s) ((s) & 0x7f)
107#define WSTOPSIG(s) WEXITSTATUS(s)
108#define WIFEXITED(s) (!WTERMSIG(s))
109#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00)
110#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
111#endif
112
113int posix_memalign (void **, size_t, size_t);
114int setenv (const char *, const char *, int);
115int unsetenv (const char *);
116#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
117int mkstemp (char *);
118int mkostemp (char *, int);
119char *mkdtemp (char *);
120#endif
121int getsubopt (char **, char *const *, char **);
122int rand_r (unsigned *);
123
124#endif
125
126
127#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
128 || defined(_BSD_SOURCE)
129#ifdef __wasilibc_unmodified_upstream /* WASI has no absolute paths */
130char *realpath (const char *__restrict, char *__restrict);
131#endif
132long int random (void);
133void srandom (unsigned int);
134char *initstate (unsigned int, char *, size_t);
135char *setstate (char *);
136int putenv (char *);
137#ifdef __wasilibc_unmodified_upstream /* WASI has no pseudo-terminals */
138int posix_openpt (int);
139int grantpt (int);
140int unlockpt (int);
141char *ptsname (int);
142#endif
143char *l64a (long);
144long a64l (const char *);
145void setkey (const char *);
146double drand48 (void);
147double erand48 (unsigned short [3]);
148long int lrand48 (void);
149long int nrand48 (unsigned short [3]);
150long mrand48 (void);
151long jrand48 (unsigned short [3]);
152void srand48 (long);
153unsigned short *seed48 (unsigned short [3]);
154void lcong48 (unsigned short [7]);
155#endif
156
157#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
158#include <alloca.h>
159#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
160char *mktemp (char *);
161int mkstemps (char *, int);
162int mkostemps (char *, int, int);
163#endif
164#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
165void *valloc (size_t);
166void *memalign(size_t, size_t);
167int getloadavg(double *, int);
168#endif
169int clearenv(void);
170#ifdef __wasilibc_unmodified_upstream /* WASI has no wait */
171#define WCOREDUMP(s) ((s) & 0x80)
172#define WIFCONTINUED(s) ((s) == 0xffff)
173void *reallocarray (void *, size_t, size_t);
174#endif
175#endif
176
177#ifdef _GNU_SOURCE
178#ifdef __wasilibc_unmodified_upstream /* WASI has no pseudo-terminals */
179int ptsname_r(int, char *, size_t);
180#endif
181char *ecvt(double, int, int *, int *);
182char *fcvt(double, int, int *, int *);
183char *gcvt(double, int, char *);
184char *secure_getenv(const char *);
185struct __locale_struct;
186float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *);
187double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *);
188long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *);
189#endif
190
191#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
192#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
193#define mkstemp64 mkstemp
194#define mkostemp64 mkostemp
195#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
196#define mkstemps64 mkstemps
197#define mkostemps64 mkostemps
198#endif
199#endif
200#endif
201
202#ifdef __wasilibc_unmodified_upstream /* Declare arc4random functions */
203#else
204#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
205#include <stdint.h>
206uint32_t arc4random(void);
207void arc4random_buf(void *, size_t);
208uint32_t arc4random_uniform(uint32_t);
209#endif
210#endif
211
212#ifdef __cplusplus
213}
214#endif
215
216#endif
lib/libc/include/wasm-wasi-musl/stdnoreturn.h created+7
......@@ -0,0 +1,7 @@
1#ifndef _STDNORETURN_H
2#define _STDNORETURN_H
3#ifndef __cplusplus
4#include <features.h>
5#define noreturn _Noreturn
6#endif
7#endif
lib/libc/include/wasm-wasi-musl/string.h created+126
......@@ -0,0 +1,126 @@
1#ifndef _STRING_H
2#define _STRING_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#else
6#include <__header_string.h>
7#endif
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <features.h>
13
14#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
15#ifdef __cplusplus
16#define NULL 0L
17#else
18#define NULL ((void*)0)
19#endif
20#else
21#define __need_NULL
22#include <stddef.h>
23#endif
24
25#define __NEED_size_t
26#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
27 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
28 || defined(_BSD_SOURCE)
29#define __NEED_locale_t
30#endif
31
32#include <bits/alltypes.h>
33
34#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
35void *memcpy (void *__restrict, const void *__restrict, size_t);
36void *memmove (void *, const void *, size_t);
37void *memset (void *, int, size_t);
38#endif
39int memcmp (const void *, const void *, size_t);
40#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
41void *memchr (const void *, int, size_t);
42#endif
43
44char *strcpy (char *__restrict, const char *__restrict);
45char *strncpy (char *__restrict, const char *__restrict, size_t);
46
47char *strcat (char *__restrict, const char *__restrict);
48char *strncat (char *__restrict, const char *__restrict, size_t);
49
50#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
51int strcmp (const char *, const char *);
52#endif
53int strncmp (const char *, const char *, size_t);
54
55int strcoll (const char *, const char *);
56size_t strxfrm (char *__restrict, const char *__restrict, size_t);
57
58char *strchr (const char *, int);
59char *strrchr (const char *, int);
60
61size_t strcspn (const char *, const char *);
62size_t strspn (const char *, const char *);
63char *strpbrk (const char *, const char *);
64char *strstr (const char *, const char *);
65char *strtok (char *__restrict, const char *__restrict);
66
67#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
68size_t strlen (const char *);
69#endif
70
71char *strerror (int);
72
73#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
74#include <strings.h>
75#endif
76
77#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
78 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
79 || defined(_BSD_SOURCE)
80char *strtok_r (char *__restrict, const char *__restrict, char **__restrict);
81int strerror_r (int, char *, size_t);
82char *stpcpy(char *__restrict, const char *__restrict);
83char *stpncpy(char *__restrict, const char *__restrict, size_t);
84size_t strnlen (const char *, size_t);
85#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
86char *strdup (const char *);
87#endif
88char *strndup (const char *, size_t);
89char *strsignal(int);
90char *strerror_l (int, locale_t);
91int strcoll_l (const char *, const char *, locale_t);
92size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
93#endif
94
95#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
96 || defined(_BSD_SOURCE)
97void *memccpy (void *__restrict, const void *__restrict, int, size_t);
98#endif
99
100#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
101char *strsep(char **, const char *);
102size_t strlcat (char *, const char *, size_t);
103size_t strlcpy (char *, const char *, size_t);
104void explicit_bzero (void *, size_t);
105#endif
106
107#ifdef _GNU_SOURCE
108#define strdupa(x) strcpy(alloca(strlen(x)+1),x)
109int strverscmp (const char *, const char *);
110char *strchrnul(const char *, int);
111char *strcasestr(const char *, const char *);
112void *memmem(const void *, size_t, const void *, size_t);
113void *memrchr(const void *, int, size_t);
114void *mempcpy(void *, const void *, size_t);
115#ifdef __wasilibc_unmodified_upstream /* avoid unprototyped decls; use <libgen.h> */
116#ifndef __cplusplus
117char *basename();
118#endif
119#endif
120#endif
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif
lib/libc/include/wasm-wasi-musl/strings.h created+39
......@@ -0,0 +1,39 @@
1#ifndef _STRINGS_H
2#define _STRINGS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8
9#define __NEED_size_t
10#define __NEED_locale_t
11#include <bits/alltypes.h>
12
13#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
14 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
15 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
16int bcmp (const void *, const void *, size_t);
17void bcopy (const void *, void *, size_t);
18void bzero (void *, size_t);
19char *index (const char *, int);
20char *rindex (const char *, int);
21#endif
22
23#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
24int ffs (int);
25int ffsl (long);
26int ffsll (long long);
27#endif
28
29int strcasecmp (const char *, const char *);
30int strncasecmp (const char *, const char *, size_t);
31
32int strcasecmp_l (const char *, const char *, locale_t);
33int strncasecmp_l (const char *, const char *, size_t, locale_t);
34
35#ifdef __cplusplus
36}
37#endif
38
39#endif
lib/libc/include/wasm-wasi-musl/stropts.h created+139
......@@ -0,0 +1,139 @@
1#ifndef _STROPTS_H
2#define _STROPTS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __SID ('S' << 8)
9
10#define I_NREAD (__SID | 1)
11#define I_PUSH (__SID | 2)
12#define I_POP (__SID | 3)
13#define I_LOOK (__SID | 4)
14#define I_FLUSH (__SID | 5)
15#define I_SRDOPT (__SID | 6)
16#define I_GRDOPT (__SID | 7)
17#define I_STR (__SID | 8)
18#define I_SETSIG (__SID | 9)
19#define I_GETSIG (__SID |10)
20#define I_FIND (__SID |11)
21#define I_LINK (__SID |12)
22#define I_UNLINK (__SID |13)
23#define I_PEEK (__SID |15)
24#define I_FDINSERT (__SID |16)
25#define I_SENDFD (__SID |17)
26#define I_RECVFD (__SID |14)
27#define I_SWROPT (__SID |19)
28#define I_GWROPT (__SID |20)
29#define I_LIST (__SID |21)
30#define I_PLINK (__SID |22)
31#define I_PUNLINK (__SID |23)
32#define I_FLUSHBAND (__SID |28)
33#define I_CKBAND (__SID |29)
34#define I_GETBAND (__SID |30)
35#define I_ATMARK (__SID |31)
36#define I_SETCLTIME (__SID |32)
37#define I_GETCLTIME (__SID |33)
38#define I_CANPUT (__SID |34)
39
40#define FMNAMESZ 8
41
42#define FLUSHR 0x01
43#define FLUSHW 0x02
44#define FLUSHRW 0x03
45#define FLUSHBAND 0x04
46
47#define S_INPUT 0x0001
48#define S_HIPRI 0x0002
49#define S_OUTPUT 0x0004
50#define S_MSG 0x0008
51#define S_ERROR 0x0010
52#define S_HANGUP 0x0020
53#define S_RDNORM 0x0040
54#define S_WRNORM S_OUTPUT
55#define S_RDBAND 0x0080
56#define S_WRBAND 0x0100
57#define S_BANDURG 0x0200
58
59#define RS_HIPRI 0x01
60
61#define RNORM 0x0000
62#define RMSGD 0x0001
63#define RMSGN 0x0002
64#define RPROTDAT 0x0004
65#define RPROTDIS 0x0008
66#define RPROTNORM 0x0010
67#define RPROTMASK 0x001C
68
69#define SNDZERO 0x001
70#define SNDPIPE 0x002
71
72#define ANYMARK 0x01
73#define LASTMARK 0x02
74
75#define MUXID_ALL (-1)
76
77#define MSG_HIPRI 0x01
78#define MSG_ANY 0x02
79#define MSG_BAND 0x04
80
81#define MORECTL 1
82#define MOREDATA 2
83
84struct bandinfo {
85 unsigned char bi_pri;
86 int bi_flag;
87};
88
89struct strbuf {
90 int maxlen;
91 int len;
92 char *buf;
93};
94
95struct strpeek {
96 struct strbuf ctlbuf;
97 struct strbuf databuf;
98 unsigned flags;
99};
100
101struct strfdinsert {
102 struct strbuf ctlbuf;
103 struct strbuf databuf;
104 unsigned flags;
105 int fildes;
106 int offset;
107};
108
109struct strioctl {
110 int ic_cmd;
111 int ic_timout;
112 int ic_len;
113 char *ic_dp;
114};
115
116struct strrecvfd {
117 int fd;
118 int uid;
119 int gid;
120 char __fill[8];
121};
122
123struct str_mlist {
124 char l_name[FMNAMESZ + 1];
125};
126
127struct str_list {
128 int sl_nmods;
129 struct str_mlist *sl_modlist;
130};
131
132int isastream(int);
133int ioctl(int, int, ...);
134
135#ifdef __cplusplus
136}
137#endif
138
139#endif
lib/libc/include/wasm-wasi-musl/sys/dir.h created+2
......@@ -0,0 +1,2 @@
1#include <dirent.h>
2#define direct dirent
lib/libc/include/wasm-wasi-musl/sys/errno.h created+2
......@@ -0,0 +1,2 @@
1#warning redirecting incorrect #include <sys/errno.h> to <errno.h>
2#include <errno.h>
lib/libc/include/wasm-wasi-musl/sys/eventfd.h created+26
......@@ -0,0 +1,26 @@
1#ifndef _SYS_EVENTFD_H
2#define _SYS_EVENTFD_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <fcntl.h>
10
11typedef uint64_t eventfd_t;
12
13#define EFD_SEMAPHORE 1
14#define EFD_CLOEXEC O_CLOEXEC
15#define EFD_NONBLOCK O_NONBLOCK
16
17int eventfd(unsigned int, int);
18int eventfd_read(int, eventfd_t *);
19int eventfd_write(int, eventfd_t);
20
21
22#ifdef __cplusplus
23}
24#endif
25
26#endif /* sys/eventfd.h */
lib/libc/include/wasm-wasi-musl/sys/fcntl.h created+2
......@@ -0,0 +1,2 @@
1#warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
2#include <fcntl.h>
lib/libc/include/wasm-wasi-musl/sys/file.h created+21
......@@ -0,0 +1,21 @@
1#ifndef _SYS_FILE_H
2#define _SYS_FILE_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#define LOCK_SH 1
8#define LOCK_EX 2
9#define LOCK_NB 4
10#define LOCK_UN 8
11
12#define L_SET 0
13#define L_INCR 1
14#define L_XTND 2
15
16int flock(int, int);
17
18#ifdef __cplusplus
19}
20#endif
21#endif
lib/libc/include/wasm-wasi-musl/sys/ioctl.h created+124
......@@ -0,0 +1,124 @@
1#ifndef _SYS_IOCTL_H
2#define _SYS_IOCTL_H
3#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_struct_winsize
9
10#include <bits/alltypes.h>
11#include <bits/ioctl.h>
12
13#define N_TTY 0
14#define N_SLIP 1
15#define N_MOUSE 2
16#define N_PPP 3
17#define N_STRIP 4
18#define N_AX25 5
19#define N_X25 6
20#define N_6PACK 7
21#define N_MASC 8
22#define N_R3964 9
23#define N_PROFIBUS_FDL 10
24#define N_IRDA 11
25#define N_SMSBLOCK 12
26#define N_HDLC 13
27#define N_SYNC_PPP 14
28#define N_HCI 15
29#define N_GIGASET_M101 16
30#define N_SLCAN 17
31#define N_PPS 18
32#define N_V253 19
33#define N_CAIF 20
34#define N_GSM0710 21
35#define N_TI_WL 22
36#define N_TRACESINK 23
37#define N_TRACEROUTER 24
38#define N_NCI 25
39#define N_SPEAKUP 26
40#define N_NULL 27
41
42#define TIOCPKT_DATA 0
43#define TIOCPKT_FLUSHREAD 1
44#define TIOCPKT_FLUSHWRITE 2
45#define TIOCPKT_STOP 4
46#define TIOCPKT_START 8
47#define TIOCPKT_NOSTOP 16
48#define TIOCPKT_DOSTOP 32
49#define TIOCPKT_IOCTL 64
50
51#define TIOCSER_TEMT 1
52
53#define SIOCADDRT 0x890B
54#define SIOCDELRT 0x890C
55#define SIOCRTMSG 0x890D
56
57#define SIOCGIFNAME 0x8910
58#define SIOCSIFLINK 0x8911
59#define SIOCGIFCONF 0x8912
60#define SIOCGIFFLAGS 0x8913
61#define SIOCSIFFLAGS 0x8914
62#define SIOCGIFADDR 0x8915
63#define SIOCSIFADDR 0x8916
64#define SIOCGIFDSTADDR 0x8917
65#define SIOCSIFDSTADDR 0x8918
66#define SIOCGIFBRDADDR 0x8919
67#define SIOCSIFBRDADDR 0x891a
68#define SIOCGIFNETMASK 0x891b
69#define SIOCSIFNETMASK 0x891c
70#define SIOCGIFMETRIC 0x891d
71#define SIOCSIFMETRIC 0x891e
72#define SIOCGIFMEM 0x891f
73#define SIOCSIFMEM 0x8920
74#define SIOCGIFMTU 0x8921
75#define SIOCSIFMTU 0x8922
76#define SIOCSIFNAME 0x8923
77#define SIOCSIFHWADDR 0x8924
78#define SIOCGIFENCAP 0x8925
79#define SIOCSIFENCAP 0x8926
80#define SIOCGIFHWADDR 0x8927
81#define SIOCGIFSLAVE 0x8929
82#define SIOCSIFSLAVE 0x8930
83#define SIOCADDMULTI 0x8931
84#define SIOCDELMULTI 0x8932
85#define SIOCGIFINDEX 0x8933
86#define SIOGIFINDEX SIOCGIFINDEX
87#define SIOCSIFPFLAGS 0x8934
88#define SIOCGIFPFLAGS 0x8935
89#define SIOCDIFADDR 0x8936
90#define SIOCSIFHWBROADCAST 0x8937
91#define SIOCGIFCOUNT 0x8938
92
93#define SIOCGIFBR 0x8940
94#define SIOCSIFBR 0x8941
95
96#define SIOCGIFTXQLEN 0x8942
97#define SIOCSIFTXQLEN 0x8943
98
99#define SIOCDARP 0x8953
100#define SIOCGARP 0x8954
101#define SIOCSARP 0x8955
102
103#define SIOCDRARP 0x8960
104#define SIOCGRARP 0x8961
105#define SIOCSRARP 0x8962
106
107#define SIOCGIFMAP 0x8970
108#define SIOCSIFMAP 0x8971
109
110#define SIOCADDDLCI 0x8980
111#define SIOCDELDLCI 0x8981
112
113#define SIOCDEVPRIVATE 0x89F0
114#define SIOCPROTOPRIVATE 0x89E0
115
116int ioctl (int, int, ...);
117
118#ifdef __cplusplus
119}
120#endif
121#else
122#include <__header_sys_ioctl.h>
123#endif
124#endif
lib/libc/include/wasm-wasi-musl/sys/mman.h created+156
......@@ -0,0 +1,156 @@
1#ifndef _WASI_EMULATED_MMAN
2#error "WASI lacks a true mmap; to enable minimal mmap emulation, \
3compile with -D_WASI_EMULATED_MMAN and link with -lwasi-emulated-mman"
4#else
5#ifndef _SYS_MMAN_H
6#define _SYS_MMAN_H
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#include <features.h>
12
13#define __NEED_mode_t
14#define __NEED_size_t
15#define __NEED_off_t
16
17#if defined(_GNU_SOURCE)
18#define __NEED_ssize_t
19#endif
20
21#include <bits/alltypes.h>
22
23#define MAP_FAILED ((void *) -1)
24
25#define MAP_SHARED 0x01
26#define MAP_PRIVATE 0x02
27#define MAP_SHARED_VALIDATE 0x03
28#define MAP_TYPE 0x0f
29#define MAP_FIXED 0x10
30#define MAP_ANON 0x20
31#define MAP_ANONYMOUS MAP_ANON
32#define MAP_NORESERVE 0x4000
33#define MAP_GROWSDOWN 0x0100
34#define MAP_DENYWRITE 0x0800
35#define MAP_EXECUTABLE 0x1000
36#define MAP_LOCKED 0x2000
37#define MAP_POPULATE 0x8000
38#define MAP_NONBLOCK 0x10000
39#define MAP_STACK 0x20000
40#define MAP_HUGETLB 0x40000
41#define MAP_SYNC 0x80000
42#define MAP_FIXED_NOREPLACE 0x100000
43#define MAP_FILE 0
44
45#define MAP_HUGE_SHIFT 26
46#define MAP_HUGE_MASK 0x3f
47#define MAP_HUGE_64KB (16 << 26)
48#define MAP_HUGE_512KB (19 << 26)
49#define MAP_HUGE_1MB (20 << 26)
50#define MAP_HUGE_2MB (21 << 26)
51#define MAP_HUGE_8MB (23 << 26)
52#define MAP_HUGE_16MB (24 << 26)
53#define MAP_HUGE_32MB (25 << 26)
54#define MAP_HUGE_256MB (28 << 26)
55#define MAP_HUGE_512MB (29 << 26)
56#define MAP_HUGE_1GB (30 << 26)
57#define MAP_HUGE_2GB (31 << 26)
58#define MAP_HUGE_16GB (34U << 26)
59
60#define PROT_NONE 0
61#define PROT_READ 1
62#define PROT_WRITE 2
63#define PROT_EXEC 4
64#define PROT_GROWSDOWN 0x01000000
65#define PROT_GROWSUP 0x02000000
66
67#define MS_ASYNC 1
68#define MS_INVALIDATE 2
69#define MS_SYNC 4
70
71#define MCL_CURRENT 1
72#define MCL_FUTURE 2
73#define MCL_ONFAULT 4
74
75#define POSIX_MADV_NORMAL 0
76#define POSIX_MADV_RANDOM 1
77#define POSIX_MADV_SEQUENTIAL 2
78#define POSIX_MADV_WILLNEED 3
79#define POSIX_MADV_DONTNEED 4
80
81#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
82#define MADV_NORMAL 0
83#define MADV_RANDOM 1
84#define MADV_SEQUENTIAL 2
85#define MADV_WILLNEED 3
86#define MADV_DONTNEED 4
87#define MADV_FREE 8
88#define MADV_REMOVE 9
89#define MADV_DONTFORK 10
90#define MADV_DOFORK 11
91#define MADV_MERGEABLE 12
92#define MADV_UNMERGEABLE 13
93#define MADV_HUGEPAGE 14
94#define MADV_NOHUGEPAGE 15
95#define MADV_DONTDUMP 16
96#define MADV_DODUMP 17
97#define MADV_WIPEONFORK 18
98#define MADV_KEEPONFORK 19
99#define MADV_COLD 20
100#define MADV_PAGEOUT 21
101#define MADV_HWPOISON 100
102#define MADV_SOFT_OFFLINE 101
103#endif
104
105#ifdef _GNU_SOURCE
106#define MREMAP_MAYMOVE 1
107#define MREMAP_FIXED 2
108#define MREMAP_DONTUNMAP 4
109
110#define MLOCK_ONFAULT 0x01
111
112#define MFD_CLOEXEC 0x0001U
113#define MFD_ALLOW_SEALING 0x0002U
114#define MFD_HUGETLB 0x0004U
115#endif
116
117#include <bits/mman.h>
118
119void *mmap (void *, size_t, int, int, int, off_t);
120int munmap (void *, size_t);
121
122int mprotect (void *, size_t, int);
123int msync (void *, size_t, int);
124
125int posix_madvise (void *, size_t, int);
126
127int mlock (const void *, size_t);
128int munlock (const void *, size_t);
129int mlockall (int);
130int munlockall (void);
131
132#ifdef _GNU_SOURCE
133void *mremap (void *, size_t, size_t, int, ...);
134int remap_file_pages (void *, size_t, int, size_t, int);
135int memfd_create (const char *, unsigned);
136int mlock2 (const void *, size_t, unsigned);
137#endif
138
139#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
140int madvise (void *, size_t, int);
141int mincore (void *, size_t, unsigned char *);
142#endif
143
144int shm_open (const char *, int, mode_t);
145int shm_unlink (const char *);
146
147#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
148#define mmap64 mmap
149#define off64_t off_t
150#endif
151
152#ifdef __cplusplus
153}
154#endif
155#endif
156#endif
lib/libc/include/wasm-wasi-musl/sys/param.h created+37
......@@ -0,0 +1,37 @@
1#ifndef _SYS_PARAM_H
2#define _SYS_PARAM_H
3
4#define MAXSYMLINKS 20
5#define MAXHOSTNAMELEN 64
6#define MAXNAMLEN 255
7#define MAXPATHLEN 4096
8#define NBBY 8
9#define NGROUPS 32
10#define CANBSIZ 255
11#define NOFILE 256
12#define NCARGS 131072
13#define DEV_BSIZE 512
14#define NOGROUP (-1)
15
16#undef MIN
17#undef MAX
18#define MIN(a,b) (((a)<(b))?(a):(b))
19#define MAX(a,b) (((a)>(b))?(a):(b))
20
21#define __bitop(x,i,o) ((x)[(i)/8] o (1<<(i)%8))
22#define setbit(x,i) __bitop(x,i,|=)
23#define clrbit(x,i) __bitop(x,i,&=~)
24#define isset(x,i) __bitop(x,i,&)
25#define isclr(x,i) !isset(x,i)
26
27#define howmany(n,d) (((n)+((d)-1))/(d))
28#define roundup(n,d) (howmany(n,d)*(d))
29#define powerof2(n) !(((n)-1) & (n))
30
31#if defined(__wasilibc_unmodified_upstream) || defined(_WASI_EMULATED_PROCESS_CLOCKS)
32#include <sys/resource.h>
33#endif
34#include <endian.h>
35#include <limits.h>
36
37#endif
lib/libc/include/wasm-wasi-musl/sys/poll.h created+2
......@@ -0,0 +1,2 @@
1#warning redirecting incorrect #include <sys/poll.h> to <poll.h>
2#include <poll.h>
lib/libc/include/wasm-wasi-musl/sys/random.h created+27
......@@ -0,0 +1,27 @@
1#ifndef _SYS_RANDOM_H
2#define _SYS_RANDOM_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#ifdef __wasilibc_unmodified_upstream /* WASI has no getrandom, but it does have getentropy */
8#define __NEED_size_t
9#define __NEED_ssize_t
10#include <bits/alltypes.h>
11
12#define GRND_NONBLOCK 0x0001
13#define GRND_RANDOM 0x0002
14#define GRND_INSECURE 0x0004
15
16ssize_t getrandom(void *, size_t, unsigned);
17#else
18#define __NEED_size_t
19#include <bits/alltypes.h>
20
21int getentropy(void *, size_t);
22#endif
23
24#ifdef __cplusplus
25}
26#endif
27#endif
lib/libc/include/wasm-wasi-musl/sys/reg.h created+9
......@@ -0,0 +1,9 @@
1#ifndef _SYS_REG_H
2#define _SYS_REG_H
3
4#include <limits.h>
5#include <unistd.h>
6
7#include <bits/reg.h>
8
9#endif
lib/libc/include/wasm-wasi-musl/sys/resource.h created+126
......@@ -0,0 +1,126 @@
1#ifndef _WASI_EMULATED_PROCESS_CLOCKS
2#error WASI lacks process-associated clocks; to enable emulation of the `getrusage` function using \
3the wall clock, which isn't sensitive to whether the program is running or suspended, \
4compile with -D_WASI_EMULATED_PROCESS_CLOCKS and link with -lwasi-emulated-process-clocks
5#else
6#ifndef _SYS_RESOURCE_H
7#define _SYS_RESOURCE_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#include <features.h>
14#include <sys/time.h>
15
16#define __NEED_id_t
17
18#ifdef _GNU_SOURCE
19#define __NEED_pid_t
20#endif
21
22#include <bits/alltypes.h>
23#include <bits/resource.h>
24
25#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
26typedef unsigned long long rlim_t;
27
28struct rlimit {
29 rlim_t rlim_cur;
30 rlim_t rlim_max;
31};
32
33struct rusage {
34 struct timeval ru_utime;
35 struct timeval ru_stime;
36 /* linux extentions, but useful */
37 long ru_maxrss;
38 long ru_ixrss;
39 long ru_idrss;
40 long ru_isrss;
41 long ru_minflt;
42 long ru_majflt;
43 long ru_nswap;
44 long ru_inblock;
45 long ru_oublock;
46 long ru_msgsnd;
47 long ru_msgrcv;
48 long ru_nsignals;
49 long ru_nvcsw;
50 long ru_nivcsw;
51 /* room for more... */
52 long __reserved[16];
53};
54
55int getrlimit (int, struct rlimit *);
56int setrlimit (int, const struct rlimit *);
57int getrusage (int, struct rusage *);
58
59int getpriority (int, id_t);
60int setpriority (int, id_t, int);
61
62#ifdef _GNU_SOURCE
63int prlimit(pid_t, int, const struct rlimit *, struct rlimit *);
64#define prlimit64 prlimit
65#endif
66
67#define PRIO_MIN (-20)
68#define PRIO_MAX 20
69
70#define PRIO_PROCESS 0
71#define PRIO_PGRP 1
72#define PRIO_USER 2
73
74#define RUSAGE_SELF 0
75#define RUSAGE_CHILDREN (-1)
76#define RUSAGE_THREAD 1
77
78#define RLIM_INFINITY (~0ULL)
79#define RLIM_SAVED_CUR RLIM_INFINITY
80#define RLIM_SAVED_MAX RLIM_INFINITY
81
82#define RLIMIT_CPU 0
83#define RLIMIT_FSIZE 1
84#define RLIMIT_DATA 2
85#define RLIMIT_STACK 3
86#define RLIMIT_CORE 4
87#ifndef RLIMIT_RSS
88#define RLIMIT_RSS 5
89#define RLIMIT_NPROC 6
90#define RLIMIT_NOFILE 7
91#define RLIMIT_MEMLOCK 8
92#define RLIMIT_AS 9
93#endif
94#define RLIMIT_LOCKS 10
95#define RLIMIT_SIGPENDING 11
96#define RLIMIT_MSGQUEUE 12
97#define RLIMIT_NICE 13
98#define RLIMIT_RTPRIO 14
99#define RLIMIT_RTTIME 15
100#define RLIMIT_NLIMITS 16
101
102#define RLIM_NLIMITS RLIMIT_NLIMITS
103
104#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
105#define RLIM64_INFINITY RLIM_INFINITY
106#define RLIM64_SAVED_CUR RLIM_SAVED_CUR
107#define RLIM64_SAVED_MAX RLIM_SAVED_MAX
108#define getrlimit64 getrlimit
109#define setrlimit64 setrlimit
110#define rlimit64 rlimit
111#define rlim64_t rlim_t
112#endif
113#else
114#include <__header_sys_resource.h>
115#endif
116
117#if _REDIR_TIME64
118__REDIR(getrusage, __getrusage_time64);
119#endif
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif
126#endif
lib/libc/include/wasm-wasi-musl/sys/select.h created+54
......@@ -0,0 +1,54 @@
1#ifndef _SYS_SELECT_H
2#define _SYS_SELECT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_size_t
10#define __NEED_time_t
11#define __NEED_suseconds_t
12#define __NEED_struct_timeval
13#define __NEED_struct_timespec
14#define __NEED_sigset_t
15
16#include <bits/alltypes.h>
17
18#define FD_SETSIZE 1024
19
20#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
21typedef unsigned long fd_mask;
22#endif
23
24#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
25typedef struct {
26 unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)];
27} fd_set;
28
29#define FD_ZERO(s) do { int __i; unsigned long *__b=(s)->fds_bits; for(__i=sizeof (fd_set)/sizeof (long); __i; __i--) *__b++=0; } while(0)
30#define FD_SET(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1UL<<((d)%(8*sizeof(long)))))
31#define FD_CLR(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1UL<<((d)%(8*sizeof(long)))))
32#define FD_ISSET(d, s) !!((s)->fds_bits[(d)/(8*sizeof(long))] & (1UL<<((d)%(8*sizeof(long)))))
33#else
34#include <__fd_set.h>
35#endif
36
37int select (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict);
38int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
39
40#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
41#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
42#define NFDBITS (8*(int)sizeof(long))
43#endif
44#endif
45
46#if _REDIR_TIME64
47__REDIR(select, __select_time64);
48__REDIR(pselect, __pselect_time64);
49#endif
50
51#ifdef __cplusplus
52}
53#endif
54#endif
lib/libc/include/wasm-wasi-musl/sys/signal.h created+2
......@@ -0,0 +1,2 @@
1#warning redirecting incorrect #include <sys/signal.h> to <signal.h>
2#include <signal.h>
lib/libc/include/wasm-wasi-musl/sys/socket.h created+445
......@@ -0,0 +1,445 @@
1#ifndef _SYS_SOCKET_H
2#define _SYS_SOCKET_H
3#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
4#else
5#include <__header_sys_socket.h>
6#endif
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#include <features.h>
12
13#define __NEED_socklen_t
14#define __NEED_sa_family_t
15#define __NEED_size_t
16#define __NEED_ssize_t
17#define __NEED_uid_t
18#define __NEED_pid_t
19#define __NEED_gid_t
20#define __NEED_struct_iovec
21
22#include <bits/alltypes.h>
23
24#include <bits/socket.h>
25
26#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
27struct msghdr {
28 void *msg_name;
29 socklen_t msg_namelen;
30 struct iovec *msg_iov;
31#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN
32 int __pad1;
33#endif
34 int msg_iovlen;
35#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN
36 int __pad1;
37#endif
38 void *msg_control;
39#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN
40 int __pad2;
41#endif
42 socklen_t msg_controllen;
43#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN
44 int __pad2;
45#endif
46 int msg_flags;
47};
48
49struct cmsghdr {
50#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN
51 int __pad1;
52#endif
53 socklen_t cmsg_len;
54#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN
55 int __pad1;
56#endif
57 int cmsg_level;
58 int cmsg_type;
59};
60#else
61#include <__struct_msghdr.h>
62#endif
63
64#ifdef _GNU_SOURCE
65struct ucred {
66 pid_t pid;
67 uid_t uid;
68 gid_t gid;
69};
70
71struct mmsghdr {
72 struct msghdr msg_hdr;
73 unsigned int msg_len;
74};
75
76struct timespec;
77
78int sendmmsg (int, struct mmsghdr *, unsigned int, unsigned int);
79int recvmmsg (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *);
80#endif
81
82struct linger {
83 int l_onoff;
84 int l_linger;
85};
86
87#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
88#define SHUT_RD 0
89#define SHUT_WR 1
90#define SHUT_RDWR 2
91
92#ifndef SOCK_STREAM
93#define SOCK_STREAM 1
94#define SOCK_DGRAM 2
95#endif
96
97#define SOCK_RAW 3
98#define SOCK_RDM 4
99#define SOCK_SEQPACKET 5
100#define SOCK_DCCP 6
101#define SOCK_PACKET 10
102
103#ifndef SOCK_CLOEXEC
104#define SOCK_CLOEXEC 02000000
105#define SOCK_NONBLOCK 04000
106#endif
107
108#define PF_UNSPEC 0
109#define PF_LOCAL 1
110#define PF_UNIX PF_LOCAL
111#define PF_FILE PF_LOCAL
112#define PF_INET 2
113#define PF_AX25 3
114#define PF_IPX 4
115#define PF_APPLETALK 5
116#define PF_NETROM 6
117#define PF_BRIDGE 7
118#define PF_ATMPVC 8
119#define PF_X25 9
120#define PF_INET6 10
121#define PF_ROSE 11
122#define PF_DECnet 12
123#define PF_NETBEUI 13
124#define PF_SECURITY 14
125#define PF_KEY 15
126#define PF_NETLINK 16
127#define PF_ROUTE PF_NETLINK
128#define PF_PACKET 17
129#define PF_ASH 18
130#define PF_ECONET 19
131#define PF_ATMSVC 20
132#define PF_RDS 21
133#define PF_SNA 22
134#define PF_IRDA 23
135#define PF_PPPOX 24
136#define PF_WANPIPE 25
137#define PF_LLC 26
138#define PF_IB 27
139#define PF_MPLS 28
140#define PF_CAN 29
141#define PF_TIPC 30
142#define PF_BLUETOOTH 31
143#define PF_IUCV 32
144#define PF_RXRPC 33
145#define PF_ISDN 34
146#define PF_PHONET 35
147#define PF_IEEE802154 36
148#define PF_CAIF 37
149#define PF_ALG 38
150#define PF_NFC 39
151#define PF_VSOCK 40
152#define PF_KCM 41
153#define PF_QIPCRTR 42
154#define PF_SMC 43
155#define PF_XDP 44
156#define PF_MAX 45
157
158#define AF_UNSPEC PF_UNSPEC
159#define AF_LOCAL PF_LOCAL
160#define AF_UNIX AF_LOCAL
161#define AF_FILE AF_LOCAL
162#define AF_INET PF_INET
163#define AF_AX25 PF_AX25
164#define AF_IPX PF_IPX
165#define AF_APPLETALK PF_APPLETALK
166#define AF_NETROM PF_NETROM
167#define AF_BRIDGE PF_BRIDGE
168#define AF_ATMPVC PF_ATMPVC
169#define AF_X25 PF_X25
170#define AF_INET6 PF_INET6
171#define AF_ROSE PF_ROSE
172#define AF_DECnet PF_DECnet
173#define AF_NETBEUI PF_NETBEUI
174#define AF_SECURITY PF_SECURITY
175#define AF_KEY PF_KEY
176#define AF_NETLINK PF_NETLINK
177#define AF_ROUTE PF_ROUTE
178#define AF_PACKET PF_PACKET
179#define AF_ASH PF_ASH
180#define AF_ECONET PF_ECONET
181#define AF_ATMSVC PF_ATMSVC
182#define AF_RDS PF_RDS
183#define AF_SNA PF_SNA
184#define AF_IRDA PF_IRDA
185#define AF_PPPOX PF_PPPOX
186#define AF_WANPIPE PF_WANPIPE
187#define AF_LLC PF_LLC
188#define AF_IB PF_IB
189#define AF_MPLS PF_MPLS
190#define AF_CAN PF_CAN
191#define AF_TIPC PF_TIPC
192#define AF_BLUETOOTH PF_BLUETOOTH
193#define AF_IUCV PF_IUCV
194#define AF_RXRPC PF_RXRPC
195#define AF_ISDN PF_ISDN
196#define AF_PHONET PF_PHONET
197#define AF_IEEE802154 PF_IEEE802154
198#define AF_CAIF PF_CAIF
199#define AF_ALG PF_ALG
200#define AF_NFC PF_NFC
201#define AF_VSOCK PF_VSOCK
202#define AF_KCM PF_KCM
203#define AF_QIPCRTR PF_QIPCRTR
204#define AF_SMC PF_SMC
205#define AF_XDP PF_XDP
206#define AF_MAX PF_MAX
207
208#ifndef SO_DEBUG
209#define SO_DEBUG 1
210#define SO_REUSEADDR 2
211#define SO_TYPE 3
212#define SO_ERROR 4
213#define SO_DONTROUTE 5
214#define SO_BROADCAST 6
215#define SO_SNDBUF 7
216#define SO_RCVBUF 8
217#define SO_KEEPALIVE 9
218#define SO_OOBINLINE 10
219#define SO_NO_CHECK 11
220#define SO_PRIORITY 12
221#define SO_LINGER 13
222#define SO_BSDCOMPAT 14
223#define SO_REUSEPORT 15
224#define SO_PASSCRED 16
225#define SO_PEERCRED 17
226#define SO_RCVLOWAT 18
227#define SO_SNDLOWAT 19
228#define SO_ACCEPTCONN 30
229#define SO_PEERSEC 31
230#define SO_SNDBUFFORCE 32
231#define SO_RCVBUFFORCE 33
232#define SO_PROTOCOL 38
233#define SO_DOMAIN 39
234#endif
235
236#ifndef SO_RCVTIMEO
237#if __LONG_MAX == 0x7fffffff
238#define SO_RCVTIMEO 66
239#define SO_SNDTIMEO 67
240#else
241#define SO_RCVTIMEO 20
242#define SO_SNDTIMEO 21
243#endif
244#endif
245
246#ifndef SO_TIMESTAMP
247#if __LONG_MAX == 0x7fffffff
248#define SO_TIMESTAMP 63
249#define SO_TIMESTAMPNS 64
250#define SO_TIMESTAMPING 65
251#else
252#define SO_TIMESTAMP 29
253#define SO_TIMESTAMPNS 35
254#define SO_TIMESTAMPING 37
255#endif
256#endif
257
258#define SO_SECURITY_AUTHENTICATION 22
259#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
260#define SO_SECURITY_ENCRYPTION_NETWORK 24
261
262#define SO_BINDTODEVICE 25
263
264#define SO_ATTACH_FILTER 26
265#define SO_DETACH_FILTER 27
266#define SO_GET_FILTER SO_ATTACH_FILTER
267
268#define SO_PEERNAME 28
269#define SCM_TIMESTAMP SO_TIMESTAMP
270#define SO_PASSSEC 34
271#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
272#define SO_MARK 36
273#define SCM_TIMESTAMPING SO_TIMESTAMPING
274#define SO_RXQ_OVFL 40
275#define SO_WIFI_STATUS 41
276#define SCM_WIFI_STATUS SO_WIFI_STATUS
277#define SO_PEEK_OFF 42
278#define SO_NOFCS 43
279#define SO_LOCK_FILTER 44
280#define SO_SELECT_ERR_QUEUE 45
281#define SO_BUSY_POLL 46
282#define SO_MAX_PACING_RATE 47
283#define SO_BPF_EXTENSIONS 48
284#define SO_INCOMING_CPU 49
285#define SO_ATTACH_BPF 50
286#define SO_DETACH_BPF SO_DETACH_FILTER
287#define SO_ATTACH_REUSEPORT_CBPF 51
288#define SO_ATTACH_REUSEPORT_EBPF 52
289#define SO_CNX_ADVICE 53
290#define SCM_TIMESTAMPING_OPT_STATS 54
291#define SO_MEMINFO 55
292#define SO_INCOMING_NAPI_ID 56
293#define SO_COOKIE 57
294#define SCM_TIMESTAMPING_PKTINFO 58
295#define SO_PEERGROUPS 59
296#define SO_ZEROCOPY 60
297#define SO_TXTIME 61
298#define SCM_TXTIME SO_TXTIME
299#define SO_BINDTOIFINDEX 62
300#define SO_DETACH_REUSEPORT_BPF 68
301
302#ifndef SOL_SOCKET
303#define SOL_SOCKET 1
304#endif
305
306#define SOL_IP 0
307#define SOL_IPV6 41
308#define SOL_ICMPV6 58
309
310#define SOL_RAW 255
311#define SOL_DECNET 261
312#define SOL_X25 262
313#define SOL_PACKET 263
314#define SOL_ATM 264
315#define SOL_AAL 265
316#define SOL_IRDA 266
317#define SOL_NETBEUI 267
318#define SOL_LLC 268
319#define SOL_DCCP 269
320#define SOL_NETLINK 270
321#define SOL_TIPC 271
322#define SOL_RXRPC 272
323#define SOL_PPPOL2TP 273
324#define SOL_BLUETOOTH 274
325#define SOL_PNPIPE 275
326#define SOL_RDS 276
327#define SOL_IUCV 277
328#define SOL_CAIF 278
329#define SOL_ALG 279
330#define SOL_NFC 280
331#define SOL_KCM 281
332#define SOL_TLS 282
333#define SOL_XDP 283
334
335#define SOMAXCONN 128
336
337#define MSG_OOB 0x0001
338#define MSG_PEEK 0x0002
339#define MSG_DONTROUTE 0x0004
340#define MSG_CTRUNC 0x0008
341#define MSG_PROXY 0x0010
342#define MSG_TRUNC 0x0020
343#define MSG_DONTWAIT 0x0040
344#define MSG_EOR 0x0080
345#define MSG_WAITALL 0x0100
346#define MSG_FIN 0x0200
347#define MSG_SYN 0x0400
348#define MSG_CONFIRM 0x0800
349#define MSG_RST 0x1000
350#define MSG_ERRQUEUE 0x2000
351#define MSG_NOSIGNAL 0x4000
352#define MSG_MORE 0x8000
353#define MSG_WAITFORONE 0x10000
354#define MSG_BATCH 0x40000
355#define MSG_ZEROCOPY 0x4000000
356#define MSG_FASTOPEN 0x20000000
357#define MSG_CMSG_CLOEXEC 0x40000000
358
359#define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
360#define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg))
361#define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen)
362
363#define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1))
364#define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) || \
365 __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
366 ? 0 : (struct cmsghdr *)__CMSG_NEXT(cmsg))
367#define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
368
369#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))
370#define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
371#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
372
373#define SCM_RIGHTS 0x01
374#define SCM_CREDENTIALS 0x02
375#endif
376
377#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
378struct sockaddr {
379 sa_family_t sa_family;
380 char sa_data[14];
381};
382#else
383#include <__struct_sockaddr.h>
384#endif
385
386#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
387struct sockaddr_storage {
388 sa_family_t ss_family;
389 char __ss_padding[128-sizeof(long)-sizeof(sa_family_t)];
390 unsigned long __ss_align;
391};
392#else
393#include <__struct_sockaddr_storage.h>
394#endif
395
396#ifdef __wasilibc_unmodified_upstream /* WASI has no socket/socketpair */
397int socket (int, int, int);
398int socketpair (int, int, int, int [2]);
399#endif
400
401int shutdown (int, int);
402
403#ifdef __wasilibc_unmodified_upstream /* WASI has no bind/connect/listen/accept */
404int bind (int, const struct sockaddr *, socklen_t);
405int connect (int, const struct sockaddr *, socklen_t);
406int listen (int, int);
407int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
408int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int);
409#endif
410
411#ifdef __wasilibc_unmodified_upstream /* WASI has no getsockname/getpeername */
412int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
413int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict);
414#endif
415
416ssize_t send (int, const void *, size_t, int);
417ssize_t recv (int, void *, size_t, int);
418#ifdef __wasilibc_unmodified_upstream /* WASI has no sendto/recvfrom */
419ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
420ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
421#endif
422#ifdef __wasilibc_unmodified_upstream /* WASI has no sendmsg/recvmsg */
423ssize_t sendmsg (int, const struct msghdr *, int);
424ssize_t recvmsg (int, struct msghdr *, int);
425#endif
426
427int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict);
428#ifdef __wasilibc_unmodified_upstream /* WASI has no setsockopt */
429int setsockopt (int, int, int, const void *, socklen_t);
430#endif
431
432#ifdef __wasilibc_unmodified_upstream /* WASI has no sockatmark */
433int sockatmark (int);
434#endif
435
436#if _REDIR_TIME64
437#ifdef _GNU_SOURCE
438__REDIR(recvmmsg, __recvmmsg_time64);
439#endif
440#endif
441
442#ifdef __cplusplus
443}
444#endif
445#endif
lib/libc/include/wasm-wasi-musl/sys/stat.h created+143
......@@ -0,0 +1,143 @@
1#ifndef _SYS_STAT_H
2#define _SYS_STAT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_dev_t
10#define __NEED_ino_t
11#define __NEED_mode_t
12#define __NEED_nlink_t
13#define __NEED_uid_t
14#define __NEED_gid_t
15#define __NEED_off_t
16#define __NEED_time_t
17#define __NEED_blksize_t
18#define __NEED_blkcnt_t
19#define __NEED_struct_timespec
20
21#include <bits/alltypes.h>
22
23#include <bits/stat.h>
24
25#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
26#define st_atime st_atim.tv_sec
27#define st_mtime st_mtim.tv_sec
28#define st_ctime st_ctim.tv_sec
29
30#define S_IFMT 0170000
31
32#define S_IFDIR 0040000
33#define S_IFCHR 0020000
34#define S_IFBLK 0060000
35#define S_IFREG 0100000
36#define S_IFIFO 0010000
37#define S_IFLNK 0120000
38#define S_IFSOCK 0140000
39
40#define S_TYPEISMQ(buf) 0
41#define S_TYPEISSEM(buf) 0
42#define S_TYPEISSHM(buf) 0
43#define S_TYPEISTMO(buf) 0
44
45#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
46#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
47#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
48#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
49#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
50#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
51#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
52
53#ifndef S_IRUSR
54#define S_ISUID 04000
55#define S_ISGID 02000
56#define S_ISVTX 01000
57#define S_IRUSR 0400
58#define S_IWUSR 0200
59#define S_IXUSR 0100
60#define S_IRWXU 0700
61#define S_IRGRP 0040
62#define S_IWGRP 0020
63#define S_IXGRP 0010
64#define S_IRWXG 0070
65#define S_IROTH 0004
66#define S_IWOTH 0002
67#define S_IXOTH 0001
68#define S_IRWXO 0007
69#endif
70
71#define UTIME_NOW 0x3fffffff
72#define UTIME_OMIT 0x3ffffffe
73#else
74#include <__header_sys_stat.h>
75#endif
76
77int stat(const char *__restrict, struct stat *__restrict);
78int fstat(int, struct stat *);
79int lstat(const char *__restrict, struct stat *__restrict);
80int fstatat(int, const char *__restrict, struct stat *__restrict, int);
81#ifdef __wasilibc_unmodified_upstream /* WASI has no chmod */
82int chmod(const char *, mode_t);
83int fchmod(int, mode_t);
84int fchmodat(int, const char *, mode_t, int);
85#endif
86#ifdef __wasilibc_unmodified_upstream /* WASI has no umask */
87mode_t umask(mode_t);
88#endif
89int mkdir(const char *, mode_t);
90#ifdef __wasilibc_unmodified_upstream /* WASI has no fifo */
91int mkfifo(const char *, mode_t);
92#endif
93int mkdirat(int, const char *, mode_t);
94#ifdef __wasilibc_unmodified_upstream /* WASI has no fifo */
95int mkfifoat(int, const char *, mode_t);
96#endif
97
98#ifdef __wasilibc_unmodified_upstream /* WASI has no mknod */
99#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
100int mknod(const char *, mode_t, dev_t);
101int mknodat(int, const char *, mode_t, dev_t);
102#endif
103#endif
104
105int futimens(int, const struct timespec [2]);
106int utimensat(int, const char *, const struct timespec [2], int);
107
108#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
109#ifdef __wasilibc_unmodified_upstream /* WASI has no chmod */
110int lchmod(const char *, mode_t);
111#endif
112#define S_IREAD S_IRUSR
113#define S_IWRITE S_IWUSR
114#define S_IEXEC S_IXUSR
115#endif
116
117#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
118#define stat64 stat
119#define fstat64 fstat
120#define lstat64 lstat
121#define fstatat64 fstatat
122#define blkcnt64_t blkcnt_t
123#define fsblkcnt64_t fsblkcnt_t
124#define fsfilcnt64_t fsfilcnt_t
125#define ino64_t ino_t
126#define off64_t off_t
127#endif
128
129#if _REDIR_TIME64
130__REDIR(stat, __stat_time64);
131__REDIR(fstat, __fstat_time64);
132__REDIR(lstat, __lstat_time64);
133__REDIR(fstatat, __fstatat_time64);
134__REDIR(futimens, __futimens_time64);
135__REDIR(utimensat, __utimensat_time64);
136#endif
137
138#ifdef __cplusplus
139}
140#endif
141#endif
142
143
lib/libc/include/wasm-wasi-musl/sys/stropts.h created+1
......@@ -0,0 +1 @@
1#include <stropts.h>
lib/libc/include/wasm-wasi-musl/sys/syscall.h created+10
......@@ -0,0 +1,10 @@
1#ifndef _SYS_SYSCALL_H
2#define _SYS_SYSCALL_H
3
4#ifdef __wasilibc_unmodified_upstream /* WASI has no syscall */
5#include <bits/syscall.h>
6#else
7/* The generic syscall funtion is not yet implemented. */
8#endif
9
10#endif
lib/libc/include/wasm-wasi-musl/sys/sysinfo.h created+36
......@@ -0,0 +1,36 @@
1#ifndef _SYS_SYSINFO_H
2#define _SYS_SYSINFO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define SI_LOAD_SHIFT 16
9
10struct sysinfo {
11 unsigned long uptime;
12 unsigned long loads[3];
13 unsigned long totalram;
14 unsigned long freeram;
15 unsigned long sharedram;
16 unsigned long bufferram;
17 unsigned long totalswap;
18 unsigned long freeswap;
19 unsigned short procs, pad;
20 unsigned long totalhigh;
21 unsigned long freehigh;
22 unsigned mem_unit;
23 char __reserved[256];
24};
25
26int sysinfo (struct sysinfo *);
27int get_nprocs_conf (void);
28int get_nprocs (void);
29long get_phys_pages (void);
30long get_avphys_pages (void);
31
32#ifdef __cplusplus
33}
34#endif
35
36#endif
lib/libc/include/wasm-wasi-musl/sys/time.h created+84
......@@ -0,0 +1,84 @@
1#ifndef _SYS_TIME_H
2#define _SYS_TIME_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#include <sys/select.h>
10
11int gettimeofday (struct timeval *__restrict, void *__restrict);
12
13#ifdef __wasilibc_unmodified_upstream /* WASI has no getitimer */
14#define ITIMER_REAL 0
15#define ITIMER_VIRTUAL 1
16#define ITIMER_PROF 2
17
18struct itimerval {
19 struct timeval it_interval;
20 struct timeval it_value;
21};
22
23int getitimer (int, struct itimerval *);
24int setitimer (int, const struct itimerval *__restrict, struct itimerval *__restrict);
25#endif
26#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
27int utimes (const char *, const struct timeval [2]);
28#endif
29
30#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
31struct timezone {
32 int tz_minuteswest;
33 int tz_dsttime;
34};
35#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
36int futimes(int, const struct timeval [2]);
37int futimesat(int, const char *, const struct timeval [2]);
38int lutimes(const char *, const struct timeval [2]);
39#endif
40#ifdef __wasilibc_unmodified_upstream /* WASI has no way to set the time */
41int settimeofday(const struct timeval *, const struct timezone *);
42int adjtime (const struct timeval *, struct timeval *);
43#endif
44#define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
45#define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
46#define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \
47 (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec)
48#define timeradd(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
49 ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
50 ((a)->tv_usec -= 1000000, (a)->tv_sec++) )
51#define timersub(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
52 ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
53 ((a)->tv_usec += 1000000, (a)->tv_sec--) )
54#endif
55
56#if defined(_GNU_SOURCE)
57#define TIMEVAL_TO_TIMESPEC(tv, ts) ( \
58 (ts)->tv_sec = (tv)->tv_sec, \
59 (ts)->tv_nsec = (tv)->tv_usec * 1000, \
60 (void)0 )
61#define TIMESPEC_TO_TIMEVAL(tv, ts) ( \
62 (tv)->tv_sec = (ts)->tv_sec, \
63 (tv)->tv_usec = (ts)->tv_nsec / 1000, \
64 (void)0 )
65#endif
66
67#if _REDIR_TIME64
68__REDIR(gettimeofday, __gettimeofday_time64);
69__REDIR(getitimer, __getitimer_time64);
70__REDIR(setitimer, __setitimer_time64);
71__REDIR(utimes, __utimes_time64);
72#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
73__REDIR(futimes, __futimes_time64);
74__REDIR(futimesat, __futimesat_time64);
75__REDIR(lutimes, __lutimes_time64);
76__REDIR(settimeofday, __settimeofday_time64);
77__REDIR(adjtime, __adjtime64);
78#endif
79#endif
80
81#ifdef __cplusplus
82}
83#endif
84#endif
lib/libc/include/wasm-wasi-musl/sys/timeb.h created+28
......@@ -0,0 +1,28 @@
1#ifndef _SYS_TIMEB_H
2#define _SYS_TIMEB_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_time_t
10
11#include <bits/alltypes.h>
12
13struct timeb {
14 time_t time;
15 unsigned short millitm;
16 short timezone, dstflag;
17};
18
19int ftime(struct timeb *);
20
21#if _REDIR_TIME64
22__REDIR(ftime, __ftime64);
23#endif
24
25#ifdef __cplusplus
26}
27#endif
28#endif
lib/libc/include/wasm-wasi-musl/sys/times.h created+34
......@@ -0,0 +1,34 @@
1#ifndef _WASI_EMULATED_PROCESS_CLOCKS
2#error WASI lacks process-associated clocks; to enable emulation of the `times` function using \
3the wall clock, which isn't sensitive to whether the program is running or suspended, \
4compile with -D_WASI_EMULATED_PROCESS_CLOCKS and link with -lwasi-emulated-process-clocks
5#else
6#ifndef _SYS_TIMES_H
7#define _SYS_TIMES_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#define __NEED_clock_t
14#include <bits/alltypes.h>
15
16#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
17struct tms {
18 clock_t tms_utime;
19 clock_t tms_stime;
20 clock_t tms_cutime;
21 clock_t tms_cstime;
22};
23#else
24#include <__struct_tms.h>
25#endif
26
27clock_t times (struct tms *);
28
29#ifdef __cplusplus
30}
31#endif
32
33#endif
34#endif
lib/libc/include/wasm-wasi-musl/sys/timex.h created+103
......@@ -0,0 +1,103 @@
1#ifndef _SYS_TIMEX_H
2#define _SYS_TIMEX_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_clockid_t
9
10#include <bits/alltypes.h>
11
12#include <sys/time.h>
13
14struct ntptimeval {
15 struct timeval time;
16 long maxerror, esterror;
17};
18
19struct timex {
20 unsigned modes;
21 long offset, freq, maxerror, esterror;
22 int status;
23 long constant, precision, tolerance;
24 struct timeval time;
25 long tick, ppsfreq, jitter;
26 int shift;
27 long stabil, jitcnt, calcnt, errcnt, stbcnt;
28 int tai;
29 int __padding[11];
30};
31
32#define ADJ_OFFSET 0x0001
33#define ADJ_FREQUENCY 0x0002
34#define ADJ_MAXERROR 0x0004
35#define ADJ_ESTERROR 0x0008
36#define ADJ_STATUS 0x0010
37#define ADJ_TIMECONST 0x0020
38#define ADJ_TAI 0x0080
39#define ADJ_SETOFFSET 0x0100
40#define ADJ_MICRO 0x1000
41#define ADJ_NANO 0x2000
42#define ADJ_TICK 0x4000
43#define ADJ_OFFSET_SINGLESHOT 0x8001
44#define ADJ_OFFSET_SS_READ 0xa001
45
46#define MOD_OFFSET ADJ_OFFSET
47#define MOD_FREQUENCY ADJ_FREQUENCY
48#define MOD_MAXERROR ADJ_MAXERROR
49#define MOD_ESTERROR ADJ_ESTERROR
50#define MOD_STATUS ADJ_STATUS
51#define MOD_TIMECONST ADJ_TIMECONST
52#define MOD_CLKB ADJ_TICK
53#define MOD_CLKA ADJ_OFFSET_SINGLESHOT
54#define MOD_TAI ADJ_TAI
55#define MOD_MICRO ADJ_MICRO
56#define MOD_NANO ADJ_NANO
57
58#define STA_PLL 0x0001
59#define STA_PPSFREQ 0x0002
60#define STA_PPSTIME 0x0004
61#define STA_FLL 0x0008
62
63#define STA_INS 0x0010
64#define STA_DEL 0x0020
65#define STA_UNSYNC 0x0040
66#define STA_FREQHOLD 0x0080
67
68#define STA_PPSSIGNAL 0x0100
69#define STA_PPSJITTER 0x0200
70#define STA_PPSWANDER 0x0400
71#define STA_PPSERROR 0x0800
72
73#define STA_CLOCKERR 0x1000
74#define STA_NANO 0x2000
75#define STA_MODE 0x4000
76#define STA_CLK 0x8000
77
78#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
79 STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
80
81#define TIME_OK 0
82#define TIME_INS 1
83#define TIME_DEL 2
84#define TIME_OOP 3
85#define TIME_WAIT 4
86#define TIME_ERROR 5
87#define TIME_BAD TIME_ERROR
88
89#define MAXTC 6
90
91int adjtimex(struct timex *);
92int clock_adjtime(clockid_t, struct timex *);
93
94#if _REDIR_TIME64
95__REDIR(adjtimex, __adjtimex_time64);
96__REDIR(clock_adjtime, __clock_adjtime64);
97#endif
98
99#ifdef __cplusplus
100}
101#endif
102
103#endif
lib/libc/include/wasm-wasi-musl/sys/ttydefaults.h created+34
......@@ -0,0 +1,34 @@
1#ifndef _SYS_TTYDEFAULTS_H
2#define _SYS_TTYDEFAULTS_H
3
4#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
5#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
6#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
7#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL)
8#define TTYDEF_SPEED (B9600)
9#define CTRL(x) ((x)&037)
10#define CEOF CTRL('d')
11
12#define CEOL '\0'
13#define CSTATUS '\0'
14
15#define CERASE 0177
16#define CINTR CTRL('c')
17#define CKILL CTRL('u')
18#define CMIN 1
19#define CQUIT 034
20#define CSUSP CTRL('z')
21#define CTIME 0
22#define CDSUSP CTRL('y')
23#define CSTART CTRL('q')
24#define CSTOP CTRL('s')
25#define CLNEXT CTRL('v')
26#define CDISCARD CTRL('o')
27#define CWERASE CTRL('w')
28#define CREPRINT CTRL('r')
29#define CEOT CEOF
30#define CBRK CEOL
31#define CRPRNT CREPRINT
32#define CFLUSH CDISCARD
33
34#endif
lib/libc/include/wasm-wasi-musl/sys/types.h created+85
......@@ -0,0 +1,85 @@
1#ifndef _SYS_TYPES_H
2#define _SYS_TYPES_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_ino_t
10#define __NEED_dev_t
11#define __NEED_uid_t
12#define __NEED_gid_t
13#define __NEED_mode_t
14#define __NEED_nlink_t
15#define __NEED_off_t
16#define __NEED_pid_t
17#define __NEED_size_t
18#define __NEED_ssize_t
19#define __NEED_time_t
20#define __NEED_timer_t
21#define __NEED_clockid_t
22
23#define __NEED_blkcnt_t
24#define __NEED_fsblkcnt_t
25#define __NEED_fsfilcnt_t
26
27#define __NEED_id_t
28#define __NEED_key_t
29#define __NEED_clock_t
30#define __NEED_suseconds_t
31#define __NEED_blksize_t
32
33#define __NEED_pthread_t
34#define __NEED_pthread_attr_t
35#define __NEED_pthread_mutexattr_t
36#define __NEED_pthread_condattr_t
37#define __NEED_pthread_rwlockattr_t
38#define __NEED_pthread_barrierattr_t
39#define __NEED_pthread_mutex_t
40#define __NEED_pthread_cond_t
41#define __NEED_pthread_rwlock_t
42#define __NEED_pthread_barrier_t
43#define __NEED_pthread_spinlock_t
44#define __NEED_pthread_key_t
45#define __NEED_pthread_once_t
46#define __NEED_useconds_t
47
48#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
49#define __NEED_int8_t
50#define __NEED_int16_t
51#define __NEED_int32_t
52#define __NEED_int64_t
53#define __NEED_u_int64_t
54#define __NEED_register_t
55#endif
56
57#include <bits/alltypes.h>
58
59#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
60typedef unsigned char u_int8_t;
61typedef unsigned short u_int16_t;
62typedef unsigned u_int32_t;
63typedef char *caddr_t;
64typedef unsigned char u_char;
65typedef unsigned short u_short, ushort;
66typedef unsigned u_int, uint;
67typedef unsigned long u_long, ulong;
68typedef long long quad_t;
69typedef unsigned long long u_quad_t;
70#include <endian.h>
71#include <sys/select.h>
72#endif
73
74#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
75#define blkcnt64_t blkcnt_t
76#define fsblkcnt64_t fsblkcnt_t
77#define fsfilcnt64_t fsfilcnt_t
78#define ino64_t ino_t
79#define off64_t off_t
80#endif
81
82#ifdef __cplusplus
83}
84#endif
85#endif
lib/libc/include/wasm-wasi-musl/sys/uio.h created+48
......@@ -0,0 +1,48 @@
1#ifndef _SYS_UIO_H
2#define _SYS_UIO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11#define __NEED_ssize_t
12#define __NEED_struct_iovec
13
14#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
15#define __NEED_off_t
16#endif
17
18#ifdef _GNU_SOURCE
19#define __NEED_pid_t
20#endif
21
22#include <bits/alltypes.h>
23
24#define UIO_MAXIOV 1024
25
26ssize_t readv (int, const struct iovec *, int);
27ssize_t writev (int, const struct iovec *, int);
28
29#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
30ssize_t preadv (int, const struct iovec *, int, off_t);
31ssize_t pwritev (int, const struct iovec *, int, off_t);
32#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
33#define preadv64 preadv
34#define pwritev64 pwritev
35#define off64_t off_t
36#endif
37#endif
38
39#ifdef _GNU_SOURCE
40ssize_t process_vm_writev(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long);
41ssize_t process_vm_readv(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long);
42#endif
43
44#ifdef __cplusplus
45}
46#endif
47
48#endif
lib/libc/include/wasm-wasi-musl/sys/un.h created+39
......@@ -0,0 +1,39 @@
1#ifndef _SYS_UN_H
2#define _SYS_UN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_sa_family_t
11#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
12#define __NEED_size_t
13#endif
14
15#include <bits/alltypes.h>
16
17#ifdef __wasilibc_unmodified_upstream /* WASI has no UNIX-domain sockets */
18struct sockaddr_un {
19 sa_family_t sun_family;
20 char sun_path[108];
21};
22#else
23#include <__struct_sockaddr_un.h>
24#endif
25
26#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
27#ifdef __wasilibc_unmodified_upstream /* Declare strlen with the same attributes as <string.h> uses */
28size_t strlen(const char *);
29#else
30size_t strlen(const char *) __attribute__((__nothrow__, __leaf__, __pure__, __nonnull__(1)));
31#endif
32#define SUN_LEN(s) (2+strlen((s)->sun_path))
33#endif
34
35#ifdef __cplusplus
36}
37#endif
38
39#endif
lib/libc/include/wasm-wasi-musl/sys/utsname.h created+29
......@@ -0,0 +1,29 @@
1#ifndef _SYS_UTSNAME_H
2#define _SYS_UTSNAME_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10struct utsname {
11 char sysname[65];
12 char nodename[65];
13 char release[65];
14 char version[65];
15 char machine[65];
16#ifdef _GNU_SOURCE
17 char domainname[65];
18#else
19 char __domainname[65];
20#endif
21};
22
23int uname (struct utsname *);
24
25#ifdef __cplusplus
26}
27#endif
28
29#endif
lib/libc/include/wasm-wasi-musl/syscall.h created+1
......@@ -0,0 +1 @@
1#include <sys/syscall.h>
lib/libc/include/wasm-wasi-musl/sysexits.h created+21
......@@ -0,0 +1,21 @@
1#ifndef _SYSEXITS_H
2#define _SYSEXITS_H
3#define EX_OK 0
4#define EX__BASE 64
5#define EX_USAGE 64
6#define EX_DATAERR 65
7#define EX_NOINPUT 66
8#define EX_NOUSER 67
9#define EX_NOHOST 68
10#define EX_UNAVAILABLE 69
11#define EX_SOFTWARE 70
12#define EX_OSERR 71
13#define EX_OSFILE 72
14#define EX_CANTCREAT 73
15#define EX_IOERR 74
16#define EX_TEMPFAIL 75
17#define EX_PROTOCOL 76
18#define EX_NOPERM 77
19#define EX_CONFIG 78
20#define EX__MAX 78
21#endif
lib/libc/include/wasm-wasi-musl/tar.h created+33
......@@ -0,0 +1,33 @@
1#ifndef _TAR_H
2#define _TAR_H
3
4#define TSUID 04000
5#define TSGID 02000
6#define TSVTX 01000
7#define TUREAD 00400
8#define TUWRITE 00200
9#define TUEXEC 00100
10#define TGREAD 00040
11#define TGWRITE 00020
12#define TGEXEC 00010
13#define TOREAD 00004
14#define TOWRITE 00002
15#define TOEXEC 00001
16
17#define REGTYPE '0'
18#define AREGTYPE '\0'
19#define LNKTYPE '1'
20#define SYMTYPE '2'
21#define CHRTYPE '3'
22#define BLKTYPE '4'
23#define DIRTYPE '5'
24#define FIFOTYPE '6'
25#define CONTTYPE '7'
26
27#define TMAGIC "ustar"
28#define TMAGLEN 6
29
30#define TVERSION "00"
31#define TVERSLEN 2
32
33#endif
lib/libc/include/wasm-wasi-musl/tgmath.h created+270
......@@ -0,0 +1,270 @@
1#ifndef _TGMATH_H
2#define _TGMATH_H
3
4/*
5the return types are only correct with gcc (__GNUC__)
6otherwise they are long double or long double complex
7
8the long double version of a function is never chosen when
9sizeof(double) == sizeof(long double)
10(but the return type is set correctly with gcc)
11*/
12
13#include <math.h>
14#include <complex.h>
15
16#define __IS_FP(x) (sizeof((x)+1ULL) == sizeof((x)+1.0f))
17#define __IS_CX(x) (__IS_FP(x) && sizeof(x) == sizeof((x)+I))
18#define __IS_REAL(x) (__IS_FP(x) && 2*sizeof(x) == sizeof((x)+I))
19
20#define __FLT(x) (__IS_REAL(x) && sizeof(x) == sizeof(float))
21#define __LDBL(x) (__IS_REAL(x) && sizeof(x) == sizeof(long double) && sizeof(long double) != sizeof(double))
22
23#define __FLTCX(x) (__IS_CX(x) && sizeof(x) == sizeof(float complex))
24#define __DBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(double complex))
25#define __LDBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(long double complex) && sizeof(long double) != sizeof(double))
26
27/* return type */
28
29#ifdef __GNUC__
30/*
31the result must be casted to the right type
32(otherwise the result type is determined by the conversion
33rules applied to all the function return types so it is long
34double or long double complex except for integral functions)
35
36this cannot be done in c99, so the typeof gcc extension is
37used and that the type of ?: depends on wether an operand is
38a null pointer constant or not
39(in c11 _Generic can be used)
40
41the c arguments below must be integer constant expressions
42so they can be in null pointer constants
43(__IS_FP above was carefully chosen this way)
44*/
45/* if c then t else void */
46#define __type1(c,t) __typeof__(*(0?(t*)0:(void*)!(c)))
47/* if c then t1 else t2 */
48#define __type2(c,t1,t2) __typeof__(*(0?(__type1(c,t1)*)0:(__type1(!(c),t2)*)0))
49/* cast to double when x is integral, otherwise use typeof(x) */
50#define __RETCAST(x) ( \
51 __type2(__IS_FP(x), __typeof__(x), double))
52/* 2 args case, should work for complex types (cpow) */
53#define __RETCAST_2(x, y) ( \
54 __type2(__IS_FP(x) && __IS_FP(y), \
55 __typeof__((x)+(y)), \
56 __typeof__((x)+(y)+1.0)))
57/* 3 args case (fma only) */
58#define __RETCAST_3(x, y, z) ( \
59 __type2(__IS_FP(x) && __IS_FP(y) && __IS_FP(z), \
60 __typeof__((x)+(y)+(z)), \
61 __typeof__((x)+(y)+(z)+1.0)))
62/* drop complex from the type of x */
63/* TODO: wrong when sizeof(long double)==sizeof(double) */
64#define __RETCAST_REAL(x) ( \
65 __type2(__IS_FP(x) && sizeof((x)+I) == sizeof(float complex), float, \
66 __type2(sizeof((x)+1.0+I) == sizeof(double complex), double, \
67 long double)))
68/* add complex to the type of x */
69#define __RETCAST_CX(x) (__typeof__(__RETCAST(x)0+I))
70#else
71#define __RETCAST(x)
72#define __RETCAST_2(x, y)
73#define __RETCAST_3(x, y, z)
74#define __RETCAST_REAL(x)
75#define __RETCAST_CX(x)
76#endif
77
78/* function selection */
79
80#define __tg_real_nocast(fun, x) ( \
81 __FLT(x) ? fun ## f (x) : \
82 __LDBL(x) ? fun ## l (x) : \
83 fun(x) )
84
85#define __tg_real(fun, x) (__RETCAST(x)__tg_real_nocast(fun, x))
86
87#define __tg_real_2_1(fun, x, y) (__RETCAST(x)( \
88 __FLT(x) ? fun ## f (x, y) : \
89 __LDBL(x) ? fun ## l (x, y) : \
90 fun(x, y) ))
91
92#define __tg_real_2(fun, x, y) (__RETCAST_2(x, y)( \
93 __FLT(x) && __FLT(y) ? fun ## f (x, y) : \
94 __LDBL((x)+(y)) ? fun ## l (x, y) : \
95 fun(x, y) ))
96
97#define __tg_complex(fun, x) (__RETCAST_CX(x)( \
98 __FLTCX((x)+I) && __IS_FP(x) ? fun ## f (x) : \
99 __LDBLCX((x)+I) ? fun ## l (x) : \
100 fun(x) ))
101
102#define __tg_complex_retreal(fun, x) (__RETCAST_REAL(x)( \
103 __FLTCX((x)+I) && __IS_FP(x) ? fun ## f (x) : \
104 __LDBLCX((x)+I) ? fun ## l (x) : \
105 fun(x) ))
106
107#define __tg_real_complex(fun, x) (__RETCAST(x)( \
108 __FLTCX(x) ? c ## fun ## f (x) : \
109 __DBLCX(x) ? c ## fun (x) : \
110 __LDBLCX(x) ? c ## fun ## l (x) : \
111 __FLT(x) ? fun ## f (x) : \
112 __LDBL(x) ? fun ## l (x) : \
113 fun(x) ))
114
115/* special cases */
116
117#define __tg_real_remquo(x, y, z) (__RETCAST_2(x, y)( \
118 __FLT(x) && __FLT(y) ? remquof(x, y, z) : \
119 __LDBL((x)+(y)) ? remquol(x, y, z) : \
120 remquo(x, y, z) ))
121
122#define __tg_real_fma(x, y, z) (__RETCAST_3(x, y, z)( \
123 __FLT(x) && __FLT(y) && __FLT(z) ? fmaf(x, y, z) : \
124 __LDBL((x)+(y)+(z)) ? fmal(x, y, z) : \
125 fma(x, y, z) ))
126
127#define __tg_real_complex_pow(x, y) (__RETCAST_2(x, y)( \
128 __FLTCX((x)+(y)) && __IS_FP(x) && __IS_FP(y) ? cpowf(x, y) : \
129 __FLTCX((x)+(y)) ? cpow(x, y) : \
130 __DBLCX((x)+(y)) ? cpow(x, y) : \
131 __LDBLCX((x)+(y)) ? cpowl(x, y) : \
132 __FLT(x) && __FLT(y) ? powf(x, y) : \
133 __LDBL((x)+(y)) ? powl(x, y) : \
134 pow(x, y) ))
135
136#define __tg_real_complex_fabs(x) (__RETCAST_REAL(x)( \
137 __FLTCX(x) ? cabsf(x) : \
138 __DBLCX(x) ? cabs(x) : \
139 __LDBLCX(x) ? cabsl(x) : \
140 __FLT(x) ? fabsf(x) : \
141 __LDBL(x) ? fabsl(x) : \
142 fabs(x) ))
143
144/* suppress any macros in math.h or complex.h */
145
146#undef acos
147#undef acosh
148#undef asin
149#undef asinh
150#undef atan
151#undef atan2
152#undef atanh
153#undef carg
154#undef cbrt
155#undef ceil
156#undef cimag
157#undef conj
158#undef copysign
159#undef cos
160#undef cosh
161#undef cproj
162#undef creal
163#undef erf
164#undef erfc
165#undef exp
166#undef exp2
167#undef expm1
168#undef fabs
169#undef fdim
170#undef floor
171#undef fma
172#undef fmax
173#undef fmin
174#undef fmod
175#undef frexp
176#undef hypot
177#undef ilogb
178#undef ldexp
179#undef lgamma
180#undef llrint
181#undef llround
182#undef log
183#undef log10
184#undef log1p
185#undef log2
186#undef logb
187#undef lrint
188#undef lround
189#undef nearbyint
190#undef nextafter
191#undef nexttoward
192#undef pow
193#undef remainder
194#undef remquo
195#undef rint
196#undef round
197#undef scalbln
198#undef scalbn
199#undef sin
200#undef sinh
201#undef sqrt
202#undef tan
203#undef tanh
204#undef tgamma
205#undef trunc
206
207/* tg functions */
208
209#define acos(x) __tg_real_complex(acos, (x))
210#define acosh(x) __tg_real_complex(acosh, (x))
211#define asin(x) __tg_real_complex(asin, (x))
212#define asinh(x) __tg_real_complex(asinh, (x))
213#define atan(x) __tg_real_complex(atan, (x))
214#define atan2(x,y) __tg_real_2(atan2, (x), (y))
215#define atanh(x) __tg_real_complex(atanh, (x))
216#define carg(x) __tg_complex_retreal(carg, (x))
217#define cbrt(x) __tg_real(cbrt, (x))
218#define ceil(x) __tg_real(ceil, (x))
219#define cimag(x) __tg_complex_retreal(cimag, (x))
220#define conj(x) __tg_complex(conj, (x))
221#define copysign(x,y) __tg_real_2(copysign, (x), (y))
222#define cos(x) __tg_real_complex(cos, (x))
223#define cosh(x) __tg_real_complex(cosh, (x))
224#define cproj(x) __tg_complex(cproj, (x))
225#define creal(x) __tg_complex_retreal(creal, (x))
226#define erf(x) __tg_real(erf, (x))
227#define erfc(x) __tg_real(erfc, (x))
228#define exp(x) __tg_real_complex(exp, (x))
229#define exp2(x) __tg_real(exp2, (x))
230#define expm1(x) __tg_real(expm1, (x))
231#define fabs(x) __tg_real_complex_fabs(x)
232#define fdim(x,y) __tg_real_2(fdim, (x), (y))
233#define floor(x) __tg_real(floor, (x))
234#define fma(x,y,z) __tg_real_fma((x), (y), (z))
235#define fmax(x,y) __tg_real_2(fmax, (x), (y))
236#define fmin(x,y) __tg_real_2(fmin, (x), (y))
237#define fmod(x,y) __tg_real_2(fmod, (x), (y))
238#define frexp(x,y) __tg_real_2_1(frexp, (x), (y))
239#define hypot(x,y) __tg_real_2(hypot, (x), (y))
240#define ilogb(x) __tg_real_nocast(ilogb, (x))
241#define ldexp(x,y) __tg_real_2_1(ldexp, (x), (y))
242#define lgamma(x) __tg_real(lgamma, (x))
243#define llrint(x) __tg_real_nocast(llrint, (x))
244#define llround(x) __tg_real_nocast(llround, (x))
245#define log(x) __tg_real_complex(log, (x))
246#define log10(x) __tg_real(log10, (x))
247#define log1p(x) __tg_real(log1p, (x))
248#define log2(x) __tg_real(log2, (x))
249#define logb(x) __tg_real(logb, (x))
250#define lrint(x) __tg_real_nocast(lrint, (x))
251#define lround(x) __tg_real_nocast(lround, (x))
252#define nearbyint(x) __tg_real(nearbyint, (x))
253#define nextafter(x,y) __tg_real_2(nextafter, (x), (y))
254#define nexttoward(x,y) __tg_real_2(nexttoward, (x), (y))
255#define pow(x,y) __tg_real_complex_pow((x), (y))
256#define remainder(x,y) __tg_real_2(remainder, (x), (y))
257#define remquo(x,y,z) __tg_real_remquo((x), (y), (z))
258#define rint(x) __tg_real(rint, (x))
259#define round(x) __tg_real(round, (x))
260#define scalbln(x,y) __tg_real_2_1(scalbln, (x), (y))
261#define scalbn(x,y) __tg_real_2_1(scalbn, (x), (y))
262#define sin(x) __tg_real_complex(sin, (x))
263#define sinh(x) __tg_real_complex(sinh, (x))
264#define sqrt(x) __tg_real_complex(sqrt, (x))
265#define tan(x) __tg_real_complex(tan, (x))
266#define tanh(x) __tg_real_complex(tanh, (x))
267#define tgamma(x) __tg_real(tgamma, (x))
268#define trunc(x) __tg_real(trunc, (x))
269
270#endif
lib/libc/include/wasm-wasi-musl/threads.h created+93
......@@ -0,0 +1,93 @@
1#ifndef _THREADS_H
2#define _THREADS_H
3
4#include <features.h>
5#include <time.h>
6
7#ifdef __cplusplus
8extern "C" {
9typedef unsigned long thrd_t;
10#else
11typedef struct __pthread *thrd_t;
12#define thread_local _Thread_local
13#endif
14
15typedef int once_flag;
16typedef unsigned tss_t;
17typedef int (*thrd_start_t)(void *);
18typedef void (*tss_dtor_t)(void *);
19
20#define __NEED_cnd_t
21#define __NEED_mtx_t
22
23#include <bits/alltypes.h>
24
25#define TSS_DTOR_ITERATIONS 4
26
27enum {
28 thrd_success = 0,
29 thrd_busy = 1,
30 thrd_error = 2,
31 thrd_nomem = 3,
32 thrd_timedout = 4,
33};
34
35enum {
36 mtx_plain = 0,
37 mtx_recursive = 1,
38 mtx_timed = 2,
39};
40
41#define ONCE_FLAG_INIT 0
42
43int thrd_create(thrd_t *, thrd_start_t, void *);
44_Noreturn void thrd_exit(int);
45
46int thrd_detach(thrd_t);
47int thrd_join(thrd_t, int *);
48
49int thrd_sleep(const struct timespec *, struct timespec *);
50void thrd_yield(void);
51
52thrd_t thrd_current(void);
53int thrd_equal(thrd_t, thrd_t);
54#ifndef __cplusplus
55#define thrd_equal(A, B) ((A) == (B))
56#endif
57
58void call_once(once_flag *, void (*)(void));
59
60int mtx_init(mtx_t *, int);
61void mtx_destroy(mtx_t *);
62
63int mtx_lock(mtx_t *);
64int mtx_timedlock(mtx_t *__restrict, const struct timespec *__restrict);
65int mtx_trylock(mtx_t *);
66int mtx_unlock(mtx_t *);
67
68int cnd_init(cnd_t *);
69void cnd_destroy(cnd_t *);
70
71int cnd_broadcast(cnd_t *);
72int cnd_signal(cnd_t *);
73
74int cnd_timedwait(cnd_t *__restrict, mtx_t *__restrict, const struct timespec *__restrict);
75int cnd_wait(cnd_t *, mtx_t *);
76
77int tss_create(tss_t *, tss_dtor_t);
78void tss_delete(tss_t);
79
80int tss_set(tss_t, void *);
81void *tss_get(tss_t);
82
83#if _REDIR_TIME64
84__REDIR(thrd_sleep, __thrd_sleep_time64);
85__REDIR(mtx_timedlock, __mtx_timedlock_time64);
86__REDIR(cnd_timedwait, __cnd_timedwait_time64);
87#endif
88
89#ifdef __cplusplus
90}
91#endif
92
93#endif
lib/libc/include/wasm-wasi-musl/time.h created+202
......@@ -0,0 +1,202 @@
1#ifndef _TIME_H
2#define _TIME_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
11#ifdef __cplusplus
12#define NULL 0L
13#else
14#define NULL ((void*)0)
15#endif
16#else
17#define __need_NULL
18#include <stddef.h>
19#endif
20
21
22#define __NEED_size_t
23#define __NEED_time_t
24#define __NEED_clock_t
25#define __NEED_struct_timespec
26
27#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
28 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
29 || defined(_BSD_SOURCE)
30#define __NEED_clockid_t
31#define __NEED_timer_t
32#define __NEED_pid_t
33#define __NEED_locale_t
34#endif
35
36#include <bits/alltypes.h>
37
38#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
39#define __tm_gmtoff tm_gmtoff
40#define __tm_zone tm_zone
41#endif
42
43#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
44struct tm {
45 int tm_sec;
46 int tm_min;
47 int tm_hour;
48 int tm_mday;
49 int tm_mon;
50 int tm_year;
51 int tm_wday;
52 int tm_yday;
53 int tm_isdst;
54 long __tm_gmtoff;
55 const char *__tm_zone;
56};
57#else
58#include <__header_time.h>
59#endif
60
61#if defined(__wasilibc_unmodified_upstream) || defined(_WASI_EMULATED_PROCESS_CLOCKS)
62clock_t clock (void);
63#else
64__attribute__((__deprecated__(
65"WASI lacks process-associated clocks; to enable emulation of the `clock` function using "
66"the wall clock, which isn't sensitive to whether the program is running or suspended, "
67"compile with -D_WASI_EMULATED_PROCESS_CLOCKS and link with -lwasi-emulated-process-clocks"
68)))
69clock_t clock (void);
70#endif
71time_t time (time_t *);
72double difftime (time_t, time_t);
73time_t mktime (struct tm *);
74size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
75struct tm *gmtime (const time_t *);
76struct tm *localtime (const time_t *);
77char *asctime (const struct tm *);
78char *ctime (const time_t *);
79int timespec_get(struct timespec *, int);
80
81#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
82#define CLOCKS_PER_SEC 1000000L
83
84#define TIME_UTC 1
85#endif
86
87#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
88 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
89 || defined(_BSD_SOURCE)
90
91size_t strftime_l (char * __restrict, size_t, const char * __restrict, const struct tm * __restrict, locale_t);
92
93struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
94struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
95char *asctime_r (const struct tm *__restrict, char *__restrict);
96char *ctime_r (const time_t *, char *);
97
98#ifdef __wasilibc_unmodified_upstream /* WASI has no timezone tables */
99void tzset (void);
100#endif
101
102struct itimerspec {
103 struct timespec it_interval;
104 struct timespec it_value;
105};
106
107#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
108#define CLOCK_REALTIME 0
109#define CLOCK_MONOTONIC 1
110#define CLOCK_PROCESS_CPUTIME_ID 2
111#define CLOCK_THREAD_CPUTIME_ID 3
112#define CLOCK_MONOTONIC_RAW 4
113#define CLOCK_REALTIME_COARSE 5
114#define CLOCK_MONOTONIC_COARSE 6
115#define CLOCK_BOOTTIME 7
116#define CLOCK_REALTIME_ALARM 8
117#define CLOCK_BOOTTIME_ALARM 9
118#define CLOCK_SGI_CYCLE 10
119#define CLOCK_TAI 11
120
121#define TIMER_ABSTIME 1
122#endif
123
124int nanosleep (const struct timespec *, struct timespec *);
125int clock_getres (clockid_t, struct timespec *);
126int clock_gettime (clockid_t, struct timespec *);
127#ifdef __wasilibc_unmodified_upstream /* WASI has no clock_settime */
128int clock_settime (clockid_t, const struct timespec *);
129#endif
130int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
131#ifdef __wasilibc_unmodified_upstream /* WASI has no clock_getcpuclockid */
132int clock_getcpuclockid (pid_t, clockid_t *);
133#endif
134
135#ifdef __wasilibc_unmodified_upstream /* WASI has no timers */
136struct sigevent;
137int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
138int timer_delete (timer_t);
139int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
140int timer_gettime (timer_t, struct itimerspec *);
141int timer_getoverrun (timer_t);
142#endif
143
144#ifdef __wasilibc_unmodified_upstream /* WASI has no timezone tables */
145extern char *tzname[2];
146#endif
147
148#endif
149
150
151#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
152char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
153#ifdef __wasilibc_unmodified_upstream /* WASI has no timezone tables */
154extern int daylight;
155extern long timezone;
156#endif
157extern int getdate_err;
158struct tm *getdate (const char *);
159#endif
160
161
162#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
163#ifdef __wasilibc_unmodified_upstream /* WASI has no stime */
164int stime(const time_t *);
165#endif
166time_t timegm(struct tm *);
167#endif
168
169#if _REDIR_TIME64
170__REDIR(time, __time64);
171__REDIR(difftime, __difftime64);
172__REDIR(mktime, __mktime64);
173__REDIR(gmtime, __gmtime64);
174__REDIR(localtime, __localtime64);
175__REDIR(ctime, __ctime64);
176__REDIR(timespec_get, __timespec_get_time64);
177#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
178 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
179 || defined(_BSD_SOURCE)
180__REDIR(gmtime_r, __gmtime64_r);
181__REDIR(localtime_r, __localtime64_r);
182__REDIR(ctime_r, __ctime64_r);
183__REDIR(nanosleep, __nanosleep_time64);
184__REDIR(clock_getres, __clock_getres_time64);
185__REDIR(clock_gettime, __clock_gettime64);
186__REDIR(clock_settime, __clock_settime64);
187__REDIR(clock_nanosleep, __clock_nanosleep_time64);
188__REDIR(timer_settime, __timer_settime64);
189__REDIR(timer_gettime, __timer_gettime64);
190#endif
191#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
192__REDIR(stime, __stime64);
193__REDIR(timegm, __timegm_time64);
194#endif
195#endif
196
197#ifdef __cplusplus
198}
199#endif
200
201
202#endif
lib/libc/include/wasm-wasi-musl/uchar.h created+29
......@@ -0,0 +1,29 @@
1#ifndef _UCHAR_H
2#define _UCHAR_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#if __cplusplus < 201103L
9typedef unsigned short char16_t;
10typedef unsigned char32_t;
11#endif
12
13#define __NEED_mbstate_t
14#define __NEED_size_t
15
16#include <features.h>
17#include <bits/alltypes.h>
18
19size_t c16rtomb(char *__restrict, char16_t, mbstate_t *__restrict);
20size_t mbrtoc16(char16_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
21
22size_t c32rtomb(char *__restrict, char32_t, mbstate_t *__restrict);
23size_t mbrtoc32(char32_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
24
25#ifdef __cplusplus
26}
27#endif
28
29#endif
lib/libc/include/wasm-wasi-musl/unistd.h created+571
......@@ -0,0 +1,571 @@
1#ifndef _UNISTD_H
2#define _UNISTD_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define STDIN_FILENO 0
11#define STDOUT_FILENO 1
12#define STDERR_FILENO 2
13
14#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
15#define SEEK_SET 0
16#define SEEK_CUR 1
17#define SEEK_END 2
18#else
19#include <__header_unistd.h>
20#endif
21
22#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
23#ifdef __cplusplus
24#define NULL 0L
25#else
26#define NULL ((void*)0)
27#endif
28#else
29#define __need_NULL
30#include <stddef.h>
31#endif
32
33#define __NEED_size_t
34#define __NEED_ssize_t
35#define __NEED_uid_t
36#define __NEED_gid_t
37#define __NEED_off_t
38#define __NEED_pid_t
39#define __NEED_intptr_t
40#define __NEED_useconds_t
41
42#include <bits/alltypes.h>
43
44#ifdef __wasilibc_unmodified_upstream /* WASI has no pipe */
45int pipe(int [2]);
46int pipe2(int [2], int);
47#endif
48int close(int);
49int posix_close(int, int);
50#ifdef __wasilibc_unmodified_upstream /* WASI has no dup */
51int dup(int);
52int dup2(int, int);
53int dup3(int, int, int);
54#endif
55off_t lseek(int, off_t, int);
56#ifdef __wasilibc_unmodified_upstream /* Optimize the readonly case of lseek */
57#else
58off_t __wasilibc_tell(int);
59
60#ifndef __cplusplus
61/*
62 * Optimize lseek in the case where it's just returning the current offset.
63 * This avoids importing `__wasi_fd_seek` altogether in many common cases.
64 *
65 * But don't do this for C++ because a simple macro wouldn't handle namespaces
66 * correctly:
67 * - User code could qualify the `lseek` call with `::`.
68 * - There may be another `lseek` in scope from a `using` declaration.
69 */
70#define lseek(fd, offset, whence) \
71 ({ \
72 off_t __f = (fd); \
73 off_t __o = (offset); \
74 off_t __w = (whence); \
75 __builtin_constant_p((offset)) && \
76 __builtin_constant_p((whence)) && \
77 __o == 0 && \
78 __w == SEEK_CUR \
79 ? __wasilibc_tell(__f) \
80 : lseek(__f, __o, __w); \
81 })
82#endif
83#endif
84int fsync(int);
85int fdatasync(int);
86
87ssize_t read(int, void *, size_t);
88ssize_t write(int, const void *, size_t);
89ssize_t pread(int, void *, size_t, off_t);
90ssize_t pwrite(int, const void *, size_t, off_t);
91
92#ifdef __wasilibc_unmodified_upstream /* WASI has no chown */
93int chown(const char *, uid_t, gid_t);
94int fchown(int, uid_t, gid_t);
95int lchown(const char *, uid_t, gid_t);
96int fchownat(int, const char *, uid_t, gid_t, int);
97#endif
98
99int link(const char *, const char *);
100int linkat(int, const char *, int, const char *, int);
101int symlink(const char *, const char *);
102int symlinkat(const char *, int, const char *);
103ssize_t readlink(const char *__restrict, char *__restrict, size_t);
104ssize_t readlinkat(int, const char *__restrict, char *__restrict, size_t);
105int unlink(const char *);
106int unlinkat(int, const char *, int);
107int rmdir(const char *);
108int truncate(const char *, off_t);
109int ftruncate(int, off_t);
110
111#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
112#define F_OK 0
113#define R_OK 4
114#define W_OK 2
115#define X_OK 1
116#endif
117
118int access(const char *, int);
119int faccessat(int, const char *, int, int);
120
121#ifdef __wasilibc_unmodified_upstream /* WASI has no fchdir */
122int fchdir(int);
123#endif
124int chdir(const char *);
125char *getcwd(char *, size_t);
126
127#ifdef __wasilibc_unmodified_upstream /* WASI has no signals */
128unsigned alarm(unsigned);
129#endif
130unsigned sleep(unsigned);
131#ifdef __wasilibc_unmodified_upstream /* WASI has no pause */
132int pause(void);
133#endif
134
135#ifdef __wasilibc_unmodified_upstream /* WASI has no fork/exec */
136pid_t fork(void);
137pid_t _Fork(void);
138int execve(const char *, char *const [], char *const []);
139int execv(const char *, char *const []);
140int execle(const char *, const char *, ...);
141int execl(const char *, const char *, ...);
142int execvp(const char *, char *const []);
143int execlp(const char *, const char *, ...);
144int fexecve(int, char *const [], char *const []);
145#endif
146_Noreturn void _exit(int);
147
148#if defined(__wasilibc_unmodified_upstream) || defined(_WASI_EMULATED_GETPID)
149pid_t getpid(void);
150#else
151__attribute__((__deprecated__(
152"WASI lacks process identifiers; to enable emulation of the `getpid` function using "
153"a placeholder value, which doesn't reflect the host PID of the program, "
154"compile with -D_WASI_EMULATED_GETPID and link with -lwasi-emulated-getpid"
155)))
156pid_t getpid(void);
157#endif
158#ifdef __wasilibc_unmodified_upstream /* WASI has no getpid etc. */
159pid_t getppid(void);
160pid_t getpgrp(void);
161pid_t getpgid(pid_t);
162int setpgid(pid_t, pid_t);
163pid_t setsid(void);
164pid_t getsid(pid_t);
165#endif
166#ifdef __wasilibc_unmodified_upstream /* WASI has no ttyname */
167char *ttyname(int);
168int ttyname_r(int, char *, size_t);
169#endif
170int isatty(int);
171#ifdef __wasilibc_unmodified_upstream /* WASI has no process groups */
172pid_t tcgetpgrp(int);
173int tcsetpgrp(int, pid_t);
174#endif
175
176#ifdef __wasilibc_unmodified_upstream /* WASI has no getuid etc. */
177uid_t getuid(void);
178uid_t geteuid(void);
179gid_t getgid(void);
180gid_t getegid(void);
181int getgroups(int, gid_t []);
182int setuid(uid_t);
183int seteuid(uid_t);
184int setgid(gid_t);
185int setegid(gid_t);
186#endif
187
188char *getlogin(void);
189int getlogin_r(char *, size_t);
190int gethostname(char *, size_t);
191char *ctermid(char *);
192
193int getopt(int, char * const [], const char *);
194extern char *optarg;
195extern int optind, opterr, optopt;
196
197long pathconf(const char *, int);
198long fpathconf(int, int);
199long sysconf(int);
200size_t confstr(int, char *, size_t);
201
202#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
203#define F_ULOCK 0
204#define F_LOCK 1
205#define F_TLOCK 2
206#define F_TEST 3
207#ifdef __wasilibc_unmodified_upstream /* WASI has no setreuid */
208int setreuid(uid_t, uid_t);
209int setregid(gid_t, gid_t);
210#endif
211#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
212int lockf(int, int, off_t);
213#endif
214long gethostid(void);
215#ifdef __wasilibc_unmodified_upstream /* WASI has no nice, sync, or setpgrp */
216int nice(int);
217void sync(void);
218pid_t setpgrp(void);
219#endif
220char *crypt(const char *, const char *);
221void encrypt(char *, int);
222void swab(const void *__restrict, void *__restrict, ssize_t);
223#endif
224
225#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \
226 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
227int usleep(unsigned);
228unsigned ualarm(unsigned, unsigned);
229#endif
230
231#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
232#define L_SET 0
233#define L_INCR 1
234#define L_XTND 2
235#ifdef __wasilibc_unmodified_upstream /* WASI has no brk */
236int brk(void *);
237#endif
238void *sbrk(intptr_t);
239#ifdef __wasilibc_unmodified_upstream /* WASI has no processes */
240pid_t vfork(void);
241int vhangup(void);
242int chroot(const char *);
243int getpagesize(void);
244int getdtablesize(void);
245int sethostname(const char *, size_t);
246int getdomainname(char *, size_t);
247int setdomainname(const char *, size_t);
248int setgroups(size_t, const gid_t *);
249char *getpass(const char *);
250int daemon(int, int);
251void setusershell(void);
252void endusershell(void);
253char *getusershell(void);
254int acct(const char *);
255long syscall(long, ...);
256int execvpe(const char *, char *const [], char *const []);
257int issetugid(void);
258#endif
259int getentropy(void *, size_t);
260extern int optreset;
261#endif
262
263#ifdef _GNU_SOURCE
264extern char **environ;
265#ifdef __wasilibc_unmodified_upstream /* WASI has no get/setresuid */
266int setresuid(uid_t, uid_t, uid_t);
267int setresgid(gid_t, gid_t, gid_t);
268int getresuid(uid_t *, uid_t *, uid_t *);
269int getresgid(gid_t *, gid_t *, gid_t *);
270#endif
271#ifdef __wasilibc_unmodified_upstream /* WASI has no cwd */
272char *get_current_dir_name(void);
273#endif
274#ifdef __wasilibc_unmodified_upstream /* WASI has no syncfs */
275int syncfs(int);
276#endif
277#ifdef __wasilibc_unmodified_upstream /* WASI has no eaccess */
278int euidaccess(const char *, int);
279int eaccess(const char *, int);
280ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
281pid_t gettid(void);
282#endif
283#endif
284
285#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
286#define lseek64 lseek
287#define pread64 pread
288#define pwrite64 pwrite
289#ifdef __wasilibc_unmodified_upstream /* WASI has no truncate */
290#define truncate64 truncate
291#endif
292#define ftruncate64 ftruncate
293#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
294#define lockf64 lockf
295#endif
296#define off64_t off_t
297#endif
298
299#define POSIX_CLOSE_RESTART 0
300
301#define _XOPEN_VERSION 700
302#define _XOPEN_UNIX 1
303#define _XOPEN_ENH_I18N 1
304
305#define _POSIX_VERSION 200809L
306#define _POSIX2_VERSION _POSIX_VERSION
307
308#define _POSIX_ADVISORY_INFO _POSIX_VERSION
309#define _POSIX_CHOWN_RESTRICTED 1
310#define _POSIX_IPV6 _POSIX_VERSION
311#ifdef __wasilibc_unmodified_upstream /* WASI has no processes, mmap, or mq */
312#define _POSIX_JOB_CONTROL 1
313#define _POSIX_MAPPED_FILES _POSIX_VERSION
314#define _POSIX_MEMLOCK _POSIX_VERSION
315#define _POSIX_MEMLOCK_RANGE _POSIX_VERSION
316#define _POSIX_MEMORY_PROTECTION _POSIX_VERSION
317#define _POSIX_MESSAGE_PASSING _POSIX_VERSION
318#endif
319#define _POSIX_FSYNC _POSIX_VERSION
320#define _POSIX_NO_TRUNC 1
321#ifdef __wasilibc_unmodified_upstream /* WASI has no raw sockets */
322#define _POSIX_RAW_SOCKETS _POSIX_VERSION
323#endif
324#define _POSIX_REALTIME_SIGNALS _POSIX_VERSION
325#define _POSIX_REGEXP 1
326#ifdef __wasilibc_unmodified_upstream /* WASI has no processes */
327#define _POSIX_SAVED_IDS 1
328#define _POSIX_SHELL 1
329#define _POSIX_SPAWN _POSIX_VERSION
330#endif
331#define _POSIX_VDISABLE 0
332
333#define _POSIX_THREADS _POSIX_VERSION
334#define _POSIX_THREAD_PROCESS_SHARED _POSIX_VERSION
335#define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION
336#define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION
337#define _POSIX_THREAD_ATTR_STACKSIZE _POSIX_VERSION
338#define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION
339#define _POSIX_THREAD_CPUTIME _POSIX_VERSION
340#define _POSIX_TIMERS _POSIX_VERSION
341#define _POSIX_TIMEOUTS _POSIX_VERSION
342#define _POSIX_MONOTONIC_CLOCK _POSIX_VERSION
343#define _POSIX_CPUTIME _POSIX_VERSION
344#define _POSIX_CLOCK_SELECTION _POSIX_VERSION
345#define _POSIX_BARRIERS _POSIX_VERSION
346#define _POSIX_SPIN_LOCKS _POSIX_VERSION
347#define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION
348#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX async I/O, semaphores, or shared memory */
349#define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION
350#define _POSIX_SEMAPHORES _POSIX_VERSION
351#define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_VERSION
352#endif
353
354#define _POSIX2_C_BIND _POSIX_VERSION
355
356#include <bits/posix.h>
357
358
359
360#define _PC_LINK_MAX 0
361#define _PC_MAX_CANON 1
362#define _PC_MAX_INPUT 2
363#define _PC_NAME_MAX 3
364#define _PC_PATH_MAX 4
365#define _PC_PIPE_BUF 5
366#define _PC_CHOWN_RESTRICTED 6
367#define _PC_NO_TRUNC 7
368#define _PC_VDISABLE 8
369#define _PC_SYNC_IO 9
370#define _PC_ASYNC_IO 10
371#define _PC_PRIO_IO 11
372#define _PC_SOCK_MAXBUF 12
373#define _PC_FILESIZEBITS 13
374#define _PC_REC_INCR_XFER_SIZE 14
375#define _PC_REC_MAX_XFER_SIZE 15
376#define _PC_REC_MIN_XFER_SIZE 16
377#define _PC_REC_XFER_ALIGN 17
378#define _PC_ALLOC_SIZE_MIN 18
379#define _PC_SYMLINK_MAX 19
380#define _PC_2_SYMLINKS 20
381
382#define _SC_ARG_MAX 0
383#define _SC_CHILD_MAX 1
384#define _SC_CLK_TCK 2
385#define _SC_NGROUPS_MAX 3
386#define _SC_OPEN_MAX 4
387#define _SC_STREAM_MAX 5
388#define _SC_TZNAME_MAX 6
389#define _SC_JOB_CONTROL 7
390#define _SC_SAVED_IDS 8
391#define _SC_REALTIME_SIGNALS 9
392#define _SC_PRIORITY_SCHEDULING 10
393#define _SC_TIMERS 11
394#define _SC_ASYNCHRONOUS_IO 12
395#define _SC_PRIORITIZED_IO 13
396#define _SC_SYNCHRONIZED_IO 14
397#define _SC_FSYNC 15
398#define _SC_MAPPED_FILES 16
399#define _SC_MEMLOCK 17
400#define _SC_MEMLOCK_RANGE 18
401#define _SC_MEMORY_PROTECTION 19
402#define _SC_MESSAGE_PASSING 20
403#define _SC_SEMAPHORES 21
404#define _SC_SHARED_MEMORY_OBJECTS 22
405#define _SC_AIO_LISTIO_MAX 23
406#define _SC_AIO_MAX 24
407#define _SC_AIO_PRIO_DELTA_MAX 25
408#define _SC_DELAYTIMER_MAX 26
409#define _SC_MQ_OPEN_MAX 27
410#define _SC_MQ_PRIO_MAX 28
411#define _SC_VERSION 29
412#define _SC_PAGE_SIZE 30
413#define _SC_PAGESIZE 30 /* !! */
414#define _SC_RTSIG_MAX 31
415#define _SC_SEM_NSEMS_MAX 32
416#define _SC_SEM_VALUE_MAX 33
417#define _SC_SIGQUEUE_MAX 34
418#define _SC_TIMER_MAX 35
419#define _SC_BC_BASE_MAX 36
420#define _SC_BC_DIM_MAX 37
421#define _SC_BC_SCALE_MAX 38
422#define _SC_BC_STRING_MAX 39
423#define _SC_COLL_WEIGHTS_MAX 40
424#define _SC_EXPR_NEST_MAX 42
425#define _SC_LINE_MAX 43
426#define _SC_RE_DUP_MAX 44
427#define _SC_2_VERSION 46
428#define _SC_2_C_BIND 47
429#define _SC_2_C_DEV 48
430#define _SC_2_FORT_DEV 49
431#define _SC_2_FORT_RUN 50
432#define _SC_2_SW_DEV 51
433#define _SC_2_LOCALEDEF 52
434#define _SC_UIO_MAXIOV 60 /* !! */
435#define _SC_IOV_MAX 60
436#define _SC_THREADS 67
437#define _SC_THREAD_SAFE_FUNCTIONS 68
438#define _SC_GETGR_R_SIZE_MAX 69
439#define _SC_GETPW_R_SIZE_MAX 70
440#define _SC_LOGIN_NAME_MAX 71
441#define _SC_TTY_NAME_MAX 72
442#define _SC_THREAD_DESTRUCTOR_ITERATIONS 73
443#define _SC_THREAD_KEYS_MAX 74
444#define _SC_THREAD_STACK_MIN 75
445#define _SC_THREAD_THREADS_MAX 76
446#define _SC_THREAD_ATTR_STACKADDR 77
447#define _SC_THREAD_ATTR_STACKSIZE 78
448#define _SC_THREAD_PRIORITY_SCHEDULING 79
449#define _SC_THREAD_PRIO_INHERIT 80
450#define _SC_THREAD_PRIO_PROTECT 81
451#define _SC_THREAD_PROCESS_SHARED 82
452#define _SC_NPROCESSORS_CONF 83
453#define _SC_NPROCESSORS_ONLN 84
454#define _SC_PHYS_PAGES 85
455#define _SC_AVPHYS_PAGES 86
456#define _SC_ATEXIT_MAX 87
457#define _SC_PASS_MAX 88
458#define _SC_XOPEN_VERSION 89
459#define _SC_XOPEN_XCU_VERSION 90
460#define _SC_XOPEN_UNIX 91
461#define _SC_XOPEN_CRYPT 92
462#define _SC_XOPEN_ENH_I18N 93
463#define _SC_XOPEN_SHM 94
464#define _SC_2_CHAR_TERM 95
465#define _SC_2_UPE 97
466#define _SC_XOPEN_XPG2 98
467#define _SC_XOPEN_XPG3 99
468#define _SC_XOPEN_XPG4 100
469#define _SC_NZERO 109
470#define _SC_XBS5_ILP32_OFF32 125
471#define _SC_XBS5_ILP32_OFFBIG 126
472#define _SC_XBS5_LP64_OFF64 127
473#define _SC_XBS5_LPBIG_OFFBIG 128
474#define _SC_XOPEN_LEGACY 129
475#define _SC_XOPEN_REALTIME 130
476#define _SC_XOPEN_REALTIME_THREADS 131
477#define _SC_ADVISORY_INFO 132
478#define _SC_BARRIERS 133
479#define _SC_CLOCK_SELECTION 137
480#define _SC_CPUTIME 138
481#define _SC_THREAD_CPUTIME 139
482#define _SC_MONOTONIC_CLOCK 149
483#define _SC_READER_WRITER_LOCKS 153
484#define _SC_SPIN_LOCKS 154
485#define _SC_REGEXP 155
486#define _SC_SHELL 157
487#define _SC_SPAWN 159
488#define _SC_SPORADIC_SERVER 160
489#define _SC_THREAD_SPORADIC_SERVER 161
490#define _SC_TIMEOUTS 164
491#define _SC_TYPED_MEMORY_OBJECTS 165
492#define _SC_2_PBS 168
493#define _SC_2_PBS_ACCOUNTING 169
494#define _SC_2_PBS_LOCATE 170
495#define _SC_2_PBS_MESSAGE 171
496#define _SC_2_PBS_TRACK 172
497#define _SC_SYMLOOP_MAX 173
498#define _SC_STREAMS 174
499#define _SC_2_PBS_CHECKPOINT 175
500#define _SC_V6_ILP32_OFF32 176
501#define _SC_V6_ILP32_OFFBIG 177
502#define _SC_V6_LP64_OFF64 178
503#define _SC_V6_LPBIG_OFFBIG 179
504#define _SC_HOST_NAME_MAX 180
505#define _SC_TRACE 181
506#define _SC_TRACE_EVENT_FILTER 182
507#define _SC_TRACE_INHERIT 183
508#define _SC_TRACE_LOG 184
509
510#define _SC_IPV6 235
511#define _SC_RAW_SOCKETS 236
512#define _SC_V7_ILP32_OFF32 237
513#define _SC_V7_ILP32_OFFBIG 238
514#define _SC_V7_LP64_OFF64 239
515#define _SC_V7_LPBIG_OFFBIG 240
516#define _SC_SS_REPL_MAX 241
517#define _SC_TRACE_EVENT_NAME_MAX 242
518#define _SC_TRACE_NAME_MAX 243
519#define _SC_TRACE_SYS_MAX 244
520#define _SC_TRACE_USER_EVENT_MAX 245
521#define _SC_XOPEN_STREAMS 246
522#define _SC_THREAD_ROBUST_PRIO_INHERIT 247
523#define _SC_THREAD_ROBUST_PRIO_PROTECT 248
524
525#define _CS_PATH 0
526#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 1
527#define _CS_GNU_LIBC_VERSION 2
528#define _CS_GNU_LIBPTHREAD_VERSION 3
529#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS 4
530#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 5
531
532#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 1116
533#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 1117
534#define _CS_POSIX_V6_ILP32_OFF32_LIBS 1118
535#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS 1119
536#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 1120
537#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 1121
538#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 1122
539#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS 1123
540#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 1124
541#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 1125
542#define _CS_POSIX_V6_LP64_OFF64_LIBS 1126
543#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS 1127
544#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 1128
545#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 1129
546#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 1130
547#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS 1131
548#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1132
549#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 1133
550#define _CS_POSIX_V7_ILP32_OFF32_LIBS 1134
551#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS 1135
552#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 1136
553#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 1137
554#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 1138
555#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS 1139
556#define _CS_POSIX_V7_LP64_OFF64_CFLAGS 1140
557#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 1141
558#define _CS_POSIX_V7_LP64_OFF64_LIBS 1142
559#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS 1143
560#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 1144
561#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 1145
562#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 1146
563#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS 1147
564#define _CS_V6_ENV 1148
565#define _CS_V7_ENV 1149
566
567#ifdef __cplusplus
568}
569#endif
570
571#endif
lib/libc/include/wasm-wasi-musl/utime.h created+29
......@@ -0,0 +1,29 @@
1#ifndef _UTIME_H
2#define _UTIME_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_time_t
11
12#include <bits/alltypes.h>
13
14struct utimbuf {
15 time_t actime;
16 time_t modtime;
17};
18
19int utime (const char *, const struct utimbuf *);
20
21#if _REDIR_TIME64
22__REDIR(utime, __utime64);
23#endif
24
25#ifdef __cplusplus
26}
27#endif
28
29#endif
lib/libc/include/wasm-wasi-musl/values.h created+39
......@@ -0,0 +1,39 @@
1#ifndef _VALUES_H
2#define _VALUES_H
3
4#include <limits.h>
5
6#define CHARBITS (sizeof(char) * 8)
7#define SHORTBITS (sizeof(short) * 8)
8#define INTBITS (sizeof(int) * 8)
9#define LONGBITS (sizeof(long) * 8)
10#define PTRBITS (sizeof(char *) * 8)
11#define DOUBLEBITS (sizeof(double) * 8)
12#define FLOATBITS (sizeof(float) * 8)
13
14#define MINSHORT SHRT_MIN
15#define MININT INT_MIN
16#define MINLONG LONG_MIN
17
18#define MAXSHORT SHRT_MAX
19#define MAXINT INT_MAX
20#define MAXLONG LONG_MAX
21
22#define HIBITS MINSHORT
23#define HIBITL MINLONG
24
25#include <float.h>
26
27#define MAXDOUBLE DBL_MAX
28#undef MAXFLOAT
29#define MAXFLOAT FLT_MAX
30#define MINDOUBLE DBL_MIN
31#define MINFLOAT FLT_MIN
32#define DMINEXP DBL_MIN_EXP
33#define FMINEXP FLT_MIN_EXP
34#define DMAXEXP DBL_MAX_EXP
35#define FMAXEXP FLT_MAX_EXP
36
37#define BITSPERBYTE CHAR_BIT
38
39#endif
lib/libc/include/wasm-wasi-musl/wasi/api.h created+2280
......@@ -0,0 +1,2280 @@
1/**
2 * THIS FILE IS AUTO-GENERATED from the following files:
3 * wasi_snapshot_preview1.witx
4 *
5 * To regenerate this file execute:
6 *
7 * cargo run --manifest-path tools/wasi-headers/Cargo.toml generate-libc
8 *
9 * Modifications to this file will cause CI to fail, the code generator tool
10 * must be modified to change this file.
11 *
12 * @file
13 * This file describes the [WASI] interface, consisting of functions, types,
14 * and defined values (macros).
15 *
16 * The interface described here is greatly inspired by [CloudABI]'s clean,
17 * thoughtfully-designed, capability-oriented, POSIX-style API.
18 *
19 * [CloudABI]: https://github.com/NuxiNL/cloudlibc
20 * [WASI]: https://github.com/WebAssembly/WASI/
21 */
22
23#ifndef __wasi_api_h
24#define __wasi_api_h
25
26#ifndef __wasi__
27#error <wasi/api.h> is only supported on WASI platforms.
28#endif
29
30#ifndef __wasm32__
31#error <wasi/api.h> only supports wasm32; doesn't yet support wasm64
32#endif
33
34#include <stddef.h>
35#include <stdint.h>
36
37_Static_assert(_Alignof(int8_t) == 1, "non-wasi data layout");
38_Static_assert(_Alignof(uint8_t) == 1, "non-wasi data layout");
39_Static_assert(_Alignof(int16_t) == 2, "non-wasi data layout");
40_Static_assert(_Alignof(uint16_t) == 2, "non-wasi data layout");
41_Static_assert(_Alignof(int32_t) == 4, "non-wasi data layout");
42_Static_assert(_Alignof(uint32_t) == 4, "non-wasi data layout");
43_Static_assert(_Alignof(int64_t) == 8, "non-wasi data layout");
44_Static_assert(_Alignof(uint64_t) == 8, "non-wasi data layout");
45_Static_assert(_Alignof(void*) == 4, "non-wasi data layout");
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51// TODO: Encoding this in witx.
52#define __WASI_DIRCOOKIE_START (UINT64_C(0))
53typedef __SIZE_TYPE__ __wasi_size_t;
54
55_Static_assert(sizeof(__wasi_size_t) == 4, "witx calculated size");
56_Static_assert(_Alignof(__wasi_size_t) == 4, "witx calculated align");
57
58/**
59 * Non-negative file size or length of a region within a file.
60 */
61typedef uint64_t __wasi_filesize_t;
62
63_Static_assert(sizeof(__wasi_filesize_t) == 8, "witx calculated size");
64_Static_assert(_Alignof(__wasi_filesize_t) == 8, "witx calculated align");
65
66/**
67 * Timestamp in nanoseconds.
68 */
69typedef uint64_t __wasi_timestamp_t;
70
71_Static_assert(sizeof(__wasi_timestamp_t) == 8, "witx calculated size");
72_Static_assert(_Alignof(__wasi_timestamp_t) == 8, "witx calculated align");
73
74/**
75 * Identifiers for clocks.
76 */
77typedef uint32_t __wasi_clockid_t;
78
79/**
80 * The clock measuring real time. Time value zero corresponds with
81 * 1970-01-01T00:00:00Z.
82 */
83#define __WASI_CLOCKID_REALTIME (UINT32_C(0))
84
85/**
86 * The store-wide monotonic clock, which is defined as a clock measuring
87 * real time, whose value cannot be adjusted and which cannot have negative
88 * clock jumps. The epoch of this clock is undefined. The absolute time
89 * value of this clock therefore has no meaning.
90 */
91#define __WASI_CLOCKID_MONOTONIC (UINT32_C(1))
92
93/**
94 * The CPU-time clock associated with the current process.
95 */
96#define __WASI_CLOCKID_PROCESS_CPUTIME_ID (UINT32_C(2))
97
98/**
99 * The CPU-time clock associated with the current thread.
100 */
101#define __WASI_CLOCKID_THREAD_CPUTIME_ID (UINT32_C(3))
102
103_Static_assert(sizeof(__wasi_clockid_t) == 4, "witx calculated size");
104_Static_assert(_Alignof(__wasi_clockid_t) == 4, "witx calculated align");
105
106/**
107 * Error codes returned by functions.
108 * Not all of these error codes are returned by the functions provided by this
109 * API; some are used in higher-level library layers, and others are provided
110 * merely for alignment with POSIX.
111 */
112typedef uint16_t __wasi_errno_t;
113
114/**
115 * No error occurred. System call completed successfully.
116 */
117#define __WASI_ERRNO_SUCCESS (UINT16_C(0))
118
119/**
120 * Argument list too long.
121 */
122#define __WASI_ERRNO_2BIG (UINT16_C(1))
123
124/**
125 * Permission denied.
126 */
127#define __WASI_ERRNO_ACCES (UINT16_C(2))
128
129/**
130 * Address in use.
131 */
132#define __WASI_ERRNO_ADDRINUSE (UINT16_C(3))
133
134/**
135 * Address not available.
136 */
137#define __WASI_ERRNO_ADDRNOTAVAIL (UINT16_C(4))
138
139/**
140 * Address family not supported.
141 */
142#define __WASI_ERRNO_AFNOSUPPORT (UINT16_C(5))
143
144/**
145 * Resource unavailable, or operation would block.
146 */
147#define __WASI_ERRNO_AGAIN (UINT16_C(6))
148
149/**
150 * Connection already in progress.
151 */
152#define __WASI_ERRNO_ALREADY (UINT16_C(7))
153
154/**
155 * Bad file descriptor.
156 */
157#define __WASI_ERRNO_BADF (UINT16_C(8))
158
159/**
160 * Bad message.
161 */
162#define __WASI_ERRNO_BADMSG (UINT16_C(9))
163
164/**
165 * Device or resource busy.
166 */
167#define __WASI_ERRNO_BUSY (UINT16_C(10))
168
169/**
170 * Operation canceled.
171 */
172#define __WASI_ERRNO_CANCELED (UINT16_C(11))
173
174/**
175 * No child processes.
176 */
177#define __WASI_ERRNO_CHILD (UINT16_C(12))
178
179/**
180 * Connection aborted.
181 */
182#define __WASI_ERRNO_CONNABORTED (UINT16_C(13))
183
184/**
185 * Connection refused.
186 */
187#define __WASI_ERRNO_CONNREFUSED (UINT16_C(14))
188
189/**
190 * Connection reset.
191 */
192#define __WASI_ERRNO_CONNRESET (UINT16_C(15))
193
194/**
195 * Resource deadlock would occur.
196 */
197#define __WASI_ERRNO_DEADLK (UINT16_C(16))
198
199/**
200 * Destination address required.
201 */
202#define __WASI_ERRNO_DESTADDRREQ (UINT16_C(17))
203
204/**
205 * Mathematics argument out of domain of function.
206 */
207#define __WASI_ERRNO_DOM (UINT16_C(18))
208
209/**
210 * Reserved.
211 */
212#define __WASI_ERRNO_DQUOT (UINT16_C(19))
213
214/**
215 * File exists.
216 */
217#define __WASI_ERRNO_EXIST (UINT16_C(20))
218
219/**
220 * Bad address.
221 */
222#define __WASI_ERRNO_FAULT (UINT16_C(21))
223
224/**
225 * File too large.
226 */
227#define __WASI_ERRNO_FBIG (UINT16_C(22))
228
229/**
230 * Host is unreachable.
231 */
232#define __WASI_ERRNO_HOSTUNREACH (UINT16_C(23))
233
234/**
235 * Identifier removed.
236 */
237#define __WASI_ERRNO_IDRM (UINT16_C(24))
238
239/**
240 * Illegal byte sequence.
241 */
242#define __WASI_ERRNO_ILSEQ (UINT16_C(25))
243
244/**
245 * Operation in progress.
246 */
247#define __WASI_ERRNO_INPROGRESS (UINT16_C(26))
248
249/**
250 * Interrupted function.
251 */
252#define __WASI_ERRNO_INTR (UINT16_C(27))
253
254/**
255 * Invalid argument.
256 */
257#define __WASI_ERRNO_INVAL (UINT16_C(28))
258
259/**
260 * I/O error.
261 */
262#define __WASI_ERRNO_IO (UINT16_C(29))
263
264/**
265 * Socket is connected.
266 */
267#define __WASI_ERRNO_ISCONN (UINT16_C(30))
268
269/**
270 * Is a directory.
271 */
272#define __WASI_ERRNO_ISDIR (UINT16_C(31))
273
274/**
275 * Too many levels of symbolic links.
276 */
277#define __WASI_ERRNO_LOOP (UINT16_C(32))
278
279/**
280 * File descriptor value too large.
281 */
282#define __WASI_ERRNO_MFILE (UINT16_C(33))
283
284/**
285 * Too many links.
286 */
287#define __WASI_ERRNO_MLINK (UINT16_C(34))
288
289/**
290 * Message too large.
291 */
292#define __WASI_ERRNO_MSGSIZE (UINT16_C(35))
293
294/**
295 * Reserved.
296 */
297#define __WASI_ERRNO_MULTIHOP (UINT16_C(36))
298
299/**
300 * Filename too long.
301 */
302#define __WASI_ERRNO_NAMETOOLONG (UINT16_C(37))
303
304/**
305 * Network is down.
306 */
307#define __WASI_ERRNO_NETDOWN (UINT16_C(38))
308
309/**
310 * Connection aborted by network.
311 */
312#define __WASI_ERRNO_NETRESET (UINT16_C(39))
313
314/**
315 * Network unreachable.
316 */
317#define __WASI_ERRNO_NETUNREACH (UINT16_C(40))
318
319/**
320 * Too many files open in system.
321 */
322#define __WASI_ERRNO_NFILE (UINT16_C(41))
323
324/**
325 * No buffer space available.
326 */
327#define __WASI_ERRNO_NOBUFS (UINT16_C(42))
328
329/**
330 * No such device.
331 */
332#define __WASI_ERRNO_NODEV (UINT16_C(43))
333
334/**
335 * No such file or directory.
336 */
337#define __WASI_ERRNO_NOENT (UINT16_C(44))
338
339/**
340 * Executable file format error.
341 */
342#define __WASI_ERRNO_NOEXEC (UINT16_C(45))
343
344/**
345 * No locks available.
346 */
347#define __WASI_ERRNO_NOLCK (UINT16_C(46))
348
349/**
350 * Reserved.
351 */
352#define __WASI_ERRNO_NOLINK (UINT16_C(47))
353
354/**
355 * Not enough space.
356 */
357#define __WASI_ERRNO_NOMEM (UINT16_C(48))
358
359/**
360 * No message of the desired type.
361 */
362#define __WASI_ERRNO_NOMSG (UINT16_C(49))
363
364/**
365 * Protocol not available.
366 */
367#define __WASI_ERRNO_NOPROTOOPT (UINT16_C(50))
368
369/**
370 * No space left on device.
371 */
372#define __WASI_ERRNO_NOSPC (UINT16_C(51))
373
374/**
375 * Function not supported.
376 */
377#define __WASI_ERRNO_NOSYS (UINT16_C(52))
378
379/**
380 * The socket is not connected.
381 */
382#define __WASI_ERRNO_NOTCONN (UINT16_C(53))
383
384/**
385 * Not a directory or a symbolic link to a directory.
386 */
387#define __WASI_ERRNO_NOTDIR (UINT16_C(54))
388
389/**
390 * Directory not empty.
391 */
392#define __WASI_ERRNO_NOTEMPTY (UINT16_C(55))
393
394/**
395 * State not recoverable.
396 */
397#define __WASI_ERRNO_NOTRECOVERABLE (UINT16_C(56))
398
399/**
400 * Not a socket.
401 */
402#define __WASI_ERRNO_NOTSOCK (UINT16_C(57))
403
404/**
405 * Not supported, or operation not supported on socket.
406 */
407#define __WASI_ERRNO_NOTSUP (UINT16_C(58))
408
409/**
410 * Inappropriate I/O control operation.
411 */
412#define __WASI_ERRNO_NOTTY (UINT16_C(59))
413
414/**
415 * No such device or address.
416 */
417#define __WASI_ERRNO_NXIO (UINT16_C(60))
418
419/**
420 * Value too large to be stored in data type.
421 */
422#define __WASI_ERRNO_OVERFLOW (UINT16_C(61))
423
424/**
425 * Previous owner died.
426 */
427#define __WASI_ERRNO_OWNERDEAD (UINT16_C(62))
428
429/**
430 * Operation not permitted.
431 */
432#define __WASI_ERRNO_PERM (UINT16_C(63))
433
434/**
435 * Broken pipe.
436 */
437#define __WASI_ERRNO_PIPE (UINT16_C(64))
438
439/**
440 * Protocol error.
441 */
442#define __WASI_ERRNO_PROTO (UINT16_C(65))
443
444/**
445 * Protocol not supported.
446 */
447#define __WASI_ERRNO_PROTONOSUPPORT (UINT16_C(66))
448
449/**
450 * Protocol wrong type for socket.
451 */
452#define __WASI_ERRNO_PROTOTYPE (UINT16_C(67))
453
454/**
455 * Result too large.
456 */
457#define __WASI_ERRNO_RANGE (UINT16_C(68))
458
459/**
460 * Read-only file system.
461 */
462#define __WASI_ERRNO_ROFS (UINT16_C(69))
463
464/**
465 * Invalid seek.
466 */
467#define __WASI_ERRNO_SPIPE (UINT16_C(70))
468
469/**
470 * No such process.
471 */
472#define __WASI_ERRNO_SRCH (UINT16_C(71))
473
474/**
475 * Reserved.
476 */
477#define __WASI_ERRNO_STALE (UINT16_C(72))
478
479/**
480 * Connection timed out.
481 */
482#define __WASI_ERRNO_TIMEDOUT (UINT16_C(73))
483
484/**
485 * Text file busy.
486 */
487#define __WASI_ERRNO_TXTBSY (UINT16_C(74))
488
489/**
490 * Cross-device link.
491 */
492#define __WASI_ERRNO_XDEV (UINT16_C(75))
493
494/**
495 * Extension: Capabilities insufficient.
496 */
497#define __WASI_ERRNO_NOTCAPABLE (UINT16_C(76))
498
499_Static_assert(sizeof(__wasi_errno_t) == 2, "witx calculated size");
500_Static_assert(_Alignof(__wasi_errno_t) == 2, "witx calculated align");
501
502/**
503 * File descriptor rights, determining which actions may be performed.
504 */
505typedef uint64_t __wasi_rights_t;
506
507/**
508 * The right to invoke `fd_datasync`.
509 * If `path_open` is set, includes the right to invoke
510 * `path_open` with `fdflags::dsync`.
511 */
512#define __WASI_RIGHTS_FD_DATASYNC ((__wasi_rights_t)(1 << 0))
513
514/**
515 * The right to invoke `fd_read` and `sock_recv`.
516 * If `rights::fd_seek` is set, includes the right to invoke `fd_pread`.
517 */
518#define __WASI_RIGHTS_FD_READ ((__wasi_rights_t)(1 << 1))
519
520/**
521 * The right to invoke `fd_seek`. This flag implies `rights::fd_tell`.
522 */
523#define __WASI_RIGHTS_FD_SEEK ((__wasi_rights_t)(1 << 2))
524
525/**
526 * The right to invoke `fd_fdstat_set_flags`.
527 */
528#define __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS ((__wasi_rights_t)(1 << 3))
529
530/**
531 * The right to invoke `fd_sync`.
532 * If `path_open` is set, includes the right to invoke
533 * `path_open` with `fdflags::rsync` and `fdflags::dsync`.
534 */
535#define __WASI_RIGHTS_FD_SYNC ((__wasi_rights_t)(1 << 4))
536
537/**
538 * The right to invoke `fd_seek` in such a way that the file offset
539 * remains unaltered (i.e., `whence::cur` with offset zero), or to
540 * invoke `fd_tell`.
541 */
542#define __WASI_RIGHTS_FD_TELL ((__wasi_rights_t)(1 << 5))
543
544/**
545 * The right to invoke `fd_write` and `sock_send`.
546 * If `rights::fd_seek` is set, includes the right to invoke `fd_pwrite`.
547 */
548#define __WASI_RIGHTS_FD_WRITE ((__wasi_rights_t)(1 << 6))
549
550/**
551 * The right to invoke `fd_advise`.
552 */
553#define __WASI_RIGHTS_FD_ADVISE ((__wasi_rights_t)(1 << 7))
554
555/**
556 * The right to invoke `fd_allocate`.
557 */
558#define __WASI_RIGHTS_FD_ALLOCATE ((__wasi_rights_t)(1 << 8))
559
560/**
561 * The right to invoke `path_create_directory`.
562 */
563#define __WASI_RIGHTS_PATH_CREATE_DIRECTORY ((__wasi_rights_t)(1 << 9))
564
565/**
566 * If `path_open` is set, the right to invoke `path_open` with `oflags::creat`.
567 */
568#define __WASI_RIGHTS_PATH_CREATE_FILE ((__wasi_rights_t)(1 << 10))
569
570/**
571 * The right to invoke `path_link` with the file descriptor as the
572 * source directory.
573 */
574#define __WASI_RIGHTS_PATH_LINK_SOURCE ((__wasi_rights_t)(1 << 11))
575
576/**
577 * The right to invoke `path_link` with the file descriptor as the
578 * target directory.
579 */
580#define __WASI_RIGHTS_PATH_LINK_TARGET ((__wasi_rights_t)(1 << 12))
581
582/**
583 * The right to invoke `path_open`.
584 */
585#define __WASI_RIGHTS_PATH_OPEN ((__wasi_rights_t)(1 << 13))
586
587/**
588 * The right to invoke `fd_readdir`.
589 */
590#define __WASI_RIGHTS_FD_READDIR ((__wasi_rights_t)(1 << 14))
591
592/**
593 * The right to invoke `path_readlink`.
594 */
595#define __WASI_RIGHTS_PATH_READLINK ((__wasi_rights_t)(1 << 15))
596
597/**
598 * The right to invoke `path_rename` with the file descriptor as the source directory.
599 */
600#define __WASI_RIGHTS_PATH_RENAME_SOURCE ((__wasi_rights_t)(1 << 16))
601
602/**
603 * The right to invoke `path_rename` with the file descriptor as the target directory.
604 */
605#define __WASI_RIGHTS_PATH_RENAME_TARGET ((__wasi_rights_t)(1 << 17))
606
607/**
608 * The right to invoke `path_filestat_get`.
609 */
610#define __WASI_RIGHTS_PATH_FILESTAT_GET ((__wasi_rights_t)(1 << 18))
611
612/**
613 * The right to change a file's size (there is no `path_filestat_set_size`).
614 * If `path_open` is set, includes the right to invoke `path_open` with `oflags::trunc`.
615 */
616#define __WASI_RIGHTS_PATH_FILESTAT_SET_SIZE ((__wasi_rights_t)(1 << 19))
617
618/**
619 * The right to invoke `path_filestat_set_times`.
620 */
621#define __WASI_RIGHTS_PATH_FILESTAT_SET_TIMES ((__wasi_rights_t)(1 << 20))
622
623/**
624 * The right to invoke `fd_filestat_get`.
625 */
626#define __WASI_RIGHTS_FD_FILESTAT_GET ((__wasi_rights_t)(1 << 21))
627
628/**
629 * The right to invoke `fd_filestat_set_size`.
630 */
631#define __WASI_RIGHTS_FD_FILESTAT_SET_SIZE ((__wasi_rights_t)(1 << 22))
632
633/**
634 * The right to invoke `fd_filestat_set_times`.
635 */
636#define __WASI_RIGHTS_FD_FILESTAT_SET_TIMES ((__wasi_rights_t)(1 << 23))
637
638/**
639 * The right to invoke `path_symlink`.
640 */
641#define __WASI_RIGHTS_PATH_SYMLINK ((__wasi_rights_t)(1 << 24))
642
643/**
644 * The right to invoke `path_remove_directory`.
645 */
646#define __WASI_RIGHTS_PATH_REMOVE_DIRECTORY ((__wasi_rights_t)(1 << 25))
647
648/**
649 * The right to invoke `path_unlink_file`.
650 */
651#define __WASI_RIGHTS_PATH_UNLINK_FILE ((__wasi_rights_t)(1 << 26))
652
653/**
654 * If `rights::fd_read` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_read`.
655 * If `rights::fd_write` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_write`.
656 */
657#define __WASI_RIGHTS_POLL_FD_READWRITE ((__wasi_rights_t)(1 << 27))
658
659/**
660 * The right to invoke `sock_shutdown`.
661 */
662#define __WASI_RIGHTS_SOCK_SHUTDOWN ((__wasi_rights_t)(1 << 28))
663
664/**
665 * A file descriptor handle.
666 */
667typedef int __wasi_fd_t;
668
669_Static_assert(sizeof(__wasi_fd_t) == 4, "witx calculated size");
670_Static_assert(_Alignof(__wasi_fd_t) == 4, "witx calculated align");
671
672/**
673 * A region of memory for scatter/gather reads.
674 */
675typedef struct __wasi_iovec_t {
676 /**
677 * The address of the buffer to be filled.
678 */
679 uint8_t * buf;
680
681 /**
682 * The length of the buffer to be filled.
683 */
684 __wasi_size_t buf_len;
685
686} __wasi_iovec_t;
687
688_Static_assert(sizeof(__wasi_iovec_t) == 8, "witx calculated size");
689_Static_assert(_Alignof(__wasi_iovec_t) == 4, "witx calculated align");
690_Static_assert(offsetof(__wasi_iovec_t, buf) == 0, "witx calculated offset");
691_Static_assert(offsetof(__wasi_iovec_t, buf_len) == 4, "witx calculated offset");
692
693/**
694 * A region of memory for scatter/gather writes.
695 */
696typedef struct __wasi_ciovec_t {
697 /**
698 * The address of the buffer to be written.
699 */
700 const uint8_t * buf;
701
702 /**
703 * The length of the buffer to be written.
704 */
705 __wasi_size_t buf_len;
706
707} __wasi_ciovec_t;
708
709_Static_assert(sizeof(__wasi_ciovec_t) == 8, "witx calculated size");
710_Static_assert(_Alignof(__wasi_ciovec_t) == 4, "witx calculated align");
711_Static_assert(offsetof(__wasi_ciovec_t, buf) == 0, "witx calculated offset");
712_Static_assert(offsetof(__wasi_ciovec_t, buf_len) == 4, "witx calculated offset");
713
714/**
715 * Relative offset within a file.
716 */
717typedef int64_t __wasi_filedelta_t;
718
719_Static_assert(sizeof(__wasi_filedelta_t) == 8, "witx calculated size");
720_Static_assert(_Alignof(__wasi_filedelta_t) == 8, "witx calculated align");
721
722/**
723 * The position relative to which to set the offset of the file descriptor.
724 */
725typedef uint8_t __wasi_whence_t;
726
727/**
728 * Seek relative to start-of-file.
729 */
730#define __WASI_WHENCE_SET (UINT8_C(0))
731
732/**
733 * Seek relative to current position.
734 */
735#define __WASI_WHENCE_CUR (UINT8_C(1))
736
737/**
738 * Seek relative to end-of-file.
739 */
740#define __WASI_WHENCE_END (UINT8_C(2))
741
742_Static_assert(sizeof(__wasi_whence_t) == 1, "witx calculated size");
743_Static_assert(_Alignof(__wasi_whence_t) == 1, "witx calculated align");
744
745/**
746 * A reference to the offset of a directory entry.
747 *
748 * The value 0 signifies the start of the directory.
749 */
750typedef uint64_t __wasi_dircookie_t;
751
752_Static_assert(sizeof(__wasi_dircookie_t) == 8, "witx calculated size");
753_Static_assert(_Alignof(__wasi_dircookie_t) == 8, "witx calculated align");
754
755/**
756 * The type for the `dirent::d_namlen` field of `dirent` struct.
757 */
758typedef uint32_t __wasi_dirnamlen_t;
759
760_Static_assert(sizeof(__wasi_dirnamlen_t) == 4, "witx calculated size");
761_Static_assert(_Alignof(__wasi_dirnamlen_t) == 4, "witx calculated align");
762
763/**
764 * File serial number that is unique within its file system.
765 */
766typedef uint64_t __wasi_inode_t;
767
768_Static_assert(sizeof(__wasi_inode_t) == 8, "witx calculated size");
769_Static_assert(_Alignof(__wasi_inode_t) == 8, "witx calculated align");
770
771/**
772 * The type of a file descriptor or file.
773 */
774typedef uint8_t __wasi_filetype_t;
775
776/**
777 * The type of the file descriptor or file is unknown or is different from any of the other types specified.
778 */
779#define __WASI_FILETYPE_UNKNOWN (UINT8_C(0))
780
781/**
782 * The file descriptor or file refers to a block device inode.
783 */
784#define __WASI_FILETYPE_BLOCK_DEVICE (UINT8_C(1))
785
786/**
787 * The file descriptor or file refers to a character device inode.
788 */
789#define __WASI_FILETYPE_CHARACTER_DEVICE (UINT8_C(2))
790
791/**
792 * The file descriptor or file refers to a directory inode.
793 */
794#define __WASI_FILETYPE_DIRECTORY (UINT8_C(3))
795
796/**
797 * The file descriptor or file refers to a regular file inode.
798 */
799#define __WASI_FILETYPE_REGULAR_FILE (UINT8_C(4))
800
801/**
802 * The file descriptor or file refers to a datagram socket.
803 */
804#define __WASI_FILETYPE_SOCKET_DGRAM (UINT8_C(5))
805
806/**
807 * The file descriptor or file refers to a byte-stream socket.
808 */
809#define __WASI_FILETYPE_SOCKET_STREAM (UINT8_C(6))
810
811/**
812 * The file refers to a symbolic link inode.
813 */
814#define __WASI_FILETYPE_SYMBOLIC_LINK (UINT8_C(7))
815
816_Static_assert(sizeof(__wasi_filetype_t) == 1, "witx calculated size");
817_Static_assert(_Alignof(__wasi_filetype_t) == 1, "witx calculated align");
818
819/**
820 * A directory entry.
821 */
822typedef struct __wasi_dirent_t {
823 /**
824 * The offset of the next directory entry stored in this directory.
825 */
826 __wasi_dircookie_t d_next;
827
828 /**
829 * The serial number of the file referred to by this directory entry.
830 */
831 __wasi_inode_t d_ino;
832
833 /**
834 * The length of the name of the directory entry.
835 */
836 __wasi_dirnamlen_t d_namlen;
837
838 /**
839 * The type of the file referred to by this directory entry.
840 */
841 __wasi_filetype_t d_type;
842
843} __wasi_dirent_t;
844
845_Static_assert(sizeof(__wasi_dirent_t) == 24, "witx calculated size");
846_Static_assert(_Alignof(__wasi_dirent_t) == 8, "witx calculated align");
847_Static_assert(offsetof(__wasi_dirent_t, d_next) == 0, "witx calculated offset");
848_Static_assert(offsetof(__wasi_dirent_t, d_ino) == 8, "witx calculated offset");
849_Static_assert(offsetof(__wasi_dirent_t, d_namlen) == 16, "witx calculated offset");
850_Static_assert(offsetof(__wasi_dirent_t, d_type) == 20, "witx calculated offset");
851
852/**
853 * File or memory access pattern advisory information.
854 */
855typedef uint8_t __wasi_advice_t;
856
857/**
858 * The application has no advice to give on its behavior with respect to the specified data.
859 */
860#define __WASI_ADVICE_NORMAL (UINT8_C(0))
861
862/**
863 * The application expects to access the specified data sequentially from lower offsets to higher offsets.
864 */
865#define __WASI_ADVICE_SEQUENTIAL (UINT8_C(1))
866
867/**
868 * The application expects to access the specified data in a random order.
869 */
870#define __WASI_ADVICE_RANDOM (UINT8_C(2))
871
872/**
873 * The application expects to access the specified data in the near future.
874 */
875#define __WASI_ADVICE_WILLNEED (UINT8_C(3))
876
877/**
878 * The application expects that it will not access the specified data in the near future.
879 */
880#define __WASI_ADVICE_DONTNEED (UINT8_C(4))
881
882/**
883 * The application expects to access the specified data once and then not reuse it thereafter.
884 */
885#define __WASI_ADVICE_NOREUSE (UINT8_C(5))
886
887_Static_assert(sizeof(__wasi_advice_t) == 1, "witx calculated size");
888_Static_assert(_Alignof(__wasi_advice_t) == 1, "witx calculated align");
889
890/**
891 * File descriptor flags.
892 */
893typedef uint16_t __wasi_fdflags_t;
894
895/**
896 * Append mode: Data written to the file is always appended to the file's end.
897 */
898#define __WASI_FDFLAGS_APPEND ((__wasi_fdflags_t)(1 << 0))
899
900/**
901 * Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
902 */
903#define __WASI_FDFLAGS_DSYNC ((__wasi_fdflags_t)(1 << 1))
904
905/**
906 * Non-blocking mode.
907 */
908#define __WASI_FDFLAGS_NONBLOCK ((__wasi_fdflags_t)(1 << 2))
909
910/**
911 * Synchronized read I/O operations.
912 */
913#define __WASI_FDFLAGS_RSYNC ((__wasi_fdflags_t)(1 << 3))
914
915/**
916 * Write according to synchronized I/O file integrity completion. In
917 * addition to synchronizing the data stored in the file, the implementation
918 * may also synchronously update the file's metadata.
919 */
920#define __WASI_FDFLAGS_SYNC ((__wasi_fdflags_t)(1 << 4))
921
922/**
923 * File descriptor attributes.
924 */
925typedef struct __wasi_fdstat_t {
926 /**
927 * File type.
928 */
929 __wasi_filetype_t fs_filetype;
930
931 /**
932 * File descriptor flags.
933 */
934 __wasi_fdflags_t fs_flags;
935
936 /**
937 * Rights that apply to this file descriptor.
938 */
939 __wasi_rights_t fs_rights_base;
940
941 /**
942 * Maximum set of rights that may be installed on new file descriptors that
943 * are created through this file descriptor, e.g., through `path_open`.
944 */
945 __wasi_rights_t fs_rights_inheriting;
946
947} __wasi_fdstat_t;
948
949_Static_assert(sizeof(__wasi_fdstat_t) == 24, "witx calculated size");
950_Static_assert(_Alignof(__wasi_fdstat_t) == 8, "witx calculated align");
951_Static_assert(offsetof(__wasi_fdstat_t, fs_filetype) == 0, "witx calculated offset");
952_Static_assert(offsetof(__wasi_fdstat_t, fs_flags) == 2, "witx calculated offset");
953_Static_assert(offsetof(__wasi_fdstat_t, fs_rights_base) == 8, "witx calculated offset");
954_Static_assert(offsetof(__wasi_fdstat_t, fs_rights_inheriting) == 16, "witx calculated offset");
955
956/**
957 * Identifier for a device containing a file system. Can be used in combination
958 * with `inode` to uniquely identify a file or directory in the filesystem.
959 */
960typedef uint64_t __wasi_device_t;
961
962_Static_assert(sizeof(__wasi_device_t) == 8, "witx calculated size");
963_Static_assert(_Alignof(__wasi_device_t) == 8, "witx calculated align");
964
965/**
966 * Which file time attributes to adjust.
967 */
968typedef uint16_t __wasi_fstflags_t;
969
970/**
971 * Adjust the last data access timestamp to the value stored in `filestat::atim`.
972 */
973#define __WASI_FSTFLAGS_ATIM ((__wasi_fstflags_t)(1 << 0))
974
975/**
976 * Adjust the last data access timestamp to the time of clock `clockid::realtime`.
977 */
978#define __WASI_FSTFLAGS_ATIM_NOW ((__wasi_fstflags_t)(1 << 1))
979
980/**
981 * Adjust the last data modification timestamp to the value stored in `filestat::mtim`.
982 */
983#define __WASI_FSTFLAGS_MTIM ((__wasi_fstflags_t)(1 << 2))
984
985/**
986 * Adjust the last data modification timestamp to the time of clock `clockid::realtime`.
987 */
988#define __WASI_FSTFLAGS_MTIM_NOW ((__wasi_fstflags_t)(1 << 3))
989
990/**
991 * Flags determining the method of how paths are resolved.
992 */
993typedef uint32_t __wasi_lookupflags_t;
994
995/**
996 * As long as the resolved path corresponds to a symbolic link, it is expanded.
997 */
998#define __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW ((__wasi_lookupflags_t)(1 << 0))
999
1000/**
1001 * Open flags used by `path_open`.
1002 */
1003typedef uint16_t __wasi_oflags_t;
1004
1005/**
1006 * Create file if it does not exist.
1007 */
1008#define __WASI_OFLAGS_CREAT ((__wasi_oflags_t)(1 << 0))
1009
1010/**
1011 * Fail if not a directory.
1012 */
1013#define __WASI_OFLAGS_DIRECTORY ((__wasi_oflags_t)(1 << 1))
1014
1015/**
1016 * Fail if file already exists.
1017 */
1018#define __WASI_OFLAGS_EXCL ((__wasi_oflags_t)(1 << 2))
1019
1020/**
1021 * Truncate file to size 0.
1022 */
1023#define __WASI_OFLAGS_TRUNC ((__wasi_oflags_t)(1 << 3))
1024
1025/**
1026 * Number of hard links to an inode.
1027 */
1028typedef uint64_t __wasi_linkcount_t;
1029
1030_Static_assert(sizeof(__wasi_linkcount_t) == 8, "witx calculated size");
1031_Static_assert(_Alignof(__wasi_linkcount_t) == 8, "witx calculated align");
1032
1033/**
1034 * File attributes.
1035 */
1036typedef struct __wasi_filestat_t {
1037 /**
1038 * Device ID of device containing the file.
1039 */
1040 __wasi_device_t dev;
1041
1042 /**
1043 * File serial number.
1044 */
1045 __wasi_inode_t ino;
1046
1047 /**
1048 * File type.
1049 */
1050 __wasi_filetype_t filetype;
1051
1052 /**
1053 * Number of hard links to the file.
1054 */
1055 __wasi_linkcount_t nlink;
1056
1057 /**
1058 * For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link.
1059 */
1060 __wasi_filesize_t size;
1061
1062 /**
1063 * Last data access timestamp.
1064 */
1065 __wasi_timestamp_t atim;
1066
1067 /**
1068 * Last data modification timestamp.
1069 */
1070 __wasi_timestamp_t mtim;
1071
1072 /**
1073 * Last file status change timestamp.
1074 */
1075 __wasi_timestamp_t ctim;
1076
1077} __wasi_filestat_t;
1078
1079_Static_assert(sizeof(__wasi_filestat_t) == 64, "witx calculated size");
1080_Static_assert(_Alignof(__wasi_filestat_t) == 8, "witx calculated align");
1081_Static_assert(offsetof(__wasi_filestat_t, dev) == 0, "witx calculated offset");
1082_Static_assert(offsetof(__wasi_filestat_t, ino) == 8, "witx calculated offset");
1083_Static_assert(offsetof(__wasi_filestat_t, filetype) == 16, "witx calculated offset");
1084_Static_assert(offsetof(__wasi_filestat_t, nlink) == 24, "witx calculated offset");
1085_Static_assert(offsetof(__wasi_filestat_t, size) == 32, "witx calculated offset");
1086_Static_assert(offsetof(__wasi_filestat_t, atim) == 40, "witx calculated offset");
1087_Static_assert(offsetof(__wasi_filestat_t, mtim) == 48, "witx calculated offset");
1088_Static_assert(offsetof(__wasi_filestat_t, ctim) == 56, "witx calculated offset");
1089
1090/**
1091 * User-provided value that may be attached to objects that is retained when
1092 * extracted from the implementation.
1093 */
1094typedef uint64_t __wasi_userdata_t;
1095
1096_Static_assert(sizeof(__wasi_userdata_t) == 8, "witx calculated size");
1097_Static_assert(_Alignof(__wasi_userdata_t) == 8, "witx calculated align");
1098
1099/**
1100 * Type of a subscription to an event or its occurrence.
1101 */
1102typedef uint8_t __wasi_eventtype_t;
1103
1104/**
1105 * The time value of clock `subscription_clock::id` has
1106 * reached timestamp `subscription_clock::timeout`.
1107 */
1108#define __WASI_EVENTTYPE_CLOCK (UINT8_C(0))
1109
1110/**
1111 * File descriptor `subscription_fd_readwrite::file_descriptor` has data
1112 * available for reading. This event always triggers for regular files.
1113 */
1114#define __WASI_EVENTTYPE_FD_READ (UINT8_C(1))
1115
1116/**
1117 * File descriptor `subscription_fd_readwrite::file_descriptor` has capacity
1118 * available for writing. This event always triggers for regular files.
1119 */
1120#define __WASI_EVENTTYPE_FD_WRITE (UINT8_C(2))
1121
1122_Static_assert(sizeof(__wasi_eventtype_t) == 1, "witx calculated size");
1123_Static_assert(_Alignof(__wasi_eventtype_t) == 1, "witx calculated align");
1124
1125/**
1126 * The state of the file descriptor subscribed to with
1127 * `eventtype::fd_read` or `eventtype::fd_write`.
1128 */
1129typedef uint16_t __wasi_eventrwflags_t;
1130
1131/**
1132 * The peer of this socket has closed or disconnected.
1133 */
1134#define __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP ((__wasi_eventrwflags_t)(1 << 0))
1135
1136/**
1137 * The contents of an `event` when type is `eventtype::fd_read` or
1138 * `eventtype::fd_write`.
1139 */
1140typedef struct __wasi_event_fd_readwrite_t {
1141 /**
1142 * The number of bytes available for reading or writing.
1143 */
1144 __wasi_filesize_t nbytes;
1145
1146 /**
1147 * The state of the file descriptor.
1148 */
1149 __wasi_eventrwflags_t flags;
1150
1151} __wasi_event_fd_readwrite_t;
1152
1153_Static_assert(sizeof(__wasi_event_fd_readwrite_t) == 16, "witx calculated size");
1154_Static_assert(_Alignof(__wasi_event_fd_readwrite_t) == 8, "witx calculated align");
1155_Static_assert(offsetof(__wasi_event_fd_readwrite_t, nbytes) == 0, "witx calculated offset");
1156_Static_assert(offsetof(__wasi_event_fd_readwrite_t, flags) == 8, "witx calculated offset");
1157
1158/**
1159 * An event that occurred.
1160 */
1161typedef struct __wasi_event_t {
1162 /**
1163 * User-provided value that got attached to `subscription::userdata`.
1164 */
1165 __wasi_userdata_t userdata;
1166
1167 /**
1168 * If non-zero, an error that occurred while processing the subscription request.
1169 */
1170 __wasi_errno_t error;
1171
1172 /**
1173 * The type of event that occured
1174 */
1175 __wasi_eventtype_t type;
1176
1177 /**
1178 * The contents of the event, if it is an `eventtype::fd_read` or
1179 * `eventtype::fd_write`. `eventtype::clock` events ignore this field.
1180 */
1181 __wasi_event_fd_readwrite_t fd_readwrite;
1182
1183} __wasi_event_t;
1184
1185_Static_assert(sizeof(__wasi_event_t) == 32, "witx calculated size");
1186_Static_assert(_Alignof(__wasi_event_t) == 8, "witx calculated align");
1187_Static_assert(offsetof(__wasi_event_t, userdata) == 0, "witx calculated offset");
1188_Static_assert(offsetof(__wasi_event_t, error) == 8, "witx calculated offset");
1189_Static_assert(offsetof(__wasi_event_t, type) == 10, "witx calculated offset");
1190_Static_assert(offsetof(__wasi_event_t, fd_readwrite) == 16, "witx calculated offset");
1191
1192/**
1193 * Flags determining how to interpret the timestamp provided in
1194 * `subscription_clock::timeout`.
1195 */
1196typedef uint16_t __wasi_subclockflags_t;
1197
1198/**
1199 * If set, treat the timestamp provided in
1200 * `subscription_clock::timeout` as an absolute timestamp of clock
1201 * `subscription_clock::id`. If clear, treat the timestamp
1202 * provided in `subscription_clock::timeout` relative to the
1203 * current time value of clock `subscription_clock::id`.
1204 */
1205#define __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME ((__wasi_subclockflags_t)(1 << 0))
1206
1207/**
1208 * The contents of a `subscription` when type is `eventtype::clock`.
1209 */
1210typedef struct __wasi_subscription_clock_t {
1211 /**
1212 * The clock against which to compare the timestamp.
1213 */
1214 __wasi_clockid_t id;
1215
1216 /**
1217 * The absolute or relative timestamp.
1218 */
1219 __wasi_timestamp_t timeout;
1220
1221 /**
1222 * The amount of time that the implementation may wait additionally
1223 * to coalesce with other events.
1224 */
1225 __wasi_timestamp_t precision;
1226
1227 /**
1228 * Flags specifying whether the timeout is absolute or relative
1229 */
1230 __wasi_subclockflags_t flags;
1231
1232} __wasi_subscription_clock_t;
1233
1234_Static_assert(sizeof(__wasi_subscription_clock_t) == 32, "witx calculated size");
1235_Static_assert(_Alignof(__wasi_subscription_clock_t) == 8, "witx calculated align");
1236_Static_assert(offsetof(__wasi_subscription_clock_t, id) == 0, "witx calculated offset");
1237_Static_assert(offsetof(__wasi_subscription_clock_t, timeout) == 8, "witx calculated offset");
1238_Static_assert(offsetof(__wasi_subscription_clock_t, precision) == 16, "witx calculated offset");
1239_Static_assert(offsetof(__wasi_subscription_clock_t, flags) == 24, "witx calculated offset");
1240
1241/**
1242 * The contents of a `subscription` when type is type is
1243 * `eventtype::fd_read` or `eventtype::fd_write`.
1244 */
1245typedef struct __wasi_subscription_fd_readwrite_t {
1246 /**
1247 * The file descriptor on which to wait for it to become ready for reading or writing.
1248 */
1249 __wasi_fd_t file_descriptor;
1250
1251} __wasi_subscription_fd_readwrite_t;
1252
1253_Static_assert(sizeof(__wasi_subscription_fd_readwrite_t) == 4, "witx calculated size");
1254_Static_assert(_Alignof(__wasi_subscription_fd_readwrite_t) == 4, "witx calculated align");
1255_Static_assert(offsetof(__wasi_subscription_fd_readwrite_t, file_descriptor) == 0, "witx calculated offset");
1256
1257/**
1258 * The contents of a `subscription`.
1259 */
1260typedef union __wasi_subscription_u_u_t {
1261 __wasi_subscription_clock_t clock;
1262 __wasi_subscription_fd_readwrite_t fd_read;
1263 __wasi_subscription_fd_readwrite_t fd_write;
1264} __wasi_subscription_u_u_t;
1265typedef struct __wasi_subscription_u_t {
1266 uint8_t tag;
1267 __wasi_subscription_u_u_t u;
1268} __wasi_subscription_u_t;
1269
1270_Static_assert(sizeof(__wasi_subscription_u_t) == 40, "witx calculated size");
1271_Static_assert(_Alignof(__wasi_subscription_u_t) == 8, "witx calculated align");
1272
1273/**
1274 * Subscription to an event.
1275 */
1276typedef struct __wasi_subscription_t {
1277 /**
1278 * User-provided value that is attached to the subscription in the
1279 * implementation and returned through `event::userdata`.
1280 */
1281 __wasi_userdata_t userdata;
1282
1283 /**
1284 * The type of the event to which to subscribe, and its contents
1285 */
1286 __wasi_subscription_u_t u;
1287
1288} __wasi_subscription_t;
1289
1290_Static_assert(sizeof(__wasi_subscription_t) == 48, "witx calculated size");
1291_Static_assert(_Alignof(__wasi_subscription_t) == 8, "witx calculated align");
1292_Static_assert(offsetof(__wasi_subscription_t, userdata) == 0, "witx calculated offset");
1293_Static_assert(offsetof(__wasi_subscription_t, u) == 8, "witx calculated offset");
1294
1295/**
1296 * Exit code generated by a process when exiting.
1297 */
1298typedef uint32_t __wasi_exitcode_t;
1299
1300_Static_assert(sizeof(__wasi_exitcode_t) == 4, "witx calculated size");
1301_Static_assert(_Alignof(__wasi_exitcode_t) == 4, "witx calculated align");
1302
1303/**
1304 * Signal condition.
1305 */
1306typedef uint8_t __wasi_signal_t;
1307
1308/**
1309 * No signal. Note that POSIX has special semantics for `kill(pid, 0)`,
1310 * so this value is reserved.
1311 */
1312#define __WASI_SIGNAL_NONE (UINT8_C(0))
1313
1314/**
1315 * Hangup.
1316 * Action: Terminates the process.
1317 */
1318#define __WASI_SIGNAL_HUP (UINT8_C(1))
1319
1320/**
1321 * Terminate interrupt signal.
1322 * Action: Terminates the process.
1323 */
1324#define __WASI_SIGNAL_INT (UINT8_C(2))
1325
1326/**
1327 * Terminal quit signal.
1328 * Action: Terminates the process.
1329 */
1330#define __WASI_SIGNAL_QUIT (UINT8_C(3))
1331
1332/**
1333 * Illegal instruction.
1334 * Action: Terminates the process.
1335 */
1336#define __WASI_SIGNAL_ILL (UINT8_C(4))
1337
1338/**
1339 * Trace/breakpoint trap.
1340 * Action: Terminates the process.
1341 */
1342#define __WASI_SIGNAL_TRAP (UINT8_C(5))
1343
1344/**
1345 * Process abort signal.
1346 * Action: Terminates the process.
1347 */
1348#define __WASI_SIGNAL_ABRT (UINT8_C(6))
1349
1350/**
1351 * Access to an undefined portion of a memory object.
1352 * Action: Terminates the process.
1353 */
1354#define __WASI_SIGNAL_BUS (UINT8_C(7))
1355
1356/**
1357 * Erroneous arithmetic operation.
1358 * Action: Terminates the process.
1359 */
1360#define __WASI_SIGNAL_FPE (UINT8_C(8))
1361
1362/**
1363 * Kill.
1364 * Action: Terminates the process.
1365 */
1366#define __WASI_SIGNAL_KILL (UINT8_C(9))
1367
1368/**
1369 * User-defined signal 1.
1370 * Action: Terminates the process.
1371 */
1372#define __WASI_SIGNAL_USR1 (UINT8_C(10))
1373
1374/**
1375 * Invalid memory reference.
1376 * Action: Terminates the process.
1377 */
1378#define __WASI_SIGNAL_SEGV (UINT8_C(11))
1379
1380/**
1381 * User-defined signal 2.
1382 * Action: Terminates the process.
1383 */
1384#define __WASI_SIGNAL_USR2 (UINT8_C(12))
1385
1386/**
1387 * Write on a pipe with no one to read it.
1388 * Action: Ignored.
1389 */
1390#define __WASI_SIGNAL_PIPE (UINT8_C(13))
1391
1392/**
1393 * Alarm clock.
1394 * Action: Terminates the process.
1395 */
1396#define __WASI_SIGNAL_ALRM (UINT8_C(14))
1397
1398/**
1399 * Termination signal.
1400 * Action: Terminates the process.
1401 */
1402#define __WASI_SIGNAL_TERM (UINT8_C(15))
1403
1404/**
1405 * Child process terminated, stopped, or continued.
1406 * Action: Ignored.
1407 */
1408#define __WASI_SIGNAL_CHLD (UINT8_C(16))
1409
1410/**
1411 * Continue executing, if stopped.
1412 * Action: Continues executing, if stopped.
1413 */
1414#define __WASI_SIGNAL_CONT (UINT8_C(17))
1415
1416/**
1417 * Stop executing.
1418 * Action: Stops executing.
1419 */
1420#define __WASI_SIGNAL_STOP (UINT8_C(18))
1421
1422/**
1423 * Terminal stop signal.
1424 * Action: Stops executing.
1425 */
1426#define __WASI_SIGNAL_TSTP (UINT8_C(19))
1427
1428/**
1429 * Background process attempting read.
1430 * Action: Stops executing.
1431 */
1432#define __WASI_SIGNAL_TTIN (UINT8_C(20))
1433
1434/**
1435 * Background process attempting write.
1436 * Action: Stops executing.
1437 */
1438#define __WASI_SIGNAL_TTOU (UINT8_C(21))
1439
1440/**
1441 * High bandwidth data is available at a socket.
1442 * Action: Ignored.
1443 */
1444#define __WASI_SIGNAL_URG (UINT8_C(22))
1445
1446/**
1447 * CPU time limit exceeded.
1448 * Action: Terminates the process.
1449 */
1450#define __WASI_SIGNAL_XCPU (UINT8_C(23))
1451
1452/**
1453 * File size limit exceeded.
1454 * Action: Terminates the process.
1455 */
1456#define __WASI_SIGNAL_XFSZ (UINT8_C(24))
1457
1458/**
1459 * Virtual timer expired.
1460 * Action: Terminates the process.
1461 */
1462#define __WASI_SIGNAL_VTALRM (UINT8_C(25))
1463
1464/**
1465 * Profiling timer expired.
1466 * Action: Terminates the process.
1467 */
1468#define __WASI_SIGNAL_PROF (UINT8_C(26))
1469
1470/**
1471 * Window changed.
1472 * Action: Ignored.
1473 */
1474#define __WASI_SIGNAL_WINCH (UINT8_C(27))
1475
1476/**
1477 * I/O possible.
1478 * Action: Terminates the process.
1479 */
1480#define __WASI_SIGNAL_POLL (UINT8_C(28))
1481
1482/**
1483 * Power failure.
1484 * Action: Terminates the process.
1485 */
1486#define __WASI_SIGNAL_PWR (UINT8_C(29))
1487
1488/**
1489 * Bad system call.
1490 * Action: Terminates the process.
1491 */
1492#define __WASI_SIGNAL_SYS (UINT8_C(30))
1493
1494_Static_assert(sizeof(__wasi_signal_t) == 1, "witx calculated size");
1495_Static_assert(_Alignof(__wasi_signal_t) == 1, "witx calculated align");
1496
1497/**
1498 * Flags provided to `sock_recv`.
1499 */
1500typedef uint16_t __wasi_riflags_t;
1501
1502/**
1503 * Returns the message without removing it from the socket's receive queue.
1504 */
1505#define __WASI_RIFLAGS_RECV_PEEK ((__wasi_riflags_t)(1 << 0))
1506
1507/**
1508 * On byte-stream sockets, block until the full amount of data can be returned.
1509 */
1510#define __WASI_RIFLAGS_RECV_WAITALL ((__wasi_riflags_t)(1 << 1))
1511
1512/**
1513 * Flags returned by `sock_recv`.
1514 */
1515typedef uint16_t __wasi_roflags_t;
1516
1517/**
1518 * Returned by `sock_recv`: Message data has been truncated.
1519 */
1520#define __WASI_ROFLAGS_RECV_DATA_TRUNCATED ((__wasi_roflags_t)(1 << 0))
1521
1522/**
1523 * Flags provided to `sock_send`. As there are currently no flags
1524 * defined, it must be set to zero.
1525 */
1526typedef uint16_t __wasi_siflags_t;
1527
1528_Static_assert(sizeof(__wasi_siflags_t) == 2, "witx calculated size");
1529_Static_assert(_Alignof(__wasi_siflags_t) == 2, "witx calculated align");
1530
1531/**
1532 * Which channels on a socket to shut down.
1533 */
1534typedef uint8_t __wasi_sdflags_t;
1535
1536/**
1537 * Disables further receive operations.
1538 */
1539#define __WASI_SDFLAGS_RD ((__wasi_sdflags_t)(1 << 0))
1540
1541/**
1542 * Disables further send operations.
1543 */
1544#define __WASI_SDFLAGS_WR ((__wasi_sdflags_t)(1 << 1))
1545
1546/**
1547 * Identifiers for preopened capabilities.
1548 */
1549typedef uint8_t __wasi_preopentype_t;
1550
1551/**
1552 * A pre-opened directory.
1553 */
1554#define __WASI_PREOPENTYPE_DIR (UINT8_C(0))
1555
1556_Static_assert(sizeof(__wasi_preopentype_t) == 1, "witx calculated size");
1557_Static_assert(_Alignof(__wasi_preopentype_t) == 1, "witx calculated align");
1558
1559/**
1560 * The contents of a $prestat when type is `preopentype::dir`.
1561 */
1562typedef struct __wasi_prestat_dir_t {
1563 /**
1564 * The length of the directory name for use with `fd_prestat_dir_name`.
1565 */
1566 __wasi_size_t pr_name_len;
1567
1568} __wasi_prestat_dir_t;
1569
1570_Static_assert(sizeof(__wasi_prestat_dir_t) == 4, "witx calculated size");
1571_Static_assert(_Alignof(__wasi_prestat_dir_t) == 4, "witx calculated align");
1572_Static_assert(offsetof(__wasi_prestat_dir_t, pr_name_len) == 0, "witx calculated offset");
1573
1574/**
1575 * Information about a pre-opened capability.
1576 */
1577typedef union __wasi_prestat_u_t {
1578 __wasi_prestat_dir_t dir;
1579} __wasi_prestat_u_t;
1580typedef struct __wasi_prestat_t {
1581 uint8_t tag;
1582 __wasi_prestat_u_t u;
1583} __wasi_prestat_t;
1584
1585_Static_assert(sizeof(__wasi_prestat_t) == 8, "witx calculated size");
1586_Static_assert(_Alignof(__wasi_prestat_t) == 4, "witx calculated align");
1587
1588/**
1589 * @defgroup wasi_snapshot_preview1
1590 * @{
1591 */
1592
1593/**
1594 * Read command-line argument data.
1595 * The size of the array should match that returned by `args_sizes_get`
1596 */
1597__wasi_errno_t __wasi_args_get(
1598 uint8_t * * argv,
1599 uint8_t * argv_buf
1600) __attribute__((__warn_unused_result__));
1601/**
1602 * Return command-line argument data sizes.
1603 * @return
1604 * Returns the number of arguments and the size of the argument string
1605 * data, or an error.
1606 */
1607__wasi_errno_t __wasi_args_sizes_get(
1608 __wasi_size_t *retptr0,
1609 __wasi_size_t *retptr1
1610) __attribute__((__warn_unused_result__));
1611/**
1612 * Read environment variable data.
1613 * The sizes of the buffers should match that returned by `environ_sizes_get`.
1614 */
1615__wasi_errno_t __wasi_environ_get(
1616 uint8_t * * environ,
1617 uint8_t * environ_buf
1618) __attribute__((__warn_unused_result__));
1619/**
1620 * Return environment variable data sizes.
1621 * @return
1622 * Returns the number of environment variable arguments and the size of the
1623 * environment variable data.
1624 */
1625__wasi_errno_t __wasi_environ_sizes_get(
1626 __wasi_size_t *retptr0,
1627 __wasi_size_t *retptr1
1628) __attribute__((__warn_unused_result__));
1629/**
1630 * Return the resolution of a clock.
1631 * Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks,
1632 * return `errno::inval`.
1633 * Note: This is similar to `clock_getres` in POSIX.
1634 * @return
1635 * The resolution of the clock, or an error if one happened.
1636 */
1637__wasi_errno_t __wasi_clock_res_get(
1638 /**
1639 * The clock for which to return the resolution.
1640 */
1641 __wasi_clockid_t id,
1642 __wasi_timestamp_t *retptr0
1643) __attribute__((__warn_unused_result__));
1644/**
1645 * Return the time value of a clock.
1646 * Note: This is similar to `clock_gettime` in POSIX.
1647 * @return
1648 * The time value of the clock.
1649 */
1650__wasi_errno_t __wasi_clock_time_get(
1651 /**
1652 * The clock for which to return the time.
1653 */
1654 __wasi_clockid_t id,
1655 /**
1656 * The maximum lag (exclusive) that the returned time value may have, compared to its actual value.
1657 */
1658 __wasi_timestamp_t precision,
1659 __wasi_timestamp_t *retptr0
1660) __attribute__((__warn_unused_result__));
1661/**
1662 * Provide file advisory information on a file descriptor.
1663 * Note: This is similar to `posix_fadvise` in POSIX.
1664 */
1665__wasi_errno_t __wasi_fd_advise(
1666 __wasi_fd_t fd,
1667 /**
1668 * The offset within the file to which the advisory applies.
1669 */
1670 __wasi_filesize_t offset,
1671 /**
1672 * The length of the region to which the advisory applies.
1673 */
1674 __wasi_filesize_t len,
1675 /**
1676 * The advice.
1677 */
1678 __wasi_advice_t advice
1679) __attribute__((__warn_unused_result__));
1680/**
1681 * Force the allocation of space in a file.
1682 * Note: This is similar to `posix_fallocate` in POSIX.
1683 */
1684__wasi_errno_t __wasi_fd_allocate(
1685 __wasi_fd_t fd,
1686 /**
1687 * The offset at which to start the allocation.
1688 */
1689 __wasi_filesize_t offset,
1690 /**
1691 * The length of the area that is allocated.
1692 */
1693 __wasi_filesize_t len
1694) __attribute__((__warn_unused_result__));
1695/**
1696 * Close a file descriptor.
1697 * Note: This is similar to `close` in POSIX.
1698 */
1699__wasi_errno_t __wasi_fd_close(
1700 __wasi_fd_t fd
1701) __attribute__((__warn_unused_result__));
1702/**
1703 * Synchronize the data of a file to disk.
1704 * Note: This is similar to `fdatasync` in POSIX.
1705 */
1706__wasi_errno_t __wasi_fd_datasync(
1707 __wasi_fd_t fd
1708) __attribute__((__warn_unused_result__));
1709/**
1710 * Get the attributes of a file descriptor.
1711 * Note: This returns similar flags to `fsync(fd, F_GETFL)` in POSIX, as well as additional fields.
1712 * @return
1713 * The buffer where the file descriptor's attributes are stored.
1714 */
1715__wasi_errno_t __wasi_fd_fdstat_get(
1716 __wasi_fd_t fd,
1717 __wasi_fdstat_t *retptr0
1718) __attribute__((__warn_unused_result__));
1719/**
1720 * Adjust the flags associated with a file descriptor.
1721 * Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX.
1722 */
1723__wasi_errno_t __wasi_fd_fdstat_set_flags(
1724 __wasi_fd_t fd,
1725 /**
1726 * The desired values of the file descriptor flags.
1727 */
1728 __wasi_fdflags_t flags
1729) __attribute__((__warn_unused_result__));
1730/**
1731 * Adjust the rights associated with a file descriptor.
1732 * This can only be used to remove rights, and returns `errno::notcapable` if called in a way that would attempt to add rights
1733 */
1734__wasi_errno_t __wasi_fd_fdstat_set_rights(
1735 __wasi_fd_t fd,
1736 /**
1737 * The desired rights of the file descriptor.
1738 */
1739 __wasi_rights_t fs_rights_base,
1740 __wasi_rights_t fs_rights_inheriting
1741) __attribute__((__warn_unused_result__));
1742/**
1743 * Return the attributes of an open file.
1744 * @return
1745 * The buffer where the file's attributes are stored.
1746 */
1747__wasi_errno_t __wasi_fd_filestat_get(
1748 __wasi_fd_t fd,
1749 __wasi_filestat_t *retptr0
1750) __attribute__((__warn_unused_result__));
1751/**
1752 * Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.
1753 * Note: This is similar to `ftruncate` in POSIX.
1754 */
1755__wasi_errno_t __wasi_fd_filestat_set_size(
1756 __wasi_fd_t fd,
1757 /**
1758 * The desired file size.
1759 */
1760 __wasi_filesize_t size
1761) __attribute__((__warn_unused_result__));
1762/**
1763 * Adjust the timestamps of an open file or directory.
1764 * Note: This is similar to `futimens` in POSIX.
1765 */
1766__wasi_errno_t __wasi_fd_filestat_set_times(
1767 __wasi_fd_t fd,
1768 /**
1769 * The desired values of the data access timestamp.
1770 */
1771 __wasi_timestamp_t atim,
1772 /**
1773 * The desired values of the data modification timestamp.
1774 */
1775 __wasi_timestamp_t mtim,
1776 /**
1777 * A bitmask indicating which timestamps to adjust.
1778 */
1779 __wasi_fstflags_t fst_flags
1780) __attribute__((__warn_unused_result__));
1781/**
1782 * Read from a file descriptor, without using and updating the file descriptor's offset.
1783 * Note: This is similar to `preadv` in POSIX.
1784 * @return
1785 * The number of bytes read.
1786 */
1787__wasi_errno_t __wasi_fd_pread(
1788 __wasi_fd_t fd,
1789 /**
1790 * List of scatter/gather vectors in which to store data.
1791 */
1792 const __wasi_iovec_t *iovs,
1793 /**
1794 * The length of the array pointed to by `iovs`.
1795 */
1796 size_t iovs_len,
1797 /**
1798 * The offset within the file at which to read.
1799 */
1800 __wasi_filesize_t offset,
1801 __wasi_size_t *retptr0
1802) __attribute__((__warn_unused_result__));
1803/**
1804 * Return a description of the given preopened file descriptor.
1805 * @return
1806 * The buffer where the description is stored.
1807 */
1808__wasi_errno_t __wasi_fd_prestat_get(
1809 __wasi_fd_t fd,
1810 __wasi_prestat_t *retptr0
1811) __attribute__((__warn_unused_result__));
1812/**
1813 * Return a description of the given preopened file descriptor.
1814 */
1815__wasi_errno_t __wasi_fd_prestat_dir_name(
1816 __wasi_fd_t fd,
1817 /**
1818 * A buffer into which to write the preopened directory name.
1819 */
1820 uint8_t * path,
1821 __wasi_size_t path_len
1822) __attribute__((__warn_unused_result__));
1823/**
1824 * Write to a file descriptor, without using and updating the file descriptor's offset.
1825 * Note: This is similar to `pwritev` in POSIX.
1826 * @return
1827 * The number of bytes written.
1828 */
1829__wasi_errno_t __wasi_fd_pwrite(
1830 __wasi_fd_t fd,
1831 /**
1832 * List of scatter/gather vectors from which to retrieve data.
1833 */
1834 const __wasi_ciovec_t *iovs,
1835 /**
1836 * The length of the array pointed to by `iovs`.
1837 */
1838 size_t iovs_len,
1839 /**
1840 * The offset within the file at which to write.
1841 */
1842 __wasi_filesize_t offset,
1843 __wasi_size_t *retptr0
1844) __attribute__((__warn_unused_result__));
1845/**
1846 * Read from a file descriptor.
1847 * Note: This is similar to `readv` in POSIX.
1848 * @return
1849 * The number of bytes read.
1850 */
1851__wasi_errno_t __wasi_fd_read(
1852 __wasi_fd_t fd,
1853 /**
1854 * List of scatter/gather vectors to which to store data.
1855 */
1856 const __wasi_iovec_t *iovs,
1857 /**
1858 * The length of the array pointed to by `iovs`.
1859 */
1860 size_t iovs_len,
1861 __wasi_size_t *retptr0
1862) __attribute__((__warn_unused_result__));
1863/**
1864 * Read directory entries from a directory.
1865 * When successful, the contents of the output buffer consist of a sequence of
1866 * directory entries. Each directory entry consists of a `dirent` object,
1867 * followed by `dirent::d_namlen` bytes holding the name of the directory
1868 * entry.
1869 * This function fills the output buffer as much as possible, potentially
1870 * truncating the last directory entry. This allows the caller to grow its
1871 * read buffer size in case it's too small to fit a single large directory
1872 * entry, or skip the oversized directory entry.
1873 * @return
1874 * The number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached.
1875 */
1876__wasi_errno_t __wasi_fd_readdir(
1877 __wasi_fd_t fd,
1878 /**
1879 * The buffer where directory entries are stored
1880 */
1881 uint8_t * buf,
1882 __wasi_size_t buf_len,
1883 /**
1884 * The location within the directory to start reading
1885 */
1886 __wasi_dircookie_t cookie,
1887 __wasi_size_t *retptr0
1888) __attribute__((__warn_unused_result__));
1889/**
1890 * Atomically replace a file descriptor by renumbering another file descriptor.
1891 * Due to the strong focus on thread safety, this environment does not provide
1892 * a mechanism to duplicate or renumber a file descriptor to an arbitrary
1893 * number, like `dup2()`. This would be prone to race conditions, as an actual
1894 * file descriptor with the same number could be allocated by a different
1895 * thread at the same time.
1896 * This function provides a way to atomically renumber file descriptors, which
1897 * would disappear if `dup2()` were to be removed entirely.
1898 */
1899__wasi_errno_t __wasi_fd_renumber(
1900 __wasi_fd_t fd,
1901 /**
1902 * The file descriptor to overwrite.
1903 */
1904 __wasi_fd_t to
1905) __attribute__((__warn_unused_result__));
1906/**
1907 * Move the offset of a file descriptor.
1908 * Note: This is similar to `lseek` in POSIX.
1909 * @return
1910 * The new offset of the file descriptor, relative to the start of the file.
1911 */
1912__wasi_errno_t __wasi_fd_seek(
1913 __wasi_fd_t fd,
1914 /**
1915 * The number of bytes to move.
1916 */
1917 __wasi_filedelta_t offset,
1918 /**
1919 * The base from which the offset is relative.
1920 */
1921 __wasi_whence_t whence,
1922 __wasi_filesize_t *retptr0
1923) __attribute__((__warn_unused_result__));
1924/**
1925 * Synchronize the data and metadata of a file to disk.
1926 * Note: This is similar to `fsync` in POSIX.
1927 */
1928__wasi_errno_t __wasi_fd_sync(
1929 __wasi_fd_t fd
1930) __attribute__((__warn_unused_result__));
1931/**
1932 * Return the current offset of a file descriptor.
1933 * Note: This is similar to `lseek(fd, 0, SEEK_CUR)` in POSIX.
1934 * @return
1935 * The current offset of the file descriptor, relative to the start of the file.
1936 */
1937__wasi_errno_t __wasi_fd_tell(
1938 __wasi_fd_t fd,
1939 __wasi_filesize_t *retptr0
1940) __attribute__((__warn_unused_result__));
1941/**
1942 * Write to a file descriptor.
1943 * Note: This is similar to `writev` in POSIX.
1944 */
1945__wasi_errno_t __wasi_fd_write(
1946 __wasi_fd_t fd,
1947 /**
1948 * List of scatter/gather vectors from which to retrieve data.
1949 */
1950 const __wasi_ciovec_t *iovs,
1951 /**
1952 * The length of the array pointed to by `iovs`.
1953 */
1954 size_t iovs_len,
1955 __wasi_size_t *retptr0
1956) __attribute__((__warn_unused_result__));
1957/**
1958 * Create a directory.
1959 * Note: This is similar to `mkdirat` in POSIX.
1960 */
1961__wasi_errno_t __wasi_path_create_directory(
1962 __wasi_fd_t fd,
1963 /**
1964 * The path at which to create the directory.
1965 */
1966 const char *path
1967) __attribute__((__warn_unused_result__));
1968/**
1969 * Return the attributes of a file or directory.
1970 * Note: This is similar to `stat` in POSIX.
1971 * @return
1972 * The buffer where the file's attributes are stored.
1973 */
1974__wasi_errno_t __wasi_path_filestat_get(
1975 __wasi_fd_t fd,
1976 /**
1977 * Flags determining the method of how the path is resolved.
1978 */
1979 __wasi_lookupflags_t flags,
1980 /**
1981 * The path of the file or directory to inspect.
1982 */
1983 const char *path,
1984 __wasi_filestat_t *retptr0
1985) __attribute__((__warn_unused_result__));
1986/**
1987 * Adjust the timestamps of a file or directory.
1988 * Note: This is similar to `utimensat` in POSIX.
1989 */
1990__wasi_errno_t __wasi_path_filestat_set_times(
1991 __wasi_fd_t fd,
1992 /**
1993 * Flags determining the method of how the path is resolved.
1994 */
1995 __wasi_lookupflags_t flags,
1996 /**
1997 * The path of the file or directory to operate on.
1998 */
1999 const char *path,
2000 /**
2001 * The desired values of the data access timestamp.
2002 */
2003 __wasi_timestamp_t atim,
2004 /**
2005 * The desired values of the data modification timestamp.
2006 */
2007 __wasi_timestamp_t mtim,
2008 /**
2009 * A bitmask indicating which timestamps to adjust.
2010 */
2011 __wasi_fstflags_t fst_flags
2012) __attribute__((__warn_unused_result__));
2013/**
2014 * Create a hard link.
2015 * Note: This is similar to `linkat` in POSIX.
2016 */
2017__wasi_errno_t __wasi_path_link(
2018 __wasi_fd_t old_fd,
2019 /**
2020 * Flags determining the method of how the path is resolved.
2021 */
2022 __wasi_lookupflags_t old_flags,
2023 /**
2024 * The source path from which to link.
2025 */
2026 const char *old_path,
2027 /**
2028 * The working directory at which the resolution of the new path starts.
2029 */
2030 __wasi_fd_t new_fd,
2031 /**
2032 * The destination path at which to create the hard link.
2033 */
2034 const char *new_path
2035) __attribute__((__warn_unused_result__));
2036/**
2037 * Open a file or directory.
2038 * The returned file descriptor is not guaranteed to be the lowest-numbered
2039 * file descriptor not currently open; it is randomized to prevent
2040 * applications from depending on making assumptions about indexes, since this
2041 * is error-prone in multi-threaded contexts. The returned file descriptor is
2042 * guaranteed to be less than 2**31.
2043 * Note: This is similar to `openat` in POSIX.
2044 * @return
2045 * The file descriptor of the file that has been opened.
2046 */
2047__wasi_errno_t __wasi_path_open(
2048 __wasi_fd_t fd,
2049 /**
2050 * Flags determining the method of how the path is resolved.
2051 */
2052 __wasi_lookupflags_t dirflags,
2053 /**
2054 * The relative path of the file or directory to open, relative to the
2055 * `path_open::fd` directory.
2056 */
2057 const char *path,
2058 /**
2059 * The method by which to open the file.
2060 */
2061 __wasi_oflags_t oflags,
2062 /**
2063 * The initial rights of the newly created file descriptor. The
2064 * implementation is allowed to return a file descriptor with fewer rights
2065 * than specified, if and only if those rights do not apply to the type of
2066 * file being opened.
2067 * The *base* rights are rights that will apply to operations using the file
2068 * descriptor itself, while the *inheriting* rights are rights that apply to
2069 * file descriptors derived from it.
2070 */
2071 __wasi_rights_t fs_rights_base,
2072 __wasi_rights_t fs_rights_inheriting,
2073 __wasi_fdflags_t fdflags,
2074 __wasi_fd_t *retptr0
2075) __attribute__((__warn_unused_result__));
2076/**
2077 * Read the contents of a symbolic link.
2078 * Note: This is similar to `readlinkat` in POSIX.
2079 * @return
2080 * The number of bytes placed in the buffer.
2081 */
2082__wasi_errno_t __wasi_path_readlink(
2083 __wasi_fd_t fd,
2084 /**
2085 * The path of the symbolic link from which to read.
2086 */
2087 const char *path,
2088 /**
2089 * The buffer to which to write the contents of the symbolic link.
2090 */
2091 uint8_t * buf,
2092 __wasi_size_t buf_len,
2093 __wasi_size_t *retptr0
2094) __attribute__((__warn_unused_result__));
2095/**
2096 * Remove a directory.
2097 * Return `errno::notempty` if the directory is not empty.
2098 * Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
2099 */
2100__wasi_errno_t __wasi_path_remove_directory(
2101 __wasi_fd_t fd,
2102 /**
2103 * The path to a directory to remove.
2104 */
2105 const char *path
2106) __attribute__((__warn_unused_result__));
2107/**
2108 * Rename a file or directory.
2109 * Note: This is similar to `renameat` in POSIX.
2110 */
2111__wasi_errno_t __wasi_path_rename(
2112 __wasi_fd_t fd,
2113 /**
2114 * The source path of the file or directory to rename.
2115 */
2116 const char *old_path,
2117 /**
2118 * The working directory at which the resolution of the new path starts.
2119 */
2120 __wasi_fd_t new_fd,
2121 /**
2122 * The destination path to which to rename the file or directory.
2123 */
2124 const char *new_path
2125) __attribute__((__warn_unused_result__));
2126/**
2127 * Create a symbolic link.
2128 * Note: This is similar to `symlinkat` in POSIX.
2129 */
2130__wasi_errno_t __wasi_path_symlink(
2131 /**
2132 * The contents of the symbolic link.
2133 */
2134 const char *old_path,
2135 __wasi_fd_t fd,
2136 /**
2137 * The destination path at which to create the symbolic link.
2138 */
2139 const char *new_path
2140) __attribute__((__warn_unused_result__));
2141/**
2142 * Unlink a file.
2143 * Return `errno::isdir` if the path refers to a directory.
2144 * Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
2145 */
2146__wasi_errno_t __wasi_path_unlink_file(
2147 __wasi_fd_t fd,
2148 /**
2149 * The path to a file to unlink.
2150 */
2151 const char *path
2152) __attribute__((__warn_unused_result__));
2153/**
2154 * Concurrently poll for the occurrence of a set of events.
2155 * @return
2156 * The number of events stored.
2157 */
2158__wasi_errno_t __wasi_poll_oneoff(
2159 /**
2160 * The events to which to subscribe.
2161 */
2162 const __wasi_subscription_t * in,
2163 /**
2164 * The events that have occurred.
2165 */
2166 __wasi_event_t * out,
2167 /**
2168 * Both the number of subscriptions and events.
2169 */
2170 __wasi_size_t nsubscriptions,
2171 __wasi_size_t *retptr0
2172) __attribute__((__warn_unused_result__));
2173/**
2174 * Terminate the process normally. An exit code of 0 indicates successful
2175 * termination of the program. The meanings of other values is dependent on
2176 * the environment.
2177 */
2178_Noreturn void __wasi_proc_exit(
2179 /**
2180 * The exit code returned by the process.
2181 */
2182 __wasi_exitcode_t rval
2183);
2184/**
2185 * Send a signal to the process of the calling thread.
2186 * Note: This is similar to `raise` in POSIX.
2187 */
2188__wasi_errno_t __wasi_proc_raise(
2189 /**
2190 * The signal condition to trigger.
2191 */
2192 __wasi_signal_t sig
2193) __attribute__((__warn_unused_result__));
2194/**
2195 * Temporarily yield execution of the calling thread.
2196 * Note: This is similar to `sched_yield` in POSIX.
2197 */
2198__wasi_errno_t __wasi_sched_yield(
2199 void
2200) __attribute__((__warn_unused_result__));
2201/**
2202 * Write high-quality random data into a buffer.
2203 * This function blocks when the implementation is unable to immediately
2204 * provide sufficient high-quality random data.
2205 * This function may execute slowly, so when large mounts of random data are
2206 * required, it's advisable to use this function to seed a pseudo-random
2207 * number generator, rather than to provide the random data directly.
2208 */
2209__wasi_errno_t __wasi_random_get(
2210 /**
2211 * The buffer to fill with random data.
2212 */
2213 uint8_t * buf,
2214 __wasi_size_t buf_len
2215) __attribute__((__warn_unused_result__));
2216/**
2217 * Receive a message from a socket.
2218 * Note: This is similar to `recv` in POSIX, though it also supports reading
2219 * the data into multiple buffers in the manner of `readv`.
2220 * @return
2221 * Number of bytes stored in ri_data and message flags.
2222 */
2223__wasi_errno_t __wasi_sock_recv(
2224 __wasi_fd_t fd,
2225 /**
2226 * List of scatter/gather vectors to which to store data.
2227 */
2228 const __wasi_iovec_t *ri_data,
2229 /**
2230 * The length of the array pointed to by `ri_data`.
2231 */
2232 size_t ri_data_len,
2233 /**
2234 * Message flags.
2235 */
2236 __wasi_riflags_t ri_flags,
2237 __wasi_size_t *retptr0,
2238 __wasi_roflags_t *retptr1
2239) __attribute__((__warn_unused_result__));
2240/**
2241 * Send a message on a socket.
2242 * Note: This is similar to `send` in POSIX, though it also supports writing
2243 * the data from multiple buffers in the manner of `writev`.
2244 * @return
2245 * Number of bytes transmitted.
2246 */
2247__wasi_errno_t __wasi_sock_send(
2248 __wasi_fd_t fd,
2249 /**
2250 * List of scatter/gather vectors to which to retrieve data
2251 */
2252 const __wasi_ciovec_t *si_data,
2253 /**
2254 * The length of the array pointed to by `si_data`.
2255 */
2256 size_t si_data_len,
2257 /**
2258 * Message flags.
2259 */
2260 __wasi_siflags_t si_flags,
2261 __wasi_size_t *retptr0
2262) __attribute__((__warn_unused_result__));
2263/**
2264 * Shut down socket send and receive channels.
2265 * Note: This is similar to `shutdown` in POSIX.
2266 */
2267__wasi_errno_t __wasi_sock_shutdown(
2268 __wasi_fd_t fd,
2269 /**
2270 * Which channels on the socket to shut down.
2271 */
2272 __wasi_sdflags_t how
2273) __attribute__((__warn_unused_result__));
2274/** @} */
2275
2276#ifdef __cplusplus
2277}
2278#endif
2279
2280#endif
lib/libc/include/wasm-wasi-musl/wasi/libc-environ.h created+19
......@@ -0,0 +1,19 @@
1#ifndef __wasi_libc_environ_h
2#define __wasi_libc_environ_h
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8/// Initialize the global environment variable state. Only needs to be
9/// called once; most users should call `__wasilibc_ensure_environ` instead.
10void __wasilibc_initialize_environ(void);
11
12/// If `__wasilibc_initialize_environ` has not yet been called, call it.
13void __wasilibc_ensure_environ(void);
14
15#ifdef __cplusplus
16}
17#endif
18
19#endif
lib/libc/include/wasm-wasi-musl/wasi/libc-find-relpath.h created+79
......@@ -0,0 +1,79 @@
1#ifndef __wasi_libc_find_relpath_h
2#define __wasi_libc_find_relpath_h
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8/**
9 * Look up the given `path`, relative to the cwd, in the preopened directory
10 * map. If a suitable entry is found, then the file descriptor for that entry
11 * is returned. Additionally the absolute path of the directory's file
12 * descriptor is returned in `abs_prefix` and the relative portion that needs
13 * to be opened is stored in `*relative_path`.
14 *
15 * The `relative_path` argument must be a pointer to a buffer valid for
16 * `relative_path_len` bytes, and this may be used as storage for the relative
17 * portion of the path being returned through `*relative_path`.
18 *
19 * See documentation on `__wasilibc_find_abspath` for more info about what the
20 * paths look like.
21 *
22 * Returns -1 on failure. Errno is set to either:
23 *
24 * * ENOMEM - failed to allocate memory for internal routines.
25 * * ENOENT - the `path` could not be found relative to any preopened dir.
26 * * ERANGE - the `relative_path` buffer is too small to hold the relative path.
27 */
28int __wasilibc_find_relpath(const char *path,
29 const char **__restrict__ abs_prefix,
30 char **relative_path,
31 size_t relative_path_len);
32
33/**
34 * Look up the given `path`, which is interpreted as absolute, in the preopened
35 * directory map. If a suitable entry is found, then the file descriptor for
36 * that entry is returned. Additionally the relative portion of the path to
37 * where the fd is opened is returned through `relative_path`, the absolute
38 * prefix which was matched is stored to `abs_prefix`, and `relative_path` may
39 * be an interior pointer to the `abspath` string.
40 *
41 * The `abs_prefix` returned string will not contain a leading `/`. Note that
42 * this may be the empty string. Additionally the returned `relative_path` will
43 * not contain a leading `/`. The `relative_path` return will not return an
44 * empty string, it will return `"."` instead if it would otherwise do so.
45 *
46 * Returns -1 on failure. Errno is set to either:
47 *
48 * * ENOMEM - failed to allocate memory for internal routines.
49 * * ENOENT - the `path` could not be found relative to any preopened dir.
50 */
51int __wasilibc_find_abspath(const char *abspath,
52 const char **__restrict__ abs_prefix,
53 const char **__restrict__ relative_path);
54
55/**
56 * Same as `__wasilibc_find_relpath`, except that this function will interpret
57 * `relative` as a malloc'd buffer that will be `realloc`'d to the appropriate
58 * size to contain the relative path.
59 *
60 * Note that this is a weak symbol and if it's not defined you can use
61 * `__wasilibc_find_relpath`. The weak-nature of this symbols means that if it's
62 * not otherwise included in the compilation then `chdir` wasn't used an there's
63 * no need for this symbol.
64 *
65 * See documentation on `__wasilibc_find_relpath` for more information.
66 */
67int __wasilibc_find_relpath_alloc(
68 const char *path,
69 const char **abs,
70 char **relative,
71 size_t *relative_len,
72 int can_realloc
73) __attribute__((weak));
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif
lib/libc/include/wasm-wasi-musl/wasi/libc-nocwd.h created+58
......@@ -0,0 +1,58 @@
1#ifndef __wasi_libc_nocwd_h
2#define __wasi_libc_nocwd_h
3
4/*
5 * In order to support AT_FDCWD, we need to wrap the *at functions to handle
6 * it by calling back into the non-at versions which perform libpreopen
7 * queries. These __wasilibc_nocwd_* forms are the underlying calls which
8 * assume AT_FDCWD has already been resolved.
9 */
10
11#define __need_size_t
12#include <stddef.h>
13#include <__typedef_ssize_t.h>
14#include <__typedef_mode_t.h>
15#include <__typedef_DIR.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21struct timespec;
22struct stat;
23struct dirent;
24
25int __wasilibc_nocwd___wasilibc_unlinkat(int, const char *)
26 __attribute__((__warn_unused_result__));
27int __wasilibc_nocwd___wasilibc_rmdirat(int, const char *)
28 __attribute__((__warn_unused_result__));
29int __wasilibc_nocwd_linkat(int, const char *, int, const char *, int)
30 __attribute__((__warn_unused_result__));
31int __wasilibc_nocwd_symlinkat(const char *, int, const char *)
32 __attribute__((__warn_unused_result__));
33ssize_t __wasilibc_nocwd_readlinkat(int, const char *__restrict, char *__restrict, size_t)
34 __attribute__((__warn_unused_result__));
35int __wasilibc_nocwd_faccessat(int, const char *, int, int)
36 __attribute__((__warn_unused_result__));
37int __wasilibc_nocwd_renameat(int, const char *, int, const char *)
38 __attribute__((__warn_unused_result__));
39int __wasilibc_nocwd_openat_nomode(int, const char *, int)
40 __attribute__((__warn_unused_result__));
41int __wasilibc_nocwd_fstatat(int, const char *__restrict, struct stat *__restrict, int)
42 __attribute__((__warn_unused_result__));
43int __wasilibc_nocwd_mkdirat_nomode(int, const char *)
44 __attribute__((__warn_unused_result__));
45int __wasilibc_nocwd_utimensat(int, const char *, const struct timespec [2], int)
46 __attribute__((__warn_unused_result__));
47DIR *__wasilibc_nocwd_opendirat(int, const char *)
48 __attribute__((__warn_unused_result__));
49int __wasilibc_nocwd_scandirat(int, const char *, struct dirent ***,
50 int (*)(const struct dirent *),
51 int (*)(const struct dirent **, const struct dirent **))
52 __attribute__((__warn_unused_result__));
53
54#ifdef __cplusplus
55}
56#endif
57
58#endif
lib/libc/include/wasm-wasi-musl/wasi/libc.h created+65
......@@ -0,0 +1,65 @@
1#ifndef __wasi_libc_h
2#define __wasi_libc_h
3
4#include <__typedef_off_t.h>
5#include <__struct_timespec.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11struct stat;
12struct timespec;
13
14/// Register the given pre-opened file descriptor under the given path.
15///
16/// This function does not take ownership of `prefix` (it makes its own copy).
17int __wasilibc_register_preopened_fd(int fd, const char *prefix);
18
19/// Renumber `fd` to `newfd`; similar to `dup2` but does a move rather than a
20/// copy.
21int __wasilibc_fd_renumber(int fd, int newfd)
22 __attribute__((__warn_unused_result__));
23
24/// Like `unlinkat`, but without depending on `__wasi_path_remove_directory`.
25int __wasilibc_unlinkat(int fd, const char *path)
26 __attribute__((__warn_unused_result__));
27
28/// An `*at` version of rmdir.
29int __wasilibc_rmdirat(int fd, const char *path)
30 __attribute__((__warn_unused_result__));
31
32/// Like `open`, but without the varargs in the signature.
33int __wasilibc_open_nomode(const char *path, int oflag);
34
35/// Like `openat`, but without the varargs in the signature.
36int __wasilibc_openat_nomode(int fd, const char *path, int oflag);
37
38/// Return the current file offset. Like `lseek(fd, 0, SEEK_CUR)`, but without
39/// depending on `lseek`.
40off_t __wasilibc_tell(int fd)
41 __attribute__((__warn_unused_result__));
42
43/* Non-`at` forms of various `*at` functions. */
44int __wasilibc_access(const char *pathname, int mode, int flags)
45 __attribute__((__warn_unused_result__));
46int __wasilibc_stat(const char *__restrict pathname, struct stat *__restrict statbuf, int flags)
47 __attribute__((__warn_unused_result__));
48int __wasilibc_utimens(const char *pathname, const struct timespec times[2], int flags)
49 __attribute__((__warn_unused_result__));
50int __wasilibc_link(const char *oldpath, const char *newpath, int flags)
51 __attribute__((__warn_unused_result__));
52int __wasilibc_link_oldat(int olddirfd, const char *oldpath, const char *newpath, int flags)
53 __attribute__((__warn_unused_result__));
54int __wasilibc_link_newat(const char *oldpath, int newdirfd, const char *newpath, int flags)
55 __attribute__((__warn_unused_result__));
56int __wasilibc_rename_oldat(int olddirfd, const char *oldpath, const char *newpath)
57 __attribute__((__warn_unused_result__));
58int __wasilibc_rename_newat(const char *oldpath, int newdirfd, const char *newpath)
59 __attribute__((__warn_unused_result__));
60
61#ifdef __cplusplus
62}
63#endif
64
65#endif
lib/libc/include/wasm-wasi-musl/wchar.h created+212
......@@ -0,0 +1,212 @@
1#ifndef _WCHAR_H
2#define _WCHAR_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_FILE
11#define __NEED___isoc_va_list
12#define __NEED_size_t
13#define __NEED_wchar_t
14#define __NEED_wint_t
15#define __NEED_mbstate_t
16
17#ifdef __wasilibc_unmodified_upstream /* WASI doesn't need to define FILE as a complete type */
18#if __STDC_VERSION__ < 201112L
19#define __NEED_struct__IO_FILE
20#endif
21#endif
22
23#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
24 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
25#define __NEED_locale_t
26#define __NEED_va_list
27#endif
28
29#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
30#define __NEED_wctype_t
31#endif
32
33#include <bits/alltypes.h>
34
35#if L'\0'-1 > 0
36#define WCHAR_MAX (0xffffffffu+L'\0')
37#define WCHAR_MIN (0+L'\0')
38#else
39#define WCHAR_MAX (0x7fffffff+L'\0')
40#define WCHAR_MIN (-1-0x7fffffff+L'\0')
41#endif
42
43#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
44#ifdef __cplusplus
45#define NULL 0L
46#else
47#define NULL ((void*)0)
48#endif
49#else
50#define __need_NULL
51#include <stddef.h>
52#endif
53
54#undef WEOF
55#define WEOF 0xffffffffU
56
57wchar_t *wcscpy (wchar_t *__restrict, const wchar_t *__restrict);
58wchar_t *wcsncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
59
60wchar_t *wcscat (wchar_t *__restrict, const wchar_t *__restrict);
61wchar_t *wcsncat (wchar_t *__restrict, const wchar_t *__restrict, size_t);
62
63int wcscmp (const wchar_t *, const wchar_t *);
64int wcsncmp (const wchar_t *, const wchar_t *, size_t);
65
66int wcscoll(const wchar_t *, const wchar_t *);
67size_t wcsxfrm (wchar_t *__restrict, const wchar_t *__restrict, size_t);
68
69wchar_t *wcschr (const wchar_t *, wchar_t);
70wchar_t *wcsrchr (const wchar_t *, wchar_t);
71
72size_t wcscspn (const wchar_t *, const wchar_t *);
73size_t wcsspn (const wchar_t *, const wchar_t *);
74wchar_t *wcspbrk (const wchar_t *, const wchar_t *);
75
76wchar_t *wcstok (wchar_t *__restrict, const wchar_t *__restrict, wchar_t **__restrict);
77
78size_t wcslen (const wchar_t *);
79
80wchar_t *wcsstr (const wchar_t *__restrict, const wchar_t *__restrict);
81wchar_t *wcswcs (const wchar_t *, const wchar_t *);
82
83wchar_t *wmemchr (const wchar_t *, wchar_t, size_t);
84int wmemcmp (const wchar_t *, const wchar_t *, size_t);
85wchar_t *wmemcpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
86wchar_t *wmemmove (wchar_t *, const wchar_t *, size_t);
87wchar_t *wmemset (wchar_t *, wchar_t, size_t);
88
89wint_t btowc (int);
90int wctob (wint_t);
91
92int mbsinit (const mbstate_t *);
93size_t mbrtowc (wchar_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
94size_t wcrtomb (char *__restrict, wchar_t, mbstate_t *__restrict);
95
96size_t mbrlen (const char *__restrict, size_t, mbstate_t *__restrict);
97
98size_t mbsrtowcs (wchar_t *__restrict, const char **__restrict, size_t, mbstate_t *__restrict);
99size_t wcsrtombs (char *__restrict, const wchar_t **__restrict, size_t, mbstate_t *__restrict);
100
101float wcstof (const wchar_t *__restrict, wchar_t **__restrict);
102double wcstod (const wchar_t *__restrict, wchar_t **__restrict);
103long double wcstold (const wchar_t *__restrict, wchar_t **__restrict);
104
105long wcstol (const wchar_t *__restrict, wchar_t **__restrict, int);
106unsigned long wcstoul (const wchar_t *__restrict, wchar_t **__restrict, int);
107
108long long wcstoll (const wchar_t *__restrict, wchar_t **__restrict, int);
109unsigned long long wcstoull (const wchar_t *__restrict, wchar_t **__restrict, int);
110
111
112
113int fwide (FILE *, int);
114
115
116int wprintf (const wchar_t *__restrict, ...);
117int fwprintf (FILE *__restrict, const wchar_t *__restrict, ...);
118int swprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, ...);
119
120int vwprintf (const wchar_t *__restrict, __isoc_va_list);
121int vfwprintf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
122int vswprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, __isoc_va_list);
123
124int wscanf (const wchar_t *__restrict, ...);
125int fwscanf (FILE *__restrict, const wchar_t *__restrict, ...);
126int swscanf (const wchar_t *__restrict, const wchar_t *__restrict, ...);
127
128int vwscanf (const wchar_t *__restrict, __isoc_va_list);
129int vfwscanf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
130int vswscanf (const wchar_t *__restrict, const wchar_t *__restrict, __isoc_va_list);
131
132wint_t fgetwc (FILE *);
133wint_t getwc (FILE *);
134wint_t getwchar (void);
135
136wint_t fputwc (wchar_t, FILE *);
137wint_t putwc (wchar_t, FILE *);
138wint_t putwchar (wchar_t);
139
140wchar_t *fgetws (wchar_t *__restrict, int, FILE *__restrict);
141int fputws (const wchar_t *__restrict, FILE *__restrict);
142
143wint_t ungetwc (wint_t, FILE *);
144
145struct tm;
146size_t wcsftime (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict);
147
148#undef iswdigit
149
150#if defined(_GNU_SOURCE)
151wint_t fgetwc_unlocked (FILE *);
152wint_t getwc_unlocked (FILE *);
153wint_t getwchar_unlocked (void);
154wint_t fputwc_unlocked (wchar_t, FILE *);
155wint_t putwc_unlocked (wchar_t, FILE *);
156wint_t putwchar_unlocked (wchar_t);
157wchar_t *fgetws_unlocked (wchar_t *__restrict, int, FILE *__restrict);
158int fputws_unlocked (const wchar_t *__restrict, FILE *__restrict);
159#endif
160
161#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
162size_t wcsftime_l (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict, locale_t);
163#endif
164
165#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
166 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
167FILE *open_wmemstream(wchar_t **, size_t *);
168size_t mbsnrtowcs(wchar_t *__restrict, const char **__restrict, size_t, size_t, mbstate_t *__restrict);
169size_t wcsnrtombs(char *__restrict, const wchar_t **__restrict, size_t, size_t, mbstate_t *__restrict);
170wchar_t *wcsdup(const wchar_t *);
171size_t wcsnlen (const wchar_t *, size_t);
172wchar_t *wcpcpy (wchar_t *__restrict, const wchar_t *__restrict);
173wchar_t *wcpncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
174int wcscasecmp(const wchar_t *, const wchar_t *);
175int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
176int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
177int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
178int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
179size_t wcsxfrm_l(wchar_t *__restrict, const wchar_t *__restrict, size_t, locale_t);
180#endif
181
182#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
183int wcwidth (wchar_t);
184int wcswidth (const wchar_t *, size_t);
185int iswalnum(wint_t);
186int iswalpha(wint_t);
187int iswblank(wint_t);
188int iswcntrl(wint_t);
189int iswdigit(wint_t);
190int iswgraph(wint_t);
191int iswlower(wint_t);
192int iswprint(wint_t);
193int iswpunct(wint_t);
194int iswspace(wint_t);
195int iswupper(wint_t);
196int iswxdigit(wint_t);
197int iswctype(wint_t, wctype_t);
198wint_t towlower(wint_t);
199wint_t towupper(wint_t);
200wctype_t wctype(const char *);
201
202#ifndef __cplusplus
203#undef iswdigit
204#define iswdigit(a) (0 ? iswdigit(a) : ((unsigned)(a)-'0') < 10)
205#endif
206#endif
207
208#ifdef __cplusplus
209}
210#endif
211
212#endif
lib/libc/include/wasm-wasi-musl/wctype.h created+79
......@@ -0,0 +1,79 @@
1#ifndef _WCTYPE_H
2#define _WCTYPE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_wint_t
11#define __NEED_wctype_t
12
13#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
14 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
15#define __NEED_locale_t
16#endif
17
18#include <bits/alltypes.h>
19
20typedef const int * wctrans_t;
21
22#undef WEOF
23#define WEOF 0xffffffffU
24
25#undef iswdigit
26
27int iswalnum(wint_t);
28int iswalpha(wint_t);
29int iswblank(wint_t);
30int iswcntrl(wint_t);
31int iswdigit(wint_t);
32int iswgraph(wint_t);
33int iswlower(wint_t);
34int iswprint(wint_t);
35int iswpunct(wint_t);
36int iswspace(wint_t);
37int iswupper(wint_t);
38int iswxdigit(wint_t);
39int iswctype(wint_t, wctype_t);
40wint_t towctrans(wint_t, wctrans_t);
41wint_t towlower(wint_t);
42wint_t towupper(wint_t);
43wctrans_t wctrans(const char *);
44wctype_t wctype(const char *);
45
46#ifndef __cplusplus
47#undef iswdigit
48#define iswdigit(a) (0 ? iswdigit(a) : ((unsigned)(a)-'0') < 10)
49#endif
50
51#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
52 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
53
54int iswalnum_l(wint_t, locale_t);
55int iswalpha_l(wint_t, locale_t);
56int iswblank_l(wint_t, locale_t);
57int iswcntrl_l(wint_t, locale_t);
58int iswdigit_l(wint_t, locale_t);
59int iswgraph_l(wint_t, locale_t);
60int iswlower_l(wint_t, locale_t);
61int iswprint_l(wint_t, locale_t);
62int iswpunct_l(wint_t, locale_t);
63int iswspace_l(wint_t, locale_t);
64int iswupper_l(wint_t, locale_t);
65int iswxdigit_l(wint_t, locale_t);
66int iswctype_l(wint_t, wctype_t, locale_t);
67wint_t towlower_l(wint_t, locale_t);
68wint_t towupper_l(wint_t, locale_t);
69wint_t towctrans_l(wint_t, wctrans_t, locale_t);
70wctrans_t wctrans_l(const char *, locale_t);
71wctype_t wctype_l(const char *, locale_t);
72
73#endif
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif
lib/libc/include/wasm32-wasi/__errno.h deleted-20
......@@ -1,20 +0,0 @@
1#ifndef __wasilibc___errno_h
2#define __wasilibc___errno_h
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#ifdef __cplusplus
9extern thread_local int errno;
10#else
11extern _Thread_local int errno;
12#endif
13
14#define errno errno
15
16#ifdef __cplusplus
17}
18#endif
19
20#endif
lib/libc/include/wasm32-wasi/__errno_values.h deleted-86
......@@ -1,86 +0,0 @@
1#ifndef __wasilibc___errno_values_h
2#define __wasilibc___errno_values_h
3
4#include <wasi/api.h>
5
6#define E2BIG __WASI_ERRNO_2BIG
7#define EACCES __WASI_ERRNO_ACCES
8#define EADDRINUSE __WASI_ERRNO_ADDRINUSE
9#define EADDRNOTAVAIL __WASI_ERRNO_ADDRNOTAVAIL
10#define EAFNOSUPPORT __WASI_ERRNO_AFNOSUPPORT
11#define EAGAIN __WASI_ERRNO_AGAIN
12#define EALREADY __WASI_ERRNO_ALREADY
13#define EBADF __WASI_ERRNO_BADF
14#define EBADMSG __WASI_ERRNO_BADMSG
15#define EBUSY __WASI_ERRNO_BUSY
16#define ECANCELED __WASI_ERRNO_CANCELED
17#define ECHILD __WASI_ERRNO_CHILD
18#define ECONNABORTED __WASI_ERRNO_CONNABORTED
19#define ECONNREFUSED __WASI_ERRNO_CONNREFUSED
20#define ECONNRESET __WASI_ERRNO_CONNRESET
21#define EDEADLK __WASI_ERRNO_DEADLK
22#define EDESTADDRREQ __WASI_ERRNO_DESTADDRREQ
23#define EDOM __WASI_ERRNO_DOM
24#define EDQUOT __WASI_ERRNO_DQUOT
25#define EEXIST __WASI_ERRNO_EXIST
26#define EFAULT __WASI_ERRNO_FAULT
27#define EFBIG __WASI_ERRNO_FBIG
28#define EHOSTUNREACH __WASI_ERRNO_HOSTUNREACH
29#define EIDRM __WASI_ERRNO_IDRM
30#define EILSEQ __WASI_ERRNO_ILSEQ
31#define EINPROGRESS __WASI_ERRNO_INPROGRESS
32#define EINTR __WASI_ERRNO_INTR
33#define EINVAL __WASI_ERRNO_INVAL
34#define EIO __WASI_ERRNO_IO
35#define EISCONN __WASI_ERRNO_ISCONN
36#define EISDIR __WASI_ERRNO_ISDIR
37#define ELOOP __WASI_ERRNO_LOOP
38#define EMFILE __WASI_ERRNO_MFILE
39#define EMLINK __WASI_ERRNO_MLINK
40#define EMSGSIZE __WASI_ERRNO_MSGSIZE
41#define EMULTIHOP __WASI_ERRNO_MULTIHOP
42#define ENAMETOOLONG __WASI_ERRNO_NAMETOOLONG
43#define ENETDOWN __WASI_ERRNO_NETDOWN
44#define ENETRESET __WASI_ERRNO_NETRESET
45#define ENETUNREACH __WASI_ERRNO_NETUNREACH
46#define ENFILE __WASI_ERRNO_NFILE
47#define ENOBUFS __WASI_ERRNO_NOBUFS
48#define ENODEV __WASI_ERRNO_NODEV
49#define ENOENT __WASI_ERRNO_NOENT
50#define ENOEXEC __WASI_ERRNO_NOEXEC
51#define ENOLCK __WASI_ERRNO_NOLCK
52#define ENOLINK __WASI_ERRNO_NOLINK
53#define ENOMEM __WASI_ERRNO_NOMEM
54#define ENOMSG __WASI_ERRNO_NOMSG
55#define ENOPROTOOPT __WASI_ERRNO_NOPROTOOPT
56#define ENOSPC __WASI_ERRNO_NOSPC
57#define ENOSYS __WASI_ERRNO_NOSYS
58#define ENOTCONN __WASI_ERRNO_NOTCONN
59#define ENOTDIR __WASI_ERRNO_NOTDIR
60#define ENOTEMPTY __WASI_ERRNO_NOTEMPTY
61#define ENOTRECOVERABLE __WASI_ERRNO_NOTRECOVERABLE
62#define ENOTSOCK __WASI_ERRNO_NOTSOCK
63#define ENOTSUP __WASI_ERRNO_NOTSUP
64#define ENOTTY __WASI_ERRNO_NOTTY
65#define ENXIO __WASI_ERRNO_NXIO
66#define EOVERFLOW __WASI_ERRNO_OVERFLOW
67#define EOWNERDEAD __WASI_ERRNO_OWNERDEAD
68#define EPERM __WASI_ERRNO_PERM
69#define EPIPE __WASI_ERRNO_PIPE
70#define EPROTO __WASI_ERRNO_PROTO
71#define EPROTONOSUPPORT __WASI_ERRNO_PROTONOSUPPORT
72#define EPROTOTYPE __WASI_ERRNO_PROTOTYPE
73#define ERANGE __WASI_ERRNO_RANGE
74#define EROFS __WASI_ERRNO_ROFS
75#define ESPIPE __WASI_ERRNO_SPIPE
76#define ESRCH __WASI_ERRNO_SRCH
77#define ESTALE __WASI_ERRNO_STALE
78#define ETIMEDOUT __WASI_ERRNO_TIMEDOUT
79#define ETXTBSY __WASI_ERRNO_TXTBSY
80#define EXDEV __WASI_ERRNO_XDEV
81#define ENOTCAPABLE __WASI_ERRNO_NOTCAPABLE
82
83#define EOPNOTSUPP ENOTSUP
84#define EWOULDBLOCK EAGAIN
85
86#endif
lib/libc/include/wasm32-wasi/__fd_set.h deleted-76
......@@ -1,76 +0,0 @@
1#ifndef __wasilibc___fd_set_h
2#define __wasilibc___fd_set_h
3
4#include <__typedef_fd_set.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10static __inline void FD_CLR(int __fd, fd_set *__set) {
11 size_t __n = __set->__nfds;
12 for (int *__p = __set->__fds, *__e = __p + __n;
13 __p < __e; ++__p)
14 {
15 if (*__p == __fd) {
16 *__p = __e[-1];
17 __set->__nfds = __n - 1;
18 return;
19 }
20 }
21}
22
23static __inline
24#ifdef __cplusplus
25bool
26#else
27_Bool
28#endif
29FD_ISSET(int __fd, const fd_set *__set)
30{
31 size_t __n = __set->__nfds;
32 for (const int *__p = __set->__fds, *__e = __p + __n;
33 __p < __e; ++__p)
34 {
35 if (*__p == __fd) {
36 return 1;
37 }
38 }
39 return 0;
40}
41
42static __inline void FD_SET(int __fd, fd_set *__set) {
43 size_t __n = __set->__nfds;
44 for (const int *__p = __set->__fds, *__e = __p + __n;
45 __p < __e; ++__p)
46 {
47 if (*__p == __fd) {
48 return;
49 }
50 }
51 __set->__nfds = __n + 1;
52 __set->__fds[__n] = __fd;
53}
54
55static __inline void FD_ZERO(fd_set *__set) {
56 __set->__nfds = 0;
57}
58
59static __inline void FD_COPY(const fd_set *__restrict __from,
60 fd_set *__restrict __to) {
61 size_t __n = __from->__nfds;
62 __to->__nfds = __n;
63 __builtin_memcpy(__to->__fds, __from->__fds, __n * sizeof(int));
64}
65
66#define FD_CLR(fd, set) (FD_CLR((fd), (set)))
67#define FD_ISSET(fd, set) (FD_ISSET((fd), (set)))
68#define FD_SET(fd, set) (FD_SET((fd), (set)))
69#define FD_ZERO(set) (FD_ZERO((set)))
70#define FD_COPY(from, to) (FD_COPY((from), (to)))
71
72#ifdef __cplusplus
73}
74#endif
75
76#endif
lib/libc/include/wasm32-wasi/__function___isatty.h deleted-14
......@@ -1,14 +0,0 @@
1#ifndef __wasilibc___function___isatty_h
2#define __wasilibc___function___isatty_h
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8int __isatty(int fd);
9
10#ifdef __cplusplus
11}
12#endif
13
14#endif
lib/libc/include/wasm32-wasi/__functions_malloc.h deleted-26
......@@ -1,26 +0,0 @@
1#ifndef __wasilibc___functions_malloc_h
2#define __wasilibc___functions_malloc_h
3
4#define __need_size_t
5#define __need_wchar_t
6#define __need_NULL
7#include <stddef.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13void *malloc(size_t __size) __attribute__((__malloc__, __warn_unused_result__));
14void free(void *__ptr);
15void *calloc(size_t __nmemb, size_t __size) __attribute__((__malloc__, __warn_unused_result__));
16void *realloc(void *__ptr, size_t __size) __attribute__((__warn_unused_result__));
17
18#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
19void *reallocarray(void *__ptr, size_t __nmemb, size_t __size) __attribute__((__warn_unused_result__));
20#endif
21
22#ifdef __cplusplus
23}
24#endif
25
26#endif
lib/libc/include/wasm32-wasi/__functions_memcpy.h deleted-20
......@@ -1,20 +0,0 @@
1#ifndef __wasilibc___functions_memcpy_h
2#define __wasilibc___functions_memcpy_h
3
4#define __need_size_t
5#define __need_NULL
6#include <stddef.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12void *memcpy(void *__restrict__ __dst, const void *__restrict__ __src, size_t __n) __attribute__((__nothrow__, __leaf__, __nonnull__(1, 2)));
13void *memmove(void *__dst, const void *__src, size_t __n) __attribute__((__nothrow__, __leaf__, __nonnull__(1, 2)));
14void *memset(void *__dst, int __c, size_t __n) __attribute__((__nothrow__, __leaf__, __nonnull__(1)));
15
16#ifdef __cplusplus
17}
18#endif
19
20#endif
lib/libc/include/wasm32-wasi/__header_dirent.h deleted-39
......@@ -1,39 +0,0 @@
1#ifndef __wasilibc___header_dirent_h
2#define __wasilibc___header_dirent_h
3
4#include <wasi/api.h>
5
6#define DT_BLK __WASI_FILETYPE_BLOCK_DEVICE
7#define DT_CHR __WASI_FILETYPE_CHARACTER_DEVICE
8#define DT_DIR __WASI_FILETYPE_DIRECTORY
9#define DT_FIFO __WASI_FILETYPE_SOCKET_STREAM
10#define DT_LNK __WASI_FILETYPE_SYMBOLIC_LINK
11#define DT_REG __WASI_FILETYPE_REGULAR_FILE
12#define DT_UNKNOWN __WASI_FILETYPE_UNKNOWN
13
14#include <__struct_dirent.h>
15#include <__typedef_DIR.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21int closedir(DIR *);
22DIR *opendir(const char *);
23DIR *fdopendir(int);
24int fdclosedir(DIR *);
25struct dirent *readdir(DIR *);
26void rewinddir(DIR *);
27void seekdir(DIR *, long);
28long telldir(DIR *);
29DIR *opendirat(int, const char *);
30void rewinddir(DIR *);
31int scandirat(int, const char *, struct dirent ***,
32 int (*)(const struct dirent *),
33 int (*)(const struct dirent **, const struct dirent **));
34
35#ifdef __cplusplus
36}
37#endif
38
39#endif
lib/libc/include/wasm32-wasi/__header_fcntl.h deleted-61
......@@ -1,61 +0,0 @@
1#ifndef __wasilibc___header_fcntl_h
2#define __wasilibc___header_fcntl_h
3
4#include <wasi/api.h>
5#include <__seek.h>
6#include <__mode_t.h>
7
8#define O_APPEND __WASI_FDFLAGS_APPEND
9#define O_DSYNC __WASI_FDFLAGS_DSYNC
10#define O_NONBLOCK __WASI_FDFLAGS_NONBLOCK
11#define O_RSYNC __WASI_FDFLAGS_RSYNC
12#define O_SYNC __WASI_FDFLAGS_SYNC
13#define O_CREAT (__WASI_OFLAGS_CREAT << 12)
14#define O_DIRECTORY (__WASI_OFLAGS_DIRECTORY << 12)
15#define O_EXCL (__WASI_OFLAGS_EXCL << 12)
16#define O_TRUNC (__WASI_OFLAGS_TRUNC << 12)
17
18#define O_NOFOLLOW (0x01000000)
19#define O_EXEC (0x02000000)
20#define O_RDONLY (0x04000000)
21#define O_SEARCH (0x08000000)
22#define O_WRONLY (0x10000000)
23
24/*
25 * O_CLOEXEC is defined to be zero, as WASI has no exec-style functions.
26 */
27#define O_CLOEXEC (0)
28
29/*
30 * O_TTY_INIT is defined to be zero, meaning that WASI implementations are
31 * expected to always initialize a terminal the first time it's opened.
32 */
33#define O_TTY_INIT (0)
34
35#define O_NOCTTY (0)
36
37#define O_RDWR (O_RDONLY | O_WRONLY)
38#define O_ACCMODE (O_EXEC | O_RDWR | O_SEARCH)
39
40#define POSIX_FADV_DONTNEED __WASI_ADVICE_DONTNEED
41#define POSIX_FADV_NOREUSE __WASI_ADVICE_NOREUSE
42#define POSIX_FADV_NORMAL __WASI_ADVICE_NORMAL
43#define POSIX_FADV_RANDOM __WASI_ADVICE_RANDOM
44#define POSIX_FADV_SEQUENTIAL __WASI_ADVICE_SEQUENTIAL
45#define POSIX_FADV_WILLNEED __WASI_ADVICE_WILLNEED
46
47#define F_GETFD (1)
48#define F_SETFD (2)
49#define F_GETFL (3)
50#define F_SETFL (4)
51
52#define FD_CLOEXEC (1)
53
54#define AT_EACCESS (0x0)
55#define AT_SYMLINK_NOFOLLOW (0x1)
56#define AT_SYMLINK_FOLLOW (0x2)
57#define AT_REMOVEDIR (0x4)
58
59#define AT_FDCWD (-2)
60
61#endif
lib/libc/include/wasm32-wasi/__header_inttypes.h deleted-182
......@@ -1,182 +0,0 @@
1#ifndef __wasilibc___include_inttypes_h
2#define __wasilibc___include_inttypes_h
3
4#include <stdint.h>
5
6#define __need_wchar_t
7#include <stddef.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13typedef struct { intmax_t quot, rem; } imaxdiv_t;
14
15intmax_t imaxabs(intmax_t);
16imaxdiv_t imaxdiv(intmax_t, intmax_t);
17intmax_t strtoimax(const char *__restrict, char **__restrict, int);
18uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
19intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
20uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
21
22#define PRId16 __INT16_FMTd__
23#define PRIi16 __INT16_FMTi__
24#define PRId32 __INT32_FMTd__
25#define PRIi32 __INT32_FMTi__
26#define PRId64 __INT64_FMTd__
27#define PRIi64 __INT64_FMTi__
28#define PRId8 __INT8_FMTd__
29#define PRIi8 __INT8_FMTi__
30#define PRIdMAX __INTMAX_FMTd__
31#define PRIiMAX __INTMAX_FMTi__
32#define PRIdPTR __INTPTR_FMTd__
33#define PRIiPTR __INTPTR_FMTi__
34#define PRIdFAST16 __INT_FAST16_FMTd__
35#define PRIiFAST16 __INT_FAST16_FMTi__
36#define PRIdFAST32 __INT_FAST32_FMTd__
37#define PRIiFAST32 __INT_FAST32_FMTi__
38#define PRIdFAST64 __INT_FAST64_FMTd__
39#define PRIiFAST64 __INT_FAST64_FMTi__
40#define PRIdFAST8 __INT_FAST8_FMTd__
41#define PRIiFAST8 __INT_FAST8_FMTi__
42#define PRIdLEAST16 __INT_LEAST16_FMTd__
43#define PRIiLEAST16 __INT_LEAST16_FMTi__
44#define PRIdLEAST32 __INT_LEAST32_FMTd__
45#define PRIiLEAST32 __INT_LEAST32_FMTi__
46#define PRIdLEAST64 __INT_LEAST64_FMTd__
47#define PRIiLEAST64 __INT_LEAST64_FMTi__
48#define PRIdLEAST8 __INT_LEAST8_FMTd__
49#define PRIiLEAST8 __INT_LEAST8_FMTi__
50#define PRIX16 __UINT16_FMTX__
51#define PRIo16 __UINT16_FMTo__
52#define PRIu16 __UINT16_FMTu__
53#define PRIx16 __UINT16_FMTx__
54#define PRIX32 __UINT32_FMTX__
55#define PRIo32 __UINT32_FMTo__
56#define PRIu32 __UINT32_FMTu__
57#define PRIx32 __UINT32_FMTx__
58#define PRIX64 __UINT64_FMTX__
59#define PRIo64 __UINT64_FMTo__
60#define PRIu64 __UINT64_FMTu__
61#define PRIx64 __UINT64_FMTx__
62#define PRIX8 __UINT8_FMTX__
63#define PRIo8 __UINT8_FMTo__
64#define PRIu8 __UINT8_FMTu__
65#define PRIx8 __UINT8_FMTx__
66#define PRIXMAX __UINTMAX_FMTX__
67#define PRIoMAX __UINTMAX_FMTo__
68#define PRIuMAX __UINTMAX_FMTu__
69#define PRIxMAX __UINTMAX_FMTx__
70#define PRIXPTR __UINTPTR_FMTX__
71#define PRIoPTR __UINTPTR_FMTo__
72#define PRIuPTR __UINTPTR_FMTu__
73#define PRIxPTR __UINTPTR_FMTx__
74#define PRIXFAST16 __UINT_FAST16_FMTX__
75#define PRIoFAST16 __UINT_FAST16_FMTo__
76#define PRIuFAST16 __UINT_FAST16_FMTu__
77#define PRIxFAST16 __UINT_FAST16_FMTx__
78#define PRIXFAST32 __UINT_FAST32_FMTX__
79#define PRIoFAST32 __UINT_FAST32_FMTo__
80#define PRIuFAST32 __UINT_FAST32_FMTu__
81#define PRIxFAST32 __UINT_FAST32_FMTx__
82#define PRIXFAST64 __UINT_FAST64_FMTX__
83#define PRIoFAST64 __UINT_FAST64_FMTo__
84#define PRIuFAST64 __UINT_FAST64_FMTu__
85#define PRIxFAST64 __UINT_FAST64_FMTx__
86#define PRIXFAST8 __UINT_FAST8_FMTX__
87#define PRIoFAST8 __UINT_FAST8_FMTo__
88#define PRIuFAST8 __UINT_FAST8_FMTu__
89#define PRIxFAST8 __UINT_FAST8_FMTx__
90#define PRIXLEAST16 __UINT_LEAST16_FMTX__
91#define PRIoLEAST16 __UINT_LEAST16_FMTo__
92#define PRIuLEAST16 __UINT_LEAST16_FMTu__
93#define PRIxLEAST16 __UINT_LEAST16_FMTx__
94#define PRIXLEAST32 __UINT_LEAST32_FMTX__
95#define PRIoLEAST32 __UINT_LEAST32_FMTo__
96#define PRIuLEAST32 __UINT_LEAST32_FMTu__
97#define PRIxLEAST32 __UINT_LEAST32_FMTx__
98#define PRIXLEAST64 __UINT_LEAST64_FMTX__
99#define PRIoLEAST64 __UINT_LEAST64_FMTo__
100#define PRIuLEAST64 __UINT_LEAST64_FMTu__
101#define PRIxLEAST64 __UINT_LEAST64_FMTx__
102#define PRIXLEAST8 __UINT_LEAST8_FMTX__
103#define PRIoLEAST8 __UINT_LEAST8_FMTo__
104#define PRIuLEAST8 __UINT_LEAST8_FMTu__
105#define PRIxLEAST8 __UINT_LEAST8_FMTx__
106
107#define SCNd16 __INT16_FMTd__
108#define SCNi16 __INT16_FMTi__
109#define SCNd32 __INT32_FMTd__
110#define SCNi32 __INT32_FMTi__
111#define SCNd64 __INT64_FMTd__
112#define SCNi64 __INT64_FMTi__
113#define SCNd8 __INT8_FMTd__
114#define SCNi8 __INT8_FMTi__
115#define SCNdMAX __INTMAX_FMTd__
116#define SCNiMAX __INTMAX_FMTi__
117#define SCNdPTR __INTPTR_FMTd__
118#define SCNiPTR __INTPTR_FMTi__
119#define SCNdFAST16 __INT_FAST16_FMTd__
120#define SCNiFAST16 __INT_FAST16_FMTi__
121#define SCNdFAST32 __INT_FAST32_FMTd__
122#define SCNiFAST32 __INT_FAST32_FMTi__
123#define SCNdFAST64 __INT_FAST64_FMTd__
124#define SCNiFAST64 __INT_FAST64_FMTi__
125#define SCNdFAST8 __INT_FAST8_FMTd__
126#define SCNiFAST8 __INT_FAST8_FMTi__
127#define SCNdLEAST16 __INT_LEAST16_FMTd__
128#define SCNiLEAST16 __INT_LEAST16_FMTi__
129#define SCNdLEAST32 __INT_LEAST32_FMTd__
130#define SCNiLEAST32 __INT_LEAST32_FMTi__
131#define SCNdLEAST64 __INT_LEAST64_FMTd__
132#define SCNiLEAST64 __INT_LEAST64_FMTi__
133#define SCNdLEAST8 __INT_LEAST8_FMTd__
134#define SCNiLEAST8 __INT_LEAST8_FMTi__
135#define SCNo16 __UINT16_FMTo__
136#define SCNu16 __UINT16_FMTu__
137#define SCNx16 __UINT16_FMTx__
138#define SCNo32 __UINT32_FMTo__
139#define SCNu32 __UINT32_FMTu__
140#define SCNx32 __UINT32_FMTx__
141#define SCNo64 __UINT64_FMTo__
142#define SCNu64 __UINT64_FMTu__
143#define SCNx64 __UINT64_FMTx__
144#define SCNo8 __UINT8_FMTo__
145#define SCNu8 __UINT8_FMTu__
146#define SCNx8 __UINT8_FMTx__
147#define SCNoMAX __UINTMAX_FMTo__
148#define SCNuMAX __UINTMAX_FMTu__
149#define SCNxMAX __UINTMAX_FMTx__
150#define SCNoPTR __UINTPTR_FMTo__
151#define SCNuPTR __UINTPTR_FMTu__
152#define SCNxPTR __UINTPTR_FMTx__
153#define SCNoFAST16 __UINT_FAST16_FMTo__
154#define SCNuFAST16 __UINT_FAST16_FMTu__
155#define SCNxFAST16 __UINT_FAST16_FMTx__
156#define SCNoFAST32 __UINT_FAST32_FMTo__
157#define SCNuFAST32 __UINT_FAST32_FMTu__
158#define SCNxFAST32 __UINT_FAST32_FMTx__
159#define SCNoFAST64 __UINT_FAST64_FMTo__
160#define SCNuFAST64 __UINT_FAST64_FMTu__
161#define SCNxFAST64 __UINT_FAST64_FMTx__
162#define SCNoFAST8 __UINT_FAST8_FMTo__
163#define SCNuFAST8 __UINT_FAST8_FMTu__
164#define SCNxFAST8 __UINT_FAST8_FMTx__
165#define SCNoLEAST16 __UINT_LEAST16_FMTo__
166#define SCNuLEAST16 __UINT_LEAST16_FMTu__
167#define SCNxLEAST16 __UINT_LEAST16_FMTx__
168#define SCNoLEAST32 __UINT_LEAST32_FMTo__
169#define SCNuLEAST32 __UINT_LEAST32_FMTu__
170#define SCNxLEAST32 __UINT_LEAST32_FMTx__
171#define SCNoLEAST64 __UINT_LEAST64_FMTo__
172#define SCNuLEAST64 __UINT_LEAST64_FMTu__
173#define SCNxLEAST64 __UINT_LEAST64_FMTx__
174#define SCNoLEAST8 __UINT_LEAST8_FMTo__
175#define SCNuLEAST8 __UINT_LEAST8_FMTu__
176#define SCNxLEAST8 __UINT_LEAST8_FMTx__
177
178#ifdef __cplusplus
179}
180#endif
181
182#endif
lib/libc/include/wasm32-wasi/__header_netinet_in.h deleted-30
......@@ -1,30 +0,0 @@
1#ifndef __wasilibc___header_netinet_in_h
2#define __wasilibc___header_netinet_in_h
3
4#include <__struct_in_addr.h>
5#include <__struct_in6_addr.h>
6#include <__struct_sockaddr_in.h>
7#include <__struct_sockaddr_in6.h>
8
9#define IPPROTO_IP 0
10#define IPPROTO_ICMP 1
11#define IPPROTO_TCP 6
12#define IPPROTO_UDP 17
13#define IPPROTO_IPV6 41
14#define IPPROTO_RAW 255
15
16#define IN6ADDR_ANY_INIT { { \
17 0x00, 0x00, 0x00, 0x00, \
18 0x00, 0x00, 0x00, 0x00, \
19 0x00, 0x00, 0x00, 0x00, \
20 0x00, 0x00, 0x00, 0x00 \
21} }
22
23#define IN6ADDR_LOOPBACK_INIT { { \
24 0x00, 0x00, 0x00, 0x00, \
25 0x00, 0x00, 0x00, 0x00, \
26 0x00, 0x00, 0x00, 0x00, \
27 0x00, 0x00, 0x00, 0x01 \
28} }
29
30#endif
lib/libc/include/wasm32-wasi/__header_poll.h deleted-27
......@@ -1,27 +0,0 @@
1#ifndef __wasilibc___header_poll_h
2#define __wasilibc___header_poll_h
3
4#include <__struct_pollfd.h>
5#include <__typedef_nfds_t.h>
6
7#define POLLRDNORM 0x1
8#define POLLWRNORM 0x2
9
10#define POLLIN POLLRDNORM
11#define POLLOUT POLLWRNORM
12
13#define POLLERR 0x1000
14#define POLLHUP 0x2000
15#define POLLNVAL 0x4000
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21int poll(struct pollfd[], nfds_t, int);
22
23#ifdef __cplusplus
24}
25#endif
26
27#endif
lib/libc/include/wasm32-wasi/__header_stdlib.h deleted-21
......@@ -1,21 +0,0 @@
1#ifndef __wasilibc___header_stdlib_h
2#define __wasilibc___header_stdlib_h
3
4#define __need_size_t
5#include <stddef.h>
6
7#include <__functions_malloc.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13void abort(void) __attribute__((__noreturn__));
14void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
15void _Exit(int) __attribute__((__noreturn__));
16
17#ifdef __cplusplus
18}
19#endif
20
21#endif
lib/libc/include/wasm32-wasi/__header_string.h deleted-23
......@@ -1,23 +0,0 @@
1#ifndef __wasilibc___header_string_h
2#define __wasilibc___header_string_h
3
4#define __need_size_t
5#define __need_NULL
6#include <stddef.h>
7
8#include <__functions_memcpy.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14size_t strlen(const char *) __attribute__((__nothrow__, __leaf__, __pure__, __nonnull__(1)));
15char *strdup(const char *) __attribute__((__nothrow__, __nonnull__(1)));
16int strcmp(const char *, const char *) __attribute__((__nothrow__, __pure__, __nonnull__(1, 2)));
17void *memchr(const void *, int, size_t) __attribute__((__nothrow__, __pure__, __nonnull__(1)));
18
19#ifdef __cplusplus
20}
21#endif
22
23#endif
lib/libc/include/wasm32-wasi/__header_sys_ioctl.h deleted-17
......@@ -1,17 +0,0 @@
1#ifndef __wasilibc___header_sys_ioctl_h
2#define __wasilibc___header_sys_ioctl_h
3
4#define FIONREAD 1
5#define FIONBIO 2
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11int ioctl(int, int, ...);
12
13#ifdef __cplusplus
14}
15#endif
16
17#endif
lib/libc/include/wasm32-wasi/__header_sys_resource.h deleted-19
......@@ -1,19 +0,0 @@
1#ifndef __wasilibc___header_sys_resource_h
2#define __wasilibc___header_sys_resource_h
3
4#include <__struct_rusage.h>
5
6#define RUSAGE_SELF 1
7#define RUSAGE_CHILDREN 2
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13int getrusage(int who, struct rusage *usage);
14
15#ifdef __cplusplus
16}
17#endif
18
19#endif
lib/libc/include/wasm32-wasi/__header_sys_socket.h deleted-41
......@@ -1,41 +0,0 @@
1#ifndef __wasilibc___header_sys_socket_h
2#define __wasilibc___header_sys_socket_h
3
4#include <__struct_msghdr.h>
5#include <__struct_sockaddr.h>
6#include <__struct_sockaddr_storage.h>
7
8#include <wasi/api.h>
9
10#define SHUT_RD __WASI_SDFLAGS_RD
11#define SHUT_WR __WASI_SDFLAGS_WR
12#define SHUT_RDWR (SHUT_RD | SHUT_WR)
13
14#define MSG_PEEK __WASI_RIFLAGS_RECV_PEEK
15#define MSG_WAITALL __WASI_RIFLAGS_RECV_WAITALL
16#define MSG_TRUNC __WASI_RIFLAGS_RECV_DATA_TRUNCATED
17
18#define SOCK_DGRAM __WASI_FILETYPE_SOCKET_DGRAM
19#define SOCK_STREAM __WASI_FILETYPE_SOCKET_STREAM
20
21#define SOCK_NONBLOCK (0x00004000)
22#define SOCK_CLOEXEC (0x00002000)
23
24#define SOL_SOCKET 0x7fffffff
25
26#define SO_TYPE 3
27
28#define AF_UNSPEC 0
29#define AF_INET 1
30#define AF_INET6 2
31#define AF_UNIX 3
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#ifdef __cplusplus
38}
39#endif
40
41#endif
lib/libc/include/wasm32-wasi/__header_sys_stat.h deleted-15
......@@ -1,15 +0,0 @@
1#ifndef __wasilibc___header_sys_stat_h
2#define __wasilibc___header_sys_stat_h
3
4#include <__struct_stat.h>
5
6#define st_atime st_atim.tv_sec
7#define st_mtime st_mtim.tv_sec
8#define st_ctime st_ctim.tv_sec
9
10#include <__mode_t.h>
11
12#define UTIME_NOW (-1)
13#define UTIME_OMIT (-2)
14
15#endif
lib/libc/include/wasm32-wasi/__header_time.h deleted-37
......@@ -1,37 +0,0 @@
1#ifndef __wasilibc___header_time_h
2#define __wasilibc___header_time_h
3
4#define __need_size_t
5#define __need_NULL
6#include <stddef.h>
7
8#include <__typedef_time_t.h>
9#include <__struct_timespec.h>
10#include <__struct_tm.h>
11#include <__typedef_clockid_t.h>
12
13#include <wasi/api.h>
14
15#define TIMER_ABSTIME __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME
16
17extern const struct __clockid _CLOCK_MONOTONIC;
18#define CLOCK_MONOTONIC (&_CLOCK_MONOTONIC)
19extern const struct __clockid _CLOCK_PROCESS_CPUTIME_ID;
20#define CLOCK_PROCESS_CPUTIME_ID (&_CLOCK_PROCESS_CPUTIME_ID)
21extern const struct __clockid _CLOCK_REALTIME;
22#define CLOCK_REALTIME (&_CLOCK_REALTIME)
23extern const struct __clockid _CLOCK_THREAD_CPUTIME_ID;
24#define CLOCK_THREAD_CPUTIME_ID (&_CLOCK_THREAD_CPUTIME_ID)
25
26/*
27 * TIME_UTC is the only standardized time base value.
28 */
29#define TIME_UTC 1
30
31/*
32 * Note that XSI specifies CLOCKS_PER_SEC to be 1000000, rather than
33 * 1000000000; the clock API is providing more precision than XSI specifies.
34 */
35#define CLOCKS_PER_SEC ((clock_t)1000000000)
36
37#endif
lib/libc/include/wasm32-wasi/__header_unistd.h deleted-28
......@@ -1,28 +0,0 @@
1#ifndef __wasilibc___header_unistd_h
2#define __wasilibc___header_unistd_h
3
4struct stat;
5
6#include <__seek.h>
7
8#define F_OK (0)
9#define X_OK (1)
10#define W_OK (2)
11#define R_OK (4)
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17int close(int fd);
18int faccessat(int, const char *, int, int);
19int fstatat(int, const char *__restrict, struct stat *__restrict, int);
20int renameat(int, const char *, int, const char *);
21int openat(int, const char *, int, ...);
22void *sbrk(intptr_t increment);
23
24#ifdef __cplusplus
25}
26#endif
27
28#endif
lib/libc/include/wasm32-wasi/__macro_FD_SETSIZE.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___macro_FD_SETSIZE_h
2#define __wasilibc___macro_FD_SETSIZE_h
3
4#define FD_SETSIZE 1024
5
6#endif
lib/libc/include/wasm32-wasi/__macro_PAGESIZE.h deleted-11
......@@ -1,11 +0,0 @@
1#ifndef __wasilibc___macro_PAGESIZE_h
2#define __wasilibc___macro_PAGESIZE_h
3
4/*
5 * The page size in WebAssembly is fixed at 64 KiB. If this ever changes,
6 * it's expected that applications will need to opt in, so we can change
7 * this.
8 */
9#define PAGESIZE (0x10000)
10
11#endif
lib/libc/include/wasm32-wasi/__mode_t.h deleted-38
......@@ -1,38 +0,0 @@
1#ifndef __wasilibc___mode_t_h
2#define __wasilibc___mode_t_h
3
4#define S_IFMT \
5 (S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK)
6#define S_IFBLK (0x6000)
7#define S_IFCHR (0x2000)
8#define S_IFDIR (0x4000)
9#define S_IFLNK (0xa000)
10#define S_IFREG (0x8000)
11#define S_IFSOCK (0xc000)
12#define S_IFIFO (0xc000)
13
14#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK)
15#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR)
16#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
17#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO)
18#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK)
19#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
20#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK)
21
22#define S_IXOTH (0x1)
23#define S_IWOTH (0x2)
24#define S_IROTH (0x4)
25#define S_IRWXO (S_IXOTH | S_IWOTH | S_IROTH)
26#define S_IXGRP (0x8)
27#define S_IWGRP (0x10)
28#define S_IRGRP (0x20)
29#define S_IRWXG (S_IXGRP | S_IWGRP | S_IRGRP)
30#define S_IXUSR (0x40)
31#define S_IWUSR (0x80)
32#define S_IRUSR (0x100)
33#define S_IRWXU (S_IXUSR | S_IWUSR | S_IRUSR)
34#define S_ISVTX (0x200)
35#define S_ISGID (0x400)
36#define S_ISUID (0x800)
37
38#endif
lib/libc/include/wasm32-wasi/__seek.h deleted-10
......@@ -1,10 +0,0 @@
1#ifndef __wasilibc___seek_h
2#define __wasilibc___seek_h
3
4#include <wasi/api.h>
5
6#define SEEK_CUR __WASI_WHENCE_CUR
7#define SEEK_END __WASI_WHENCE_END
8#define SEEK_SET __WASI_WHENCE_SET
9
10#endif
lib/libc/include/wasm32-wasi/__struct_dirent.h deleted-14
......@@ -1,14 +0,0 @@
1#ifndef __wasilibc___struct_dirent_h
2#define __wasilibc___struct_dirent_h
3
4#include <__typedef_ino_t.h>
5
6#define _DIRENT_HAVE_D_TYPE
7
8struct dirent {
9 ino_t d_ino;
10 unsigned char d_type;
11 char d_name[];
12};
13
14#endif
lib/libc/include/wasm32-wasi/__struct_in6_addr.h deleted-8
......@@ -1,8 +0,0 @@
1#ifndef __wasilibc___struct_in6_addr_h
2#define __wasilibc___struct_in6_addr_h
3
4struct in6_addr {
5 _Alignas(int32_t) unsigned char s6_addr[16];
6};
7
8#endif
lib/libc/include/wasm32-wasi/__struct_in_addr.h deleted-10
......@@ -1,10 +0,0 @@
1#ifndef __wasilibc___struct_in_addr_h
2#define __wasilibc___struct_in_addr_h
3
4#include <__typedef_in_addr_t.h>
5
6struct in_addr {
7 in_addr_t s_addr;
8};
9
10#endif
lib/libc/include/wasm32-wasi/__struct_iovec.h deleted-12
......@@ -1,12 +0,0 @@
1#ifndef __wasilibc___struct_iovec_h
2#define __wasilibc___struct_iovec_h
3
4#define __need_size_t
5#include <stddef.h>
6
7struct iovec {
8 void *iov_base;
9 size_t iov_len;
10};
11
12#endif
lib/libc/include/wasm32-wasi/__struct_msghdr.h deleted-16
......@@ -1,16 +0,0 @@
1#ifndef __wasilibc___struct_msghdr_h
2#define __wasilibc___struct_msghdr_h
3
4#include <__typedef_socklen_t.h>
5
6struct msghdr {
7 void *msg_name;
8 socklen_t msg_namelen;
9 struct iovec *msg_iov;
10 int msg_iovlen;
11 void *msg_control;
12 socklen_t msg_controllen;
13 int msg_flags;
14};
15
16#endif
lib/libc/include/wasm32-wasi/__struct_pollfd.h deleted-10
......@@ -1,10 +0,0 @@
1#ifndef __wasilibc___struct_pollfd_h
2#define __wasilibc___struct_pollfd_h
3
4struct pollfd {
5 int fd;
6 short events;
7 short revents;
8};
9
10#endif
lib/libc/include/wasm32-wasi/__struct_rusage.h deleted-12
......@@ -1,12 +0,0 @@
1#ifndef __wasilibc___struct_rusage_h
2#define __wasilibc___struct_rusage_h
3
4#include <__struct_timeval.h>
5
6/* TODO: Add more features here. */
7struct rusage {
8 struct timeval ru_utime;
9 struct timeval ru_stime;
10};
11
12#endif
lib/libc/include/wasm32-wasi/__struct_sockaddr.h deleted-14
......@@ -1,14 +0,0 @@
1#ifndef __wasilibc___struct_sockaddr_h
2#define __wasilibc___struct_sockaddr_h
3
4#define __need_STDDEF_H_misc
5#include <stddef.h>
6
7#include <__typedef_sa_family_t.h>
8
9struct sockaddr {
10 _Alignas(max_align_t) sa_family_t sa_family;
11 char sa_data[0];
12};
13
14#endif
lib/libc/include/wasm32-wasi/__struct_sockaddr_in.h deleted-17
......@@ -1,17 +0,0 @@
1#ifndef __wasilibc___struct_sockaddr_in_h
2#define __wasilibc___struct_sockaddr_in_h
3
4#define __need_STDDEF_H_misc
5#include <stddef.h>
6
7#include <__typedef_sa_family_t.h>
8#include <__typedef_in_port_t.h>
9#include <__struct_in_addr.h>
10
11struct sockaddr_in {
12 _Alignas(max_align_t) sa_family_t sin_family;
13 in_port_t sin_port;
14 struct in_addr sin_addr;
15};
16
17#endif
lib/libc/include/wasm32-wasi/__struct_sockaddr_in6.h deleted-19
......@@ -1,19 +0,0 @@
1#ifndef __wasilibc___struct_sockaddr_in6_h
2#define __wasilibc___struct_sockaddr_in6_h
3
4#define __need_STDDEF_H_misc
5#include <stddef.h>
6
7#include <__typedef_sa_family_t.h>
8#include <__typedef_in_port_t.h>
9#include <__struct_in6_addr.h>
10
11struct sockaddr_in6 {
12 _Alignas(max_align_t) sa_family_t sin6_family;
13 in_port_t sin6_port;
14 unsigned sin6_flowinfo;
15 struct in6_addr sin6_addr;
16 unsigned sin6_scope_id;
17};
18
19#endif
lib/libc/include/wasm32-wasi/__struct_sockaddr_storage.h deleted-14
......@@ -1,14 +0,0 @@
1#ifndef __wasilibc___struct_sockaddr_storage_h
2#define __wasilibc___struct_sockaddr_storage_h
3
4#define __need_STDDEF_H_misc
5#include <stddef.h>
6
7#include <__typedef_sa_family_t.h>
8
9struct sockaddr_storage {
10 _Alignas(max_align_t) sa_family_t ss_family;
11 char __ss_data[32];
12};
13
14#endif
lib/libc/include/wasm32-wasi/__struct_sockaddr_un.h deleted-13
......@@ -1,13 +0,0 @@
1#ifndef __wasilibc___struct_sockaddr_un_h
2#define __wasilibc___struct_sockaddr_un_h
3
4#define __need_STDDEF_H_misc
5#include <stddef.h>
6
7#include <__typedef_sa_family_t.h>
8
9struct sockaddr_un {
10 _Alignas(max_align_t) sa_family_t sun_family;
11};
12
13#endif
lib/libc/include/wasm32-wasi/__struct_stat.h deleted-35
......@@ -1,35 +0,0 @@
1#ifndef __wasilibc___struct_stat_h
2#define __wasilibc___struct_stat_h
3
4#include <__typedef_dev_t.h>
5#include <__typedef_ino_t.h>
6#include <__typedef_nlink_t.h>
7#include <__typedef_mode_t.h>
8#include <__typedef_uid_t.h>
9#include <__typedef_gid_t.h>
10#include <__typedef_off_t.h>
11#include <__typedef_blksize_t.h>
12#include <__typedef_blkcnt_t.h>
13#include <__struct_timespec.h>
14
15struct stat {
16 dev_t st_dev;
17 ino_t st_ino;
18 nlink_t st_nlink;
19
20 mode_t st_mode;
21 uid_t st_uid;
22 gid_t st_gid;
23 unsigned int __pad0;
24 dev_t st_rdev;
25 off_t st_size;
26 blksize_t st_blksize;
27 blkcnt_t st_blocks;
28
29 struct timespec st_atim;
30 struct timespec st_mtim;
31 struct timespec st_ctim;
32 long long __reserved[3];
33};
34
35#endif
lib/libc/include/wasm32-wasi/__struct_timespec.h deleted-12
......@@ -1,12 +0,0 @@
1#ifndef __wasilibc___struct_timespec_h
2#define __wasilibc___struct_timespec_h
3
4#include <__typedef_time_t.h>
5
6/* As specified in POSIX. */
7struct timespec {
8 time_t tv_sec;
9 long tv_nsec;
10};
11
12#endif
lib/libc/include/wasm32-wasi/__struct_timeval.h deleted-13
......@@ -1,13 +0,0 @@
1#ifndef __wasilibc___struct_timeval_h
2#define __wasilibc___struct_timeval_h
3
4#include <__typedef_time_t.h>
5#include <__typedef_suseconds_t.h>
6
7/* As specified in POSIX. */
8struct timeval {
9 time_t tv_sec;
10 suseconds_t tv_usec;
11};
12
13#endif
lib/libc/include/wasm32-wasi/__struct_tm.h deleted-19
......@@ -1,19 +0,0 @@
1#ifndef __wasilibc___struct_tm_h
2#define __wasilibc___struct_tm_h
3
4struct tm {
5 int tm_sec;
6 int tm_min;
7 int tm_hour;
8 int tm_mday;
9 int tm_mon;
10 int tm_year;
11 int tm_wday;
12 int tm_yday;
13 int tm_isdst;
14 int __tm_gmtoff;
15 const char *__tm_zone;
16 int __tm_nsec;
17};
18
19#endif
lib/libc/include/wasm32-wasi/__struct_tms.h deleted-13
......@@ -1,13 +0,0 @@
1#ifndef __wasilibc___struct_tms_h
2#define __wasilibc___struct_tms_h
3
4#include <__typedef_clock_t.h>
5
6struct tms {
7 clock_t tms_utime;
8 clock_t tms_stime;
9 clock_t tms_cutime;
10 clock_t tms_cstime;
11};
12
13#endif
lib/libc/include/wasm32-wasi/__typedef_DIR.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___typedef_DIR_h
2#define __wasilibc___typedef_DIR_h
3
4typedef struct _DIR DIR;
5
6#endif
lib/libc/include/wasm32-wasi/__typedef_blkcnt_t.h deleted-7
......@@ -1,7 +0,0 @@
1#ifndef __wasilibc___typedef_blkcnt_t_h
2#define __wasilibc___typedef_blkcnt_t_h
3
4/* Define these as 64-bit signed integers to support files larger than 2 GiB. */
5typedef long long blkcnt_t;
6
7#endif
lib/libc/include/wasm32-wasi/__typedef_blksize_t.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___typedef_blksize_t_h
2#define __wasilibc___typedef_blksize_t_h
3
4typedef long blksize_t;
5
6#endif
lib/libc/include/wasm32-wasi/__typedef_clock_t.h deleted-7
......@@ -1,7 +0,0 @@
1#ifndef __wasilibc___typedef_clock_t_h
2#define __wasilibc___typedef_clock_t_h
3
4/* Define this as a 64-bit signed integer to avoid wraparounds. */
5typedef long long clock_t;
6
7#endif
lib/libc/include/wasm32-wasi/__typedef_clockid_t.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___typedef_clockid_t_h
2#define __wasilibc___typedef_clockid_t_h
3
4typedef const struct __clockid *clockid_t;
5
6#endif
lib/libc/include/wasm32-wasi/__typedef_dev_t.h deleted-7
......@@ -1,7 +0,0 @@
1#ifndef __wasilibc___typedef_dev_t_h
2#define __wasilibc___typedef_dev_t_h
3
4/* Define these as 64-bit integers to support billions of devices. */
5typedef unsigned long long dev_t;
6
7#endif
lib/libc/include/wasm32-wasi/__typedef_fd_set.h deleted-14
......@@ -1,14 +0,0 @@
1#ifndef __wasilibc___typedef_fd_set_h
2#define __wasilibc___typedef_fd_set_h
3
4#define __need_size_t
5#include <stddef.h>
6
7#include <__macro_FD_SETSIZE.h>
8
9typedef struct {
10 size_t __nfds;
11 int __fds[FD_SETSIZE];
12} fd_set;
13
14#endif
lib/libc/include/wasm32-wasi/__typedef_gid_t.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___typedef_gid_t_h
2#define __wasilibc___typedef_gid_t_h
3
4typedef unsigned gid_t;
5
6#endif
lib/libc/include/wasm32-wasi/__typedef_in_addr_t.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___typedef_in_addr_t_h
2#define __wasilibc___typedef_in_addr_t_h
3
4typedef unsigned in_addr_t;
5
6#endif
lib/libc/include/wasm32-wasi/__typedef_in_port_t.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___typedef_in_port_t_h
2#define __wasilibc___typedef_in_port_t_h
3
4typedef unsigned short in_port_t;
5
6#endif
lib/libc/include/wasm32-wasi/__typedef_ino_t.h deleted-7
......@@ -1,7 +0,0 @@
1#ifndef __wasilibc___typedef_ino_t_h
2#define __wasilibc___typedef_ino_t_h
3
4/* Define these as 64-bit integers to support billions of inodes. */
5typedef unsigned long long ino_t;
6
7#endif
lib/libc/include/wasm32-wasi/__typedef_mode_t.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___typedef_mode_t_h
2#define __wasilibc___typedef_mode_t_h
3
4typedef unsigned mode_t;
5
6#endif
lib/libc/include/wasm32-wasi/__typedef_nfds_t.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___typedef_nfds_t_h
2#define __wasilibc___typedef_nfds_t_h
3
4typedef unsigned long nfds_t;
5
6#endif
lib/libc/include/wasm32-wasi/__typedef_nlink_t.h deleted-7
......@@ -1,7 +0,0 @@
1#ifndef __wasilibc___typedef_nlink_t_h
2#define __wasilibc___typedef_nlink_t_h
3
4/* Define these as 64-bit unsigned integers to support billions of links. */
5typedef unsigned long long nlink_t;
6
7#endif
lib/libc/include/wasm32-wasi/__typedef_off_t.h deleted-7
......@@ -1,7 +0,0 @@
1#ifndef __wasilibc___typedef_off_t_h
2#define __wasilibc___typedef_off_t_h
3
4/* Define these as 64-bit signed integers to support files larger than 2 GiB. */
5typedef long long off_t;
6
7#endif
lib/libc/include/wasm32-wasi/__typedef_sa_family_t.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___typedef_sa_family_t_h
2#define __wasilibc___typedef_sa_family_t_h
3
4typedef unsigned short sa_family_t;
5
6#endif
lib/libc/include/wasm32-wasi/__typedef_sigset_t.h deleted-7
......@@ -1,7 +0,0 @@
1#ifndef __wasilibc___typedef_sigset_t_h
2#define __wasilibc___typedef_sigset_t_h
3
4/* TODO: This is just a placeholder for now. Keep this in sync with musl. */
5typedef unsigned char sigset_t;
6
7#endif
lib/libc/include/wasm32-wasi/__typedef_socklen_t.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___typedef_socklen_t_h
2#define __wasilibc___typedef_socklen_t_h
3
4typedef unsigned socklen_t;
5
6#endif
lib/libc/include/wasm32-wasi/__typedef_ssize_t.h deleted-7
......@@ -1,7 +0,0 @@
1#ifndef __wasilibc___typedef_ssize_t_h
2#define __wasilibc___typedef_ssize_t_h
3
4/* This is defined to be the same size as size_t. */
5typedef long ssize_t;
6
7#endif
lib/libc/include/wasm32-wasi/__typedef_suseconds_t.h deleted-8
......@@ -1,8 +0,0 @@
1#ifndef __wasilibc___typedef_suseconds_t_h
2#define __wasilibc___typedef_suseconds_t_h
3
4/* Define this to be 64-bit as its main use is in struct timeval where the
5 extra space would otherwise be padding. */
6typedef long long suseconds_t;
7
8#endif
lib/libc/include/wasm32-wasi/__typedef_time_t.h deleted-7
......@@ -1,7 +0,0 @@
1#ifndef __wasilibc___typedef_time_t_h
2#define __wasilibc___typedef_time_t_h
3
4/* Define this as a 64-bit signed integer to avoid the 2038 bug. */
5typedef long long time_t;
6
7#endif
lib/libc/include/wasm32-wasi/__typedef_uid_t.h deleted-6
......@@ -1,6 +0,0 @@
1#ifndef __wasilibc___typedef_uid_t_h
2#define __wasilibc___typedef_uid_t_h
3
4typedef unsigned uid_t;
5
6#endif
lib/libc/include/wasm32-wasi/alloca.h deleted-19
......@@ -1,19 +0,0 @@
1#ifndef _ALLOCA_H
2#define _ALLOCA_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_size_t
9#include <bits/alltypes.h>
10
11void *alloca(size_t);
12
13#define alloca __builtin_alloca
14
15#ifdef __cplusplus
16}
17#endif
18
19#endif
lib/libc/include/wasm32-wasi/ar.h deleted-25
......@@ -1,25 +0,0 @@
1#ifndef _AR_H
2#define _AR_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define ARMAG "!<arch>\n"
9#define SARMAG 8
10#define ARFMAG "`\n"
11
12struct ar_hdr {
13 char ar_name[16];
14 char ar_date[12];
15 char ar_uid[6], ar_gid[6];
16 char ar_mode[8];
17 char ar_size[10];
18 char ar_fmag[2];
19};
20
21#ifdef __cplusplus
22}
23#endif
24
25#endif
lib/libc/include/wasm32-wasi/arpa/ftp.h deleted-35
......@@ -1,35 +0,0 @@
1#ifndef _ARPA_FTP_H
2#define _ARPA_FTP_H
3#define PRELIM 1
4#define COMPLETE 2
5#define CONTINUE 3
6#define TRANSIENT 4
7#define ERROR 5
8#define TYPE_A 1
9#define TYPE_E 2
10#define TYPE_I 3
11#define TYPE_L 4
12#define FORM_N 1
13#define FORM_T 2
14#define FORM_C 3
15#define STRU_F 1
16#define STRU_R 2
17#define STRU_P 3
18#define MODE_S 1
19#define MODE_B 2
20#define MODE_C 3
21#define REC_ESC '\377'
22#define REC_EOR '\001'
23#define REC_EOF '\002'
24#define BLK_EOR 0x80
25#define BLK_EOF 0x40
26#define BLK_ERRORS 0x20
27#define BLK_RESTART 0x10
28#define BLK_BYTECOUNT 2
29#ifdef FTP_NAMES
30char *modenames[] = {"0", "Stream", "Block", "Compressed" };
31char *strunames[] = {"0", "File", "Record", "Page" };
32char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" };
33char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" };
34#endif
35#endif
lib/libc/include/wasm32-wasi/arpa/inet.h deleted-35
......@@ -1,35 +0,0 @@
1#ifndef _ARPA_INET_H
2#define _ARPA_INET_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <netinet/in.h>
10
11uint32_t htonl(uint32_t);
12uint16_t htons(uint16_t);
13uint32_t ntohl(uint32_t);
14uint16_t ntohs(uint16_t);
15
16#ifdef __wasilibc_unmodified_upstream /* WASI has no inet_addr */
17in_addr_t inet_addr (const char *);
18in_addr_t inet_network (const char *);
19char *inet_ntoa (struct in_addr);
20#endif
21int inet_pton (int, const char *__restrict, void *__restrict);
22const char *inet_ntop (int, const void *__restrict, char *__restrict, socklen_t);
23
24int inet_aton (const char *, struct in_addr *);
25#ifdef __wasilibc_unmodified_upstream /* WASI has no inet_makeaddr */
26struct in_addr inet_makeaddr(in_addr_t, in_addr_t);
27in_addr_t inet_lnaof(struct in_addr);
28in_addr_t inet_netof(struct in_addr);
29#endif
30
31#ifdef __cplusplus
32}
33#endif
34
35#endif
lib/libc/include/wasm32-wasi/arpa/nameser.h deleted-455
......@@ -1,455 +0,0 @@
1#ifndef _ARPA_NAMESER_H
2#define _ARPA_NAMESER_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stddef.h>
9#include <stdint.h>
10
11#define __NAMESER 19991006
12#define NS_PACKETSZ 512
13#define NS_MAXDNAME 1025
14#define NS_MAXMSG 65535
15#define NS_MAXCDNAME 255
16#define NS_MAXLABEL 63
17#define NS_HFIXEDSZ 12
18#define NS_QFIXEDSZ 4
19#define NS_RRFIXEDSZ 10
20#define NS_INT32SZ 4
21#define NS_INT16SZ 2
22#define NS_INT8SZ 1
23#define NS_INADDRSZ 4
24#define NS_IN6ADDRSZ 16
25#define NS_CMPRSFLGS 0xc0
26#define NS_DEFAULTPORT 53
27
28typedef enum __ns_sect {
29 ns_s_qd = 0,
30 ns_s_zn = 0,
31 ns_s_an = 1,
32 ns_s_pr = 1,
33 ns_s_ns = 2,
34 ns_s_ud = 2,
35 ns_s_ar = 3,
36 ns_s_max = 4
37} ns_sect;
38
39typedef struct __ns_msg {
40 const unsigned char *_msg, *_eom;
41 uint16_t _id, _flags, _counts[ns_s_max];
42 const unsigned char *_sections[ns_s_max];
43 ns_sect _sect;
44 int _rrnum;
45 const unsigned char *_msg_ptr;
46} ns_msg;
47
48struct _ns_flagdata { int mask, shift; };
49extern const struct _ns_flagdata _ns_flagdata[];
50
51#define ns_msg_id(handle) ((handle)._id + 0)
52#define ns_msg_base(handle) ((handle)._msg + 0)
53#define ns_msg_end(handle) ((handle)._eom + 0)
54#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
55#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
56#define ns_msg_getflag(handle, flag) \
57 (((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift)
58
59typedef struct __ns_rr {
60 char name[NS_MAXDNAME];
61 uint16_t type;
62 uint16_t rr_class;
63 uint32_t ttl;
64 uint16_t rdlength;
65 const unsigned char *rdata;
66} ns_rr;
67
68#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
69#define ns_rr_type(rr) ((ns_type)((rr).type + 0))
70#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
71#define ns_rr_ttl(rr) ((rr).ttl + 0)
72#define ns_rr_rdlen(rr) ((rr).rdlength + 0)
73#define ns_rr_rdata(rr) ((rr).rdata + 0)
74
75typedef enum __ns_flag {
76 ns_f_qr,
77 ns_f_opcode,
78 ns_f_aa,
79 ns_f_tc,
80 ns_f_rd,
81 ns_f_ra,
82 ns_f_z,
83 ns_f_ad,
84 ns_f_cd,
85 ns_f_rcode,
86 ns_f_max
87} ns_flag;
88
89typedef enum __ns_opcode {
90 ns_o_query = 0,
91 ns_o_iquery = 1,
92 ns_o_status = 2,
93 ns_o_notify = 4,
94 ns_o_update = 5,
95 ns_o_max = 6
96} ns_opcode;
97
98typedef enum __ns_rcode {
99 ns_r_noerror = 0,
100 ns_r_formerr = 1,
101 ns_r_servfail = 2,
102 ns_r_nxdomain = 3,
103 ns_r_notimpl = 4,
104 ns_r_refused = 5,
105 ns_r_yxdomain = 6,
106 ns_r_yxrrset = 7,
107 ns_r_nxrrset = 8,
108 ns_r_notauth = 9,
109 ns_r_notzone = 10,
110 ns_r_max = 11,
111 ns_r_badvers = 16,
112 ns_r_badsig = 16,
113 ns_r_badkey = 17,
114 ns_r_badtime = 18
115} ns_rcode;
116
117typedef enum __ns_update_operation {
118 ns_uop_delete = 0,
119 ns_uop_add = 1,
120 ns_uop_max = 2
121} ns_update_operation;
122
123struct ns_tsig_key {
124 char name[NS_MAXDNAME], alg[NS_MAXDNAME];
125 unsigned char *data;
126 int len;
127};
128typedef struct ns_tsig_key ns_tsig_key;
129
130struct ns_tcp_tsig_state {
131 int counter;
132 struct dst_key *key;
133 void *ctx;
134 unsigned char sig[NS_PACKETSZ];
135 int siglen;
136};
137typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
138
139#define NS_TSIG_FUDGE 300
140#define NS_TSIG_TCP_COUNT 100
141#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
142
143#define NS_TSIG_ERROR_NO_TSIG -10
144#define NS_TSIG_ERROR_NO_SPACE -11
145#define NS_TSIG_ERROR_FORMERR -12
146
147typedef enum __ns_type {
148 ns_t_invalid = 0,
149 ns_t_a = 1,
150 ns_t_ns = 2,
151 ns_t_md = 3,
152 ns_t_mf = 4,
153 ns_t_cname = 5,
154 ns_t_soa = 6,
155 ns_t_mb = 7,
156 ns_t_mg = 8,
157 ns_t_mr = 9,
158 ns_t_null = 10,
159 ns_t_wks = 11,
160 ns_t_ptr = 12,
161 ns_t_hinfo = 13,
162 ns_t_minfo = 14,
163 ns_t_mx = 15,
164 ns_t_txt = 16,
165 ns_t_rp = 17,
166 ns_t_afsdb = 18,
167 ns_t_x25 = 19,
168 ns_t_isdn = 20,
169 ns_t_rt = 21,
170 ns_t_nsap = 22,
171 ns_t_nsap_ptr = 23,
172 ns_t_sig = 24,
173 ns_t_key = 25,
174 ns_t_px = 26,
175 ns_t_gpos = 27,
176 ns_t_aaaa = 28,
177 ns_t_loc = 29,
178 ns_t_nxt = 30,
179 ns_t_eid = 31,
180 ns_t_nimloc = 32,
181 ns_t_srv = 33,
182 ns_t_atma = 34,
183 ns_t_naptr = 35,
184 ns_t_kx = 36,
185 ns_t_cert = 37,
186 ns_t_a6 = 38,
187 ns_t_dname = 39,
188 ns_t_sink = 40,
189 ns_t_opt = 41,
190 ns_t_apl = 42,
191 ns_t_tkey = 249,
192 ns_t_tsig = 250,
193 ns_t_ixfr = 251,
194 ns_t_axfr = 252,
195 ns_t_mailb = 253,
196 ns_t_maila = 254,
197 ns_t_any = 255,
198 ns_t_zxfr = 256,
199 ns_t_max = 65536
200} ns_type;
201
202#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
203 (t) == ns_t_mailb || (t) == ns_t_maila)
204#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
205#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
206#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
207#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
208 (t) == ns_t_zxfr)
209
210typedef enum __ns_class {
211 ns_c_invalid = 0,
212 ns_c_in = 1,
213 ns_c_2 = 2,
214 ns_c_chaos = 3,
215 ns_c_hs = 4,
216 ns_c_none = 254,
217 ns_c_any = 255,
218 ns_c_max = 65536
219} ns_class;
220
221typedef enum __ns_key_types {
222 ns_kt_rsa = 1,
223 ns_kt_dh = 2,
224 ns_kt_dsa = 3,
225 ns_kt_private = 254
226} ns_key_types;
227
228typedef enum __ns_cert_types {
229 cert_t_pkix = 1,
230 cert_t_spki = 2,
231 cert_t_pgp = 3,
232 cert_t_url = 253,
233 cert_t_oid = 254
234} ns_cert_types;
235
236#define NS_KEY_TYPEMASK 0xC000
237#define NS_KEY_TYPE_AUTH_CONF 0x0000
238#define NS_KEY_TYPE_CONF_ONLY 0x8000
239#define NS_KEY_TYPE_AUTH_ONLY 0x4000
240#define NS_KEY_TYPE_NO_KEY 0xC000
241#define NS_KEY_NO_AUTH 0x8000
242#define NS_KEY_NO_CONF 0x4000
243#define NS_KEY_RESERVED2 0x2000
244#define NS_KEY_EXTENDED_FLAGS 0x1000
245#define NS_KEY_RESERVED4 0x0800
246#define NS_KEY_RESERVED5 0x0400
247#define NS_KEY_NAME_TYPE 0x0300
248#define NS_KEY_NAME_USER 0x0000
249#define NS_KEY_NAME_ENTITY 0x0200
250#define NS_KEY_NAME_ZONE 0x0100
251#define NS_KEY_NAME_RESERVED 0x0300
252#define NS_KEY_RESERVED8 0x0080
253#define NS_KEY_RESERVED9 0x0040
254#define NS_KEY_RESERVED10 0x0020
255#define NS_KEY_RESERVED11 0x0010
256#define NS_KEY_SIGNATORYMASK 0x000F
257#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
258 NS_KEY_RESERVED4 | \
259 NS_KEY_RESERVED5 | \
260 NS_KEY_RESERVED8 | \
261 NS_KEY_RESERVED9 | \
262 NS_KEY_RESERVED10 | \
263 NS_KEY_RESERVED11 )
264#define NS_KEY_RESERVED_BITMASK2 0xFFFF
265#define NS_ALG_MD5RSA 1
266#define NS_ALG_DH 2
267#define NS_ALG_DSA 3
268#define NS_ALG_DSS NS_ALG_DSA
269#define NS_ALG_EXPIRE_ONLY 253
270#define NS_ALG_PRIVATE_OID 254
271
272#define NS_KEY_PROT_TLS 1
273#define NS_KEY_PROT_EMAIL 2
274#define NS_KEY_PROT_DNSSEC 3
275#define NS_KEY_PROT_IPSEC 4
276#define NS_KEY_PROT_ANY 255
277
278#define NS_MD5RSA_MIN_BITS 512
279#define NS_MD5RSA_MAX_BITS 4096
280#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
281#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4)
282#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8)
283#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8)
284
285#define NS_DSA_SIG_SIZE 41
286#define NS_DSA_MIN_SIZE 213
287#define NS_DSA_MAX_BYTES 405
288
289#define NS_SIG_TYPE 0
290#define NS_SIG_ALG 2
291#define NS_SIG_LABELS 3
292#define NS_SIG_OTTL 4
293#define NS_SIG_EXPIR 8
294#define NS_SIG_SIGNED 12
295#define NS_SIG_FOOT 16
296#define NS_SIG_SIGNER 18
297#define NS_NXT_BITS 8
298#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS)))
299#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
300#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS)))
301#define NS_NXT_MAX 127
302
303#define NS_OPT_DNSSEC_OK 0x8000U
304#define NS_OPT_NSID 3
305
306#define NS_GET16(s, cp) (void)((s) = ns_get16(((cp)+=2)-2))
307#define NS_GET32(l, cp) (void)((l) = ns_get32(((cp)+=4)-4))
308#define NS_PUT16(s, cp) ns_put16((s), ((cp)+=2)-2)
309#define NS_PUT32(l, cp) ns_put32((l), ((cp)+=4)-4)
310
311unsigned ns_get16(const unsigned char *);
312unsigned long ns_get32(const unsigned char *);
313void ns_put16(unsigned, unsigned char *);
314void ns_put32(unsigned long, unsigned char *);
315
316int ns_initparse(const unsigned char *, int, ns_msg *);
317int ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
318int ns_skiprr(const unsigned char *, const unsigned char *, ns_sect, int);
319int ns_name_uncompress(const unsigned char *, const unsigned char *, const unsigned char *, char *, size_t);
320
321
322#define __BIND 19950621
323
324typedef struct {
325 unsigned id :16;
326#if __BYTE_ORDER == __BIG_ENDIAN
327 unsigned qr: 1;
328 unsigned opcode: 4;
329 unsigned aa: 1;
330 unsigned tc: 1;
331 unsigned rd: 1;
332 unsigned ra: 1;
333 unsigned unused :1;
334 unsigned ad: 1;
335 unsigned cd: 1;
336 unsigned rcode :4;
337#else
338 unsigned rd :1;
339 unsigned tc :1;
340 unsigned aa :1;
341 unsigned opcode :4;
342 unsigned qr :1;
343 unsigned rcode :4;
344 unsigned cd: 1;
345 unsigned ad: 1;
346 unsigned unused :1;
347 unsigned ra :1;
348#endif
349 unsigned qdcount :16;
350 unsigned ancount :16;
351 unsigned nscount :16;
352 unsigned arcount :16;
353} HEADER;
354
355#define PACKETSZ NS_PACKETSZ
356#define MAXDNAME NS_MAXDNAME
357#define MAXCDNAME NS_MAXCDNAME
358#define MAXLABEL NS_MAXLABEL
359#define HFIXEDSZ NS_HFIXEDSZ
360#define QFIXEDSZ NS_QFIXEDSZ
361#define RRFIXEDSZ NS_RRFIXEDSZ
362#define INT32SZ NS_INT32SZ
363#define INT16SZ NS_INT16SZ
364#define INT8SZ NS_INT8SZ
365#define INADDRSZ NS_INADDRSZ
366#define IN6ADDRSZ NS_IN6ADDRSZ
367#define INDIR_MASK NS_CMPRSFLGS
368#define NAMESERVER_PORT NS_DEFAULTPORT
369
370#define S_ZONE ns_s_zn
371#define S_PREREQ ns_s_pr
372#define S_UPDATE ns_s_ud
373#define S_ADDT ns_s_ar
374
375#define QUERY ns_o_query
376#define IQUERY ns_o_iquery
377#define STATUS ns_o_status
378#define NS_NOTIFY_OP ns_o_notify
379#define NS_UPDATE_OP ns_o_update
380
381#define NOERROR ns_r_noerror
382#define FORMERR ns_r_formerr
383#define SERVFAIL ns_r_servfail
384#define NXDOMAIN ns_r_nxdomain
385#define NOTIMP ns_r_notimpl
386#define REFUSED ns_r_refused
387#define YXDOMAIN ns_r_yxdomain
388#define YXRRSET ns_r_yxrrset
389#define NXRRSET ns_r_nxrrset
390#define NOTAUTH ns_r_notauth
391#define NOTZONE ns_r_notzone
392
393#define DELETE ns_uop_delete
394#define ADD ns_uop_add
395
396#define T_A ns_t_a
397#define T_NS ns_t_ns
398#define T_MD ns_t_md
399#define T_MF ns_t_mf
400#define T_CNAME ns_t_cname
401#define T_SOA ns_t_soa
402#define T_MB ns_t_mb
403#define T_MG ns_t_mg
404#define T_MR ns_t_mr
405#define T_NULL ns_t_null
406#define T_WKS ns_t_wks
407#define T_PTR ns_t_ptr
408#define T_HINFO ns_t_hinfo
409#define T_MINFO ns_t_minfo
410#define T_MX ns_t_mx
411#define T_TXT ns_t_txt
412#define T_RP ns_t_rp
413#define T_AFSDB ns_t_afsdb
414#define T_X25 ns_t_x25
415#define T_ISDN ns_t_isdn
416#define T_RT ns_t_rt
417#define T_NSAP ns_t_nsap
418#define T_NSAP_PTR ns_t_nsap_ptr
419#define T_SIG ns_t_sig
420#define T_KEY ns_t_key
421#define T_PX ns_t_px
422#define T_GPOS ns_t_gpos
423#define T_AAAA ns_t_aaaa
424#define T_LOC ns_t_loc
425#define T_NXT ns_t_nxt
426#define T_EID ns_t_eid
427#define T_NIMLOC ns_t_nimloc
428#define T_SRV ns_t_srv
429#define T_ATMA ns_t_atma
430#define T_NAPTR ns_t_naptr
431#define T_A6 ns_t_a6
432#define T_DNAME ns_t_dname
433#define T_TSIG ns_t_tsig
434#define T_IXFR ns_t_ixfr
435#define T_AXFR ns_t_axfr
436#define T_MAILB ns_t_mailb
437#define T_MAILA ns_t_maila
438#define T_ANY ns_t_any
439
440#define C_IN ns_c_in
441#define C_CHAOS ns_c_chaos
442#define C_HS ns_c_hs
443#define C_NONE ns_c_none
444#define C_ANY ns_c_any
445
446#define GETSHORT NS_GET16
447#define GETLONG NS_GET32
448#define PUTSHORT NS_PUT16
449#define PUTLONG NS_PUT32
450
451#ifdef __cplusplus
452}
453#endif
454
455#endif
lib/libc/include/wasm32-wasi/arpa/nameser_compat.h deleted-2
......@@ -1,2 +0,0 @@
1#include <arpa/nameser.h>
2
lib/libc/include/wasm32-wasi/arpa/telnet.h deleted-251
......@@ -1,251 +0,0 @@
1#ifndef _ARPA_TELNET_H
2#define _ARPA_TELNET_H
3
4#define IAC 255
5#define DONT 254
6#define DO 253
7#define WONT 252
8#define WILL 251
9#define SB 250
10#define GA 249
11#define EL 248
12#define EC 247
13#define AYT 246
14#define AO 245
15#define IP 244
16#define BREAK 243
17#define DM 242
18#define NOP 241
19#define SE 240
20#define EOR 239
21#define ABORT 238
22#define SUSP 237
23#define xEOF 236
24
25#define SYNCH 242
26
27#define telcmds ((char [][6]){ "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0 })
28
29#define TELCMD_FIRST xEOF
30#define TELCMD_LAST IAC
31#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
32 (unsigned int)(x) >= TELCMD_FIRST)
33#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
34
35#define TELOPT_BINARY 0
36#define TELOPT_ECHO 1
37#define TELOPT_RCP 2
38#define TELOPT_SGA 3
39#define TELOPT_NAMS 4
40#define TELOPT_STATUS 5
41#define TELOPT_TM 6
42#define TELOPT_RCTE 7
43#define TELOPT_NAOL 8
44#define TELOPT_NAOP 9
45#define TELOPT_NAOCRD 10
46#define TELOPT_NAOHTS 11
47#define TELOPT_NAOHTD 12
48#define TELOPT_NAOFFD 13
49#define TELOPT_NAOVTS 14
50#define TELOPT_NAOVTD 15
51#define TELOPT_NAOLFD 16
52#define TELOPT_XASCII 17
53#define TELOPT_LOGOUT 18
54#define TELOPT_BM 19
55#define TELOPT_DET 20
56#define TELOPT_SUPDUP 21
57#define TELOPT_SUPDUPOUTPUT 22
58#define TELOPT_SNDLOC 23
59#define TELOPT_TTYPE 24
60#define TELOPT_EOR 25
61#define TELOPT_TUID 26
62#define TELOPT_OUTMRK 27
63#define TELOPT_TTYLOC 28
64#define TELOPT_3270REGIME 29
65#define TELOPT_X3PAD 30
66#define TELOPT_NAWS 31
67#define TELOPT_TSPEED 32
68#define TELOPT_LFLOW 33
69#define TELOPT_LINEMODE 34
70#define TELOPT_XDISPLOC 35
71#define TELOPT_OLD_ENVIRON 36
72#define TELOPT_AUTHENTICATION 37/* Authenticate */
73#define TELOPT_ENCRYPT 38
74#define TELOPT_NEW_ENVIRON 39
75#define TELOPT_EXOPL 255
76
77
78#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
79#ifdef TELOPTS
80char *telopts[NTELOPTS+1] = {
81 "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
82 "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
83 "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
84 "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
85 "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
86 "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
87 "TACACS UID", "OUTPUT MARKING", "TTYLOC",
88 "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
89 "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
90 "ENCRYPT", "NEW-ENVIRON",
91 0,
92};
93#define TELOPT_FIRST TELOPT_BINARY
94#define TELOPT_LAST TELOPT_NEW_ENVIRON
95#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
96#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
97#endif
98
99#define TELQUAL_IS 0
100#define TELQUAL_SEND 1
101#define TELQUAL_INFO 2
102#define TELQUAL_REPLY 2
103#define TELQUAL_NAME 3
104
105#define LFLOW_OFF 0
106#define LFLOW_ON 1
107#define LFLOW_RESTART_ANY 2
108#define LFLOW_RESTART_XON 3
109
110
111#define LM_MODE 1
112#define LM_FORWARDMASK 2
113#define LM_SLC 3
114
115#define MODE_EDIT 0x01
116#define MODE_TRAPSIG 0x02
117#define MODE_ACK 0x04
118#define MODE_SOFT_TAB 0x08
119#define MODE_LIT_ECHO 0x10
120
121#define MODE_MASK 0x1f
122
123#define MODE_FLOW 0x0100
124#define MODE_ECHO 0x0200
125#define MODE_INBIN 0x0400
126#define MODE_OUTBIN 0x0800
127#define MODE_FORCE 0x1000
128
129#define SLC_SYNCH 1
130#define SLC_BRK 2
131#define SLC_IP 3
132#define SLC_AO 4
133#define SLC_AYT 5
134#define SLC_EOR 6
135#define SLC_ABORT 7
136#define SLC_EOF 8
137#define SLC_SUSP 9
138#define SLC_EC 10
139#define SLC_EL 11
140#define SLC_EW 12
141#define SLC_RP 13
142#define SLC_LNEXT 14
143#define SLC_XON 15
144#define SLC_XOFF 16
145#define SLC_FORW1 17
146#define SLC_FORW2 18
147
148#define NSLC 18
149
150#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
151 "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
152 "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
153#ifdef SLC_NAMES
154char *slc_names[] = {
155 SLC_NAMELIST
156};
157#else
158extern char *slc_names[];
159#define SLC_NAMES SLC_NAMELIST
160#endif
161
162#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
163#define SLC_NAME(x) slc_names[x]
164
165#define SLC_NOSUPPORT 0
166#define SLC_CANTCHANGE 1
167#define SLC_VARIABLE 2
168#define SLC_DEFAULT 3
169#define SLC_LEVELBITS 0x03
170
171#define SLC_FUNC 0
172#define SLC_FLAGS 1
173#define SLC_VALUE 2
174
175#define SLC_ACK 0x80
176#define SLC_FLUSHIN 0x40
177#define SLC_FLUSHOUT 0x20
178
179#define OLD_ENV_VAR 1
180#define OLD_ENV_VALUE 0
181#define NEW_ENV_VAR 0
182#define NEW_ENV_VALUE 1
183#define ENV_ESC 2
184#define ENV_USERVAR 3
185
186#define AUTH_WHO_CLIENT 0
187#define AUTH_WHO_SERVER 1
188#define AUTH_WHO_MASK 1
189
190#define AUTH_HOW_ONE_WAY 0
191#define AUTH_HOW_MUTUAL 2
192#define AUTH_HOW_MASK 2
193
194#define AUTHTYPE_NULL 0
195#define AUTHTYPE_KERBEROS_V4 1
196#define AUTHTYPE_KERBEROS_V5 2
197#define AUTHTYPE_SPX 3
198#define AUTHTYPE_MINK 4
199#define AUTHTYPE_CNT 5
200
201#define AUTHTYPE_TEST 99
202
203#ifdef AUTH_NAMES
204char *authtype_names[] = {
205 "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
206};
207#else
208extern char *authtype_names[];
209#endif
210
211#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
212#define AUTHTYPE_NAME(x) authtype_names[x]
213
214#define ENCRYPT_IS 0
215#define ENCRYPT_SUPPORT 1
216#define ENCRYPT_REPLY 2
217#define ENCRYPT_START 3
218#define ENCRYPT_END 4
219#define ENCRYPT_REQSTART 5
220#define ENCRYPT_REQEND 6
221#define ENCRYPT_ENC_KEYID 7
222#define ENCRYPT_DEC_KEYID 8
223#define ENCRYPT_CNT 9
224
225#define ENCTYPE_ANY 0
226#define ENCTYPE_DES_CFB64 1
227#define ENCTYPE_DES_OFB64 2
228#define ENCTYPE_CNT 3
229
230#ifdef ENCRYPT_NAMES
231char *encrypt_names[] = {
232 "IS", "SUPPORT", "REPLY", "START", "END",
233 "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
234 0,
235};
236char *enctype_names[] = {
237 "ANY", "DES_CFB64", "DES_OFB64", 0,
238};
239#else
240extern char *encrypt_names[];
241extern char *enctype_names[];
242#endif
243
244
245#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
246#define ENCRYPT_NAME(x) encrypt_names[x]
247
248#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
249#define ENCTYPE_NAME(x) enctype_names[x]
250
251#endif
lib/libc/include/wasm32-wasi/arpa/tftp.h deleted-31
......@@ -1,31 +0,0 @@
1#ifndef _ARPA_TFTP_H
2#define _ARPA_TFTP_H
3#define SEGSIZE 512
4#define RRQ 01
5#define WRQ 02
6#define DATA 03
7#define ACK 04
8#define ERROR 05
9struct tftphdr {
10 short th_opcode;
11 union {
12 unsigned short tu_block;
13 short tu_code;
14 char tu_stuff[1];
15 } th_u;
16 char th_data[1];
17};
18#define th_block th_u.tu_block
19#define th_code th_u.tu_code
20#define th_stuff th_u.tu_stuff
21#define th_msg th_data
22#define EUNDEF 0
23#define ENOTFOUND 1
24#define EACCESS 2
25#define ENOSPACE 3
26#define EBADOP 4
27#define EBADID 5
28#define EEXISTS 6
29#define ENOUSER 7
30#endif
31
lib/libc/include/wasm32-wasi/assert.h deleted-23
......@@ -1,23 +0,0 @@
1#include <features.h>
2
3#undef assert
4
5#ifdef NDEBUG
6#define assert(x) (void)0
7#else
8#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
9#endif
10
11#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
12#define static_assert _Static_assert
13#endif
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19_Noreturn void __assert_fail (const char *, const char *, int, const char *);
20
21#ifdef __cplusplus
22}
23#endif
lib/libc/include/wasm32-wasi/bits/alltypes.h deleted-460
......@@ -1,460 +0,0 @@
1#define _Addr long
2#define _Int64 long long
3#define _Reg long long
4
5#define __BYTE_ORDER __BYTE_ORDER__
6
7#define __LONG_MAX __LONG_MAX__
8
9/*
10 * Rather than define everything ourselves here in the musl layer, for
11 * WASI, reference the definitions in the lower layers.
12 */
13
14#if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t)
15#define __need_wchar_t
16#include <stddef.h>
17#define __DEFINED_wchar_t
18#endif
19
20#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t)
21#define __need_wint_t
22#include <stddef.h>
23#define __DEFINED_wint_t
24#endif
25
26#if defined(__NEED_float_t) && !defined(__DEFINED_float_t)
27typedef float float_t;
28#define __DEFINED_float_t
29#endif
30
31#if defined(__NEED_double_t) && !defined(__DEFINED_double_t)
32typedef double double_t;
33#define __DEFINED_double_t
34#endif
35
36
37#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
38#define __need_max_align_t
39#include <stddef.h>
40#define __DEFINED_max_align_t
41#endif
42
43#if defined(__NEED_time_t) && !defined(__DEFINED_time_t)
44#include <__typedef_time_t.h>
45#define __DEFINED_time_t
46#endif
47
48#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
49#include <__typedef_suseconds_t.h>
50#define __DEFINED_suseconds_t
51#endif
52
53#if defined(__NEED_clockid_t) && !defined(__DEFINED_clockid_t)
54#include <__typedef_clockid_t.h>
55#define __DEFINED_clockid_t
56#endif
57
58#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t)
59#include <__typedef_sigset_t.h>
60#define __DEFINED_sigset_t
61#endif
62
63#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t)
64#include <__typedef_clock_t.h>
65#define __DEFINED_clock_t
66#endif
67#define __LITTLE_ENDIAN 1234
68#define __BIG_ENDIAN 4321
69#define __USE_TIME_BITS64 1
70
71#if defined(__NEED_size_t) && !defined(__DEFINED_size_t)
72typedef unsigned _Addr size_t;
73#define __DEFINED_size_t
74#endif
75
76#if defined(__NEED_uintptr_t) && !defined(__DEFINED_uintptr_t)
77typedef unsigned _Addr uintptr_t;
78#define __DEFINED_uintptr_t
79#endif
80
81#if defined(__NEED_ptrdiff_t) && !defined(__DEFINED_ptrdiff_t)
82typedef _Addr ptrdiff_t;
83#define __DEFINED_ptrdiff_t
84#endif
85
86#if defined(__NEED_ssize_t) && !defined(__DEFINED_ssize_t)
87typedef _Addr ssize_t;
88#define __DEFINED_ssize_t
89#endif
90
91#if defined(__NEED_intptr_t) && !defined(__DEFINED_intptr_t)
92typedef _Addr intptr_t;
93#define __DEFINED_intptr_t
94#endif
95
96#if defined(__NEED_regoff_t) && !defined(__DEFINED_regoff_t)
97typedef _Addr regoff_t;
98#define __DEFINED_regoff_t
99#endif
100
101#if defined(__NEED_register_t) && !defined(__DEFINED_register_t)
102typedef _Reg register_t;
103#define __DEFINED_register_t
104#endif
105
106#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
107#if defined(__NEED_time_t) && !defined(__DEFINED_time_t)
108typedef _Int64 time_t;
109#define __DEFINED_time_t
110#endif
111
112#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
113typedef _Int64 suseconds_t;
114#define __DEFINED_suseconds_t
115#endif
116
117#else
118#if defined(__NEED_time_t) && !defined(__DEFINED_time_t)
119#include <__typedef_time_t.h>
120#define __DEFINED_time_t
121#endif
122
123#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
124#include <__typedef_suseconds_t.h>
125#define __DEFINED_suseconds_t
126#endif
127#endif
128
129#if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t)
130typedef signed char int8_t;
131#define __DEFINED_int8_t
132#endif
133
134#if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t)
135typedef signed short int16_t;
136#define __DEFINED_int16_t
137#endif
138
139#if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t)
140typedef signed int int32_t;
141#define __DEFINED_int32_t
142#endif
143
144#if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t)
145typedef signed _Int64 int64_t;
146#define __DEFINED_int64_t
147#endif
148
149#if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t)
150typedef signed _Int64 intmax_t;
151#define __DEFINED_intmax_t
152#endif
153
154#if defined(__NEED_uint8_t) && !defined(__DEFINED_uint8_t)
155typedef unsigned char uint8_t;
156#define __DEFINED_uint8_t
157#endif
158
159#if defined(__NEED_uint16_t) && !defined(__DEFINED_uint16_t)
160typedef unsigned short uint16_t;
161#define __DEFINED_uint16_t
162#endif
163
164#if defined(__NEED_uint32_t) && !defined(__DEFINED_uint32_t)
165typedef unsigned int uint32_t;
166#define __DEFINED_uint32_t
167#endif
168
169#if defined(__NEED_uint64_t) && !defined(__DEFINED_uint64_t)
170typedef unsigned _Int64 uint64_t;
171#define __DEFINED_uint64_t
172#endif
173
174#if defined(__NEED_u_int64_t) && !defined(__DEFINED_u_int64_t)
175typedef unsigned _Int64 u_int64_t;
176#define __DEFINED_u_int64_t
177#endif
178
179#if defined(__NEED_uintmax_t) && !defined(__DEFINED_uintmax_t)
180typedef unsigned _Int64 uintmax_t;
181#define __DEFINED_uintmax_t
182#endif
183
184
185#if defined(__NEED_mode_t) && !defined(__DEFINED_mode_t)
186typedef unsigned mode_t;
187#define __DEFINED_mode_t
188#endif
189
190#if defined(__NEED_nlink_t) && !defined(__DEFINED_nlink_t)
191typedef unsigned _Reg nlink_t;
192#define __DEFINED_nlink_t
193#endif
194
195#if defined(__NEED_off_t) && !defined(__DEFINED_off_t)
196typedef _Int64 off_t;
197#define __DEFINED_off_t
198#endif
199
200#if defined(__NEED_ino_t) && !defined(__DEFINED_ino_t)
201typedef unsigned _Int64 ino_t;
202#define __DEFINED_ino_t
203#endif
204
205#if defined(__NEED_dev_t) && !defined(__DEFINED_dev_t)
206typedef unsigned _Int64 dev_t;
207#define __DEFINED_dev_t
208#endif
209
210#if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t)
211typedef long blksize_t;
212#define __DEFINED_blksize_t
213#endif
214
215#if defined(__NEED_blkcnt_t) && !defined(__DEFINED_blkcnt_t)
216typedef _Int64 blkcnt_t;
217#define __DEFINED_blkcnt_t
218#endif
219
220#if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t)
221typedef unsigned _Int64 fsblkcnt_t;
222#define __DEFINED_fsblkcnt_t
223#endif
224
225#if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t)
226typedef unsigned _Int64 fsfilcnt_t;
227#define __DEFINED_fsfilcnt_t
228#endif
229
230
231#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t)
232typedef unsigned wint_t;
233#define __DEFINED_wint_t
234#endif
235
236#if defined(__NEED_wctype_t) && !defined(__DEFINED_wctype_t)
237typedef unsigned long wctype_t;
238#define __DEFINED_wctype_t
239#endif
240
241
242#if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t)
243typedef void * timer_t;
244#define __DEFINED_timer_t
245#endif
246
247#if defined(__NEED_clockid_t) && !defined(__DEFINED_clockid_t)
248typedef int clockid_t;
249#define __DEFINED_clockid_t
250#endif
251
252#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t)
253typedef long clock_t;
254#define __DEFINED_clock_t
255#endif
256
257#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
258#if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval)
259struct timeval { time_t tv_sec; suseconds_t tv_usec; };
260#define __DEFINED_struct_timeval
261#endif
262
263#if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec)
264struct timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); };
265#define __DEFINED_struct_timespec
266#endif
267
268#else
269#include <__struct_timeval.h>
270#include <__struct_timespec.h>
271#endif
272
273#if defined(__NEED_pid_t) && !defined(__DEFINED_pid_t)
274typedef int pid_t;
275#define __DEFINED_pid_t
276#endif
277
278#if defined(__NEED_id_t) && !defined(__DEFINED_id_t)
279typedef unsigned id_t;
280#define __DEFINED_id_t
281#endif
282
283#if defined(__NEED_uid_t) && !defined(__DEFINED_uid_t)
284typedef unsigned uid_t;
285#define __DEFINED_uid_t
286#endif
287
288#if defined(__NEED_gid_t) && !defined(__DEFINED_gid_t)
289typedef unsigned gid_t;
290#define __DEFINED_gid_t
291#endif
292
293#if defined(__NEED_key_t) && !defined(__DEFINED_key_t)
294typedef int key_t;
295#define __DEFINED_key_t
296#endif
297
298#if defined(__NEED_useconds_t) && !defined(__DEFINED_useconds_t)
299typedef unsigned useconds_t;
300#define __DEFINED_useconds_t
301#endif
302
303
304#ifdef __cplusplus
305#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t)
306typedef unsigned long pthread_t;
307#define __DEFINED_pthread_t
308#endif
309
310#else
311#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t)
312typedef struct __pthread * pthread_t;
313#define __DEFINED_pthread_t
314#endif
315
316#endif
317#if defined(__NEED_pthread_once_t) && !defined(__DEFINED_pthread_once_t)
318typedef int pthread_once_t;
319#define __DEFINED_pthread_once_t
320#endif
321
322#if defined(__NEED_pthread_key_t) && !defined(__DEFINED_pthread_key_t)
323typedef unsigned pthread_key_t;
324#define __DEFINED_pthread_key_t
325#endif
326
327#if defined(__NEED_pthread_spinlock_t) && !defined(__DEFINED_pthread_spinlock_t)
328typedef int pthread_spinlock_t;
329#define __DEFINED_pthread_spinlock_t
330#endif
331
332#if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t)
333typedef struct { unsigned __attr; } pthread_mutexattr_t;
334#define __DEFINED_pthread_mutexattr_t
335#endif
336
337#if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t)
338typedef struct { unsigned __attr; } pthread_condattr_t;
339#define __DEFINED_pthread_condattr_t
340#endif
341
342#if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t)
343typedef struct { unsigned __attr; } pthread_barrierattr_t;
344#define __DEFINED_pthread_barrierattr_t
345#endif
346
347#if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t)
348typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t;
349#define __DEFINED_pthread_rwlockattr_t
350#endif
351
352
353#ifdef __wasilibc_unmodified_upstream /* WASI doesn't need to define FILE as a complete type */
354#if defined(__NEED_struct__IO_FILE) && !defined(__DEFINED_struct__IO_FILE)
355struct _IO_FILE { char __x; };
356#define __DEFINED_struct__IO_FILE
357#endif
358
359#endif
360#if defined(__NEED_FILE) && !defined(__DEFINED_FILE)
361typedef struct _IO_FILE FILE;
362#define __DEFINED_FILE
363#endif
364
365
366#if defined(__NEED_va_list) && !defined(__DEFINED_va_list)
367typedef __builtin_va_list va_list;
368#define __DEFINED_va_list
369#endif
370
371#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list)
372typedef __builtin_va_list __isoc_va_list;
373#define __DEFINED___isoc_va_list
374#endif
375
376
377#if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t)
378typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
379#define __DEFINED_mbstate_t
380#endif
381
382
383#if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t)
384typedef struct __locale_struct * locale_t;
385#define __DEFINED_locale_t
386#endif
387
388
389#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t)
390typedef struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t;
391#define __DEFINED_sigset_t
392#endif
393
394
395#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
396#if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec)
397struct iovec { void *iov_base; size_t iov_len; };
398#define __DEFINED_struct_iovec
399#endif
400
401#else
402#include <__struct_iovec.h>
403#endif
404
405#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize)
406struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; };
407#define __DEFINED_struct_winsize
408#endif
409
410
411#if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t)
412typedef unsigned socklen_t;
413#define __DEFINED_socklen_t
414#endif
415
416#if defined(__NEED_sa_family_t) && !defined(__DEFINED_sa_family_t)
417typedef unsigned short sa_family_t;
418#define __DEFINED_sa_family_t
419#endif
420
421
422#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t)
423typedef struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t;
424#define __DEFINED_pthread_attr_t
425#endif
426
427#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t)
428typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } pthread_mutex_t;
429#define __DEFINED_pthread_mutex_t
430#endif
431
432#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t)
433typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } mtx_t;
434#define __DEFINED_mtx_t
435#endif
436
437#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t)
438typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } pthread_cond_t;
439#define __DEFINED_pthread_cond_t
440#endif
441
442#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t)
443typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } cnd_t;
444#define __DEFINED_cnd_t
445#endif
446
447#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t)
448typedef struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t;
449#define __DEFINED_pthread_rwlock_t
450#endif
451
452#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t)
453typedef struct { union { int __i[sizeof(long)==8?8:5]; volatile int __vi[sizeof(long)==8?8:5]; void *__p[sizeof(long)==8?4:5]; } __u; } pthread_barrier_t;
454#define __DEFINED_pthread_barrier_t
455#endif
456
457
458#undef _Addr
459#undef _Int64
460#undef _Reg
lib/libc/include/wasm32-wasi/bits/dirent.h deleted-1
......@@ -1 +0,0 @@
1#include <__struct_dirent.h>
lib/libc/include/wasm32-wasi/bits/fcntl.h deleted-1
......@@ -1 +0,0 @@
1/* Use the WASI libc fcntl implementation bits. */
lib/libc/include/wasm32-wasi/bits/fenv.h deleted-10
......@@ -1,10 +0,0 @@
1#define FE_ALL_EXCEPT 0
2#define FE_TONEAREST 0
3
4typedef unsigned long fexcept_t;
5
6typedef struct {
7 unsigned long __cw;
8} fenv_t;
9
10#define FE_DFL_ENV ((const fenv_t *) -1)
lib/libc/include/wasm32-wasi/bits/float.h deleted-16
......@@ -1,16 +0,0 @@
1#define FLT_EVAL_METHOD 0
2
3#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
4#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
5#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
6#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
7
8#define LDBL_MANT_DIG 113
9#define LDBL_MIN_EXP (-16381)
10#define LDBL_MAX_EXP 16384
11
12#define LDBL_DIG 33
13#define LDBL_MIN_10_EXP (-4931)
14#define LDBL_MAX_10_EXP 4932
15
16#define DECIMAL_DIG 36
lib/libc/include/wasm32-wasi/bits/hwcap.h deleted
lib/libc/include/wasm32-wasi/bits/io.h deleted
lib/libc/include/wasm32-wasi/bits/ioctl.h deleted-1
......@@ -1 +0,0 @@
1/* Use the WASI libc ioctl implementation bits. */
lib/libc/include/wasm32-wasi/bits/ioctl_fix.h deleted
lib/libc/include/wasm32-wasi/bits/ipcstat.h deleted-1
......@@ -1 +0,0 @@
1#define IPC_STAT 2
lib/libc/include/wasm32-wasi/bits/limits.h deleted-1
......@@ -1 +0,0 @@
1#include <__macro_PAGESIZE.h>
lib/libc/include/wasm32-wasi/bits/mman.h deleted
lib/libc/include/wasm32-wasi/bits/poll.h deleted
lib/libc/include/wasm32-wasi/bits/posix.h deleted-2
......@@ -1,2 +0,0 @@
1#define _POSIX_V6_ILP32_OFFBIG (1)
2#define _POSIX_V7_ILP32_OFFBIG (1)
lib/libc/include/wasm32-wasi/bits/reg.h deleted-2
......@@ -1,2 +0,0 @@
1#undef __WORDSIZE
2#define __WORDSIZE 64
lib/libc/include/wasm32-wasi/bits/resource.h deleted
lib/libc/include/wasm32-wasi/bits/signal.h deleted-40
......@@ -1,40 +0,0 @@
1#ifdef _WASI_EMULATED_SIGNAL
2
3#define SIGHUP 1
4#define SIGINT 2
5#define SIGQUIT 3
6#define SIGILL 4
7#define SIGTRAP 5
8#define SIGABRT 6
9#define SIGIOT SIGABRT
10#define SIGBUS 7
11#define SIGFPE 8
12#define SIGKILL 9
13#define SIGUSR1 10
14#define SIGSEGV 11
15#define SIGUSR2 12
16#define SIGPIPE 13
17#define SIGALRM 14
18#define SIGTERM 15
19#define SIGSTKFLT 16
20#define SIGCHLD 17
21#define SIGCONT 18
22#define SIGSTOP 19
23#define SIGTSTP 20
24#define SIGTTIN 21
25#define SIGTTOU 22
26#define SIGURG 23
27#define SIGXCPU 24
28#define SIGXFSZ 25
29#define SIGVTALRM 26
30#define SIGPROF 27
31#define SIGWINCH 28
32#define SIGIO 29
33#define SIGPOLL 29
34#define SIGPWR 30
35#define SIGSYS 31
36#define SIGUNUSED SIGSYS
37
38#define _NSIG 65
39
40#endif
lib/libc/include/wasm32-wasi/bits/socket.h deleted
lib/libc/include/wasm32-wasi/bits/stat.h deleted-1
......@@ -1 +0,0 @@
1#include <__struct_stat.h>
lib/libc/include/wasm32-wasi/bits/stdint.h deleted-20
......@@ -1,20 +0,0 @@
1typedef int16_t int_fast16_t;
2typedef int32_t int_fast32_t;
3typedef uint16_t uint_fast16_t;
4typedef uint32_t uint_fast32_t;
5
6#define INT_FAST16_MIN INT16_MIN
7#define INT_FAST32_MIN INT32_MIN
8
9#define INT_FAST16_MAX INT16_MAX
10#define INT_FAST32_MAX INT32_MAX
11
12#define UINT_FAST16_MAX UINT16_MAX
13#define UINT_FAST32_MAX UINT32_MAX
14
15#define INTPTR_MIN INT32_MIN
16#define INTPTR_MAX INT32_MAX
17#define UINTPTR_MAX UINT32_MAX
18#define PTRDIFF_MIN INT32_MIN
19#define PTRDIFF_MAX INT32_MAX
20#define SIZE_MAX UINT32_MAX
lib/libc/include/wasm32-wasi/byteswap.h deleted-26
......@@ -1,26 +0,0 @@
1#ifndef _BYTESWAP_H
2#define _BYTESWAP_H
3
4#include <features.h>
5#include <stdint.h>
6
7static __inline uint16_t __bswap_16(uint16_t __x)
8{
9 return __x<<8 | __x>>8;
10}
11
12static __inline uint32_t __bswap_32(uint32_t __x)
13{
14 return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
15}
16
17static __inline uint64_t __bswap_64(uint64_t __x)
18{
19 return __bswap_32(__x)+0ULL<<32 | __bswap_32(__x>>32);
20}
21
22#define bswap_16(x) __bswap_16(x)
23#define bswap_32(x) __bswap_32(x)
24#define bswap_64(x) __bswap_64(x)
25
26#endif
lib/libc/include/wasm32-wasi/complex.h deleted-143
......@@ -1,143 +0,0 @@
1#ifndef _COMPLEX_H
2#define _COMPLEX_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define complex _Complex
9#ifdef __GNUC__
10#define _Complex_I (__extension__ (0.0f+1.0fi))
11#else
12#define _Complex_I (0.0f+1.0fi)
13#endif
14#define I _Complex_I
15
16double complex cacos(double complex);
17float complex cacosf(float complex);
18long double complex cacosl(long double complex);
19
20double complex casin(double complex);
21float complex casinf(float complex);
22long double complex casinl(long double complex);
23
24double complex catan(double complex);
25float complex catanf(float complex);
26long double complex catanl(long double complex);
27
28double complex ccos(double complex);
29float complex ccosf(float complex);
30long double complex ccosl(long double complex);
31
32double complex csin(double complex);
33float complex csinf(float complex);
34long double complex csinl(long double complex);
35
36double complex ctan(double complex);
37float complex ctanf(float complex);
38long double complex ctanl(long double complex);
39
40double complex cacosh(double complex);
41float complex cacoshf(float complex);
42long double complex cacoshl(long double complex);
43
44double complex casinh(double complex);
45float complex casinhf(float complex);
46long double complex casinhl(long double complex);
47
48double complex catanh(double complex);
49float complex catanhf(float complex);
50long double complex catanhl(long double complex);
51
52double complex ccosh(double complex);
53float complex ccoshf(float complex);
54long double complex ccoshl(long double complex);
55
56double complex csinh(double complex);
57float complex csinhf(float complex);
58long double complex csinhl(long double complex);
59
60double complex ctanh(double complex);
61float complex ctanhf(float complex);
62long double complex ctanhl(long double complex);
63
64double complex cexp(double complex);
65float complex cexpf(float complex);
66long double complex cexpl(long double complex);
67
68double complex clog(double complex);
69float complex clogf(float complex);
70long double complex clogl(long double complex);
71
72double cabs(double complex);
73float cabsf(float complex);
74long double cabsl(long double complex);
75
76double complex cpow(double complex, double complex);
77float complex cpowf(float complex, float complex);
78long double complex cpowl(long double complex, long double complex);
79
80double complex csqrt(double complex);
81float complex csqrtf(float complex);
82long double complex csqrtl(long double complex);
83
84double carg(double complex);
85float cargf(float complex);
86long double cargl(long double complex);
87
88double cimag(double complex);
89float cimagf(float complex);
90long double cimagl(long double complex);
91
92double complex conj(double complex);
93float complex conjf(float complex);
94long double complex conjl(long double complex);
95
96double complex cproj(double complex);
97float complex cprojf(float complex);
98long double complex cprojl(long double complex);
99
100double creal(double complex);
101float crealf(float complex);
102long double creall(long double complex);
103
104#ifdef __wasilibc_unmodified_upstream /* Use the compiler's real/imag operators rather than union type punning */
105#ifndef __cplusplus
106#define __CIMAG(x, t) \
107 (+(union { _Complex t __z; t __xy[2]; }){(_Complex t)(x)}.__xy[1])
108
109#define creal(x) ((double)(x))
110#define crealf(x) ((float)(x))
111#define creall(x) ((long double)(x))
112
113#define cimag(x) __CIMAG(x, double)
114#define cimagf(x) __CIMAG(x, float)
115#define cimagl(x) __CIMAG(x, long double)
116#endif
117#else
118#define creal(x) (__builtin_creal(x))
119#define crealf(x) (__builtin_crealf(x))
120#define creall(x) (__builtin_creall(x))
121
122#define cimag(x) (__builtin_cimag(x))
123#define cimagf(x) (__builtin_cimagf(x))
124#define cimagl(x) (__builtin_cimagl(x))
125#endif
126
127#if __STDC_VERSION__ >= 201112L
128#if defined(_Imaginary_I)
129#define __CMPLX(x, y, t) ((t)(x) + _Imaginary_I*(t)(y))
130#elif defined(__clang__)
131#define __CMPLX(x, y, t) (+(_Complex t){ (t)(x), (t)(y) })
132#else
133#define __CMPLX(x, y, t) (__builtin_complex((t)(x), (t)(y)))
134#endif
135#define CMPLX(x, y) __CMPLX(x, y, double)
136#define CMPLXF(x, y) __CMPLX(x, y, float)
137#define CMPLXL(x, y) __CMPLX(x, y, long double)
138#endif
139
140#ifdef __cplusplus
141}
142#endif
143#endif
lib/libc/include/wasm32-wasi/cpio.h deleted-29
......@@ -1,29 +0,0 @@
1#ifndef _CPIO_H
2#define _CPIO_H
3
4#define MAGIC "070707"
5
6#define C_IRUSR 000400
7#define C_IWUSR 000200
8#define C_IXUSR 000100
9#define C_IRGRP 000040
10#define C_IWGRP 000020
11#define C_IXGRP 000010
12#define C_IROTH 000004
13#define C_IWOTH 000002
14#define C_IXOTH 000001
15
16#define C_ISUID 004000
17#define C_ISGID 002000
18#define C_ISVTX 001000
19
20#define C_ISBLK 060000
21#define C_ISCHR 020000
22#define C_ISDIR 040000
23#define C_ISFIFO 010000
24#define C_ISSOCK 0140000
25#define C_ISLNK 0120000
26#define C_ISCTG 0110000
27#define C_ISREG 0100000
28
29#endif
lib/libc/include/wasm32-wasi/crypt.h deleted-20
......@@ -1,20 +0,0 @@
1#ifndef _CRYPT_H
2#define _CRYPT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8struct crypt_data {
9 int initialized;
10 char __buf[256];
11};
12
13char *crypt(const char *, const char *);
14char *crypt_r(const char *, const char *, struct crypt_data *);
15
16#ifdef __cplusplus
17}
18#endif
19
20#endif
lib/libc/include/wasm32-wasi/ctype.h deleted-75
......@@ -1,75 +0,0 @@
1#ifndef _CTYPE_H
2#define _CTYPE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10int isalnum(int);
11int isalpha(int);
12int isblank(int);
13int iscntrl(int);
14int isdigit(int);
15int isgraph(int);
16int islower(int);
17int isprint(int);
18int ispunct(int);
19int isspace(int);
20int isupper(int);
21int isxdigit(int);
22int tolower(int);
23int toupper(int);
24
25#ifndef __cplusplus
26static __inline int __isspace(int _c)
27{
28 return _c == ' ' || (unsigned)_c-'\t' < 5;
29}
30
31#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a)|32)-'a') < 26)
32#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10)
33#define islower(a) (0 ? islower(a) : ((unsigned)(a)-'a') < 26)
34#define isupper(a) (0 ? isupper(a) : ((unsigned)(a)-'A') < 26)
35#define isprint(a) (0 ? isprint(a) : ((unsigned)(a)-0x20) < 0x5f)
36#define isgraph(a) (0 ? isgraph(a) : ((unsigned)(a)-0x21) < 0x5e)
37#define isspace(a) __isspace(a)
38#endif
39
40
41#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
42 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
43 || defined(_BSD_SOURCE)
44
45#define __NEED_locale_t
46#include <bits/alltypes.h>
47
48int isalnum_l(int, locale_t);
49int isalpha_l(int, locale_t);
50int isblank_l(int, locale_t);
51int iscntrl_l(int, locale_t);
52int isdigit_l(int, locale_t);
53int isgraph_l(int, locale_t);
54int islower_l(int, locale_t);
55int isprint_l(int, locale_t);
56int ispunct_l(int, locale_t);
57int isspace_l(int, locale_t);
58int isupper_l(int, locale_t);
59int isxdigit_l(int, locale_t);
60int tolower_l(int, locale_t);
61int toupper_l(int, locale_t);
62
63int isascii(int);
64int toascii(int);
65#define _tolower(a) ((a)|0x20)
66#define _toupper(a) ((a)&0x5f)
67#define isascii(a) (0 ? isascii(a) : (unsigned)(a) < 128)
68
69#endif
70
71#ifdef __cplusplus
72}
73#endif
74
75#endif
lib/libc/include/wasm32-wasi/dirent.h deleted-89
......@@ -1,89 +0,0 @@
1#ifndef _DIRENT_H
2#define _DIRENT_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#else
6#include <__header_dirent.h>
7#endif
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <features.h>
13
14#define __NEED_ino_t
15#define __NEED_off_t
16#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
17#define __NEED_size_t
18#endif
19
20#include <bits/alltypes.h>
21
22#include <bits/dirent.h>
23
24#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
25typedef struct __dirstream DIR;
26#else
27#include <__typedef_DIR.h>
28#endif
29
30#define d_fileno d_ino
31
32int closedir(DIR *);
33DIR *fdopendir(int);
34DIR *opendir(const char *);
35struct dirent *readdir(DIR *);
36#ifdef __wasilibc_unmodified_upstream /* readdir_r is obsolete */
37int readdir_r(DIR *__restrict, struct dirent *__restrict, struct dirent **__restrict);
38#endif
39void rewinddir(DIR *);
40int dirfd(DIR *);
41
42int alphasort(const struct dirent **, const struct dirent **);
43int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
44
45#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
46void seekdir(DIR *, long);
47long telldir(DIR *);
48#endif
49
50#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
51#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
52#define DT_UNKNOWN 0
53#define DT_FIFO 1
54#define DT_CHR 2
55#define DT_DIR 4
56#define DT_BLK 6
57#define DT_REG 8
58#define DT_LNK 10
59#define DT_SOCK 12
60#define DT_WHT 14
61#define IFTODT(x) ((x)>>12 & 017)
62#define DTTOIF(x) ((x)<<12)
63#endif
64int getdents(int, struct dirent *, size_t);
65#endif
66
67#ifdef _GNU_SOURCE
68int versionsort(const struct dirent **, const struct dirent **);
69#endif
70
71#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
72#define dirent64 dirent
73#define readdir64 readdir
74#ifdef __wasilibc_unmodified_upstream /* readdir_r is obsolete */
75#define readdir64_r readdir_r
76#endif
77#define scandir64 scandir
78#define alphasort64 alphasort
79#define versionsort64 versionsort
80#define off64_t off_t
81#define ino64_t ino_t
82#define getdents64 getdents
83#endif
84
85#ifdef __cplusplus
86}
87#endif
88
89#endif
lib/libc/include/wasm32-wasi/endian.h deleted-80
......@@ -1,80 +0,0 @@
1#ifndef _ENDIAN_H
2#define _ENDIAN_H
3
4#include <features.h>
5
6#define __NEED_uint16_t
7#define __NEED_uint32_t
8#define __NEED_uint64_t
9
10#include <bits/alltypes.h>
11
12#define __PDP_ENDIAN 3412
13
14#define BIG_ENDIAN __BIG_ENDIAN
15#define LITTLE_ENDIAN __LITTLE_ENDIAN
16#define PDP_ENDIAN __PDP_ENDIAN
17#define BYTE_ORDER __BYTE_ORDER
18
19static __inline uint16_t __bswap16(uint16_t __x)
20{
21 return __x<<8 | __x>>8;
22}
23
24static __inline uint32_t __bswap32(uint32_t __x)
25{
26 return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24;
27}
28
29static __inline uint64_t __bswap64(uint64_t __x)
30{
31 return __bswap32(__x)+0ULL<<32 | __bswap32(__x>>32);
32}
33
34#if __BYTE_ORDER == __LITTLE_ENDIAN
35#define htobe16(x) __bswap16(x)
36#define be16toh(x) __bswap16(x)
37#define htobe32(x) __bswap32(x)
38#define be32toh(x) __bswap32(x)
39#define htobe64(x) __bswap64(x)
40#define be64toh(x) __bswap64(x)
41#define htole16(x) (uint16_t)(x)
42#define le16toh(x) (uint16_t)(x)
43#define htole32(x) (uint32_t)(x)
44#define le32toh(x) (uint32_t)(x)
45#define htole64(x) (uint64_t)(x)
46#define le64toh(x) (uint64_t)(x)
47#else
48#define htobe16(x) (uint16_t)(x)
49#define be16toh(x) (uint16_t)(x)
50#define htobe32(x) (uint32_t)(x)
51#define be32toh(x) (uint32_t)(x)
52#define htobe64(x) (uint64_t)(x)
53#define be64toh(x) (uint64_t)(x)
54#define htole16(x) __bswap16(x)
55#define le16toh(x) __bswap16(x)
56#define htole32(x) __bswap32(x)
57#define le32toh(x) __bswap32(x)
58#define htole64(x) __bswap64(x)
59#define le64toh(x) __bswap64(x)
60#endif
61
62#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
63#if __BYTE_ORDER == __LITTLE_ENDIAN
64#define betoh16(x) __bswap16(x)
65#define betoh32(x) __bswap32(x)
66#define betoh64(x) __bswap64(x)
67#define letoh16(x) (uint16_t)(x)
68#define letoh32(x) (uint32_t)(x)
69#define letoh64(x) (uint64_t)(x)
70#else
71#define betoh16(x) (uint16_t)(x)
72#define betoh32(x) (uint32_t)(x)
73#define betoh64(x) (uint64_t)(x)
74#define letoh16(x) __bswap16(x)
75#define letoh32(x) __bswap32(x)
76#define letoh64(x) __bswap64(x)
77#endif
78#endif
79
80#endif
lib/libc/include/wasm32-wasi/err.h deleted-25
......@@ -1,25 +0,0 @@
1#ifndef _ERR_H
2#define _ERR_H
3
4#include <features.h>
5#include <stdarg.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11void warn(const char *, ...);
12void vwarn(const char *, va_list);
13void warnx(const char *, ...);
14void vwarnx(const char *, va_list);
15
16_Noreturn void err(int, const char *, ...);
17_Noreturn void verr(int, const char *, va_list);
18_Noreturn void errx(int, const char *, ...);
19_Noreturn void verrx(int, const char *, va_list);
20
21#ifdef __cplusplus
22}
23#endif
24
25#endif
lib/libc/include/wasm32-wasi/errno.h deleted-32
......@@ -1,32 +0,0 @@
1#ifndef _ERRNO_H
2#define _ERRNO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
11#include <bits/errno.h>
12
13#ifdef __GNUC__
14__attribute__((const))
15#endif
16int *__errno_location(void);
17#define errno (*__errno_location())
18#else
19#include <__errno.h>
20#include <__errno_values.h>
21#endif
22
23#ifdef _GNU_SOURCE
24extern char *program_invocation_short_name, *program_invocation_name;
25#endif
26
27#ifdef __cplusplus
28}
29#endif
30
31#endif
32
lib/libc/include/wasm32-wasi/fcntl.h deleted-246
......@@ -1,246 +0,0 @@
1#ifndef _FCNTL_H
2#define _FCNTL_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#else
6#include <__header_fcntl.h>
7#endif
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <features.h>
13
14#define __NEED_off_t
15#define __NEED_pid_t
16#define __NEED_mode_t
17
18#ifdef _GNU_SOURCE
19#define __NEED_size_t
20#define __NEED_ssize_t
21#define __NEED_struct_iovec
22#endif
23
24#include <bits/alltypes.h>
25
26#include <bits/fcntl.h>
27
28struct flock {
29 short l_type;
30 short l_whence;
31 off_t l_start;
32 off_t l_len;
33 pid_t l_pid;
34};
35
36int creat(const char *, mode_t);
37int fcntl(int, int, ...);
38int open(const char *, int, ...);
39int openat(int, const char *, int, ...);
40int posix_fadvise(int, off_t, off_t, int);
41int posix_fallocate(int, off_t, off_t);
42
43#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
44#define O_SEARCH O_PATH
45#define O_EXEC O_PATH
46#define O_TTY_INIT 0
47
48#define O_ACCMODE (03|O_SEARCH)
49#define O_RDONLY 00
50#define O_WRONLY 01
51#define O_RDWR 02
52
53#define F_OFD_GETLK 36
54#define F_OFD_SETLK 37
55#define F_OFD_SETLKW 38
56
57#define F_DUPFD_CLOEXEC 1030
58
59#define F_RDLCK 0
60#define F_WRLCK 1
61#define F_UNLCK 2
62
63#define FD_CLOEXEC 1
64
65#define AT_FDCWD (-100)
66#define AT_SYMLINK_NOFOLLOW 0x100
67#define AT_REMOVEDIR 0x200
68#define AT_SYMLINK_FOLLOW 0x400
69#define AT_EACCESS 0x200
70
71#define POSIX_FADV_NORMAL 0
72#define POSIX_FADV_RANDOM 1
73#define POSIX_FADV_SEQUENTIAL 2
74#define POSIX_FADV_WILLNEED 3
75#ifndef POSIX_FADV_DONTNEED
76#define POSIX_FADV_DONTNEED 4
77#define POSIX_FADV_NOREUSE 5
78#endif
79
80#undef SEEK_SET
81#undef SEEK_CUR
82#undef SEEK_END
83#define SEEK_SET 0
84#define SEEK_CUR 1
85#define SEEK_END 2
86
87#ifndef S_IRUSR
88#define S_ISUID 04000
89#define S_ISGID 02000
90#define S_ISVTX 01000
91#define S_IRUSR 0400
92#define S_IWUSR 0200
93#define S_IXUSR 0100
94#define S_IRWXU 0700
95#define S_IRGRP 0040
96#define S_IWGRP 0020
97#define S_IXGRP 0010
98#define S_IRWXG 0070
99#define S_IROTH 0004
100#define S_IWOTH 0002
101#define S_IXOTH 0001
102#define S_IRWXO 0007
103#endif
104
105#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
106#define AT_NO_AUTOMOUNT 0x800
107#define AT_EMPTY_PATH 0x1000
108#define AT_STATX_SYNC_TYPE 0x6000
109#define AT_STATX_SYNC_AS_STAT 0x0000
110#define AT_STATX_FORCE_SYNC 0x2000
111#define AT_STATX_DONT_SYNC 0x4000
112#define AT_RECURSIVE 0x8000
113
114#define FAPPEND O_APPEND
115#define FFSYNC O_SYNC
116#define FASYNC O_ASYNC
117#define FNONBLOCK O_NONBLOCK
118#define FNDELAY O_NDELAY
119
120#define F_OK 0
121#define R_OK 4
122#define W_OK 2
123#define X_OK 1
124#define F_ULOCK 0
125#define F_LOCK 1
126#define F_TLOCK 2
127#define F_TEST 3
128
129#define F_SETLEASE 1024
130#define F_GETLEASE 1025
131#define F_NOTIFY 1026
132#define F_CANCELLK 1029
133#define F_SETPIPE_SZ 1031
134#define F_GETPIPE_SZ 1032
135#define F_ADD_SEALS 1033
136#define F_GET_SEALS 1034
137
138#define F_SEAL_SEAL 0x0001
139#define F_SEAL_SHRINK 0x0002
140#define F_SEAL_GROW 0x0004
141#define F_SEAL_WRITE 0x0008
142#define F_SEAL_FUTURE_WRITE 0x0010
143
144#define F_GET_RW_HINT 1035
145#define F_SET_RW_HINT 1036
146#define F_GET_FILE_RW_HINT 1037
147#define F_SET_FILE_RW_HINT 1038
148
149#define RWF_WRITE_LIFE_NOT_SET 0
150#define RWH_WRITE_LIFE_NONE 1
151#define RWH_WRITE_LIFE_SHORT 2
152#define RWH_WRITE_LIFE_MEDIUM 3
153#define RWH_WRITE_LIFE_LONG 4
154#define RWH_WRITE_LIFE_EXTREME 5
155
156#define DN_ACCESS 0x00000001
157#define DN_MODIFY 0x00000002
158#define DN_CREATE 0x00000004
159#define DN_DELETE 0x00000008
160#define DN_RENAME 0x00000010
161#define DN_ATTRIB 0x00000020
162#define DN_MULTISHOT 0x80000000
163
164int lockf(int, int, off_t);
165#endif
166#endif
167
168#if defined(_GNU_SOURCE)
169#ifdef __wasilibc_unmodified_upstream /* WASI has no name_to_handle_at */
170#define F_OWNER_TID 0
171#define F_OWNER_PID 1
172#define F_OWNER_PGRP 2
173#define F_OWNER_GID 2
174struct file_handle {
175 unsigned handle_bytes;
176 int handle_type;
177 unsigned char f_handle[];
178};
179#endif
180#ifdef __wasilibc_unmodified_upstream /* WASI has no F_GETOWN_EX */
181struct f_owner_ex {
182 int type;
183 pid_t pid;
184};
185#endif
186#ifdef __wasilibc_unmodified_upstream /* WASI has no fallocate */
187#define FALLOC_FL_KEEP_SIZE 1
188#define FALLOC_FL_PUNCH_HOLE 2
189#endif
190#ifdef __wasilibc_unmodified_upstream /* WASI has no name_to_handle_at */
191#define MAX_HANDLE_SZ 128
192#endif
193#ifdef __wasilibc_unmodified_upstream /* WASI has no syc_file_range */
194#define SYNC_FILE_RANGE_WAIT_BEFORE 1
195#define SYNC_FILE_RANGE_WRITE 2
196#define SYNC_FILE_RANGE_WAIT_AFTER 4
197#endif
198#ifdef __wasilibc_unmodified_upstream /* WASI has no splice */
199#define SPLICE_F_MOVE 1
200#define SPLICE_F_NONBLOCK 2
201#define SPLICE_F_MORE 4
202#define SPLICE_F_GIFT 8
203#endif
204#ifdef __wasilibc_unmodified_upstream /* WASI has no fallocate */
205int fallocate(int, int, off_t, off_t);
206#define fallocate64 fallocate
207#endif
208#ifdef __wasilibc_unmodified_upstream /* WASI has no name_to_handle_at */
209int name_to_handle_at(int, const char *, struct file_handle *, int *, int);
210int open_by_handle_at(int, struct file_handle *, int);
211#endif
212#ifdef __wasilibc_unmodified_upstream /* WASI has no readahead */
213ssize_t readahead(int, off_t, size_t);
214#endif
215#ifdef __wasilibc_unmodified_upstream /* WASI has no splice, syc_file_range, or tee */
216int sync_file_range(int, off_t, off_t, unsigned);
217ssize_t vmsplice(int, const struct iovec *, size_t, unsigned);
218ssize_t splice(int, off_t *, int, off_t *, size_t, unsigned);
219ssize_t tee(int, int, size_t, unsigned);
220#endif
221#define loff_t off_t
222#endif
223
224#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
225#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
226#define F_GETLK64 F_GETLK
227#define F_SETLK64 F_SETLK
228#define F_SETLKW64 F_SETLKW
229#define flock64 flock
230#endif
231#define open64 open
232#define openat64 openat
233#define creat64 creat
234#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
235#define lockf64 lockf
236#endif
237#define posix_fadvise64 posix_fadvise
238#define posix_fallocate64 posix_fallocate
239#define off64_t off_t
240#endif
241
242#ifdef __cplusplus
243}
244#endif
245
246#endif
lib/libc/include/wasm32-wasi/features.h deleted-40
......@@ -1,40 +0,0 @@
1#ifndef _FEATURES_H
2#define _FEATURES_H
3
4#if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE)
5#define _GNU_SOURCE 1
6#endif
7
8#if defined(_DEFAULT_SOURCE) && !defined(_BSD_SOURCE)
9#define _BSD_SOURCE 1
10#endif
11
12#if !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) \
13 && !defined(_XOPEN_SOURCE) && !defined(_GNU_SOURCE) \
14 && !defined(_BSD_SOURCE) && !defined(__STRICT_ANSI__)
15#define _BSD_SOURCE 1
16#define _XOPEN_SOURCE 700
17#endif
18
19#if __STDC_VERSION__ >= 199901L
20#define __restrict restrict
21#elif !defined(__GNUC__)
22#define __restrict
23#endif
24
25#if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
26#define __inline inline
27#elif !defined(__GNUC__)
28#define __inline
29#endif
30
31#if __STDC_VERSION__ >= 201112L
32#elif defined(__GNUC__)
33#define _Noreturn __attribute__((__noreturn__))
34#else
35#define _Noreturn
36#endif
37
38#define __REDIR(x,y) __typeof__(x) x __asm__(#y)
39
40#endif
lib/libc/include/wasm32-wasi/fenv.h deleted-28
......@@ -1,28 +0,0 @@
1#ifndef _FENV_H
2#define _FENV_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <bits/fenv.h>
9
10int feclearexcept(int);
11int fegetexceptflag(fexcept_t *, int);
12int feraiseexcept(int);
13int fesetexceptflag(const fexcept_t *, int);
14int fetestexcept(int);
15
16int fegetround(void);
17int fesetround(int);
18
19int fegetenv(fenv_t *);
20int feholdexcept(fenv_t *);
21int fesetenv(const fenv_t *);
22int feupdateenv(const fenv_t *);
23
24#ifdef __cplusplus
25}
26#endif
27#endif
28
lib/libc/include/wasm32-wasi/float.h deleted-56
......@@ -1,56 +0,0 @@
1#ifndef _FLOAT_H
2#define _FLOAT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of FLT_ROUNDS */
9int __flt_rounds(void);
10#define FLT_ROUNDS (__flt_rounds())
11#else
12#define FLT_ROUNDS (__builtin_flt_rounds())
13#endif
14
15#define FLT_RADIX 2
16
17#define FLT_TRUE_MIN 1.40129846432481707092e-45F
18#define FLT_MIN 1.17549435082228750797e-38F
19#define FLT_MAX 3.40282346638528859812e+38F
20#define FLT_EPSILON 1.1920928955078125e-07F
21
22#define FLT_MANT_DIG 24
23#define FLT_MIN_EXP (-125)
24#define FLT_MAX_EXP 128
25#define FLT_HAS_SUBNORM 1
26
27#define FLT_DIG 6
28#define FLT_DECIMAL_DIG 9
29#define FLT_MIN_10_EXP (-37)
30#define FLT_MAX_10_EXP 38
31
32#define DBL_TRUE_MIN 4.94065645841246544177e-324
33#define DBL_MIN 2.22507385850720138309e-308
34#define DBL_MAX 1.79769313486231570815e+308
35#define DBL_EPSILON 2.22044604925031308085e-16
36
37#define DBL_MANT_DIG 53
38#define DBL_MIN_EXP (-1021)
39#define DBL_MAX_EXP 1024
40#define DBL_HAS_SUBNORM 1
41
42#define DBL_DIG 15
43#define DBL_DECIMAL_DIG 17
44#define DBL_MIN_10_EXP (-307)
45#define DBL_MAX_10_EXP 308
46
47#define LDBL_HAS_SUBNORM 1
48#define LDBL_DECIMAL_DIG DECIMAL_DIG
49
50#include <bits/float.h>
51
52#ifdef __cplusplus
53}
54#endif
55
56#endif
lib/libc/include/wasm32-wasi/fmtmsg.h deleted-47
......@@ -1,47 +0,0 @@
1#ifndef _FMTMSG_H
2#define _FMTMSG_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define MM_HARD 1
9#define MM_SOFT 2
10#define MM_FIRM 4
11
12#define MM_APPL 8
13#define MM_UTIL 16
14#define MM_OPSYS 32
15
16#define MM_RECOVER 64
17#define MM_NRECOV 128
18
19#define MM_PRINT 256
20#define MM_CONSOLE 512
21
22#define MM_NULLMC 0L
23
24#define MM_HALT 1
25#define MM_ERROR 2
26#define MM_WARNING 3
27#define MM_INFO 4
28#define MM_NOSEV 0
29
30#define MM_OK 0
31#define MM_NOTOK (-1)
32#define MM_NOMSG 1
33#define MM_NOCON 4
34
35#define MM_NULLLBL ((char*)0)
36#define MM_NULLTXT ((char*)0)
37#define MM_NULLACT ((char*)0)
38#define MM_NULLTAG ((char*)0)
39#define MM_NULLSEV 0
40
41int fmtmsg(long, const char *, int, const char *, const char *, const char *);
42
43#ifdef __cplusplus
44}
45#endif
46
47#endif
lib/libc/include/wasm32-wasi/fnmatch.h deleted-24
......@@ -1,24 +0,0 @@
1#ifndef _FNMATCH_H
2#define _FNMATCH_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define FNM_PATHNAME 0x1
9#define FNM_NOESCAPE 0x2
10#define FNM_PERIOD 0x4
11#define FNM_LEADING_DIR 0x8
12#define FNM_CASEFOLD 0x10
13#define FNM_FILE_NAME FNM_PATHNAME
14
15#define FNM_NOMATCH 1
16#define FNM_NOSYS (-1)
17
18int fnmatch(const char *, const char *, int);
19
20#ifdef __cplusplus
21}
22#endif
23
24#endif
lib/libc/include/wasm32-wasi/ftw.h deleted-45
......@@ -1,45 +0,0 @@
1#ifndef _FTW_H
2#define _FTW_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <sys/stat.h>
10
11#define FTW_F 1
12#define FTW_D 2
13#define FTW_DNR 3
14#define FTW_NS 4
15#define FTW_SL 5
16#define FTW_DP 6
17#define FTW_SLN 7
18
19#define FTW_PHYS 1
20#define FTW_MOUNT 2
21#define FTW_CHDIR 4
22#define FTW_DEPTH 8
23
24struct FTW {
25 int base;
26 int level;
27};
28
29#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
30int ftw(const char *, int (*)(const char *, const struct stat *, int), int);
31#endif
32int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *), int, int);
33
34#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
35#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
36#define ftw64 ftw
37#endif
38#define nftw64 nftw
39#endif
40
41#ifdef __cplusplus
42}
43#endif
44
45#endif
lib/libc/include/wasm32-wasi/getopt.h deleted-30
......@@ -1,30 +0,0 @@
1#ifndef _GETOPT_H
2#define _GETOPT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8int getopt(int, char * const [], const char *);
9extern char *optarg;
10extern int optind, opterr, optopt, optreset;
11
12struct option {
13 const char *name;
14 int has_arg;
15 int *flag;
16 int val;
17};
18
19int getopt_long(int, char *const *, const char *, const struct option *, int *);
20int getopt_long_only(int, char *const *, const char *, const struct option *, int *);
21
22#define no_argument 0
23#define required_argument 1
24#define optional_argument 2
25
26#ifdef __cplusplus
27}
28#endif
29
30#endif
lib/libc/include/wasm32-wasi/glob.h deleted-54
......@@ -1,54 +0,0 @@
1#ifndef _GLOB_H
2#define _GLOB_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11
12#include <bits/alltypes.h>
13
14typedef struct {
15 size_t gl_pathc;
16 char **gl_pathv;
17 size_t gl_offs;
18 int __dummy1;
19 void *__dummy2[5];
20} glob_t;
21
22int glob(const char *__restrict, int, int (*)(const char *, int), glob_t *__restrict);
23void globfree(glob_t *);
24
25#define GLOB_ERR 0x01
26#define GLOB_MARK 0x02
27#define GLOB_NOSORT 0x04
28#define GLOB_DOOFFS 0x08
29#define GLOB_NOCHECK 0x10
30#define GLOB_APPEND 0x20
31#define GLOB_NOESCAPE 0x40
32#define GLOB_PERIOD 0x80
33
34#ifdef __wasilibc_unmodified_upstream // WASI has no usernames
35#define GLOB_TILDE 0x1000
36#define GLOB_TILDE_CHECK 0x4000
37#endif
38
39#define GLOB_NOSPACE 1
40#define GLOB_ABORTED 2
41#define GLOB_NOMATCH 3
42#define GLOB_NOSYS 4
43
44#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
45#define glob64 glob
46#define globfree64 globfree
47#define glob64_t glob_t
48#endif
49
50#ifdef __cplusplus
51}
52#endif
53
54#endif
lib/libc/include/wasm32-wasi/iconv.h deleted-24
......@@ -1,24 +0,0 @@
1#ifndef _ICONV_H
2#define _ICONV_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11
12#include <bits/alltypes.h>
13
14typedef void *iconv_t;
15
16iconv_t iconv_open(const char *, const char *);
17size_t iconv(iconv_t, char **__restrict, size_t *__restrict, char **__restrict, size_t *__restrict);
18int iconv_close(iconv_t);
19
20#ifdef __cplusplus
21}
22#endif
23
24#endif
lib/libc/include/wasm32-wasi/ifaddrs.h deleted-35
......@@ -1,35 +0,0 @@
1#ifndef _IFADDRS_H
2#define _IFADDRS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <netinet/in.h>
10#include <sys/socket.h>
11
12struct ifaddrs {
13 struct ifaddrs *ifa_next;
14 char *ifa_name;
15 unsigned ifa_flags;
16 struct sockaddr *ifa_addr;
17 struct sockaddr *ifa_netmask;
18 union {
19 struct sockaddr *ifu_broadaddr;
20 struct sockaddr *ifu_dstaddr;
21 } ifa_ifu;
22 void *ifa_data;
23};
24#define ifa_broadaddr ifa_ifu.ifu_broadaddr
25#define ifa_dstaddr ifa_ifu.ifu_dstaddr
26
27void freeifaddrs(struct ifaddrs *);
28int getifaddrs(struct ifaddrs **);
29
30#ifdef __cplusplus
31}
32#endif
33
34#endif
35
lib/libc/include/wasm32-wasi/inttypes.h deleted-233
......@@ -1,233 +0,0 @@
1#ifndef _INTTYPES_H
2#define _INTTYPES_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9#include <features.h>
10#include <stdint.h>
11
12#define __NEED_wchar_t
13#include <bits/alltypes.h>
14
15typedef struct { intmax_t quot, rem; } imaxdiv_t;
16
17intmax_t imaxabs(intmax_t);
18imaxdiv_t imaxdiv(intmax_t, intmax_t);
19
20intmax_t strtoimax(const char *__restrict, char **__restrict, int);
21uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
22
23intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
24uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
25
26#if UINTPTR_MAX == UINT64_MAX
27#define __PRI64 "l"
28#define __PRIPTR "l"
29#else
30#define __PRI64 "ll"
31#define __PRIPTR ""
32#endif
33
34#define PRId8 "d"
35#define PRId16 "d"
36#define PRId32 "d"
37#define PRId64 __PRI64 "d"
38
39#define PRIdLEAST8 "d"
40#define PRIdLEAST16 "d"
41#define PRIdLEAST32 "d"
42#define PRIdLEAST64 __PRI64 "d"
43
44#define PRIdFAST8 "d"
45#define PRIdFAST16 "d"
46#define PRIdFAST32 "d"
47#define PRIdFAST64 __PRI64 "d"
48
49#define PRIi8 "i"
50#define PRIi16 "i"
51#define PRIi32 "i"
52#define PRIi64 __PRI64 "i"
53
54#define PRIiLEAST8 "i"
55#define PRIiLEAST16 "i"
56#define PRIiLEAST32 "i"
57#define PRIiLEAST64 __PRI64 "i"
58
59#define PRIiFAST8 "i"
60#define PRIiFAST16 "i"
61#define PRIiFAST32 "i"
62#define PRIiFAST64 __PRI64 "i"
63
64#define PRIo8 "o"
65#define PRIo16 "o"
66#define PRIo32 "o"
67#define PRIo64 __PRI64 "o"
68
69#define PRIoLEAST8 "o"
70#define PRIoLEAST16 "o"
71#define PRIoLEAST32 "o"
72#define PRIoLEAST64 __PRI64 "o"
73
74#define PRIoFAST8 "o"
75#define PRIoFAST16 "o"
76#define PRIoFAST32 "o"
77#define PRIoFAST64 __PRI64 "o"
78
79#define PRIu8 "u"
80#define PRIu16 "u"
81#define PRIu32 "u"
82#define PRIu64 __PRI64 "u"
83
84#define PRIuLEAST8 "u"
85#define PRIuLEAST16 "u"
86#define PRIuLEAST32 "u"
87#define PRIuLEAST64 __PRI64 "u"
88
89#define PRIuFAST8 "u"
90#define PRIuFAST16 "u"
91#define PRIuFAST32 "u"
92#define PRIuFAST64 __PRI64 "u"
93
94#define PRIx8 "x"
95#define PRIx16 "x"
96#define PRIx32 "x"
97#define PRIx64 __PRI64 "x"
98
99#define PRIxLEAST8 "x"
100#define PRIxLEAST16 "x"
101#define PRIxLEAST32 "x"
102#define PRIxLEAST64 __PRI64 "x"
103
104#define PRIxFAST8 "x"
105#define PRIxFAST16 "x"
106#define PRIxFAST32 "x"
107#define PRIxFAST64 __PRI64 "x"
108
109#define PRIX8 "X"
110#define PRIX16 "X"
111#define PRIX32 "X"
112#define PRIX64 __PRI64 "X"
113
114#define PRIXLEAST8 "X"
115#define PRIXLEAST16 "X"
116#define PRIXLEAST32 "X"
117#define PRIXLEAST64 __PRI64 "X"
118
119#define PRIXFAST8 "X"
120#define PRIXFAST16 "X"
121#define PRIXFAST32 "X"
122#define PRIXFAST64 __PRI64 "X"
123
124#define PRIdMAX __PRI64 "d"
125#define PRIiMAX __PRI64 "i"
126#define PRIoMAX __PRI64 "o"
127#define PRIuMAX __PRI64 "u"
128#define PRIxMAX __PRI64 "x"
129#define PRIXMAX __PRI64 "X"
130
131#define PRIdPTR __PRIPTR "d"
132#define PRIiPTR __PRIPTR "i"
133#define PRIoPTR __PRIPTR "o"
134#define PRIuPTR __PRIPTR "u"
135#define PRIxPTR __PRIPTR "x"
136#define PRIXPTR __PRIPTR "X"
137
138#define SCNd8 "hhd"
139#define SCNd16 "hd"
140#define SCNd32 "d"
141#define SCNd64 __PRI64 "d"
142
143#define SCNdLEAST8 "hhd"
144#define SCNdLEAST16 "hd"
145#define SCNdLEAST32 "d"
146#define SCNdLEAST64 __PRI64 "d"
147
148#define SCNdFAST8 "hhd"
149#define SCNdFAST16 "d"
150#define SCNdFAST32 "d"
151#define SCNdFAST64 __PRI64 "d"
152
153#define SCNi8 "hhi"
154#define SCNi16 "hi"
155#define SCNi32 "i"
156#define SCNi64 __PRI64 "i"
157
158#define SCNiLEAST8 "hhi"
159#define SCNiLEAST16 "hi"
160#define SCNiLEAST32 "i"
161#define SCNiLEAST64 __PRI64 "i"
162
163#define SCNiFAST8 "hhi"
164#define SCNiFAST16 "i"
165#define SCNiFAST32 "i"
166#define SCNiFAST64 __PRI64 "i"
167
168#define SCNu8 "hhu"
169#define SCNu16 "hu"
170#define SCNu32 "u"
171#define SCNu64 __PRI64 "u"
172
173#define SCNuLEAST8 "hhu"
174#define SCNuLEAST16 "hu"
175#define SCNuLEAST32 "u"
176#define SCNuLEAST64 __PRI64 "u"
177
178#define SCNuFAST8 "hhu"
179#define SCNuFAST16 "u"
180#define SCNuFAST32 "u"
181#define SCNuFAST64 __PRI64 "u"
182
183#define SCNo8 "hho"
184#define SCNo16 "ho"
185#define SCNo32 "o"
186#define SCNo64 __PRI64 "o"
187
188#define SCNoLEAST8 "hho"
189#define SCNoLEAST16 "ho"
190#define SCNoLEAST32 "o"
191#define SCNoLEAST64 __PRI64 "o"
192
193#define SCNoFAST8 "hho"
194#define SCNoFAST16 "o"
195#define SCNoFAST32 "o"
196#define SCNoFAST64 __PRI64 "o"
197
198#define SCNx8 "hhx"
199#define SCNx16 "hx"
200#define SCNx32 "x"
201#define SCNx64 __PRI64 "x"
202
203#define SCNxLEAST8 "hhx"
204#define SCNxLEAST16 "hx"
205#define SCNxLEAST32 "x"
206#define SCNxLEAST64 __PRI64 "x"
207
208#define SCNxFAST8 "hhx"
209#define SCNxFAST16 "x"
210#define SCNxFAST32 "x"
211#define SCNxFAST64 __PRI64 "x"
212
213#define SCNdMAX __PRI64 "d"
214#define SCNiMAX __PRI64 "i"
215#define SCNoMAX __PRI64 "o"
216#define SCNuMAX __PRI64 "u"
217#define SCNxMAX __PRI64 "x"
218
219#define SCNdPTR __PRIPTR "d"
220#define SCNiPTR __PRIPTR "i"
221#define SCNoPTR __PRIPTR "o"
222#define SCNuPTR __PRIPTR "u"
223#define SCNxPTR __PRIPTR "x"
224
225#ifdef __cplusplus
226}
227#endif
228#else
229#include <__header_inttypes.h>
230#endif
231
232#endif
233
lib/libc/include/wasm32-wasi/iso646.h deleted-20
......@@ -1,20 +0,0 @@
1#ifndef _ISO646_H
2#define _ISO646_H
3
4#ifndef __cplusplus
5
6#define and &&
7#define and_eq &=
8#define bitand &
9#define bitor |
10#define compl ~
11#define not !
12#define not_eq !=
13#define or ||
14#define or_eq |=
15#define xor ^
16#define xor_eq ^=
17
18#endif
19
20#endif
lib/libc/include/wasm32-wasi/langinfo.h deleted-98
......@@ -1,98 +0,0 @@
1#ifndef _LANGINFO_H
2#define _LANGINFO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <nl_types.h>
10
11#define __NEED_locale_t
12
13#include <bits/alltypes.h>
14
15#define ABDAY_1 0x20000
16#define ABDAY_2 0x20001
17#define ABDAY_3 0x20002
18#define ABDAY_4 0x20003
19#define ABDAY_5 0x20004
20#define ABDAY_6 0x20005
21#define ABDAY_7 0x20006
22
23#define DAY_1 0x20007
24#define DAY_2 0x20008
25#define DAY_3 0x20009
26#define DAY_4 0x2000A
27#define DAY_5 0x2000B
28#define DAY_6 0x2000C
29#define DAY_7 0x2000D
30
31#define ABMON_1 0x2000E
32#define ABMON_2 0x2000F
33#define ABMON_3 0x20010
34#define ABMON_4 0x20011
35#define ABMON_5 0x20012
36#define ABMON_6 0x20013
37#define ABMON_7 0x20014
38#define ABMON_8 0x20015
39#define ABMON_9 0x20016
40#define ABMON_10 0x20017
41#define ABMON_11 0x20018
42#define ABMON_12 0x20019
43
44#define MON_1 0x2001A
45#define MON_2 0x2001B
46#define MON_3 0x2001C
47#define MON_4 0x2001D
48#define MON_5 0x2001E
49#define MON_6 0x2001F
50#define MON_7 0x20020
51#define MON_8 0x20021
52#define MON_9 0x20022
53#define MON_10 0x20023
54#define MON_11 0x20024
55#define MON_12 0x20025
56
57#define AM_STR 0x20026
58#define PM_STR 0x20027
59
60#define D_T_FMT 0x20028
61#define D_FMT 0x20029
62#define T_FMT 0x2002A
63#define T_FMT_AMPM 0x2002B
64
65#define ERA 0x2002C
66#define ERA_D_FMT 0x2002E
67#define ALT_DIGITS 0x2002F
68#define ERA_D_T_FMT 0x20030
69#define ERA_T_FMT 0x20031
70
71#define CODESET 14
72
73#define CRNCYSTR 0x4000F
74
75#define RADIXCHAR 0x10000
76#define THOUSEP 0x10001
77#define YESEXPR 0x50000
78#define NOEXPR 0x50001
79
80#define _NL_LOCALE_NAME(cat) (((cat)<<16) | 0xffff)
81
82#if defined(_GNU_SOURCE)
83#define NL_LOCALE_NAME(cat) _NL_LOCALE_NAME(cat)
84#endif
85
86#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
87#define YESSTR 0x50002
88#define NOSTR 0x50003
89#endif
90
91char *nl_langinfo(nl_item);
92char *nl_langinfo_l(nl_item, locale_t);
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif
lib/libc/include/wasm32-wasi/libgen.h deleted-15
......@@ -1,15 +0,0 @@
1#ifndef _LIBGEN_H
2#define _LIBGEN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8char *dirname(char *);
9char *basename(char *);
10
11#ifdef __cplusplus
12}
13#endif
14
15#endif
lib/libc/include/wasm32-wasi/limits.h deleted-180
......@@ -1,180 +0,0 @@
1#ifndef _LIMITS_H
2#define _LIMITS_H
3
4#include <features.h>
5
6#include <bits/alltypes.h> /* __LONG_MAX */
7
8/* Support signed or unsigned plain-char */
9
10#if '\xff' > 0
11#define CHAR_MIN 0
12#define CHAR_MAX 255
13#else
14#define CHAR_MIN (-128)
15#define CHAR_MAX 127
16#endif
17
18#define CHAR_BIT 8
19#define SCHAR_MIN (-128)
20#define SCHAR_MAX 127
21#define UCHAR_MAX 255
22#define SHRT_MIN (-1-0x7fff)
23#define SHRT_MAX 0x7fff
24#define USHRT_MAX 0xffff
25#define INT_MIN (-1-0x7fffffff)
26#define INT_MAX 0x7fffffff
27#define UINT_MAX 0xffffffffU
28#define LONG_MIN (-LONG_MAX-1)
29#define LONG_MAX __LONG_MAX
30#define ULONG_MAX (2UL*LONG_MAX+1)
31#define LLONG_MIN (-LLONG_MAX-1)
32#define LLONG_MAX 0x7fffffffffffffffLL
33#define ULLONG_MAX (2ULL*LLONG_MAX+1)
34
35#define MB_LEN_MAX 4
36
37#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
38 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
39
40#include <bits/limits.h>
41
42#ifdef __wasilibc_unmodified_upstream /* WASI has no pipes */
43#define PIPE_BUF 4096
44#endif
45#define FILESIZEBITS 64
46#ifndef NAME_MAX
47#define NAME_MAX 255
48#endif
49#define PATH_MAX 4096
50#define NGROUPS_MAX 32
51#define ARG_MAX 131072
52#define IOV_MAX 1024
53#define SYMLOOP_MAX 40
54#define WORD_BIT 32
55#define SSIZE_MAX LONG_MAX
56#define TZNAME_MAX 6
57#define TTY_NAME_MAX 32
58#define HOST_NAME_MAX 255
59
60#if LONG_MAX == 0x7fffffffL
61#define LONG_BIT 32
62#else
63#define LONG_BIT 64
64#endif
65
66/* Implementation choices... */
67
68#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
69#define PTHREAD_KEYS_MAX 128
70#define PTHREAD_STACK_MIN 2048
71#define PTHREAD_DESTRUCTOR_ITERATIONS 4
72#endif
73#ifdef __wasilibc_unmodified_upstream /* WASI has no semaphores */
74#define SEM_VALUE_MAX 0x7fffffff
75#define SEM_NSEMS_MAX 256
76#endif
77#define DELAYTIMER_MAX 0x7fffffff
78#ifdef __wasilibc_unmodified_upstream /* WASI has no mq */
79#define MQ_PRIO_MAX 32768
80#endif
81#ifdef __wasilibc_unmodified_upstream /* WASI has no usernames */
82#define LOGIN_NAME_MAX 256
83#endif
84
85/* Arbitrary numbers... */
86
87#ifdef __wasilibc_unmodified_upstream /* WASI has no shell commands */
88#define BC_BASE_MAX 99
89#define BC_DIM_MAX 2048
90#define BC_SCALE_MAX 99
91#define BC_STRING_MAX 1000
92#endif
93#define CHARCLASS_NAME_MAX 14
94#define COLL_WEIGHTS_MAX 2
95#ifdef __wasilibc_unmodified_upstream /* WASI has no shell commands */
96#define EXPR_NEST_MAX 32
97#define LINE_MAX 4096
98#endif
99#define RE_DUP_MAX 255
100
101#define NL_ARGMAX 9
102#define NL_MSGMAX 32767
103#define NL_SETMAX 255
104#define NL_TEXTMAX 2048
105
106#endif
107
108#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE)
109
110#ifdef PAGESIZE
111#define PAGE_SIZE PAGESIZE
112#endif
113#define NZERO 20
114#define NL_LANGMAX 32
115
116#endif
117
118#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \
119 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
120
121#define NL_NMAX 16
122
123#endif
124
125/* POSIX/SUS requirements follow. These numbers come directly
126 * from SUS and have nothing to do with the host system. */
127
128#define _POSIX_AIO_LISTIO_MAX 2
129#define _POSIX_AIO_MAX 1
130#define _POSIX_ARG_MAX 4096
131#define _POSIX_CHILD_MAX 25
132#define _POSIX_CLOCKRES_MIN 20000000
133#define _POSIX_DELAYTIMER_MAX 32
134#define _POSIX_HOST_NAME_MAX 255
135#define _POSIX_LINK_MAX 8
136#define _POSIX_LOGIN_NAME_MAX 9
137#define _POSIX_MAX_CANON 255
138#define _POSIX_MAX_INPUT 255
139#define _POSIX_MQ_OPEN_MAX 8
140#define _POSIX_MQ_PRIO_MAX 32
141#define _POSIX_NAME_MAX 14
142#define _POSIX_NGROUPS_MAX 8
143#define _POSIX_OPEN_MAX 20
144#define _POSIX_PATH_MAX 256
145#define _POSIX_PIPE_BUF 512
146#define _POSIX_RE_DUP_MAX 255
147#define _POSIX_RTSIG_MAX 8
148#define _POSIX_SEM_NSEMS_MAX 256
149#define _POSIX_SEM_VALUE_MAX 32767
150#define _POSIX_SIGQUEUE_MAX 32
151#define _POSIX_SSIZE_MAX 32767
152#define _POSIX_STREAM_MAX 8
153#define _POSIX_SS_REPL_MAX 4
154#define _POSIX_SYMLINK_MAX 255
155#define _POSIX_SYMLOOP_MAX 8
156#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
157#define _POSIX_THREAD_KEYS_MAX 128
158#define _POSIX_THREAD_THREADS_MAX 64
159#define _POSIX_TIMER_MAX 32
160#define _POSIX_TRACE_EVENT_NAME_MAX 30
161#define _POSIX_TRACE_NAME_MAX 8
162#define _POSIX_TRACE_SYS_MAX 8
163#define _POSIX_TRACE_USER_EVENT_MAX 32
164#define _POSIX_TTY_NAME_MAX 9
165#define _POSIX_TZNAME_MAX 6
166#define _POSIX2_BC_BASE_MAX 99
167#define _POSIX2_BC_DIM_MAX 2048
168#define _POSIX2_BC_SCALE_MAX 99
169#define _POSIX2_BC_STRING_MAX 1000
170#define _POSIX2_CHARCLASS_NAME_MAX 14
171#define _POSIX2_COLL_WEIGHTS_MAX 2
172#define _POSIX2_EXPR_NEST_MAX 32
173#define _POSIX2_LINE_MAX 2048
174#define _POSIX2_RE_DUP_MAX 255
175
176#define _XOPEN_IOV_MAX 16
177#define _XOPEN_NAME_MAX 255
178#define _XOPEN_PATH_MAX 1024
179
180#endif
lib/libc/include/wasm32-wasi/locale.h deleted-91
......@@ -1,91 +0,0 @@
1#ifndef _LOCALE_H
2#define _LOCALE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
11#ifdef __cplusplus
12#define NULL 0L
13#else
14#define NULL ((void*)0)
15#endif
16#else
17#define __need_NULL
18#include <stddef.h>
19#endif
20
21#define LC_CTYPE 0
22#define LC_NUMERIC 1
23#define LC_TIME 2
24#define LC_COLLATE 3
25#define LC_MONETARY 4
26#define LC_MESSAGES 5
27#define LC_ALL 6
28
29struct lconv {
30 char *decimal_point;
31 char *thousands_sep;
32 char *grouping;
33
34 char *int_curr_symbol;
35 char *currency_symbol;
36 char *mon_decimal_point;
37 char *mon_thousands_sep;
38 char *mon_grouping;
39 char *positive_sign;
40 char *negative_sign;
41 char int_frac_digits;
42 char frac_digits;
43 char p_cs_precedes;
44 char p_sep_by_space;
45 char n_cs_precedes;
46 char n_sep_by_space;
47 char p_sign_posn;
48 char n_sign_posn;
49 char int_p_cs_precedes;
50 char int_p_sep_by_space;
51 char int_n_cs_precedes;
52 char int_n_sep_by_space;
53 char int_p_sign_posn;
54 char int_n_sign_posn;
55};
56
57
58char *setlocale (int, const char *);
59struct lconv *localeconv(void);
60
61
62#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
63 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
64
65#define __NEED_locale_t
66
67#include <bits/alltypes.h>
68
69#define LC_GLOBAL_LOCALE ((locale_t)-1)
70
71#define LC_CTYPE_MASK (1<<LC_CTYPE)
72#define LC_NUMERIC_MASK (1<<LC_NUMERIC)
73#define LC_TIME_MASK (1<<LC_TIME)
74#define LC_COLLATE_MASK (1<<LC_COLLATE)
75#define LC_MONETARY_MASK (1<<LC_MONETARY)
76#define LC_MESSAGES_MASK (1<<LC_MESSAGES)
77#define LC_ALL_MASK 0x7fffffff
78
79locale_t duplocale(locale_t);
80void freelocale(locale_t);
81locale_t newlocale(int, const char *, locale_t);
82locale_t uselocale(locale_t);
83
84#endif
85
86
87#ifdef __cplusplus
88}
89#endif
90
91#endif
lib/libc/include/wasm32-wasi/malloc.h deleted-33
......@@ -1,33 +0,0 @@
1#ifndef _MALLOC_H
2#define _MALLOC_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#else
6#include <__functions_malloc.h>
7#endif
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#define __NEED_size_t
13
14#include <bits/alltypes.h>
15
16#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
17void *malloc (size_t);
18void *calloc (size_t, size_t);
19void *realloc (void *, size_t);
20void free (void *);
21#endif
22#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
23void *valloc (size_t);
24void *memalign(size_t, size_t);
25#endif
26
27size_t malloc_usable_size(void *);
28
29#ifdef __cplusplus
30}
31#endif
32
33#endif
lib/libc/include/wasm32-wasi/math.h deleted-459
......@@ -1,459 +0,0 @@
1#ifndef _MATH_H
2#define _MATH_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_float_t
11#define __NEED_double_t
12#include <bits/alltypes.h>
13
14#if 100*__GNUC__+__GNUC_MINOR__ >= 303
15#define NAN __builtin_nanf("")
16#define INFINITY __builtin_inff()
17#else
18#define NAN (0.0f/0.0f)
19#define INFINITY 1e5000f
20#endif
21
22#define HUGE_VALF INFINITY
23#define HUGE_VAL ((double)INFINITY)
24#define HUGE_VALL ((long double)INFINITY)
25
26#define MATH_ERRNO 1
27#define MATH_ERREXCEPT 2
28#define math_errhandling 2
29
30#define FP_ILOGBNAN (-1-0x7fffffff)
31#define FP_ILOGB0 FP_ILOGBNAN
32
33#define FP_NAN 0
34#define FP_INFINITE 1
35#define FP_ZERO 2
36#define FP_SUBNORMAL 3
37#define FP_NORMAL 4
38
39#ifdef __FP_FAST_FMA
40#define FP_FAST_FMA 1
41#endif
42
43#ifdef __FP_FAST_FMAF
44#define FP_FAST_FMAF 1
45#endif
46
47#ifdef __FP_FAST_FMAL
48#define FP_FAST_FMAL 1
49#endif
50
51#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of the fpclassify-like operations */
52int __fpclassify(double);
53int __fpclassifyf(float);
54int __fpclassifyl(long double);
55
56static __inline unsigned __FLOAT_BITS(float __f)
57{
58 union {float __f; unsigned __i;} __u;
59 __u.__f = __f;
60 return __u.__i;
61}
62static __inline unsigned long long __DOUBLE_BITS(double __f)
63{
64 union {double __f; unsigned long long __i;} __u;
65 __u.__f = __f;
66 return __u.__i;
67}
68
69#define fpclassify(x) ( \
70 sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \
71 sizeof(x) == sizeof(double) ? __fpclassify(x) : \
72 __fpclassifyl(x) )
73
74#define isinf(x) ( \
75 sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 : \
76 sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) == 0x7ffULL<<52 : \
77 __fpclassifyl(x) == FP_INFINITE)
78
79#define isnan(x) ( \
80 sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \
81 sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \
82 __fpclassifyl(x) == FP_NAN)
83
84#define isnormal(x) ( \
85 sizeof(x) == sizeof(float) ? ((__FLOAT_BITS(x)+0x00800000) & 0x7fffffff) >= 0x01000000 : \
86 sizeof(x) == sizeof(double) ? ((__DOUBLE_BITS(x)+(1ULL<<52)) & -1ULL>>1) >= 1ULL<<53 : \
87 __fpclassifyl(x) == FP_NORMAL)
88
89#define isfinite(x) ( \
90 sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000 : \
91 sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) < 0x7ffULL<<52 : \
92 __fpclassifyl(x) > FP_INFINITE)
93
94int __signbit(double);
95int __signbitf(float);
96int __signbitl(long double);
97
98#define signbit(x) ( \
99 sizeof(x) == sizeof(float) ? (int)(__FLOAT_BITS(x)>>31) : \
100 sizeof(x) == sizeof(double) ? (int)(__DOUBLE_BITS(x)>>63) : \
101 __signbitl(x) )
102
103#define isunordered(x,y) (isnan((x)) ? ((void)(y),1) : isnan((y)))
104
105#define __ISREL_DEF(rel, op, type) \
106static __inline int __is##rel(type __x, type __y) \
107{ return !isunordered(__x,__y) && __x op __y; }
108
109__ISREL_DEF(lessf, <, float_t)
110__ISREL_DEF(less, <, double_t)
111__ISREL_DEF(lessl, <, long double)
112__ISREL_DEF(lessequalf, <=, float_t)
113__ISREL_DEF(lessequal, <=, double_t)
114__ISREL_DEF(lessequall, <=, long double)
115__ISREL_DEF(lessgreaterf, !=, float_t)
116__ISREL_DEF(lessgreater, !=, double_t)
117__ISREL_DEF(lessgreaterl, !=, long double)
118__ISREL_DEF(greaterf, >, float_t)
119__ISREL_DEF(greater, >, double_t)
120__ISREL_DEF(greaterl, >, long double)
121__ISREL_DEF(greaterequalf, >=, float_t)
122__ISREL_DEF(greaterequal, >=, double_t)
123__ISREL_DEF(greaterequall, >=, long double)
124
125#define __tg_pred_2(x, y, p) ( \
126 sizeof((x)+(y)) == sizeof(float) ? p##f(x, y) : \
127 sizeof((x)+(y)) == sizeof(double) ? p(x, y) : \
128 p##l(x, y) )
129
130#define isless(x, y) __tg_pred_2(x, y, __isless)
131#define islessequal(x, y) __tg_pred_2(x, y, __islessequal)
132#define islessgreater(x, y) __tg_pred_2(x, y, __islessgreater)
133#define isgreater(x, y) __tg_pred_2(x, y, __isgreater)
134#define isgreaterequal(x, y) __tg_pred_2(x, y, __isgreaterequal)
135#else
136#define fpclassify(x) (__builtin_fpclassify(FP_NAN, FP_INFINITE, \
137 FP_NORMAL, FP_SUBNORMAL, \
138 FP_ZERO, x))
139#define isinf(x) (__builtin_isinf(x))
140#define isnan(x) (__builtin_isnan(x))
141#define isnormal(x) (__builtin_isnormal(x))
142#define isfinite(x) (__builtin_isfinite(x))
143#define signbit(x) (__builtin_signbit(x))
144#define isunordered(x, y) (__builtin_isunordered(x, y))
145#define isless(x, y) (__builtin_isless(x, y))
146#define islessequal(x, y) (__builtin_islessequal(x, y))
147#define islessgreater(x, y) (__builtin_islessgreater(x, y))
148#define isgreater(x, y) (__builtin_isgreater(x, y))
149#define isgreaterequal(x, y) (__builtin_isgreaterequal(x, y))
150#endif
151
152double acos(double);
153float acosf(float);
154long double acosl(long double);
155
156double acosh(double);
157float acoshf(float);
158long double acoshl(long double);
159
160double asin(double);
161float asinf(float);
162long double asinl(long double);
163
164double asinh(double);
165float asinhf(float);
166long double asinhl(long double);
167
168double atan(double);
169float atanf(float);
170long double atanl(long double);
171
172double atan2(double, double);
173float atan2f(float, float);
174long double atan2l(long double, long double);
175
176double atanh(double);
177float atanhf(float);
178long double atanhl(long double);
179
180double cbrt(double);
181float cbrtf(float);
182long double cbrtl(long double);
183
184double ceil(double);
185float ceilf(float);
186long double ceill(long double);
187
188double copysign(double, double);
189float copysignf(float, float);
190long double copysignl(long double, long double);
191
192double cos(double);
193float cosf(float);
194long double cosl(long double);
195
196double cosh(double);
197float coshf(float);
198long double coshl(long double);
199
200double erf(double);
201float erff(float);
202long double erfl(long double);
203
204double erfc(double);
205float erfcf(float);
206long double erfcl(long double);
207
208double exp(double);
209float expf(float);
210long double expl(long double);
211
212double exp2(double);
213float exp2f(float);
214long double exp2l(long double);
215
216double expm1(double);
217float expm1f(float);
218long double expm1l(long double);
219
220double fabs(double);
221float fabsf(float);
222long double fabsl(long double);
223
224double fdim(double, double);
225float fdimf(float, float);
226long double fdiml(long double, long double);
227
228double floor(double);
229float floorf(float);
230long double floorl(long double);
231
232double fma(double, double, double);
233float fmaf(float, float, float);
234long double fmal(long double, long double, long double);
235
236double fmax(double, double);
237float fmaxf(float, float);
238long double fmaxl(long double, long double);
239
240double fmin(double, double);
241float fminf(float, float);
242long double fminl(long double, long double);
243
244double fmod(double, double);
245float fmodf(float, float);
246long double fmodl(long double, long double);
247
248double frexp(double, int *);
249float frexpf(float, int *);
250long double frexpl(long double, int *);
251
252double hypot(double, double);
253float hypotf(float, float);
254long double hypotl(long double, long double);
255
256int ilogb(double);
257int ilogbf(float);
258int ilogbl(long double);
259
260double ldexp(double, int);
261float ldexpf(float, int);
262long double ldexpl(long double, int);
263
264double lgamma(double);
265float lgammaf(float);
266long double lgammal(long double);
267
268long long llrint(double);
269long long llrintf(float);
270long long llrintl(long double);
271
272long long llround(double);
273long long llroundf(float);
274long long llroundl(long double);
275
276double log(double);
277float logf(float);
278long double logl(long double);
279
280double log10(double);
281float log10f(float);
282long double log10l(long double);
283
284double log1p(double);
285float log1pf(float);
286long double log1pl(long double);
287
288double log2(double);
289float log2f(float);
290long double log2l(long double);
291
292double logb(double);
293float logbf(float);
294long double logbl(long double);
295
296long lrint(double);
297long lrintf(float);
298long lrintl(long double);
299
300long lround(double);
301long lroundf(float);
302long lroundl(long double);
303
304double modf(double, double *);
305float modff(float, float *);
306long double modfl(long double, long double *);
307
308double nan(const char *);
309float nanf(const char *);
310long double nanl(const char *);
311
312double nearbyint(double);
313float nearbyintf(float);
314long double nearbyintl(long double);
315
316double nextafter(double, double);
317float nextafterf(float, float);
318long double nextafterl(long double, long double);
319
320double nexttoward(double, long double);
321float nexttowardf(float, long double);
322long double nexttowardl(long double, long double);
323
324double pow(double, double);
325float powf(float, float);
326long double powl(long double, long double);
327
328double remainder(double, double);
329float remainderf(float, float);
330long double remainderl(long double, long double);
331
332double remquo(double, double, int *);
333float remquof(float, float, int *);
334long double remquol(long double, long double, int *);
335
336double rint(double);
337float rintf(float);
338long double rintl(long double);
339
340double round(double);
341float roundf(float);
342long double roundl(long double);
343
344double scalbln(double, long);
345float scalblnf(float, long);
346long double scalblnl(long double, long);
347
348double scalbn(double, int);
349float scalbnf(float, int);
350long double scalbnl(long double, int);
351
352double sin(double);
353float sinf(float);
354long double sinl(long double);
355
356double sinh(double);
357float sinhf(float);
358long double sinhl(long double);
359
360double sqrt(double);
361float sqrtf(float);
362long double sqrtl(long double);
363
364double tan(double);
365float tanf(float);
366long double tanl(long double);
367
368double tanh(double);
369float tanhf(float);
370long double tanhl(long double);
371
372double tgamma(double);
373float tgammaf(float);
374long double tgammal(long double);
375
376double trunc(double);
377float truncf(float);
378long double truncl(long double);
379
380
381#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE)
382#undef MAXFLOAT
383#define MAXFLOAT 3.40282346638528859812e+38F
384#endif
385
386#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
387#define M_E 2.7182818284590452354 /* e */
388#define M_LOG2E 1.4426950408889634074 /* log_2 e */
389#define M_LOG10E 0.43429448190325182765 /* log_10 e */
390#define M_LN2 0.69314718055994530942 /* log_e 2 */
391#define M_LN10 2.30258509299404568402 /* log_e 10 */
392#define M_PI 3.14159265358979323846 /* pi */
393#define M_PI_2 1.57079632679489661923 /* pi/2 */
394#define M_PI_4 0.78539816339744830962 /* pi/4 */
395#define M_1_PI 0.31830988618379067154 /* 1/pi */
396#define M_2_PI 0.63661977236758134308 /* 2/pi */
397#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
398#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
399#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
400
401extern int signgam;
402
403double j0(double);
404double j1(double);
405double jn(int, double);
406
407double y0(double);
408double y1(double);
409double yn(int, double);
410#endif
411
412#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
413#define HUGE 3.40282346638528859812e+38F
414
415double drem(double, double);
416float dremf(float, float);
417
418int finite(double);
419int finitef(float);
420
421double scalb(double, double);
422float scalbf(float, float);
423
424double significand(double);
425float significandf(float);
426
427double lgamma_r(double, int*);
428float lgammaf_r(float, int*);
429
430float j0f(float);
431float j1f(float);
432float jnf(int, float);
433
434float y0f(float);
435float y1f(float);
436float ynf(int, float);
437#endif
438
439#ifdef _GNU_SOURCE
440long double lgammal_r(long double, int*);
441
442void sincos(double, double*, double*);
443void sincosf(float, float*, float*);
444void sincosl(long double, long double*, long double*);
445
446double exp10(double);
447float exp10f(float);
448long double exp10l(long double);
449
450double pow10(double);
451float pow10f(float);
452long double pow10l(long double);
453#endif
454
455#ifdef __cplusplus
456}
457#endif
458
459#endif
lib/libc/include/wasm32-wasi/memory.h deleted-1
......@@ -1 +0,0 @@
1#include <string.h>
lib/libc/include/wasm32-wasi/monetary.h deleted-23
......@@ -1,23 +0,0 @@
1#ifndef _MONETARY_H
2#define _MONETARY_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_ssize_t
11#define __NEED_size_t
12#define __NEED_locale_t
13
14#include <bits/alltypes.h>
15
16ssize_t strfmon(char *__restrict, size_t, const char *__restrict, ...);
17ssize_t strfmon_l(char *__restrict, size_t, locale_t, const char *__restrict, ...);
18
19#ifdef __cplusplus
20}
21#endif
22
23#endif
lib/libc/include/wasm32-wasi/mqueue.h deleted-41
......@@ -1,41 +0,0 @@
1#ifndef _MQUEUE_H
2#define _MQUEUE_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_size_t
10#define __NEED_ssize_t
11#define __NEED_pthread_attr_t
12#define __NEED_time_t
13#define __NEED_struct_timespec
14#include <bits/alltypes.h>
15
16typedef int mqd_t;
17struct mq_attr {
18 long mq_flags, mq_maxmsg, mq_msgsize, mq_curmsgs, __unused[4];
19};
20struct sigevent;
21
22int mq_close(mqd_t);
23int mq_getattr(mqd_t, struct mq_attr *);
24int mq_notify(mqd_t, const struct sigevent *);
25mqd_t mq_open(const char *, int, ...);
26ssize_t mq_receive(mqd_t, char *, size_t, unsigned *);
27int mq_send(mqd_t, const char *, size_t, unsigned);
28int mq_setattr(mqd_t, const struct mq_attr *__restrict, struct mq_attr *__restrict);
29ssize_t mq_timedreceive(mqd_t, char *__restrict, size_t, unsigned *__restrict, const struct timespec *__restrict);
30int mq_timedsend(mqd_t, const char *, size_t, unsigned, const struct timespec *);
31int mq_unlink(const char *);
32
33#if _REDIR_TIME64
34__REDIR(mq_timedreceive, __mq_timedreceive_time64);
35__REDIR(mq_timedsend, __mq_timedsend_time64);
36#endif
37
38#ifdef __cplusplus
39}
40#endif
41#endif
lib/libc/include/wasm32-wasi/netinet/icmp6.h deleted-305
......@@ -1,305 +0,0 @@
1#ifndef _NETINET_ICMP6_H
2#define _NETINET_ICMP6_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <string.h>
10#include <sys/types.h>
11#include <netinet/in.h>
12
13#define ICMP6_FILTER 1
14
15#define ICMP6_FILTER_BLOCK 1
16#define ICMP6_FILTER_PASS 2
17#define ICMP6_FILTER_BLOCKOTHERS 3
18#define ICMP6_FILTER_PASSONLY 4
19
20struct icmp6_filter {
21 uint32_t icmp6_filt[8];
22};
23
24struct icmp6_hdr {
25 uint8_t icmp6_type;
26 uint8_t icmp6_code;
27 uint16_t icmp6_cksum;
28 union {
29 uint32_t icmp6_un_data32[1];
30 uint16_t icmp6_un_data16[2];
31 uint8_t icmp6_un_data8[4];
32 } icmp6_dataun;
33};
34
35#define icmp6_data32 icmp6_dataun.icmp6_un_data32
36#define icmp6_data16 icmp6_dataun.icmp6_un_data16
37#define icmp6_data8 icmp6_dataun.icmp6_un_data8
38#define icmp6_pptr icmp6_data32[0]
39#define icmp6_mtu icmp6_data32[0]
40#define icmp6_id icmp6_data16[0]
41#define icmp6_seq icmp6_data16[1]
42#define icmp6_maxdelay icmp6_data16[0]
43
44#define ICMP6_DST_UNREACH 1
45#define ICMP6_PACKET_TOO_BIG 2
46#define ICMP6_TIME_EXCEEDED 3
47#define ICMP6_PARAM_PROB 4
48
49#define ICMP6_INFOMSG_MASK 0x80
50
51#define ICMP6_ECHO_REQUEST 128
52#define ICMP6_ECHO_REPLY 129
53#define MLD_LISTENER_QUERY 130
54#define MLD_LISTENER_REPORT 131
55#define MLD_LISTENER_REDUCTION 132
56
57#define ICMP6_DST_UNREACH_NOROUTE 0
58#define ICMP6_DST_UNREACH_ADMIN 1
59#define ICMP6_DST_UNREACH_BEYONDSCOPE 2
60#define ICMP6_DST_UNREACH_ADDR 3
61#define ICMP6_DST_UNREACH_NOPORT 4
62
63#define ICMP6_TIME_EXCEED_TRANSIT 0
64#define ICMP6_TIME_EXCEED_REASSEMBLY 1
65
66#define ICMP6_PARAMPROB_HEADER 0
67#define ICMP6_PARAMPROB_NEXTHEADER 1
68#define ICMP6_PARAMPROB_OPTION 2
69
70#define ICMP6_FILTER_WILLPASS(type, filterp) \
71 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
72
73#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
74 ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
75
76#define ICMP6_FILTER_SETPASS(type, filterp) \
77 ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
78
79#define ICMP6_FILTER_SETBLOCK(type, filterp) \
80 ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))))
81
82#define ICMP6_FILTER_SETPASSALL(filterp) \
83 memset (filterp, 0, sizeof (struct icmp6_filter));
84
85#define ICMP6_FILTER_SETBLOCKALL(filterp) \
86 memset (filterp, 0xFF, sizeof (struct icmp6_filter));
87
88#define ND_ROUTER_SOLICIT 133
89#define ND_ROUTER_ADVERT 134
90#define ND_NEIGHBOR_SOLICIT 135
91#define ND_NEIGHBOR_ADVERT 136
92#define ND_REDIRECT 137
93
94struct nd_router_solicit {
95 struct icmp6_hdr nd_rs_hdr;
96};
97
98#define nd_rs_type nd_rs_hdr.icmp6_type
99#define nd_rs_code nd_rs_hdr.icmp6_code
100#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
101#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
102
103struct nd_router_advert {
104 struct icmp6_hdr nd_ra_hdr;
105 uint32_t nd_ra_reachable;
106 uint32_t nd_ra_retransmit;
107};
108
109#define nd_ra_type nd_ra_hdr.icmp6_type
110#define nd_ra_code nd_ra_hdr.icmp6_code
111#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
112#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
113#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
114#define ND_RA_FLAG_MANAGED 0x80
115#define ND_RA_FLAG_OTHER 0x40
116#define ND_RA_FLAG_HOME_AGENT 0x20
117#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
118
119struct nd_neighbor_solicit {
120 struct icmp6_hdr nd_ns_hdr;
121 struct in6_addr nd_ns_target;
122};
123
124#define nd_ns_type nd_ns_hdr.icmp6_type
125#define nd_ns_code nd_ns_hdr.icmp6_code
126#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
127#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
128
129struct nd_neighbor_advert {
130 struct icmp6_hdr nd_na_hdr;
131 struct in6_addr nd_na_target;
132};
133
134#define nd_na_type nd_na_hdr.icmp6_type
135#define nd_na_code nd_na_hdr.icmp6_code
136#define nd_na_cksum nd_na_hdr.icmp6_cksum
137#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
138#if __BYTE_ORDER == __BIG_ENDIAN
139#define ND_NA_FLAG_ROUTER 0x80000000
140#define ND_NA_FLAG_SOLICITED 0x40000000
141#define ND_NA_FLAG_OVERRIDE 0x20000000
142#else
143#define ND_NA_FLAG_ROUTER 0x00000080
144#define ND_NA_FLAG_SOLICITED 0x00000040
145#define ND_NA_FLAG_OVERRIDE 0x00000020
146#endif
147
148struct nd_redirect {
149 struct icmp6_hdr nd_rd_hdr;
150 struct in6_addr nd_rd_target;
151 struct in6_addr nd_rd_dst;
152};
153
154#define nd_rd_type nd_rd_hdr.icmp6_type
155#define nd_rd_code nd_rd_hdr.icmp6_code
156#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
157#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
158
159struct nd_opt_hdr {
160 uint8_t nd_opt_type;
161 uint8_t nd_opt_len;
162};
163
164#define ND_OPT_SOURCE_LINKADDR 1
165#define ND_OPT_TARGET_LINKADDR 2
166#define ND_OPT_PREFIX_INFORMATION 3
167#define ND_OPT_REDIRECTED_HEADER 4
168#define ND_OPT_MTU 5
169#define ND_OPT_RTR_ADV_INTERVAL 7
170#define ND_OPT_HOME_AGENT_INFO 8
171
172struct nd_opt_prefix_info {
173 uint8_t nd_opt_pi_type;
174 uint8_t nd_opt_pi_len;
175 uint8_t nd_opt_pi_prefix_len;
176 uint8_t nd_opt_pi_flags_reserved;
177 uint32_t nd_opt_pi_valid_time;
178 uint32_t nd_opt_pi_preferred_time;
179 uint32_t nd_opt_pi_reserved2;
180 struct in6_addr nd_opt_pi_prefix;
181};
182
183#define ND_OPT_PI_FLAG_ONLINK 0x80
184#define ND_OPT_PI_FLAG_AUTO 0x40
185#define ND_OPT_PI_FLAG_RADDR 0x20
186
187struct nd_opt_rd_hdr {
188 uint8_t nd_opt_rh_type;
189 uint8_t nd_opt_rh_len;
190 uint16_t nd_opt_rh_reserved1;
191 uint32_t nd_opt_rh_reserved2;
192};
193
194struct nd_opt_mtu {
195 uint8_t nd_opt_mtu_type;
196 uint8_t nd_opt_mtu_len;
197 uint16_t nd_opt_mtu_reserved;
198 uint32_t nd_opt_mtu_mtu;
199};
200
201struct mld_hdr {
202 struct icmp6_hdr mld_icmp6_hdr;
203 struct in6_addr mld_addr;
204};
205
206#define mld_type mld_icmp6_hdr.icmp6_type
207#define mld_code mld_icmp6_hdr.icmp6_code
208#define mld_cksum mld_icmp6_hdr.icmp6_cksum
209#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
210#define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
211
212#define ICMP6_ROUTER_RENUMBERING 138
213
214struct icmp6_router_renum {
215 struct icmp6_hdr rr_hdr;
216 uint8_t rr_segnum;
217 uint8_t rr_flags;
218 uint16_t rr_maxdelay;
219 uint32_t rr_reserved;
220};
221
222#define rr_type rr_hdr.icmp6_type
223#define rr_code rr_hdr.icmp6_code
224#define rr_cksum rr_hdr.icmp6_cksum
225#define rr_seqnum rr_hdr.icmp6_data32[0]
226
227#define ICMP6_RR_FLAGS_TEST 0x80
228#define ICMP6_RR_FLAGS_REQRESULT 0x40
229#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
230#define ICMP6_RR_FLAGS_SPECSITE 0x10
231#define ICMP6_RR_FLAGS_PREVDONE 0x08
232
233struct rr_pco_match {
234 uint8_t rpm_code;
235 uint8_t rpm_len;
236 uint8_t rpm_ordinal;
237 uint8_t rpm_matchlen;
238 uint8_t rpm_minlen;
239 uint8_t rpm_maxlen;
240 uint16_t rpm_reserved;
241 struct in6_addr rpm_prefix;
242};
243
244#define RPM_PCO_ADD 1
245#define RPM_PCO_CHANGE 2
246#define RPM_PCO_SETGLOBAL 3
247
248struct rr_pco_use {
249 uint8_t rpu_uselen;
250 uint8_t rpu_keeplen;
251 uint8_t rpu_ramask;
252 uint8_t rpu_raflags;
253 uint32_t rpu_vltime;
254 uint32_t rpu_pltime;
255 uint32_t rpu_flags;
256 struct in6_addr rpu_prefix;
257};
258
259#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
260#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10
261
262#if __BYTE_ORDER == __BIG_ENDIAN
263#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
264#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
265#else
266#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
267#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
268#endif
269
270struct rr_result {
271 uint16_t rrr_flags;
272 uint8_t rrr_ordinal;
273 uint8_t rrr_matchedlen;
274 uint32_t rrr_ifid;
275 struct in6_addr rrr_prefix;
276};
277
278#if __BYTE_ORDER == __BIG_ENDIAN
279#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
280#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
281#else
282#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
283#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
284#endif
285
286struct nd_opt_adv_interval {
287 uint8_t nd_opt_adv_interval_type;
288 uint8_t nd_opt_adv_interval_len;
289 uint16_t nd_opt_adv_interval_reserved;
290 uint32_t nd_opt_adv_interval_ival;
291};
292
293struct nd_opt_home_agent_info {
294 uint8_t nd_opt_home_agent_info_type;
295 uint8_t nd_opt_home_agent_info_len;
296 uint16_t nd_opt_home_agent_info_reserved;
297 uint16_t nd_opt_home_agent_info_preference;
298 uint16_t nd_opt_home_agent_info_lifetime;
299};
300
301#ifdef __cplusplus
302}
303#endif
304
305#endif
lib/libc/include/wasm32-wasi/netinet/igmp.h deleted-45
......@@ -1,45 +0,0 @@
1#ifndef _NETINET_IGMP_H
2#define _NETINET_IGMP_H
3
4#include <stdint.h>
5#include <netinet/in.h>
6
7struct igmp {
8 uint8_t igmp_type;
9 uint8_t igmp_code;
10 uint16_t igmp_cksum;
11 struct in_addr igmp_group;
12};
13
14#define IGMP_MINLEN 8
15
16#define IGMP_MEMBERSHIP_QUERY 0x11
17#define IGMP_V1_MEMBERSHIP_REPORT 0x12
18#define IGMP_V2_MEMBERSHIP_REPORT 0x16
19#define IGMP_V2_LEAVE_GROUP 0x17
20
21#define IGMP_DVMRP 0x13
22#define IGMP_PIM 0x14
23#define IGMP_TRACE 0x15
24
25#define IGMP_MTRACE_RESP 0x1e
26#define IGMP_MTRACE 0x1f
27
28#define IGMP_MAX_HOST_REPORT_DELAY 10
29#define IGMP_TIMER_SCALE 10
30
31#define IGMP_DELAYING_MEMBER 1
32#define IGMP_IDLE_MEMBER 2
33#define IGMP_LAZY_MEMBER 3
34#define IGMP_SLEEPING_MEMBER 4
35#define IGMP_AWAKENING_MEMBER 5
36
37#define IGMP_v1_ROUTER 1
38#define IGMP_v2_ROUTER 2
39
40#define IGMP_HOST_MEMBERSHIP_QUERY IGMP_MEMBERSHIP_QUERY
41#define IGMP_HOST_MEMBERSHIP_REPORT IGMP_V1_MEMBERSHIP_REPORT
42#define IGMP_HOST_NEW_MEMBERSHIP_REPORT IGMP_V2_MEMBERSHIP_REPORT
43#define IGMP_HOST_LEAVE_MESSAGE IGMP_V2_LEAVE_GROUP
44
45#endif
lib/libc/include/wasm32-wasi/netinet/in.h deleted-432
......@@ -1,432 +0,0 @@
1#ifndef _NETINET_IN_H
2#define _NETINET_IN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <inttypes.h>
10#include <sys/socket.h>
11#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
12#else
13#include <__header_netinet_in.h>
14#endif
15
16typedef uint16_t in_port_t;
17typedef uint32_t in_addr_t;
18#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
19struct in_addr { in_addr_t s_addr; };
20#endif
21
22#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
23struct sockaddr_in {
24 sa_family_t sin_family;
25 in_port_t sin_port;
26 struct in_addr sin_addr;
27 uint8_t sin_zero[8];
28};
29#endif
30
31#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
32struct in6_addr {
33 union {
34 uint8_t __s6_addr[16];
35 uint16_t __s6_addr16[8];
36 uint32_t __s6_addr32[4];
37 } __in6_union;
38};
39#define s6_addr __in6_union.__s6_addr
40#define s6_addr16 __in6_union.__s6_addr16
41#define s6_addr32 __in6_union.__s6_addr32
42#endif
43
44#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
45struct sockaddr_in6 {
46 sa_family_t sin6_family;
47 in_port_t sin6_port;
48 uint32_t sin6_flowinfo;
49 struct in6_addr sin6_addr;
50 uint32_t sin6_scope_id;
51};
52#endif
53
54struct ipv6_mreq {
55 struct in6_addr ipv6mr_multiaddr;
56 unsigned ipv6mr_interface;
57};
58
59#define INADDR_ANY ((in_addr_t) 0x00000000)
60#define INADDR_BROADCAST ((in_addr_t) 0xffffffff)
61#define INADDR_NONE ((in_addr_t) 0xffffffff)
62#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001)
63
64#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000)
65#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001)
66#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002)
67#define INADDR_ALLSNOOPERS_GROUP ((in_addr_t) 0xe000006a)
68#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff)
69
70#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
71#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
72#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
73#endif
74
75extern const struct in6_addr in6addr_any, in6addr_loopback;
76
77#define INET_ADDRSTRLEN 16
78#define INET6_ADDRSTRLEN 46
79
80uint32_t htonl(uint32_t);
81uint16_t htons(uint16_t);
82uint32_t ntohl(uint32_t);
83uint16_t ntohs(uint16_t);
84
85#define IPPORT_RESERVED 1024
86
87#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
88#define IPPROTO_IP 0
89#define IPPROTO_HOPOPTS 0
90#define IPPROTO_ICMP 1
91#define IPPROTO_IGMP 2
92#define IPPROTO_IPIP 4
93#define IPPROTO_TCP 6
94#define IPPROTO_EGP 8
95#define IPPROTO_PUP 12
96#define IPPROTO_UDP 17
97#define IPPROTO_IDP 22
98#define IPPROTO_TP 29
99#define IPPROTO_DCCP 33
100#define IPPROTO_IPV6 41
101#define IPPROTO_ROUTING 43
102#define IPPROTO_FRAGMENT 44
103#define IPPROTO_RSVP 46
104#define IPPROTO_GRE 47
105#define IPPROTO_ESP 50
106#define IPPROTO_AH 51
107#define IPPROTO_ICMPV6 58
108#define IPPROTO_NONE 59
109#define IPPROTO_DSTOPTS 60
110#define IPPROTO_MTP 92
111#define IPPROTO_BEETPH 94
112#define IPPROTO_ENCAP 98
113#define IPPROTO_PIM 103
114#define IPPROTO_COMP 108
115#define IPPROTO_SCTP 132
116#define IPPROTO_MH 135
117#define IPPROTO_UDPLITE 136
118#define IPPROTO_MPLS 137
119#define IPPROTO_ETHERNET 143
120#define IPPROTO_RAW 255
121#define IPPROTO_MPTCP 262
122#define IPPROTO_MAX 263
123#endif
124
125#define IN6_IS_ADDR_UNSPECIFIED(a) \
126 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
127 ((uint32_t *) (a))[2] == 0 && ((uint32_t *) (a))[3] == 0)
128
129#define IN6_IS_ADDR_LOOPBACK(a) \
130 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
131 ((uint32_t *) (a))[2] == 0 && \
132 ((uint8_t *) (a))[12] == 0 && ((uint8_t *) (a))[13] == 0 && \
133 ((uint8_t *) (a))[14] == 0 && ((uint8_t *) (a))[15] == 1 )
134
135#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
136
137#define IN6_IS_ADDR_LINKLOCAL(a) \
138 ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0x80)
139
140#define IN6_IS_ADDR_SITELOCAL(a) \
141 ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0xc0)
142
143#define IN6_IS_ADDR_V4MAPPED(a) \
144 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
145 ((uint8_t *) (a))[8] == 0 && ((uint8_t *) (a))[9] == 0 && \
146 ((uint8_t *) (a))[10] == 0xff && ((uint8_t *) (a))[11] == 0xff)
147
148#define IN6_IS_ADDR_V4COMPAT(a) \
149 (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \
150 ((uint32_t *) (a))[2] == 0 && ((uint8_t *) (a))[15] > 1)
151
152#define IN6_IS_ADDR_MC_NODELOCAL(a) \
153 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x1))
154
155#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
156 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x2))
157
158#define IN6_IS_ADDR_MC_SITELOCAL(a) \
159 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x5))
160
161#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
162 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0x8))
163
164#define IN6_IS_ADDR_MC_GLOBAL(a) \
165 (IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *) (a))[1] & 0xf) == 0xe))
166
167#define __ARE_4_EQUAL(a,b) \
168 (!( (0[a]-0[b]) | (1[a]-1[b]) | (2[a]-2[b]) | (3[a]-3[b]) ))
169#define IN6_ARE_ADDR_EQUAL(a,b) \
170 __ARE_4_EQUAL((const uint32_t *)(a), (const uint32_t *)(b))
171
172#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0)
173#define IN_CLASSA_NET 0xff000000
174#define IN_CLASSA_NSHIFT 24
175#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
176#define IN_CLASSA_MAX 128
177#define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
178#define IN_CLASSB_NET 0xffff0000
179#define IN_CLASSB_NSHIFT 16
180#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
181#define IN_CLASSB_MAX 65536
182#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
183#define IN_CLASSC_NET 0xffffff00
184#define IN_CLASSC_NSHIFT 8
185#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
186#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
187#define IN_MULTICAST(a) IN_CLASSD(a)
188#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
189#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
190
191#define IN_LOOPBACKNET 127
192
193
194#define IP_TOS 1
195#define IP_TTL 2
196#define IP_HDRINCL 3
197#define IP_OPTIONS 4
198#define IP_ROUTER_ALERT 5
199#define IP_RECVOPTS 6
200#define IP_RETOPTS 7
201#define IP_PKTINFO 8
202#define IP_PKTOPTIONS 9
203#define IP_PMTUDISC 10
204#define IP_MTU_DISCOVER 10
205#define IP_RECVERR 11
206#define IP_RECVTTL 12
207#define IP_RECVTOS 13
208#define IP_MTU 14
209#define IP_FREEBIND 15
210#define IP_IPSEC_POLICY 16
211#define IP_XFRM_POLICY 17
212#define IP_PASSSEC 18
213#define IP_TRANSPARENT 19
214#define IP_ORIGDSTADDR 20
215#define IP_RECVORIGDSTADDR IP_ORIGDSTADDR
216#define IP_MINTTL 21
217#define IP_NODEFRAG 22
218#define IP_CHECKSUM 23
219#define IP_BIND_ADDRESS_NO_PORT 24
220#define IP_RECVFRAGSIZE 25
221#define IP_RECVERR_RFC4884 26
222#define IP_MULTICAST_IF 32
223#define IP_MULTICAST_TTL 33
224#define IP_MULTICAST_LOOP 34
225#define IP_ADD_MEMBERSHIP 35
226#define IP_DROP_MEMBERSHIP 36
227#define IP_UNBLOCK_SOURCE 37
228#define IP_BLOCK_SOURCE 38
229#define IP_ADD_SOURCE_MEMBERSHIP 39
230#define IP_DROP_SOURCE_MEMBERSHIP 40
231#define IP_MSFILTER 41
232#define IP_MULTICAST_ALL 49
233#define IP_UNICAST_IF 50
234
235#define IP_RECVRETOPTS IP_RETOPTS
236
237#define IP_PMTUDISC_DONT 0
238#define IP_PMTUDISC_WANT 1
239#define IP_PMTUDISC_DO 2
240#define IP_PMTUDISC_PROBE 3
241#define IP_PMTUDISC_INTERFACE 4
242#define IP_PMTUDISC_OMIT 5
243
244#define IP_DEFAULT_MULTICAST_TTL 1
245#define IP_DEFAULT_MULTICAST_LOOP 1
246#define IP_MAX_MEMBERSHIPS 20
247
248struct ip_opts {
249 struct in_addr ip_dst;
250 char ip_opts[40];
251};
252
253#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
254
255#define MCAST_JOIN_GROUP 42
256#define MCAST_BLOCK_SOURCE 43
257#define MCAST_UNBLOCK_SOURCE 44
258#define MCAST_LEAVE_GROUP 45
259#define MCAST_JOIN_SOURCE_GROUP 46
260#define MCAST_LEAVE_SOURCE_GROUP 47
261#define MCAST_MSFILTER 48
262
263#define MCAST_EXCLUDE 0
264#define MCAST_INCLUDE 1
265
266struct ip_mreq {
267 struct in_addr imr_multiaddr;
268 struct in_addr imr_interface;
269};
270
271struct ip_mreqn {
272 struct in_addr imr_multiaddr;
273 struct in_addr imr_address;
274 int imr_ifindex;
275};
276
277struct ip_mreq_source {
278 struct in_addr imr_multiaddr;
279 struct in_addr imr_interface;
280 struct in_addr imr_sourceaddr;
281};
282
283struct ip_msfilter {
284 struct in_addr imsf_multiaddr;
285 struct in_addr imsf_interface;
286 uint32_t imsf_fmode;
287 uint32_t imsf_numsrc;
288 struct in_addr imsf_slist[1];
289};
290#define IP_MSFILTER_SIZE(numsrc) \
291 (sizeof(struct ip_msfilter) - sizeof(struct in_addr) \
292 + (numsrc) * sizeof(struct in_addr))
293
294struct group_req {
295 uint32_t gr_interface;
296 struct sockaddr_storage gr_group;
297};
298
299struct group_source_req {
300 uint32_t gsr_interface;
301 struct sockaddr_storage gsr_group;
302 struct sockaddr_storage gsr_source;
303};
304
305struct group_filter {
306 uint32_t gf_interface;
307 struct sockaddr_storage gf_group;
308 uint32_t gf_fmode;
309 uint32_t gf_numsrc;
310 struct sockaddr_storage gf_slist[1];
311};
312#define GROUP_FILTER_SIZE(numsrc) \
313 (sizeof(struct group_filter) - sizeof(struct sockaddr_storage) \
314 + (numsrc) * sizeof(struct sockaddr_storage))
315
316struct in_pktinfo {
317 int ipi_ifindex;
318 struct in_addr ipi_spec_dst;
319 struct in_addr ipi_addr;
320};
321
322struct in6_pktinfo {
323 struct in6_addr ipi6_addr;
324 unsigned ipi6_ifindex;
325};
326
327struct ip6_mtuinfo {
328 struct sockaddr_in6 ip6m_addr;
329 uint32_t ip6m_mtu;
330};
331#endif
332
333#define IPV6_ADDRFORM 1
334#define IPV6_2292PKTINFO 2
335#define IPV6_2292HOPOPTS 3
336#define IPV6_2292DSTOPTS 4
337#define IPV6_2292RTHDR 5
338#define IPV6_2292PKTOPTIONS 6
339#define IPV6_CHECKSUM 7
340#define IPV6_2292HOPLIMIT 8
341#define IPV6_NEXTHOP 9
342#define IPV6_AUTHHDR 10
343#define IPV6_UNICAST_HOPS 16
344#define IPV6_MULTICAST_IF 17
345#define IPV6_MULTICAST_HOPS 18
346#define IPV6_MULTICAST_LOOP 19
347#define IPV6_JOIN_GROUP 20
348#define IPV6_LEAVE_GROUP 21
349#define IPV6_ROUTER_ALERT 22
350#define IPV6_MTU_DISCOVER 23
351#define IPV6_MTU 24
352#define IPV6_RECVERR 25
353#define IPV6_V6ONLY 26
354#define IPV6_JOIN_ANYCAST 27
355#define IPV6_LEAVE_ANYCAST 28
356#define IPV6_MULTICAST_ALL 29
357#define IPV6_ROUTER_ALERT_ISOLATE 30
358#define IPV6_IPSEC_POLICY 34
359#define IPV6_XFRM_POLICY 35
360#define IPV6_HDRINCL 36
361
362#define IPV6_RECVPKTINFO 49
363#define IPV6_PKTINFO 50
364#define IPV6_RECVHOPLIMIT 51
365#define IPV6_HOPLIMIT 52
366#define IPV6_RECVHOPOPTS 53
367#define IPV6_HOPOPTS 54
368#define IPV6_RTHDRDSTOPTS 55
369#define IPV6_RECVRTHDR 56
370#define IPV6_RTHDR 57
371#define IPV6_RECVDSTOPTS 58
372#define IPV6_DSTOPTS 59
373#define IPV6_RECVPATHMTU 60
374#define IPV6_PATHMTU 61
375#define IPV6_DONTFRAG 62
376#define IPV6_RECVTCLASS 66
377#define IPV6_TCLASS 67
378#define IPV6_AUTOFLOWLABEL 70
379#define IPV6_ADDR_PREFERENCES 72
380#define IPV6_MINHOPCOUNT 73
381#define IPV6_ORIGDSTADDR 74
382#define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR
383#define IPV6_TRANSPARENT 75
384#define IPV6_UNICAST_IF 76
385#define IPV6_RECVFRAGSIZE 77
386#define IPV6_FREEBIND 78
387
388#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
389#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
390#define IPV6_RXHOPOPTS IPV6_HOPOPTS
391#define IPV6_RXDSTOPTS IPV6_DSTOPTS
392
393#define IPV6_PMTUDISC_DONT 0
394#define IPV6_PMTUDISC_WANT 1
395#define IPV6_PMTUDISC_DO 2
396#define IPV6_PMTUDISC_PROBE 3
397#define IPV6_PMTUDISC_INTERFACE 4
398#define IPV6_PMTUDISC_OMIT 5
399
400#define IPV6_PREFER_SRC_TMP 0x0001
401#define IPV6_PREFER_SRC_PUBLIC 0x0002
402#define IPV6_PREFER_SRC_PUBTMP_DEFAULT 0x0100
403#define IPV6_PREFER_SRC_COA 0x0004
404#define IPV6_PREFER_SRC_HOME 0x0400
405#define IPV6_PREFER_SRC_CGA 0x0008
406#define IPV6_PREFER_SRC_NONCGA 0x0800
407
408#define IPV6_RTHDR_LOOSE 0
409#define IPV6_RTHDR_STRICT 1
410
411#define IPV6_RTHDR_TYPE_0 0
412
413#define __UAPI_DEF_IN_ADDR 0
414#define __UAPI_DEF_IN_IPPROTO 0
415#define __UAPI_DEF_IN_PKTINFO 0
416#define __UAPI_DEF_IP_MREQ 0
417#define __UAPI_DEF_SOCKADDR_IN 0
418#define __UAPI_DEF_IN_CLASS 0
419#define __UAPI_DEF_IN6_ADDR 0
420#define __UAPI_DEF_IN6_ADDR_ALT 0
421#define __UAPI_DEF_SOCKADDR_IN6 0
422#define __UAPI_DEF_IPV6_MREQ 0
423#define __UAPI_DEF_IPPROTO_V6 0
424#define __UAPI_DEF_IPV6_OPTIONS 0
425#define __UAPI_DEF_IN6_PKTINFO 0
426#define __UAPI_DEF_IP6_MTUINFO 0
427
428#ifdef __cplusplus
429}
430#endif
431
432#endif
lib/libc/include/wasm32-wasi/netinet/in_systm.h deleted-9
......@@ -1,9 +0,0 @@
1#ifndef _NETINET_IN_SYSTM_H
2#define _NETINET_IN_SYSTM_H
3
4#include <stdint.h>
5
6typedef uint16_t n_short;
7typedef uint32_t n_long, n_time;
8
9#endif
lib/libc/include/wasm32-wasi/netinet/ip.h deleted-199
......@@ -1,199 +0,0 @@
1#ifndef _NETINET_IP_H
2#define _NETINET_IP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <netinet/in.h>
10
11struct timestamp {
12 uint8_t len;
13 uint8_t ptr;
14#if __BYTE_ORDER == __LITTLE_ENDIAN
15 unsigned int flags:4;
16 unsigned int overflow:4;
17#else
18 unsigned int overflow:4;
19 unsigned int flags:4;
20#endif
21 uint32_t data[9];
22 };
23
24struct iphdr {
25#if __BYTE_ORDER == __LITTLE_ENDIAN
26 unsigned int ihl:4;
27 unsigned int version:4;
28#else
29 unsigned int version:4;
30 unsigned int ihl:4;
31#endif
32 uint8_t tos;
33 uint16_t tot_len;
34 uint16_t id;
35 uint16_t frag_off;
36 uint8_t ttl;
37 uint8_t protocol;
38 uint16_t check;
39 uint32_t saddr;
40 uint32_t daddr;
41};
42
43struct ip {
44#if __BYTE_ORDER == __LITTLE_ENDIAN
45 unsigned int ip_hl:4;
46 unsigned int ip_v:4;
47#else
48 unsigned int ip_v:4;
49 unsigned int ip_hl:4;
50#endif
51 uint8_t ip_tos;
52 uint16_t ip_len;
53 uint16_t ip_id;
54 uint16_t ip_off;
55 uint8_t ip_ttl;
56 uint8_t ip_p;
57 uint16_t ip_sum;
58 struct in_addr ip_src, ip_dst;
59};
60
61#define IP_RF 0x8000
62#define IP_DF 0x4000
63#define IP_MF 0x2000
64#define IP_OFFMASK 0x1fff
65
66struct ip_timestamp {
67 uint8_t ipt_code;
68 uint8_t ipt_len;
69 uint8_t ipt_ptr;
70#if __BYTE_ORDER == __LITTLE_ENDIAN
71 unsigned int ipt_flg:4;
72 unsigned int ipt_oflw:4;
73#else
74 unsigned int ipt_oflw:4;
75 unsigned int ipt_flg:4;
76#endif
77 uint32_t data[9];
78};
79
80#define IPVERSION 4
81#define IP_MAXPACKET 65535
82
83#define IPTOS_ECN_MASK 0x03
84#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
85#define IPTOS_ECN_NOT_ECT 0x00
86#define IPTOS_ECN_ECT1 0x01
87#define IPTOS_ECN_ECT0 0x02
88#define IPTOS_ECN_CE 0x03
89
90#define IPTOS_DSCP_MASK 0xfc
91#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
92#define IPTOS_DSCP_AF11 0x28
93#define IPTOS_DSCP_AF12 0x30
94#define IPTOS_DSCP_AF13 0x38
95#define IPTOS_DSCP_AF21 0x48
96#define IPTOS_DSCP_AF22 0x50
97#define IPTOS_DSCP_AF23 0x58
98#define IPTOS_DSCP_AF31 0x68
99#define IPTOS_DSCP_AF32 0x70
100#define IPTOS_DSCP_AF33 0x78
101#define IPTOS_DSCP_AF41 0x88
102#define IPTOS_DSCP_AF42 0x90
103#define IPTOS_DSCP_AF43 0x98
104#define IPTOS_DSCP_EF 0xb8
105
106#define IPTOS_CLASS_MASK 0xe0
107#define IPTOS_CLASS(x) ((x) & IPTOS_CLASS_MASK)
108#define IPTOS_CLASS_CS0 0x00
109#define IPTOS_CLASS_CS1 0x20
110#define IPTOS_CLASS_CS2 0x40
111#define IPTOS_CLASS_CS3 0x60
112#define IPTOS_CLASS_CS4 0x80
113#define IPTOS_CLASS_CS5 0xa0
114#define IPTOS_CLASS_CS6 0xc0
115#define IPTOS_CLASS_CS7 0xe0
116#define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0
117
118#define IPTOS_TOS_MASK 0x1E
119#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
120#define IPTOS_LOWDELAY 0x10
121#define IPTOS_THROUGHPUT 0x08
122#define IPTOS_RELIABILITY 0x04
123#define IPTOS_LOWCOST 0x02
124#define IPTOS_MINCOST IPTOS_LOWCOST
125
126#define IPTOS_PREC_MASK 0xe0
127#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
128#define IPTOS_PREC_NETCONTROL 0xe0
129#define IPTOS_PREC_INTERNETCONTROL 0xc0
130#define IPTOS_PREC_CRITIC_ECP 0xa0
131#define IPTOS_PREC_FLASHOVERRIDE 0x80
132#define IPTOS_PREC_FLASH 0x60
133#define IPTOS_PREC_IMMEDIATE 0x40
134#define IPTOS_PREC_PRIORITY 0x20
135#define IPTOS_PREC_ROUTINE 0x00
136
137#define IPOPT_COPY 0x80
138#define IPOPT_CLASS_MASK 0x60
139#define IPOPT_NUMBER_MASK 0x1f
140
141#define IPOPT_COPIED(o) ((o) & IPOPT_COPY)
142#define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK)
143#define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK)
144
145#define IPOPT_CONTROL 0x00
146#define IPOPT_RESERVED1 0x20
147#define IPOPT_DEBMEAS 0x40
148#define IPOPT_MEASUREMENT IPOPT_DEBMEAS
149#define IPOPT_RESERVED2 0x60
150
151#define IPOPT_EOL 0
152#define IPOPT_END IPOPT_EOL
153#define IPOPT_NOP 1
154#define IPOPT_NOOP IPOPT_NOP
155
156#define IPOPT_RR 7
157#define IPOPT_TS 68
158#define IPOPT_TIMESTAMP IPOPT_TS
159#define IPOPT_SECURITY 130
160#define IPOPT_SEC IPOPT_SECURITY
161#define IPOPT_LSRR 131
162#define IPOPT_SATID 136
163#define IPOPT_SID IPOPT_SATID
164#define IPOPT_SSRR 137
165#define IPOPT_RA 148
166
167#define IPOPT_OPTVAL 0
168#define IPOPT_OLEN 1
169#define IPOPT_OFFSET 2
170#define IPOPT_MINOFF 4
171
172#define MAX_IPOPTLEN 40
173
174#define IPOPT_TS_TSONLY 0
175#define IPOPT_TS_TSANDADDR 1
176#define IPOPT_TS_PRESPEC 3
177
178#define IPOPT_SECUR_UNCLASS 0x0000
179#define IPOPT_SECUR_CONFID 0xf135
180#define IPOPT_SECUR_EFTO 0x789a
181#define IPOPT_SECUR_MMMM 0xbc4d
182#define IPOPT_SECUR_RESTR 0xaf13
183#define IPOPT_SECUR_SECRET 0xd788
184#define IPOPT_SECUR_TOPSECRET 0x6bc5
185
186#define MAXTTL 255
187#define IPDEFTTL 64
188#define IPFRAGTTL 60
189#define IPTTLDEC 1
190
191#define IP_MSS 576
192
193#define __UAPI_DEF_IPHDR 0
194
195#ifdef __cplusplus
196}
197#endif
198
199#endif
lib/libc/include/wasm32-wasi/netinet/ip6.h deleted-141
......@@ -1,141 +0,0 @@
1#ifndef _NETINET_IP6_H
2#define _NETINET_IP6_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <netinet/in.h>
10
11struct ip6_hdr {
12 union {
13 struct ip6_hdrctl {
14 uint32_t ip6_un1_flow;
15 uint16_t ip6_un1_plen;
16 uint8_t ip6_un1_nxt;
17 uint8_t ip6_un1_hlim;
18 } ip6_un1;
19 uint8_t ip6_un2_vfc;
20 } ip6_ctlun;
21 struct in6_addr ip6_src;
22 struct in6_addr ip6_dst;
23};
24
25#define ip6_vfc ip6_ctlun.ip6_un2_vfc
26#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
27#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
28#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
29#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
30#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
31
32struct ip6_ext {
33 uint8_t ip6e_nxt;
34 uint8_t ip6e_len;
35};
36
37struct ip6_hbh {
38 uint8_t ip6h_nxt;
39 uint8_t ip6h_len;
40};
41
42struct ip6_dest {
43 uint8_t ip6d_nxt;
44 uint8_t ip6d_len;
45};
46
47struct ip6_rthdr {
48 uint8_t ip6r_nxt;
49 uint8_t ip6r_len;
50 uint8_t ip6r_type;
51 uint8_t ip6r_segleft;
52};
53
54struct ip6_rthdr0 {
55 uint8_t ip6r0_nxt;
56 uint8_t ip6r0_len;
57 uint8_t ip6r0_type;
58 uint8_t ip6r0_segleft;
59 uint8_t ip6r0_reserved;
60 uint8_t ip6r0_slmap[3];
61 struct in6_addr ip6r0_addr[];
62};
63
64struct ip6_frag {
65 uint8_t ip6f_nxt;
66 uint8_t ip6f_reserved;
67 uint16_t ip6f_offlg;
68 uint32_t ip6f_ident;
69};
70
71#if __BYTE_ORDER == __BIG_ENDIAN
72#define IP6F_OFF_MASK 0xfff8
73#define IP6F_RESERVED_MASK 0x0006
74#define IP6F_MORE_FRAG 0x0001
75#else
76#define IP6F_OFF_MASK 0xf8ff
77#define IP6F_RESERVED_MASK 0x0600
78#define IP6F_MORE_FRAG 0x0100
79#endif
80
81struct ip6_opt {
82 uint8_t ip6o_type;
83 uint8_t ip6o_len;
84};
85
86#define IP6OPT_TYPE(o) ((o) & 0xc0)
87#define IP6OPT_TYPE_SKIP 0x00
88#define IP6OPT_TYPE_DISCARD 0x40
89#define IP6OPT_TYPE_FORCEICMP 0x80
90#define IP6OPT_TYPE_ICMP 0xc0
91#define IP6OPT_TYPE_MUTABLE 0x20
92
93#define IP6OPT_PAD1 0
94#define IP6OPT_PADN 1
95
96#define IP6OPT_JUMBO 0xc2
97#define IP6OPT_NSAP_ADDR 0xc3
98#define IP6OPT_TUNNEL_LIMIT 0x04
99#define IP6OPT_ROUTER_ALERT 0x05
100
101struct ip6_opt_jumbo {
102 uint8_t ip6oj_type;
103 uint8_t ip6oj_len;
104 uint8_t ip6oj_jumbo_len[4];
105};
106#define IP6OPT_JUMBO_LEN 6
107
108struct ip6_opt_nsap {
109 uint8_t ip6on_type;
110 uint8_t ip6on_len;
111 uint8_t ip6on_src_nsap_len;
112 uint8_t ip6on_dst_nsap_len;
113};
114
115struct ip6_opt_tunnel {
116 uint8_t ip6ot_type;
117 uint8_t ip6ot_len;
118 uint8_t ip6ot_encap_limit;
119};
120
121struct ip6_opt_router {
122 uint8_t ip6or_type;
123 uint8_t ip6or_len;
124 uint8_t ip6or_value[2];
125};
126
127#if __BYTE_ORDER == __BIG_ENDIAN
128#define IP6_ALERT_MLD 0x0000
129#define IP6_ALERT_RSVP 0x0001
130#define IP6_ALERT_AN 0x0002
131#else
132#define IP6_ALERT_MLD 0x0000
133#define IP6_ALERT_RSVP 0x0100
134#define IP6_ALERT_AN 0x0200
135#endif
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif
lib/libc/include/wasm32-wasi/netinet/ip_icmp.h deleted-193
......@@ -1,193 +0,0 @@
1#ifndef _NETINET_IP_ICMP_H
2#define _NETINET_IP_ICMP_H
3
4#include <stdint.h>
5#include <netinet/in.h>
6#include <netinet/ip.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12struct icmphdr {
13 uint8_t type;
14 uint8_t code;
15 uint16_t checksum;
16 union {
17 struct {
18 uint16_t id;
19 uint16_t sequence;
20 } echo;
21 uint32_t gateway;
22 struct {
23 uint16_t __unused;
24 uint16_t mtu;
25 } frag;
26 uint8_t reserved[4];
27 } un;
28};
29
30#define ICMP_ECHOREPLY 0
31#define ICMP_DEST_UNREACH 3
32#define ICMP_SOURCE_QUENCH 4
33#define ICMP_REDIRECT 5
34#define ICMP_ECHO 8
35#define ICMP_TIME_EXCEEDED 11
36#define ICMP_PARAMETERPROB 12
37#define ICMP_TIMESTAMP 13
38#define ICMP_TIMESTAMPREPLY 14
39#define ICMP_INFO_REQUEST 15
40#define ICMP_INFO_REPLY 16
41#define ICMP_ADDRESS 17
42#define ICMP_ADDRESSREPLY 18
43#define NR_ICMP_TYPES 18
44
45
46#define ICMP_NET_UNREACH 0
47#define ICMP_HOST_UNREACH 1
48#define ICMP_PROT_UNREACH 2
49#define ICMP_PORT_UNREACH 3
50#define ICMP_FRAG_NEEDED 4
51#define ICMP_SR_FAILED 5
52#define ICMP_NET_UNKNOWN 6
53#define ICMP_HOST_UNKNOWN 7
54#define ICMP_HOST_ISOLATED 8
55#define ICMP_NET_ANO 9
56#define ICMP_HOST_ANO 10
57#define ICMP_NET_UNR_TOS 11
58#define ICMP_HOST_UNR_TOS 12
59#define ICMP_PKT_FILTERED 13
60#define ICMP_PREC_VIOLATION 14
61#define ICMP_PREC_CUTOFF 15
62#define NR_ICMP_UNREACH 15
63
64#define ICMP_REDIR_NET 0
65#define ICMP_REDIR_HOST 1
66#define ICMP_REDIR_NETTOS 2
67#define ICMP_REDIR_HOSTTOS 3
68
69#define ICMP_EXC_TTL 0
70#define ICMP_EXC_FRAGTIME 1
71
72
73struct icmp_ra_addr {
74 uint32_t ira_addr;
75 uint32_t ira_preference;
76};
77
78struct icmp {
79 uint8_t icmp_type;
80 uint8_t icmp_code;
81 uint16_t icmp_cksum;
82 union {
83 uint8_t ih_pptr;
84 struct in_addr ih_gwaddr;
85 struct ih_idseq {
86 uint16_t icd_id;
87 uint16_t icd_seq;
88 } ih_idseq;
89 uint32_t ih_void;
90
91 struct ih_pmtu {
92 uint16_t ipm_void;
93 uint16_t ipm_nextmtu;
94 } ih_pmtu;
95
96 struct ih_rtradv {
97 uint8_t irt_num_addrs;
98 uint8_t irt_wpa;
99 uint16_t irt_lifetime;
100 } ih_rtradv;
101 } icmp_hun;
102 union {
103 struct {
104 uint32_t its_otime;
105 uint32_t its_rtime;
106 uint32_t its_ttime;
107 } id_ts;
108 struct {
109 struct ip idi_ip;
110 } id_ip;
111 struct icmp_ra_addr id_radv;
112 uint32_t id_mask;
113 uint8_t id_data[1];
114 } icmp_dun;
115};
116
117#define icmp_pptr icmp_hun.ih_pptr
118#define icmp_gwaddr icmp_hun.ih_gwaddr
119#define icmp_id icmp_hun.ih_idseq.icd_id
120#define icmp_seq icmp_hun.ih_idseq.icd_seq
121#define icmp_void icmp_hun.ih_void
122#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
123#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
124#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
125#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
126#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
127#define icmp_otime icmp_dun.id_ts.its_otime
128#define icmp_rtime icmp_dun.id_ts.its_rtime
129#define icmp_ttime icmp_dun.id_ts.its_ttime
130#define icmp_ip icmp_dun.id_ip.idi_ip
131#define icmp_radv icmp_dun.id_radv
132#define icmp_mask icmp_dun.id_mask
133#define icmp_data icmp_dun.id_data
134
135#define ICMP_MINLEN 8
136#define ICMP_TSLEN (8 + 3 * sizeof (n_time))
137#define ICMP_MASKLEN 12
138#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8)
139#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
140
141#define ICMP_UNREACH 3
142#define ICMP_SOURCEQUENCH 4
143#define ICMP_ROUTERADVERT 9
144#define ICMP_ROUTERSOLICIT 10
145#define ICMP_TIMXCEED 11
146#define ICMP_PARAMPROB 12
147#define ICMP_TSTAMP 13
148#define ICMP_TSTAMPREPLY 14
149#define ICMP_IREQ 15
150#define ICMP_IREQREPLY 16
151#define ICMP_MASKREQ 17
152#define ICMP_MASKREPLY 18
153#define ICMP_MAXTYPE 18
154
155#define ICMP_UNREACH_NET 0
156#define ICMP_UNREACH_HOST 1
157#define ICMP_UNREACH_PROTOCOL 2
158#define ICMP_UNREACH_PORT 3
159#define ICMP_UNREACH_NEEDFRAG 4
160#define ICMP_UNREACH_SRCFAIL 5
161#define ICMP_UNREACH_NET_UNKNOWN 6
162#define ICMP_UNREACH_HOST_UNKNOWN 7
163#define ICMP_UNREACH_ISOLATED 8
164#define ICMP_UNREACH_NET_PROHIB 9
165#define ICMP_UNREACH_HOST_PROHIB 10
166#define ICMP_UNREACH_TOSNET 11
167#define ICMP_UNREACH_TOSHOST 12
168#define ICMP_UNREACH_FILTER_PROHIB 13
169#define ICMP_UNREACH_HOST_PRECEDENCE 14
170#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
171
172#define ICMP_REDIRECT_NET 0
173#define ICMP_REDIRECT_HOST 1
174#define ICMP_REDIRECT_TOSNET 2
175#define ICMP_REDIRECT_TOSHOST 3
176
177#define ICMP_TIMXCEED_INTRANS 0
178#define ICMP_TIMXCEED_REASS 1
179
180#define ICMP_PARAMPROB_OPTABSENT 1
181
182#define ICMP_INFOTYPE(type) \
183 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
184 (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
185 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
186 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
187 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
188
189#ifdef __cplusplus
190}
191#endif
192
193#endif
lib/libc/include/wasm32-wasi/netinet/tcp.h deleted-294
......@@ -1,294 +0,0 @@
1#ifndef _NETINET_TCP_H
2#define _NETINET_TCP_H
3
4#include <features.h>
5
6#define TCP_NODELAY 1
7#define TCP_MAXSEG 2
8#define TCP_CORK 3
9#define TCP_KEEPIDLE 4
10#define TCP_KEEPINTVL 5
11#define TCP_KEEPCNT 6
12#define TCP_SYNCNT 7
13#define TCP_LINGER2 8
14#define TCP_DEFER_ACCEPT 9
15#define TCP_WINDOW_CLAMP 10
16#define TCP_INFO 11
17#define TCP_QUICKACK 12
18#define TCP_CONGESTION 13
19#define TCP_MD5SIG 14
20#define TCP_THIN_LINEAR_TIMEOUTS 16
21#define TCP_THIN_DUPACK 17
22#define TCP_USER_TIMEOUT 18
23#define TCP_REPAIR 19
24#define TCP_REPAIR_QUEUE 20
25#define TCP_QUEUE_SEQ 21
26#define TCP_REPAIR_OPTIONS 22
27#define TCP_FASTOPEN 23
28#define TCP_TIMESTAMP 24
29#define TCP_NOTSENT_LOWAT 25
30#define TCP_CC_INFO 26
31#define TCP_SAVE_SYN 27
32#define TCP_SAVED_SYN 28
33#define TCP_REPAIR_WINDOW 29
34#define TCP_FASTOPEN_CONNECT 30
35#define TCP_ULP 31
36#define TCP_MD5SIG_EXT 32
37#define TCP_FASTOPEN_KEY 33
38#define TCP_FASTOPEN_NO_COOKIE 34
39#define TCP_ZEROCOPY_RECEIVE 35
40#define TCP_INQ 36
41#define TCP_TX_DELAY 37
42
43#define TCP_CM_INQ TCP_INQ
44
45#define TCP_ESTABLISHED 1
46#define TCP_SYN_SENT 2
47#define TCP_SYN_RECV 3
48#define TCP_FIN_WAIT1 4
49#define TCP_FIN_WAIT2 5
50#define TCP_TIME_WAIT 6
51#define TCP_CLOSE 7
52#define TCP_CLOSE_WAIT 8
53#define TCP_LAST_ACK 9
54#define TCP_LISTEN 10
55#define TCP_CLOSING 11
56
57enum {
58 TCP_NLA_PAD,
59 TCP_NLA_BUSY,
60 TCP_NLA_RWND_LIMITED,
61 TCP_NLA_SNDBUF_LIMITED,
62 TCP_NLA_DATA_SEGS_OUT,
63 TCP_NLA_TOTAL_RETRANS,
64 TCP_NLA_PACING_RATE,
65 TCP_NLA_DELIVERY_RATE,
66 TCP_NLA_SND_CWND,
67 TCP_NLA_REORDERING,
68 TCP_NLA_MIN_RTT,
69 TCP_NLA_RECUR_RETRANS,
70 TCP_NLA_DELIVERY_RATE_APP_LMT,
71 TCP_NLA_SNDQ_SIZE,
72 TCP_NLA_CA_STATE,
73 TCP_NLA_SND_SSTHRESH,
74 TCP_NLA_DELIVERED,
75 TCP_NLA_DELIVERED_CE,
76 TCP_NLA_BYTES_SENT,
77 TCP_NLA_BYTES_RETRANS,
78 TCP_NLA_DSACK_DUPS,
79 TCP_NLA_REORD_SEEN,
80 TCP_NLA_SRTT,
81 TCP_NLA_TIMEOUT_REHASH,
82 TCP_NLA_BYTES_NOTSENT,
83};
84
85#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
86#define TCPOPT_EOL 0
87#define TCPOPT_NOP 1
88#define TCPOPT_MAXSEG 2
89#define TCPOPT_WINDOW 3
90#define TCPOPT_SACK_PERMITTED 4
91#define TCPOPT_SACK 5
92#define TCPOPT_TIMESTAMP 8
93#define TCPOLEN_SACK_PERMITTED 2
94#define TCPOLEN_WINDOW 3
95#define TCPOLEN_MAXSEG 4
96#define TCPOLEN_TIMESTAMP 10
97
98#define SOL_TCP 6
99
100#include <sys/types.h>
101#include <sys/socket.h>
102#include <stdint.h>
103
104typedef uint32_t tcp_seq;
105
106#define TH_FIN 0x01
107#define TH_SYN 0x02
108#define TH_RST 0x04
109#define TH_PUSH 0x08
110#define TH_ACK 0x10
111#define TH_URG 0x20
112
113struct tcphdr {
114#ifdef _GNU_SOURCE
115#ifdef __GNUC__
116 __extension__
117#endif
118 union { struct {
119
120 uint16_t source;
121 uint16_t dest;
122 uint32_t seq;
123 uint32_t ack_seq;
124#if __BYTE_ORDER == __LITTLE_ENDIAN
125 uint16_t res1:4;
126 uint16_t doff:4;
127 uint16_t fin:1;
128 uint16_t syn:1;
129 uint16_t rst:1;
130 uint16_t psh:1;
131 uint16_t ack:1;
132 uint16_t urg:1;
133 uint16_t res2:2;
134#else
135 uint16_t doff:4;
136 uint16_t res1:4;
137 uint16_t res2:2;
138 uint16_t urg:1;
139 uint16_t ack:1;
140 uint16_t psh:1;
141 uint16_t rst:1;
142 uint16_t syn:1;
143 uint16_t fin:1;
144#endif
145 uint16_t window;
146 uint16_t check;
147 uint16_t urg_ptr;
148
149 }; struct {
150#endif
151
152 uint16_t th_sport;
153 uint16_t th_dport;
154 uint32_t th_seq;
155 uint32_t th_ack;
156#if __BYTE_ORDER == __LITTLE_ENDIAN
157 uint8_t th_x2:4;
158 uint8_t th_off:4;
159#else
160 uint8_t th_off:4;
161 uint8_t th_x2:4;
162#endif
163 uint8_t th_flags;
164 uint16_t th_win;
165 uint16_t th_sum;
166 uint16_t th_urp;
167
168#ifdef _GNU_SOURCE
169 }; };
170#endif
171};
172#endif
173
174#ifdef _GNU_SOURCE
175#define TCPI_OPT_TIMESTAMPS 1
176#define TCPI_OPT_SACK 2
177#define TCPI_OPT_WSCALE 4
178#define TCPI_OPT_ECN 8
179
180#define TCP_CA_Open 0
181#define TCP_CA_Disorder 1
182#define TCP_CA_CWR 2
183#define TCP_CA_Recovery 3
184#define TCP_CA_Loss 4
185
186enum tcp_fastopen_client_fail {
187 TFO_STATUS_UNSPEC,
188 TFO_COOKIE_UNAVAILABLE,
189 TFO_DATA_NOT_ACKED,
190 TFO_SYN_RETRANSMITTED,
191};
192
193struct tcp_info {
194 uint8_t tcpi_state;
195 uint8_t tcpi_ca_state;
196 uint8_t tcpi_retransmits;
197 uint8_t tcpi_probes;
198 uint8_t tcpi_backoff;
199 uint8_t tcpi_options;
200 uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
201 uint8_t tcpi_delivery_rate_app_limited : 1, tcpi_fastopen_client_fail : 2;
202 uint32_t tcpi_rto;
203 uint32_t tcpi_ato;
204 uint32_t tcpi_snd_mss;
205 uint32_t tcpi_rcv_mss;
206 uint32_t tcpi_unacked;
207 uint32_t tcpi_sacked;
208 uint32_t tcpi_lost;
209 uint32_t tcpi_retrans;
210 uint32_t tcpi_fackets;
211 uint32_t tcpi_last_data_sent;
212 uint32_t tcpi_last_ack_sent;
213 uint32_t tcpi_last_data_recv;
214 uint32_t tcpi_last_ack_recv;
215 uint32_t tcpi_pmtu;
216 uint32_t tcpi_rcv_ssthresh;
217 uint32_t tcpi_rtt;
218 uint32_t tcpi_rttvar;
219 uint32_t tcpi_snd_ssthresh;
220 uint32_t tcpi_snd_cwnd;
221 uint32_t tcpi_advmss;
222 uint32_t tcpi_reordering;
223 uint32_t tcpi_rcv_rtt;
224 uint32_t tcpi_rcv_space;
225 uint32_t tcpi_total_retrans;
226 uint64_t tcpi_pacing_rate;
227 uint64_t tcpi_max_pacing_rate;
228 uint64_t tcpi_bytes_acked;
229 uint64_t tcpi_bytes_received;
230 uint32_t tcpi_segs_out;
231 uint32_t tcpi_segs_in;
232 uint32_t tcpi_notsent_bytes;
233 uint32_t tcpi_min_rtt;
234 uint32_t tcpi_data_segs_in;
235 uint32_t tcpi_data_segs_out;
236 uint64_t tcpi_delivery_rate;
237 uint64_t tcpi_busy_time;
238 uint64_t tcpi_rwnd_limited;
239 uint64_t tcpi_sndbuf_limited;
240 uint32_t tcpi_delivered;
241 uint32_t tcpi_delivered_ce;
242 uint64_t tcpi_bytes_sent;
243 uint64_t tcpi_bytes_retrans;
244 uint32_t tcpi_dsack_dups;
245 uint32_t tcpi_reord_seen;
246 uint32_t tcpi_rcv_ooopack;
247 uint32_t tcpi_snd_wnd;
248};
249
250#define TCP_MD5SIG_MAXKEYLEN 80
251
252#define TCP_MD5SIG_FLAG_PREFIX 0x1
253#define TCP_MD5SIG_FLAG_IFINDEX 0x2
254
255struct tcp_md5sig {
256 struct sockaddr_storage tcpm_addr;
257 uint8_t tcpm_flags;
258 uint8_t tcpm_prefixlen;
259 uint16_t tcpm_keylen;
260 int tcpm_ifindex;
261 uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
262};
263
264struct tcp_diag_md5sig {
265 uint8_t tcpm_family;
266 uint8_t tcpm_prefixlen;
267 uint16_t tcpm_keylen;
268 uint32_t tcpm_addr[4];
269 uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN];
270};
271
272#define TCP_REPAIR_ON 1
273#define TCP_REPAIR_OFF 0
274#define TCP_REPAIR_OFF_NO_WP -1
275
276struct tcp_repair_window {
277 uint32_t snd_wl1;
278 uint32_t snd_wnd;
279 uint32_t max_window;
280 uint32_t rcv_wnd;
281 uint32_t rcv_wup;
282};
283
284struct tcp_zerocopy_receive {
285 uint64_t address;
286 uint32_t length;
287 uint32_t recv_skip_hint;
288 uint32_t inq;
289 int32_t err;
290};
291
292#endif
293
294#endif
lib/libc/include/wasm32-wasi/netinet/udp.h deleted-46
......@@ -1,46 +0,0 @@
1#ifndef _NETINET_UDP_H
2#define _NETINET_UDP_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9#include <stdint.h>
10
11#ifdef _GNU_SOURCE
12#define uh_sport source
13#define uh_dport dest
14#define uh_ulen len
15#define uh_sum check
16#endif
17
18struct udphdr {
19 uint16_t uh_sport;
20 uint16_t uh_dport;
21 uint16_t uh_ulen;
22 uint16_t uh_sum;
23};
24
25#define UDP_CORK 1
26#define UDP_ENCAP 100
27#define UDP_NO_CHECK6_TX 101
28#define UDP_NO_CHECK6_RX 102
29#define UDP_SEGMENT 103
30#define UDP_GRO 104
31
32#define UDP_ENCAP_ESPINUDP_NON_IKE 1
33#define UDP_ENCAP_ESPINUDP 2
34#define UDP_ENCAP_L2TPINUDP 3
35#define UDP_ENCAP_GTP0 4
36#define UDP_ENCAP_GTP1U 5
37#define UDP_ENCAP_RXRPC 6
38#define TCP_ENCAP_ESPINTCP 7
39
40#define SOL_UDP 17
41
42#ifdef __cplusplus
43}
44#endif
45
46#endif
lib/libc/include/wasm32-wasi/netpacket/packet.h deleted-62
......@@ -1,62 +0,0 @@
1#ifndef _NETPACKET_PACKET_H
2#define _NETPACKET_PACKET_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8struct sockaddr_ll {
9 unsigned short sll_family, sll_protocol;
10 int sll_ifindex;
11 unsigned short sll_hatype;
12 unsigned char sll_pkttype, sll_halen;
13 unsigned char sll_addr[8];
14};
15
16struct packet_mreq {
17 int mr_ifindex;
18 unsigned short int mr_type, mr_alen;
19 unsigned char mr_address[8];
20};
21
22#define PACKET_HOST 0
23#define PACKET_BROADCAST 1
24#define PACKET_MULTICAST 2
25#define PACKET_OTHERHOST 3
26#define PACKET_OUTGOING 4
27#define PACKET_LOOPBACK 5
28#define PACKET_FASTROUTE 6
29
30#define PACKET_ADD_MEMBERSHIP 1
31#define PACKET_DROP_MEMBERSHIP 2
32#define PACKET_RECV_OUTPUT 3
33#define PACKET_RX_RING 5
34#define PACKET_STATISTICS 6
35#define PACKET_COPY_THRESH 7
36#define PACKET_AUXDATA 8
37#define PACKET_ORIGDEV 9
38#define PACKET_VERSION 10
39#define PACKET_HDRLEN 11
40#define PACKET_RESERVE 12
41#define PACKET_TX_RING 13
42#define PACKET_LOSS 14
43#define PACKET_VNET_HDR 15
44#define PACKET_TX_TIMESTAMP 16
45#define PACKET_TIMESTAMP 17
46#define PACKET_FANOUT 18
47#define PACKET_TX_HAS_OFF 19
48#define PACKET_QDISC_BYPASS 20
49#define PACKET_ROLLOVER_STATS 21
50#define PACKET_FANOUT_DATA 22
51#define PACKET_IGNORE_OUTGOING 23
52
53#define PACKET_MR_MULTICAST 0
54#define PACKET_MR_PROMISC 1
55#define PACKET_MR_ALLMULTI 2
56#define PACKET_MR_UNICAST 3
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif
lib/libc/include/wasm32-wasi/nl_types.h deleted-22
......@@ -1,22 +0,0 @@
1#ifndef _NL_TYPES_H
2#define _NL_TYPES_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define NL_SETD 1
9#define NL_CAT_LOCALE 1
10
11typedef int nl_item;
12typedef void *nl_catd;
13
14nl_catd catopen (const char *, int);
15char *catgets (nl_catd, int, int, const char *);
16int catclose (nl_catd);
17
18#ifdef __cplusplus
19}
20#endif
21
22#endif
lib/libc/include/wasm32-wasi/poll.h deleted-69
......@@ -1,69 +0,0 @@
1#ifndef _POLL_H
2#define _POLL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#include <bits/poll.h>
11
12#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
13#define POLLIN 0x001
14#define POLLPRI 0x002
15#define POLLOUT 0x004
16#define POLLERR 0x008
17#define POLLHUP 0x010
18#define POLLNVAL 0x020
19#define POLLRDNORM 0x040
20#define POLLRDBAND 0x080
21#ifndef POLLWRNORM
22#define POLLWRNORM 0x100
23#define POLLWRBAND 0x200
24#endif
25#ifndef POLLMSG
26#define POLLMSG 0x400
27#define POLLRDHUP 0x2000
28#endif
29#else
30#include <__header_poll.h>
31#endif
32
33#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
34typedef unsigned long nfds_t;
35#else
36#include <__typedef_nfds_t.h>
37#endif
38
39#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
40struct pollfd {
41 int fd;
42 short events;
43 short revents;
44};
45#else
46#include <__struct_pollfd.h>
47#endif
48
49int poll (struct pollfd *, nfds_t, int);
50
51#ifdef _GNU_SOURCE
52#define __NEED_time_t
53#define __NEED_struct_timespec
54#define __NEED_sigset_t
55#include <bits/alltypes.h>
56int ppoll(struct pollfd *, nfds_t, const struct timespec *, const sigset_t *);
57#endif
58
59#if _REDIR_TIME64
60#ifdef _GNU_SOURCE
61__REDIR(ppoll, __ppoll_time64);
62#endif
63#endif
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif
lib/libc/include/wasm32-wasi/regex.h deleted-62
......@@ -1,62 +0,0 @@
1#ifndef _REGEX_H
2#define _REGEX_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_regoff_t
11#define __NEED_size_t
12
13#include <bits/alltypes.h>
14
15typedef struct re_pattern_buffer {
16 size_t re_nsub;
17 void *__opaque, *__padding[4];
18 size_t __nsub2;
19 char __padding2;
20} regex_t;
21
22typedef struct {
23 regoff_t rm_so;
24 regoff_t rm_eo;
25} regmatch_t;
26
27#define REG_EXTENDED 1
28#define REG_ICASE 2
29#define REG_NEWLINE 4
30#define REG_NOSUB 8
31
32#define REG_NOTBOL 1
33#define REG_NOTEOL 2
34
35#define REG_OK 0
36#define REG_NOMATCH 1
37#define REG_BADPAT 2
38#define REG_ECOLLATE 3
39#define REG_ECTYPE 4
40#define REG_EESCAPE 5
41#define REG_ESUBREG 6
42#define REG_EBRACK 7
43#define REG_EPAREN 8
44#define REG_EBRACE 9
45#define REG_BADBR 10
46#define REG_ERANGE 11
47#define REG_ESPACE 12
48#define REG_BADRPT 13
49
50#define REG_ENOSYS -1
51
52int regcomp(regex_t *__restrict, const char *__restrict, int);
53int regexec(const regex_t *__restrict, const char *__restrict, size_t, regmatch_t *__restrict, int);
54void regfree(regex_t *);
55
56size_t regerror(int, const regex_t *__restrict, char *__restrict, size_t);
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif
lib/libc/include/wasm32-wasi/sched.h deleted-152
......@@ -1,152 +0,0 @@
1#ifndef _SCHED_H
2#define _SCHED_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_struct_timespec
10#define __NEED_pid_t
11#define __NEED_time_t
12
13#ifdef _GNU_SOURCE
14#define __NEED_size_t
15#endif
16
17#include <bits/alltypes.h>
18
19#ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */
20struct sched_param {
21 int sched_priority;
22 int __reserved1;
23#if _REDIR_TIME64
24 long __reserved2[4];
25#else
26 struct {
27 time_t __reserved1;
28 long __reserved2;
29 } __reserved2[2];
30#endif
31 int __reserved3;
32};
33
34int sched_get_priority_max(int);
35int sched_get_priority_min(int);
36int sched_getparam(pid_t, struct sched_param *);
37int sched_getscheduler(pid_t);
38int sched_rr_get_interval(pid_t, struct timespec *);
39int sched_setparam(pid_t, const struct sched_param *);
40int sched_setscheduler(pid_t, int, const struct sched_param *);
41#endif
42int sched_yield(void);
43
44#ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */
45#define SCHED_OTHER 0
46#define SCHED_FIFO 1
47#define SCHED_RR 2
48#define SCHED_BATCH 3
49#define SCHED_IDLE 5
50#define SCHED_DEADLINE 6
51#define SCHED_RESET_ON_FORK 0x40000000
52
53#ifdef _GNU_SOURCE
54#define CSIGNAL 0x000000ff
55#define CLONE_NEWTIME 0x00000080
56#define CLONE_VM 0x00000100
57#define CLONE_FS 0x00000200
58#define CLONE_FILES 0x00000400
59#define CLONE_SIGHAND 0x00000800
60#define CLONE_PIDFD 0x00001000
61#define CLONE_PTRACE 0x00002000
62#define CLONE_VFORK 0x00004000
63#define CLONE_PARENT 0x00008000
64#define CLONE_THREAD 0x00010000
65#define CLONE_NEWNS 0x00020000
66#define CLONE_SYSVSEM 0x00040000
67#define CLONE_SETTLS 0x00080000
68#define CLONE_PARENT_SETTID 0x00100000
69#define CLONE_CHILD_CLEARTID 0x00200000
70#define CLONE_DETACHED 0x00400000
71#define CLONE_UNTRACED 0x00800000
72#define CLONE_CHILD_SETTID 0x01000000
73#define CLONE_NEWCGROUP 0x02000000
74#define CLONE_NEWUTS 0x04000000
75#define CLONE_NEWIPC 0x08000000
76#define CLONE_NEWUSER 0x10000000
77#define CLONE_NEWPID 0x20000000
78#define CLONE_NEWNET 0x40000000
79#define CLONE_IO 0x80000000
80int clone (int (*)(void *), void *, int, void *, ...);
81int unshare(int);
82int setns(int, int);
83
84void *memcpy(void *__restrict, const void *__restrict, size_t);
85int memcmp(const void *, const void *, size_t);
86void *memset (void *, int, size_t);
87void *calloc(size_t, size_t);
88void free(void *);
89
90typedef struct cpu_set_t { unsigned long __bits[128/sizeof(long)]; } cpu_set_t;
91int __sched_cpucount(size_t, const cpu_set_t *);
92int sched_getcpu(void);
93int sched_getaffinity(pid_t, size_t, cpu_set_t *);
94int sched_setaffinity(pid_t, size_t, const cpu_set_t *);
95
96#define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \
97 (((unsigned long *)(set))[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) )
98
99#define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=)
100#define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &=~)
101#define CPU_ISSET_S(i, size, set) __CPU_op_S(i, size, set, &)
102
103#define __CPU_op_func_S(func, op) \
104static __inline void __CPU_##func##_S(size_t __size, cpu_set_t *__dest, \
105 const cpu_set_t *__src1, const cpu_set_t *__src2) \
106{ \
107 size_t __i; \
108 for (__i=0; __i<__size/sizeof(long); __i++) \
109 ((unsigned long *)__dest)[__i] = ((unsigned long *)__src1)[__i] \
110 op ((unsigned long *)__src2)[__i] ; \
111}
112
113__CPU_op_func_S(AND, &)
114__CPU_op_func_S(OR, |)
115__CPU_op_func_S(XOR, ^)
116
117#define CPU_AND_S(a,b,c,d) __CPU_AND_S(a,b,c,d)
118#define CPU_OR_S(a,b,c,d) __CPU_OR_S(a,b,c,d)
119#define CPU_XOR_S(a,b,c,d) __CPU_XOR_S(a,b,c,d)
120
121#define CPU_COUNT_S(size,set) __sched_cpucount(size,set)
122#define CPU_ZERO_S(size,set) memset(set,0,size)
123#define CPU_EQUAL_S(size,set1,set2) (!memcmp(set1,set2,size))
124
125#define CPU_ALLOC_SIZE(n) (sizeof(long) * ( (n)/(8*sizeof(long)) \
126 + ((n)%(8*sizeof(long)) + 8*sizeof(long)-1)/(8*sizeof(long)) ) )
127#define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
128#define CPU_FREE(set) free(set)
129
130#define CPU_SETSIZE 128
131
132#define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set)
133#define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set)
134#define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set)
135#define CPU_AND(d,s1,s2) CPU_AND_S(sizeof(cpu_set_t),d,s1,s2)
136#define CPU_OR(d,s1,s2) CPU_OR_S(sizeof(cpu_set_t),d,s1,s2)
137#define CPU_XOR(d,s1,s2) CPU_XOR_S(sizeof(cpu_set_t),d,s1,s2)
138#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t),set)
139#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set)
140#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2)
141
142#endif
143#endif
144
145#if _REDIR_TIME64
146__REDIR(sched_rr_get_interval, __sched_rr_get_interval_time64);
147#endif
148
149#ifdef __cplusplus
150}
151#endif
152#endif
lib/libc/include/wasm32-wasi/search.h deleted-63
......@@ -1,63 +0,0 @@
1#ifndef _SEARCH_H
2#define _SEARCH_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11#include <bits/alltypes.h>
12
13typedef enum { FIND, ENTER } ACTION;
14typedef enum { preorder, postorder, endorder, leaf } VISIT;
15
16typedef struct entry {
17 char *key;
18 void *data;
19} ENTRY;
20
21int hcreate(size_t);
22void hdestroy(void);
23ENTRY *hsearch(ENTRY, ACTION);
24
25#ifdef _GNU_SOURCE
26struct hsearch_data {
27 struct __tab *__tab;
28 unsigned int __unused1;
29 unsigned int __unused2;
30};
31
32int hcreate_r(size_t, struct hsearch_data *);
33void hdestroy_r(struct hsearch_data *);
34int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
35#endif
36
37void insque(void *, void *);
38void remque(void *);
39
40void *lsearch(const void *, void *, size_t *, size_t,
41 int (*)(const void *, const void *));
42void *lfind(const void *, const void *, size_t *, size_t,
43 int (*)(const void *, const void *));
44
45void *tdelete(const void *__restrict, void **__restrict, int(*)(const void *, const void *));
46void *tfind(const void *, void *const *, int(*)(const void *, const void *));
47void *tsearch(const void *, void **, int (*)(const void *, const void *));
48void twalk(const void *, void (*)(const void *, VISIT, int));
49
50#ifdef _GNU_SOURCE
51struct qelem {
52 struct qelem *q_forw, *q_back;
53 char q_data[1];
54};
55
56void tdestroy(void *, void (*)(void *));
57#endif
58
59#ifdef __cplusplus
60}
61#endif
62
63#endif
lib/libc/include/wasm32-wasi/semaphore.h deleted-39
......@@ -1,39 +0,0 @@
1#ifndef _SEMAPHORE_H
2#define _SEMAPHORE_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_time_t
10#define __NEED_struct_timespec
11#include <bits/alltypes.h>
12
13#include <fcntl.h>
14
15#define SEM_FAILED ((sem_t *)0)
16
17typedef struct {
18 volatile int __val[4*sizeof(long)/sizeof(int)];
19} sem_t;
20
21int sem_close(sem_t *);
22int sem_destroy(sem_t *);
23int sem_getvalue(sem_t *__restrict, int *__restrict);
24int sem_init(sem_t *, int, unsigned);
25sem_t *sem_open(const char *, int, ...);
26int sem_post(sem_t *);
27int sem_timedwait(sem_t *__restrict, const struct timespec *__restrict);
28int sem_trywait(sem_t *);
29int sem_unlink(const char *);
30int sem_wait(sem_t *);
31
32#if _REDIR_TIME64
33__REDIR(sem_timedwait, __sem_timedwait_time64);
34#endif
35
36#ifdef __cplusplus
37}
38#endif
39#endif
lib/libc/include/wasm32-wasi/signal.h deleted-331
......@@ -1,331 +0,0 @@
1#ifndef _WASI_EMULATED_SIGNAL
2#error "wasm lacks signal support; to enable minimal signal emulation, \
3compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
4#else
5#ifndef _SIGNAL_H
6#define _SIGNAL_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <features.h>
13
14#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
15 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
16 || defined(_BSD_SOURCE)
17
18#ifdef __wasilibc_unmodified_upstream /* WASI has no ucontext support */
19#ifdef _GNU_SOURCE
20#define __ucontext ucontext
21#endif
22
23#define __NEED_size_t
24#define __NEED_pid_t
25#define __NEED_uid_t
26#define __NEED_struct_timespec
27#define __NEED_pthread_t
28#define __NEED_pthread_attr_t
29#define __NEED_time_t
30#define __NEED_clock_t
31#define __NEED_sigset_t
32
33#include <bits/alltypes.h>
34
35#define SIG_BLOCK 0
36#define SIG_UNBLOCK 1
37#define SIG_SETMASK 2
38
39#define SI_ASYNCNL (-60)
40#define SI_TKILL (-6)
41#define SI_SIGIO (-5)
42#define SI_ASYNCIO (-4)
43#define SI_MESGQ (-3)
44#define SI_TIMER (-2)
45#define SI_QUEUE (-1)
46#define SI_USER 0
47#define SI_KERNEL 128
48
49typedef struct sigaltstack stack_t;
50#endif
51
52#endif
53
54#include <bits/signal.h>
55
56#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
57 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
58 || defined(_BSD_SOURCE)
59
60#ifdef __wasilibc_unmodified_upstream /* WASI has no sigaction */
61#define SIG_HOLD ((void (*)(int)) 2)
62
63#define FPE_INTDIV 1
64#define FPE_INTOVF 2
65#define FPE_FLTDIV 3
66#define FPE_FLTOVF 4
67#define FPE_FLTUND 5
68#define FPE_FLTRES 6
69#define FPE_FLTINV 7
70#define FPE_FLTSUB 8
71
72#define ILL_ILLOPC 1
73#define ILL_ILLOPN 2
74#define ILL_ILLADR 3
75#define ILL_ILLTRP 4
76#define ILL_PRVOPC 5
77#define ILL_PRVREG 6
78#define ILL_COPROC 7
79#define ILL_BADSTK 8
80
81#define SEGV_MAPERR 1
82#define SEGV_ACCERR 2
83#define SEGV_BNDERR 3
84#define SEGV_PKUERR 4
85
86#define BUS_ADRALN 1
87#define BUS_ADRERR 2
88#define BUS_OBJERR 3
89#define BUS_MCEERR_AR 4
90#define BUS_MCEERR_AO 5
91
92#define CLD_EXITED 1
93#define CLD_KILLED 2
94#define CLD_DUMPED 3
95#define CLD_TRAPPED 4
96#define CLD_STOPPED 5
97#define CLD_CONTINUED 6
98
99union sigval {
100 int sival_int;
101 void *sival_ptr;
102};
103
104typedef struct {
105#ifdef __SI_SWAP_ERRNO_CODE
106 int si_signo, si_code, si_errno;
107#else
108 int si_signo, si_errno, si_code;
109#endif
110 union {
111 char __pad[128 - 2*sizeof(int) - sizeof(long)];
112 struct {
113 union {
114 struct {
115 pid_t si_pid;
116 uid_t si_uid;
117 } __piduid;
118 struct {
119 int si_timerid;
120 int si_overrun;
121 } __timer;
122 } __first;
123 union {
124 union sigval si_value;
125 struct {
126 int si_status;
127 clock_t si_utime, si_stime;
128 } __sigchld;
129 } __second;
130 } __si_common;
131 struct {
132 void *si_addr;
133 short si_addr_lsb;
134 union {
135 struct {
136 void *si_lower;
137 void *si_upper;
138 } __addr_bnd;
139 unsigned si_pkey;
140 } __first;
141 } __sigfault;
142 struct {
143 long si_band;
144 int si_fd;
145 } __sigpoll;
146 struct {
147 void *si_call_addr;
148 int si_syscall;
149 unsigned si_arch;
150 } __sigsys;
151 } __si_fields;
152} siginfo_t;
153#define si_pid __si_fields.__si_common.__first.__piduid.si_pid
154#define si_uid __si_fields.__si_common.__first.__piduid.si_uid
155#define si_status __si_fields.__si_common.__second.__sigchld.si_status
156#define si_utime __si_fields.__si_common.__second.__sigchld.si_utime
157#define si_stime __si_fields.__si_common.__second.__sigchld.si_stime
158#define si_value __si_fields.__si_common.__second.si_value
159#define si_addr __si_fields.__sigfault.si_addr
160#define si_addr_lsb __si_fields.__sigfault.si_addr_lsb
161#define si_lower __si_fields.__sigfault.__first.__addr_bnd.si_lower
162#define si_upper __si_fields.__sigfault.__first.__addr_bnd.si_upper
163#define si_pkey __si_fields.__sigfault.__first.si_pkey
164#define si_band __si_fields.__sigpoll.si_band
165#define si_fd __si_fields.__sigpoll.si_fd
166#define si_timerid __si_fields.__si_common.__first.__timer.si_timerid
167#define si_overrun __si_fields.__si_common.__first.__timer.si_overrun
168#define si_ptr si_value.sival_ptr
169#define si_int si_value.sival_int
170#define si_call_addr __si_fields.__sigsys.si_call_addr
171#define si_syscall __si_fields.__sigsys.si_syscall
172#define si_arch __si_fields.__sigsys.si_arch
173
174struct sigaction {
175 union {
176 void (*sa_handler)(int);
177 void (*sa_sigaction)(int, siginfo_t *, void *);
178 } __sa_handler;
179 sigset_t sa_mask;
180 int sa_flags;
181 void (*sa_restorer)(void);
182};
183#define sa_handler __sa_handler.sa_handler
184#define sa_sigaction __sa_handler.sa_sigaction
185
186struct sigevent {
187 union sigval sigev_value;
188 int sigev_signo;
189 int sigev_notify;
190 union {
191 char __pad[64 - 2*sizeof(int) - sizeof(union sigval)];
192 pid_t sigev_notify_thread_id;
193 struct {
194 void (*sigev_notify_function)(union sigval);
195 pthread_attr_t *sigev_notify_attributes;
196 } __sev_thread;
197 } __sev_fields;
198};
199
200#define sigev_notify_thread_id __sev_fields.sigev_notify_thread_id
201#define sigev_notify_function __sev_fields.__sev_thread.sigev_notify_function
202#define sigev_notify_attributes __sev_fields.__sev_thread.sigev_notify_attributes
203
204#define SIGEV_SIGNAL 0
205#define SIGEV_NONE 1
206#define SIGEV_THREAD 2
207#define SIGEV_THREAD_ID 4
208#endif
209
210#ifdef __wasilibc_unmodified_upstream /* WASI has no realtime signals */
211int __libc_current_sigrtmin(void);
212int __libc_current_sigrtmax(void);
213
214#define SIGRTMIN (__libc_current_sigrtmin())
215#define SIGRTMAX (__libc_current_sigrtmax())
216#endif
217
218#ifdef __wasilibc_unmodified_upstream /* WASI has no signals */
219int kill(pid_t, int);
220
221int sigemptyset(sigset_t *);
222int sigfillset(sigset_t *);
223int sigaddset(sigset_t *, int);
224int sigdelset(sigset_t *, int);
225int sigismember(const sigset_t *, int);
226
227int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict);
228int sigsuspend(const sigset_t *);
229int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict);
230int sigpending(sigset_t *);
231int sigwait(const sigset_t *__restrict, int *__restrict);
232int sigwaitinfo(const sigset_t *__restrict, siginfo_t *__restrict);
233int sigtimedwait(const sigset_t *__restrict, siginfo_t *__restrict, const struct timespec *__restrict);
234int sigqueue(pid_t, int, union sigval);
235#endif
236
237#ifdef __wasilibc_unmodified_upstream /* WASI has no threads yet */
238int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict);
239int pthread_kill(pthread_t, int);
240#endif
241
242#ifdef __wasilibc_unmodified_upstream /* WASI has no siginfo */
243void psiginfo(const siginfo_t *, const char *);
244#endif
245void psignal(int, const char *);
246
247#endif
248
249#ifdef __wasilibc_unmodified_upstream /* WASI has no signals */
250#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
251int killpg(pid_t, int);
252int sigaltstack(const stack_t *__restrict, stack_t *__restrict);
253int sighold(int);
254int sigignore(int);
255int siginterrupt(int, int);
256int sigpause(int);
257int sigrelse(int);
258void (*sigset(int, void (*)(int)))(int);
259#define TRAP_BRKPT 1
260#define TRAP_TRACE 2
261#define TRAP_BRANCH 3
262#define TRAP_HWBKPT 4
263#define TRAP_UNK 5
264#define POLL_IN 1
265#define POLL_OUT 2
266#define POLL_MSG 3
267#define POLL_ERR 4
268#define POLL_PRI 5
269#define POLL_HUP 6
270#define SS_ONSTACK 1
271#define SS_DISABLE 2
272#define SS_AUTODISARM (1U << 31)
273#define SS_FLAG_BITS SS_AUTODISARM
274#endif
275#endif
276
277#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
278#define NSIG _NSIG
279typedef void (*sig_t)(int);
280#endif
281
282#ifdef _GNU_SOURCE
283typedef void (*sighandler_t)(int);
284void (*bsd_signal(int, void (*)(int)))(int);
285#ifdef __wasilibc_unmodified_upstream /* WASI has no signal sets */
286int sigisemptyset(const sigset_t *);
287int sigorset (sigset_t *, const sigset_t *, const sigset_t *);
288int sigandset(sigset_t *, const sigset_t *, const sigset_t *);
289
290#define SA_NOMASK SA_NODEFER
291#define SA_ONESHOT SA_RESETHAND
292#endif
293#endif
294
295#ifdef __wasilibc_unmodified_upstream /* 1 is a valid function pointer on wasm */
296#define SIG_ERR ((void (*)(int))-1)
297#define SIG_DFL ((void (*)(int)) 0)
298#define SIG_IGN ((void (*)(int)) 1)
299#else
300void __SIG_ERR(int);
301void __SIG_IGN(int);
302#define SIG_ERR (__SIG_ERR)
303#define SIG_DFL ((void (*)(int)) 0)
304#define SIG_IGN (__SIG_IGN)
305#endif
306
307#ifdef __wasilibc_unmodified_upstream /* Make sig_atomic_t 64-bit on wasm64 */
308typedef int sig_atomic_t;
309#else
310typedef long sig_atomic_t;
311#endif
312
313void (*signal(int, void (*)(int)))(int);
314int raise(int);
315
316#ifdef __wasilibc_unmodified_upstream /* WASI has no sigtimedwait */
317#if _REDIR_TIME64
318#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
319 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
320 || defined(_BSD_SOURCE)
321__REDIR(sigtimedwait, __sigtimedwait_time64);
322#endif
323#endif
324#endif
325
326#ifdef __cplusplus
327}
328#endif
329
330#endif
331#endif
lib/libc/include/wasm32-wasi/stdalign.h deleted-20
......@@ -1,20 +0,0 @@
1#ifndef _STDALIGN_H
2#define _STDALIGN_H
3
4#ifndef __cplusplus
5
6/* this whole header only works in C11 or with compiler extensions */
7#if __STDC_VERSION__ < 201112L && defined( __GNUC__)
8#define _Alignas(t) __attribute__((__aligned__(t)))
9#define _Alignof(t) __alignof__(t)
10#endif
11
12#define alignas _Alignas
13#define alignof _Alignof
14
15#endif
16
17#define __alignas_is_defined 1
18#define __alignof_is_defined 1
19
20#endif
lib/libc/include/wasm32-wasi/stdbool.h deleted-14
......@@ -1,14 +0,0 @@
1#ifndef _STDBOOL_H
2#define _STDBOOL_H
3
4#ifndef __cplusplus
5
6#define true 1
7#define false 0
8#define bool _Bool
9
10#endif
11
12#define __bool_true_false_are_defined 1
13
14#endif
lib/libc/include/wasm32-wasi/stdc-predef.h deleted-10
......@@ -1,10 +0,0 @@
1#ifndef _STDC_PREDEF_H
2#define _STDC_PREDEF_H
3
4#define __STDC_ISO_10646__ 201206L
5
6#if !defined(__GCC_IEC_559) || __GCC_IEC_559 > 0
7#define __STDC_IEC_559__ 1
8#endif
9
10#endif
lib/libc/include/wasm32-wasi/stdint.h deleted-117
......@@ -1,117 +0,0 @@
1#ifndef _STDINT_H
2#define _STDINT_H
3
4#define __NEED_int8_t
5#define __NEED_int16_t
6#define __NEED_int32_t
7#define __NEED_int64_t
8
9#define __NEED_uint8_t
10#define __NEED_uint16_t
11#define __NEED_uint32_t
12#define __NEED_uint64_t
13
14#define __NEED_intptr_t
15#define __NEED_uintptr_t
16
17#define __NEED_intmax_t
18#define __NEED_uintmax_t
19
20#include <bits/alltypes.h>
21
22typedef int8_t int_fast8_t;
23typedef int64_t int_fast64_t;
24
25typedef int8_t int_least8_t;
26typedef int16_t int_least16_t;
27typedef int32_t int_least32_t;
28typedef int64_t int_least64_t;
29
30typedef uint8_t uint_fast8_t;
31typedef uint64_t uint_fast64_t;
32
33typedef uint8_t uint_least8_t;
34typedef uint16_t uint_least16_t;
35typedef uint32_t uint_least32_t;
36typedef uint64_t uint_least64_t;
37
38#define INT8_MIN (-1-0x7f)
39#define INT16_MIN (-1-0x7fff)
40#define INT32_MIN (-1-0x7fffffff)
41#define INT64_MIN (-1-0x7fffffffffffffff)
42
43#define INT8_MAX (0x7f)
44#define INT16_MAX (0x7fff)
45#define INT32_MAX (0x7fffffff)
46#define INT64_MAX (0x7fffffffffffffff)
47
48#define UINT8_MAX (0xff)
49#define UINT16_MAX (0xffff)
50#define UINT32_MAX (0xffffffffu)
51#define UINT64_MAX (0xffffffffffffffffu)
52
53#define INT_FAST8_MIN INT8_MIN
54#define INT_FAST64_MIN INT64_MIN
55
56#define INT_LEAST8_MIN INT8_MIN
57#define INT_LEAST16_MIN INT16_MIN
58#define INT_LEAST32_MIN INT32_MIN
59#define INT_LEAST64_MIN INT64_MIN
60
61#define INT_FAST8_MAX INT8_MAX
62#define INT_FAST64_MAX INT64_MAX
63
64#define INT_LEAST8_MAX INT8_MAX
65#define INT_LEAST16_MAX INT16_MAX
66#define INT_LEAST32_MAX INT32_MAX
67#define INT_LEAST64_MAX INT64_MAX
68
69#define UINT_FAST8_MAX UINT8_MAX
70#define UINT_FAST64_MAX UINT64_MAX
71
72#define UINT_LEAST8_MAX UINT8_MAX
73#define UINT_LEAST16_MAX UINT16_MAX
74#define UINT_LEAST32_MAX UINT32_MAX
75#define UINT_LEAST64_MAX UINT64_MAX
76
77#define INTMAX_MIN INT64_MIN
78#define INTMAX_MAX INT64_MAX
79#define UINTMAX_MAX UINT64_MAX
80
81#define WINT_MIN 0U
82#define WINT_MAX UINT32_MAX
83
84#if L'\0'-1 > 0
85#define WCHAR_MAX (0xffffffffu+L'\0')
86#define WCHAR_MIN (0+L'\0')
87#else
88#define WCHAR_MAX (0x7fffffff+L'\0')
89#define WCHAR_MIN (-1-0x7fffffff+L'\0')
90#endif
91
92#define SIG_ATOMIC_MIN INT32_MIN
93#define SIG_ATOMIC_MAX INT32_MAX
94
95#include <bits/stdint.h>
96
97#define INT8_C(c) c
98#define INT16_C(c) c
99#define INT32_C(c) c
100
101#define UINT8_C(c) c
102#define UINT16_C(c) c
103#define UINT32_C(c) c ## U
104
105#if UINTPTR_MAX == UINT64_MAX
106#define INT64_C(c) c ## L
107#define UINT64_C(c) c ## UL
108#define INTMAX_C(c) c ## L
109#define UINTMAX_C(c) c ## UL
110#else
111#define INT64_C(c) c ## LL
112#define UINT64_C(c) c ## ULL
113#define INTMAX_C(c) c ## LL
114#define UINTMAX_C(c) c ## ULL
115#endif
116
117#endif
lib/libc/include/wasm32-wasi/stdio.h deleted-252
......@@ -1,252 +0,0 @@
1#ifndef _STDIO_H
2#define _STDIO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_FILE
11#define __NEED___isoc_va_list
12#define __NEED_size_t
13
14#ifdef __wasilibc_unmodified_upstream /* WASI doesn't need to define FILE as a complete type */
15#if __STDC_VERSION__ < 201112L
16#define __NEED_struct__IO_FILE
17#endif
18#endif
19
20#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
21 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
22 || defined(_BSD_SOURCE)
23#define __NEED_ssize_t
24#define __NEED_off_t
25#define __NEED_va_list
26#endif
27
28#include <bits/alltypes.h>
29
30#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
31#ifdef __cplusplus
32#define NULL 0L
33#else
34#define NULL ((void*)0)
35#endif
36#else
37#define __need_NULL
38#include <stddef.h>
39#endif
40
41#undef EOF
42#define EOF (-1)
43
44#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
45#undef SEEK_SET
46#undef SEEK_CUR
47#undef SEEK_END
48#define SEEK_SET 0
49#define SEEK_CUR 1
50#define SEEK_END 2
51#else
52#include <__seek.h>
53#endif
54
55#define _IOFBF 0
56#define _IOLBF 1
57#define _IONBF 2
58
59#define BUFSIZ 1024
60#define FILENAME_MAX 4096
61#define FOPEN_MAX 1000
62#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
63#define TMP_MAX 10000
64#define L_tmpnam 20
65#endif
66
67typedef union _G_fpos64_t {
68 char __opaque[16];
69 long long __lldata;
70 double __align;
71} fpos_t;
72
73extern FILE *const stdin;
74extern FILE *const stdout;
75extern FILE *const stderr;
76
77#define stdin (stdin)
78#define stdout (stdout)
79#define stderr (stderr)
80
81FILE *fopen(const char *__restrict, const char *__restrict);
82FILE *freopen(const char *__restrict, const char *__restrict, FILE *__restrict);
83int fclose(FILE *);
84
85int remove(const char *);
86int rename(const char *, const char *);
87
88int feof(FILE *);
89int ferror(FILE *);
90int fflush(FILE *);
91void clearerr(FILE *);
92
93int fseek(FILE *, long, int);
94long ftell(FILE *);
95void rewind(FILE *);
96
97int fgetpos(FILE *__restrict, fpos_t *__restrict);
98int fsetpos(FILE *, const fpos_t *);
99
100size_t fread(void *__restrict, size_t, size_t, FILE *__restrict);
101size_t fwrite(const void *__restrict, size_t, size_t, FILE *__restrict);
102
103int fgetc(FILE *);
104int getc(FILE *);
105int getchar(void);
106int ungetc(int, FILE *);
107
108int fputc(int, FILE *);
109int putc(int, FILE *);
110int putchar(int);
111
112char *fgets(char *__restrict, int, FILE *__restrict);
113#if __STDC_VERSION__ < 201112L
114#ifdef __wasilibc_unmodified_upstream /* gets is obsolete */
115char *gets(char *);
116#else
117char *gets(char *) __attribute__((__deprecated__("gets is not defined on WASI")));
118#endif
119#endif
120
121int fputs(const char *__restrict, FILE *__restrict);
122int puts(const char *);
123
124int printf(const char *__restrict, ...);
125int fprintf(FILE *__restrict, const char *__restrict, ...);
126int sprintf(char *__restrict, const char *__restrict, ...);
127int snprintf(char *__restrict, size_t, const char *__restrict, ...);
128
129int vprintf(const char *__restrict, __isoc_va_list);
130int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list);
131int vsprintf(char *__restrict, const char *__restrict, __isoc_va_list);
132int vsnprintf(char *__restrict, size_t, const char *__restrict, __isoc_va_list);
133
134int scanf(const char *__restrict, ...);
135int fscanf(FILE *__restrict, const char *__restrict, ...);
136int sscanf(const char *__restrict, const char *__restrict, ...);
137int vscanf(const char *__restrict, __isoc_va_list);
138int vfscanf(FILE *__restrict, const char *__restrict, __isoc_va_list);
139int vsscanf(const char *__restrict, const char *__restrict, __isoc_va_list);
140
141void perror(const char *);
142
143int setvbuf(FILE *__restrict, char *__restrict, int, size_t);
144void setbuf(FILE *__restrict, char *__restrict);
145
146#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
147char *tmpnam(char *);
148FILE *tmpfile(void);
149#else
150char *tmpnam(char *) __attribute__((__deprecated__("tmpnam is not defined on WASI")));
151FILE *tmpfile(void) __attribute__((__deprecated__("tmpfile is not defined on WASI")));
152#endif
153
154#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
155 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
156 || defined(_BSD_SOURCE)
157FILE *fmemopen(void *__restrict, size_t, const char *__restrict);
158FILE *open_memstream(char **, size_t *);
159FILE *fdopen(int, const char *);
160#ifdef __wasilibc_unmodified_upstream /* WASI has no popen */
161FILE *popen(const char *, const char *);
162int pclose(FILE *);
163#endif
164int fileno(FILE *);
165int fseeko(FILE *, off_t, int);
166off_t ftello(FILE *);
167int dprintf(int, const char *__restrict, ...);
168int vdprintf(int, const char *__restrict, __isoc_va_list);
169#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
170void flockfile(FILE *);
171int ftrylockfile(FILE *);
172void funlockfile(FILE *);
173#endif
174int getc_unlocked(FILE *);
175int getchar_unlocked(void);
176int putc_unlocked(int, FILE *);
177int putchar_unlocked(int);
178ssize_t getdelim(char **__restrict, size_t *__restrict, int, FILE *__restrict);
179ssize_t getline(char **__restrict, size_t *__restrict, FILE *__restrict);
180int renameat(int, const char *, int, const char *);
181char *ctermid(char *);
182#define L_ctermid 20
183#endif
184
185
186#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
187#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
188 || defined(_BSD_SOURCE)
189#define P_tmpdir "/tmp"
190char *tempnam(const char *, const char *);
191#endif
192#endif
193
194#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
195#define L_cuserid 20
196char *cuserid(char *);
197void setlinebuf(FILE *);
198void setbuffer(FILE *, char *, size_t);
199int fgetc_unlocked(FILE *);
200int fputc_unlocked(int, FILE *);
201int fflush_unlocked(FILE *);
202size_t fread_unlocked(void *, size_t, size_t, FILE *);
203size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
204void clearerr_unlocked(FILE *);
205int feof_unlocked(FILE *);
206int ferror_unlocked(FILE *);
207int fileno_unlocked(FILE *);
208int getw(FILE *);
209int putw(int, FILE *);
210char *fgetln(FILE *, size_t *);
211int asprintf(char **, const char *, ...);
212int vasprintf(char **, const char *, __isoc_va_list);
213#endif
214
215#ifdef _GNU_SOURCE
216char *fgets_unlocked(char *, int, FILE *);
217int fputs_unlocked(const char *, FILE *);
218
219typedef ssize_t (cookie_read_function_t)(void *, char *, size_t);
220typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t);
221typedef int (cookie_seek_function_t)(void *, off_t *, int);
222typedef int (cookie_close_function_t)(void *);
223
224typedef struct _IO_cookie_io_functions_t {
225 cookie_read_function_t *read;
226 cookie_write_function_t *write;
227 cookie_seek_function_t *seek;
228 cookie_close_function_t *close;
229} cookie_io_functions_t;
230
231FILE *fopencookie(void *, const char *, cookie_io_functions_t);
232#endif
233
234#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
235#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
236#define tmpfile64 tmpfile
237#endif
238#define fopen64 fopen
239#define freopen64 freopen
240#define fseeko64 fseeko
241#define ftello64 ftello
242#define fgetpos64 fgetpos
243#define fsetpos64 fsetpos
244#define fpos64_t fpos_t
245#define off64_t off_t
246#endif
247
248#ifdef __cplusplus
249}
250#endif
251
252#endif
lib/libc/include/wasm32-wasi/stdio_ext.h deleted-34
......@@ -1,34 +0,0 @@
1#ifndef _STDIO_EXT_H
2#define _STDIO_EXT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdio.h>
9
10#define FSETLOCKING_QUERY 0
11#define FSETLOCKING_INTERNAL 1
12#define FSETLOCKING_BYCALLER 2
13
14void _flushlbf(void);
15int __fsetlocking(FILE *, int);
16int __fwriting(FILE *);
17int __freading(FILE *);
18int __freadable(FILE *);
19int __fwritable(FILE *);
20int __flbf(FILE *);
21size_t __fbufsize(FILE *);
22size_t __fpending(FILE *);
23int __fpurge(FILE *);
24
25size_t __freadahead(FILE *);
26const char *__freadptr(FILE *, size_t *);
27void __freadptrinc(FILE *, size_t);
28void __fseterr(FILE *);
29
30#ifdef __cplusplus
31}
32#endif
33
34#endif
lib/libc/include/wasm32-wasi/stdlib.h deleted-216
......@@ -1,216 +0,0 @@
1#ifndef _STDLIB_H
2#define _STDLIB_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#else
6#include <__functions_malloc.h>
7#include <__header_stdlib.h>
8#endif
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#include <features.h>
14
15#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
16#ifdef __cplusplus
17#define NULL 0L
18#else
19#define NULL ((void*)0)
20#endif
21#else
22#define __need_NULL
23#include <stddef.h>
24#endif
25
26#define __NEED_size_t
27#define __NEED_wchar_t
28
29#include <bits/alltypes.h>
30
31int atoi (const char *);
32long atol (const char *);
33long long atoll (const char *);
34double atof (const char *);
35
36float strtof (const char *__restrict, char **__restrict);
37double strtod (const char *__restrict, char **__restrict);
38long double strtold (const char *__restrict, char **__restrict);
39
40long strtol (const char *__restrict, char **__restrict, int);
41unsigned long strtoul (const char *__restrict, char **__restrict, int);
42long long strtoll (const char *__restrict, char **__restrict, int);
43unsigned long long strtoull (const char *__restrict, char **__restrict, int);
44
45int rand (void);
46void srand (unsigned);
47
48#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
49void *malloc (size_t);
50void *calloc (size_t, size_t);
51void *realloc (void *, size_t);
52void free (void *);
53#endif
54void *aligned_alloc(size_t, size_t);
55
56_Noreturn void abort (void);
57int atexit (void (*) (void));
58_Noreturn void exit (int);
59_Noreturn void _Exit (int);
60int at_quick_exit (void (*) (void));
61_Noreturn void quick_exit (int);
62
63char *getenv (const char *);
64
65int system (const char *);
66
67void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
68void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
69
70int abs (int);
71long labs (long);
72long long llabs (long long);
73
74typedef struct { int quot, rem; } div_t;
75typedef struct { long quot, rem; } ldiv_t;
76typedef struct { long long quot, rem; } lldiv_t;
77
78div_t div (int, int);
79ldiv_t ldiv (long, long);
80lldiv_t lldiv (long long, long long);
81
82int mblen (const char *, size_t);
83int mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
84int wctomb (char *, wchar_t);
85size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t);
86size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t);
87
88#define EXIT_FAILURE 1
89#define EXIT_SUCCESS 0
90
91size_t __ctype_get_mb_cur_max(void);
92#define MB_CUR_MAX (__ctype_get_mb_cur_max())
93
94#define RAND_MAX (0x7fffffff)
95
96
97#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
98 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
99 || defined(_BSD_SOURCE)
100
101#ifdef __wasilibc_unmodified_upstream /* WASI has no wait */
102#define WNOHANG 1
103#define WUNTRACED 2
104
105#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
106#define WTERMSIG(s) ((s) & 0x7f)
107#define WSTOPSIG(s) WEXITSTATUS(s)
108#define WIFEXITED(s) (!WTERMSIG(s))
109#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00)
110#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
111#endif
112
113int posix_memalign (void **, size_t, size_t);
114int setenv (const char *, const char *, int);
115int unsetenv (const char *);
116#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
117int mkstemp (char *);
118int mkostemp (char *, int);
119char *mkdtemp (char *);
120#endif
121int getsubopt (char **, char *const *, char **);
122int rand_r (unsigned *);
123
124#endif
125
126
127#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
128 || defined(_BSD_SOURCE)
129#ifdef __wasilibc_unmodified_upstream /* WASI has no absolute paths */
130char *realpath (const char *__restrict, char *__restrict);
131#endif
132long int random (void);
133void srandom (unsigned int);
134char *initstate (unsigned int, char *, size_t);
135char *setstate (char *);
136int putenv (char *);
137#ifdef __wasilibc_unmodified_upstream /* WASI has no pseudo-terminals */
138int posix_openpt (int);
139int grantpt (int);
140int unlockpt (int);
141char *ptsname (int);
142#endif
143char *l64a (long);
144long a64l (const char *);
145void setkey (const char *);
146double drand48 (void);
147double erand48 (unsigned short [3]);
148long int lrand48 (void);
149long int nrand48 (unsigned short [3]);
150long mrand48 (void);
151long jrand48 (unsigned short [3]);
152void srand48 (long);
153unsigned short *seed48 (unsigned short [3]);
154void lcong48 (unsigned short [7]);
155#endif
156
157#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
158#include <alloca.h>
159#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
160char *mktemp (char *);
161int mkstemps (char *, int);
162int mkostemps (char *, int, int);
163#endif
164#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
165void *valloc (size_t);
166void *memalign(size_t, size_t);
167int getloadavg(double *, int);
168#endif
169int clearenv(void);
170#ifdef __wasilibc_unmodified_upstream /* WASI has no wait */
171#define WCOREDUMP(s) ((s) & 0x80)
172#define WIFCONTINUED(s) ((s) == 0xffff)
173void *reallocarray (void *, size_t, size_t);
174#endif
175#endif
176
177#ifdef _GNU_SOURCE
178#ifdef __wasilibc_unmodified_upstream /* WASI has no pseudo-terminals */
179int ptsname_r(int, char *, size_t);
180#endif
181char *ecvt(double, int, int *, int *);
182char *fcvt(double, int, int *, int *);
183char *gcvt(double, int, char *);
184char *secure_getenv(const char *);
185struct __locale_struct;
186float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *);
187double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *);
188long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *);
189#endif
190
191#ifdef __wasilibc_unmodified_upstream /* WASI has no temp directories */
192#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
193#define mkstemp64 mkstemp
194#define mkostemp64 mkostemp
195#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
196#define mkstemps64 mkstemps
197#define mkostemps64 mkostemps
198#endif
199#endif
200#endif
201
202#ifdef __wasilibc_unmodified_upstream /* Declare arc4random functions */
203#else
204#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
205#include <stdint.h>
206uint32_t arc4random(void);
207void arc4random_buf(void *, size_t);
208uint32_t arc4random_uniform(uint32_t);
209#endif
210#endif
211
212#ifdef __cplusplus
213}
214#endif
215
216#endif
lib/libc/include/wasm32-wasi/stdnoreturn.h deleted-7
......@@ -1,7 +0,0 @@
1#ifndef _STDNORETURN_H
2#define _STDNORETURN_H
3#ifndef __cplusplus
4#include <features.h>
5#define noreturn _Noreturn
6#endif
7#endif
lib/libc/include/wasm32-wasi/string.h deleted-126
......@@ -1,126 +0,0 @@
1#ifndef _STRING_H
2#define _STRING_H
3
4#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
5#else
6#include <__header_string.h>
7#endif
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <features.h>
13
14#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
15#ifdef __cplusplus
16#define NULL 0L
17#else
18#define NULL ((void*)0)
19#endif
20#else
21#define __need_NULL
22#include <stddef.h>
23#endif
24
25#define __NEED_size_t
26#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
27 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
28 || defined(_BSD_SOURCE)
29#define __NEED_locale_t
30#endif
31
32#include <bits/alltypes.h>
33
34#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
35void *memcpy (void *__restrict, const void *__restrict, size_t);
36void *memmove (void *, const void *, size_t);
37void *memset (void *, int, size_t);
38#endif
39int memcmp (const void *, const void *, size_t);
40#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
41void *memchr (const void *, int, size_t);
42#endif
43
44char *strcpy (char *__restrict, const char *__restrict);
45char *strncpy (char *__restrict, const char *__restrict, size_t);
46
47char *strcat (char *__restrict, const char *__restrict);
48char *strncat (char *__restrict, const char *__restrict, size_t);
49
50#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
51int strcmp (const char *, const char *);
52#endif
53int strncmp (const char *, const char *, size_t);
54
55int strcoll (const char *, const char *);
56size_t strxfrm (char *__restrict, const char *__restrict, size_t);
57
58char *strchr (const char *, int);
59char *strrchr (const char *, int);
60
61size_t strcspn (const char *, const char *);
62size_t strspn (const char *, const char *);
63char *strpbrk (const char *, const char *);
64char *strstr (const char *, const char *);
65char *strtok (char *__restrict, const char *__restrict);
66
67#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
68size_t strlen (const char *);
69#endif
70
71char *strerror (int);
72
73#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
74#include <strings.h>
75#endif
76
77#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
78 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
79 || defined(_BSD_SOURCE)
80char *strtok_r (char *__restrict, const char *__restrict, char **__restrict);
81int strerror_r (int, char *, size_t);
82char *stpcpy(char *__restrict, const char *__restrict);
83char *stpncpy(char *__restrict, const char *__restrict, size_t);
84size_t strnlen (const char *, size_t);
85#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
86char *strdup (const char *);
87#endif
88char *strndup (const char *, size_t);
89char *strsignal(int);
90char *strerror_l (int, locale_t);
91int strcoll_l (const char *, const char *, locale_t);
92size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
93#endif
94
95#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
96 || defined(_BSD_SOURCE)
97void *memccpy (void *__restrict, const void *__restrict, int, size_t);
98#endif
99
100#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
101char *strsep(char **, const char *);
102size_t strlcat (char *, const char *, size_t);
103size_t strlcpy (char *, const char *, size_t);
104void explicit_bzero (void *, size_t);
105#endif
106
107#ifdef _GNU_SOURCE
108#define strdupa(x) strcpy(alloca(strlen(x)+1),x)
109int strverscmp (const char *, const char *);
110char *strchrnul(const char *, int);
111char *strcasestr(const char *, const char *);
112void *memmem(const void *, size_t, const void *, size_t);
113void *memrchr(const void *, int, size_t);
114void *mempcpy(void *, const void *, size_t);
115#ifdef __wasilibc_unmodified_upstream /* avoid unprototyped decls; use <libgen.h> */
116#ifndef __cplusplus
117char *basename();
118#endif
119#endif
120#endif
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif
lib/libc/include/wasm32-wasi/strings.h deleted-39
......@@ -1,39 +0,0 @@
1#ifndef _STRINGS_H
2#define _STRINGS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8
9#define __NEED_size_t
10#define __NEED_locale_t
11#include <bits/alltypes.h>
12
13#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
14 || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
15 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
16int bcmp (const void *, const void *, size_t);
17void bcopy (const void *, void *, size_t);
18void bzero (void *, size_t);
19char *index (const char *, int);
20char *rindex (const char *, int);
21#endif
22
23#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
24int ffs (int);
25int ffsl (long);
26int ffsll (long long);
27#endif
28
29int strcasecmp (const char *, const char *);
30int strncasecmp (const char *, const char *, size_t);
31
32int strcasecmp_l (const char *, const char *, locale_t);
33int strncasecmp_l (const char *, const char *, size_t, locale_t);
34
35#ifdef __cplusplus
36}
37#endif
38
39#endif
lib/libc/include/wasm32-wasi/stropts.h deleted-139
......@@ -1,139 +0,0 @@
1#ifndef _STROPTS_H
2#define _STROPTS_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __SID ('S' << 8)
9
10#define I_NREAD (__SID | 1)
11#define I_PUSH (__SID | 2)
12#define I_POP (__SID | 3)
13#define I_LOOK (__SID | 4)
14#define I_FLUSH (__SID | 5)
15#define I_SRDOPT (__SID | 6)
16#define I_GRDOPT (__SID | 7)
17#define I_STR (__SID | 8)
18#define I_SETSIG (__SID | 9)
19#define I_GETSIG (__SID |10)
20#define I_FIND (__SID |11)
21#define I_LINK (__SID |12)
22#define I_UNLINK (__SID |13)
23#define I_PEEK (__SID |15)
24#define I_FDINSERT (__SID |16)
25#define I_SENDFD (__SID |17)
26#define I_RECVFD (__SID |14)
27#define I_SWROPT (__SID |19)
28#define I_GWROPT (__SID |20)
29#define I_LIST (__SID |21)
30#define I_PLINK (__SID |22)
31#define I_PUNLINK (__SID |23)
32#define I_FLUSHBAND (__SID |28)
33#define I_CKBAND (__SID |29)
34#define I_GETBAND (__SID |30)
35#define I_ATMARK (__SID |31)
36#define I_SETCLTIME (__SID |32)
37#define I_GETCLTIME (__SID |33)
38#define I_CANPUT (__SID |34)
39
40#define FMNAMESZ 8
41
42#define FLUSHR 0x01
43#define FLUSHW 0x02
44#define FLUSHRW 0x03
45#define FLUSHBAND 0x04
46
47#define S_INPUT 0x0001
48#define S_HIPRI 0x0002
49#define S_OUTPUT 0x0004
50#define S_MSG 0x0008
51#define S_ERROR 0x0010
52#define S_HANGUP 0x0020
53#define S_RDNORM 0x0040
54#define S_WRNORM S_OUTPUT
55#define S_RDBAND 0x0080
56#define S_WRBAND 0x0100
57#define S_BANDURG 0x0200
58
59#define RS_HIPRI 0x01
60
61#define RNORM 0x0000
62#define RMSGD 0x0001
63#define RMSGN 0x0002
64#define RPROTDAT 0x0004
65#define RPROTDIS 0x0008
66#define RPROTNORM 0x0010
67#define RPROTMASK 0x001C
68
69#define SNDZERO 0x001
70#define SNDPIPE 0x002
71
72#define ANYMARK 0x01
73#define LASTMARK 0x02
74
75#define MUXID_ALL (-1)
76
77#define MSG_HIPRI 0x01
78#define MSG_ANY 0x02
79#define MSG_BAND 0x04
80
81#define MORECTL 1
82#define MOREDATA 2
83
84struct bandinfo {
85 unsigned char bi_pri;
86 int bi_flag;
87};
88
89struct strbuf {
90 int maxlen;
91 int len;
92 char *buf;
93};
94
95struct strpeek {
96 struct strbuf ctlbuf;
97 struct strbuf databuf;
98 unsigned flags;
99};
100
101struct strfdinsert {
102 struct strbuf ctlbuf;
103 struct strbuf databuf;
104 unsigned flags;
105 int fildes;
106 int offset;
107};
108
109struct strioctl {
110 int ic_cmd;
111 int ic_timout;
112 int ic_len;
113 char *ic_dp;
114};
115
116struct strrecvfd {
117 int fd;
118 int uid;
119 int gid;
120 char __fill[8];
121};
122
123struct str_mlist {
124 char l_name[FMNAMESZ + 1];
125};
126
127struct str_list {
128 int sl_nmods;
129 struct str_mlist *sl_modlist;
130};
131
132int isastream(int);
133int ioctl(int, int, ...);
134
135#ifdef __cplusplus
136}
137#endif
138
139#endif
lib/libc/include/wasm32-wasi/sys/dir.h deleted-2
......@@ -1,2 +0,0 @@
1#include <dirent.h>
2#define direct dirent
lib/libc/include/wasm32-wasi/sys/errno.h deleted-2
......@@ -1,2 +0,0 @@
1#warning redirecting incorrect #include <sys/errno.h> to <errno.h>
2#include <errno.h>
lib/libc/include/wasm32-wasi/sys/eventfd.h deleted-26
......@@ -1,26 +0,0 @@
1#ifndef _SYS_EVENTFD_H
2#define _SYS_EVENTFD_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <fcntl.h>
10
11typedef uint64_t eventfd_t;
12
13#define EFD_SEMAPHORE 1
14#define EFD_CLOEXEC O_CLOEXEC
15#define EFD_NONBLOCK O_NONBLOCK
16
17int eventfd(unsigned int, int);
18int eventfd_read(int, eventfd_t *);
19int eventfd_write(int, eventfd_t);
20
21
22#ifdef __cplusplus
23}
24#endif
25
26#endif /* sys/eventfd.h */
lib/libc/include/wasm32-wasi/sys/fcntl.h deleted-2
......@@ -1,2 +0,0 @@
1#warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
2#include <fcntl.h>
lib/libc/include/wasm32-wasi/sys/file.h deleted-21
......@@ -1,21 +0,0 @@
1#ifndef _SYS_FILE_H
2#define _SYS_FILE_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#define LOCK_SH 1
8#define LOCK_EX 2
9#define LOCK_NB 4
10#define LOCK_UN 8
11
12#define L_SET 0
13#define L_INCR 1
14#define L_XTND 2
15
16int flock(int, int);
17
18#ifdef __cplusplus
19}
20#endif
21#endif
lib/libc/include/wasm32-wasi/sys/ioctl.h deleted-124
......@@ -1,124 +0,0 @@
1#ifndef _SYS_IOCTL_H
2#define _SYS_IOCTL_H
3#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_struct_winsize
9
10#include <bits/alltypes.h>
11#include <bits/ioctl.h>
12
13#define N_TTY 0
14#define N_SLIP 1
15#define N_MOUSE 2
16#define N_PPP 3
17#define N_STRIP 4
18#define N_AX25 5
19#define N_X25 6
20#define N_6PACK 7
21#define N_MASC 8
22#define N_R3964 9
23#define N_PROFIBUS_FDL 10
24#define N_IRDA 11
25#define N_SMSBLOCK 12
26#define N_HDLC 13
27#define N_SYNC_PPP 14
28#define N_HCI 15
29#define N_GIGASET_M101 16
30#define N_SLCAN 17
31#define N_PPS 18
32#define N_V253 19
33#define N_CAIF 20
34#define N_GSM0710 21
35#define N_TI_WL 22
36#define N_TRACESINK 23
37#define N_TRACEROUTER 24
38#define N_NCI 25
39#define N_SPEAKUP 26
40#define N_NULL 27
41
42#define TIOCPKT_DATA 0
43#define TIOCPKT_FLUSHREAD 1
44#define TIOCPKT_FLUSHWRITE 2
45#define TIOCPKT_STOP 4
46#define TIOCPKT_START 8
47#define TIOCPKT_NOSTOP 16
48#define TIOCPKT_DOSTOP 32
49#define TIOCPKT_IOCTL 64
50
51#define TIOCSER_TEMT 1
52
53#define SIOCADDRT 0x890B
54#define SIOCDELRT 0x890C
55#define SIOCRTMSG 0x890D
56
57#define SIOCGIFNAME 0x8910
58#define SIOCSIFLINK 0x8911
59#define SIOCGIFCONF 0x8912
60#define SIOCGIFFLAGS 0x8913
61#define SIOCSIFFLAGS 0x8914
62#define SIOCGIFADDR 0x8915
63#define SIOCSIFADDR 0x8916
64#define SIOCGIFDSTADDR 0x8917
65#define SIOCSIFDSTADDR 0x8918
66#define SIOCGIFBRDADDR 0x8919
67#define SIOCSIFBRDADDR 0x891a
68#define SIOCGIFNETMASK 0x891b
69#define SIOCSIFNETMASK 0x891c
70#define SIOCGIFMETRIC 0x891d
71#define SIOCSIFMETRIC 0x891e
72#define SIOCGIFMEM 0x891f
73#define SIOCSIFMEM 0x8920
74#define SIOCGIFMTU 0x8921
75#define SIOCSIFMTU 0x8922
76#define SIOCSIFNAME 0x8923
77#define SIOCSIFHWADDR 0x8924
78#define SIOCGIFENCAP 0x8925
79#define SIOCSIFENCAP 0x8926
80#define SIOCGIFHWADDR 0x8927
81#define SIOCGIFSLAVE 0x8929
82#define SIOCSIFSLAVE 0x8930
83#define SIOCADDMULTI 0x8931
84#define SIOCDELMULTI 0x8932
85#define SIOCGIFINDEX 0x8933
86#define SIOGIFINDEX SIOCGIFINDEX
87#define SIOCSIFPFLAGS 0x8934
88#define SIOCGIFPFLAGS 0x8935
89#define SIOCDIFADDR 0x8936
90#define SIOCSIFHWBROADCAST 0x8937
91#define SIOCGIFCOUNT 0x8938
92
93#define SIOCGIFBR 0x8940
94#define SIOCSIFBR 0x8941
95
96#define SIOCGIFTXQLEN 0x8942
97#define SIOCSIFTXQLEN 0x8943
98
99#define SIOCDARP 0x8953
100#define SIOCGARP 0x8954
101#define SIOCSARP 0x8955
102
103#define SIOCDRARP 0x8960
104#define SIOCGRARP 0x8961
105#define SIOCSRARP 0x8962
106
107#define SIOCGIFMAP 0x8970
108#define SIOCSIFMAP 0x8971
109
110#define SIOCADDDLCI 0x8980
111#define SIOCDELDLCI 0x8981
112
113#define SIOCDEVPRIVATE 0x89F0
114#define SIOCPROTOPRIVATE 0x89E0
115
116int ioctl (int, int, ...);
117
118#ifdef __cplusplus
119}
120#endif
121#else
122#include <__header_sys_ioctl.h>
123#endif
124#endif
lib/libc/include/wasm32-wasi/sys/mman.h deleted-156
......@@ -1,156 +0,0 @@
1#ifndef _WASI_EMULATED_MMAN
2#error "WASI lacks a true mmap; to enable minimal mmap emulation, \
3compile with -D_WASI_EMULATED_MMAN and link with -lwasi-emulated-mman"
4#else
5#ifndef _SYS_MMAN_H
6#define _SYS_MMAN_H
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#include <features.h>
12
13#define __NEED_mode_t
14#define __NEED_size_t
15#define __NEED_off_t
16
17#if defined(_GNU_SOURCE)
18#define __NEED_ssize_t
19#endif
20
21#include <bits/alltypes.h>
22
23#define MAP_FAILED ((void *) -1)
24
25#define MAP_SHARED 0x01
26#define MAP_PRIVATE 0x02
27#define MAP_SHARED_VALIDATE 0x03
28#define MAP_TYPE 0x0f
29#define MAP_FIXED 0x10
30#define MAP_ANON 0x20
31#define MAP_ANONYMOUS MAP_ANON
32#define MAP_NORESERVE 0x4000
33#define MAP_GROWSDOWN 0x0100
34#define MAP_DENYWRITE 0x0800
35#define MAP_EXECUTABLE 0x1000
36#define MAP_LOCKED 0x2000
37#define MAP_POPULATE 0x8000
38#define MAP_NONBLOCK 0x10000
39#define MAP_STACK 0x20000
40#define MAP_HUGETLB 0x40000
41#define MAP_SYNC 0x80000
42#define MAP_FIXED_NOREPLACE 0x100000
43#define MAP_FILE 0
44
45#define MAP_HUGE_SHIFT 26
46#define MAP_HUGE_MASK 0x3f
47#define MAP_HUGE_64KB (16 << 26)
48#define MAP_HUGE_512KB (19 << 26)
49#define MAP_HUGE_1MB (20 << 26)
50#define MAP_HUGE_2MB (21 << 26)
51#define MAP_HUGE_8MB (23 << 26)
52#define MAP_HUGE_16MB (24 << 26)
53#define MAP_HUGE_32MB (25 << 26)
54#define MAP_HUGE_256MB (28 << 26)
55#define MAP_HUGE_512MB (29 << 26)
56#define MAP_HUGE_1GB (30 << 26)
57#define MAP_HUGE_2GB (31 << 26)
58#define MAP_HUGE_16GB (34U << 26)
59
60#define PROT_NONE 0
61#define PROT_READ 1
62#define PROT_WRITE 2
63#define PROT_EXEC 4
64#define PROT_GROWSDOWN 0x01000000
65#define PROT_GROWSUP 0x02000000
66
67#define MS_ASYNC 1
68#define MS_INVALIDATE 2
69#define MS_SYNC 4
70
71#define MCL_CURRENT 1
72#define MCL_FUTURE 2
73#define MCL_ONFAULT 4
74
75#define POSIX_MADV_NORMAL 0
76#define POSIX_MADV_RANDOM 1
77#define POSIX_MADV_SEQUENTIAL 2
78#define POSIX_MADV_WILLNEED 3
79#define POSIX_MADV_DONTNEED 4
80
81#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
82#define MADV_NORMAL 0
83#define MADV_RANDOM 1
84#define MADV_SEQUENTIAL 2
85#define MADV_WILLNEED 3
86#define MADV_DONTNEED 4
87#define MADV_FREE 8
88#define MADV_REMOVE 9
89#define MADV_DONTFORK 10
90#define MADV_DOFORK 11
91#define MADV_MERGEABLE 12
92#define MADV_UNMERGEABLE 13
93#define MADV_HUGEPAGE 14
94#define MADV_NOHUGEPAGE 15
95#define MADV_DONTDUMP 16
96#define MADV_DODUMP 17
97#define MADV_WIPEONFORK 18
98#define MADV_KEEPONFORK 19
99#define MADV_COLD 20
100#define MADV_PAGEOUT 21
101#define MADV_HWPOISON 100
102#define MADV_SOFT_OFFLINE 101
103#endif
104
105#ifdef _GNU_SOURCE
106#define MREMAP_MAYMOVE 1
107#define MREMAP_FIXED 2
108#define MREMAP_DONTUNMAP 4
109
110#define MLOCK_ONFAULT 0x01
111
112#define MFD_CLOEXEC 0x0001U
113#define MFD_ALLOW_SEALING 0x0002U
114#define MFD_HUGETLB 0x0004U
115#endif
116
117#include <bits/mman.h>
118
119void *mmap (void *, size_t, int, int, int, off_t);
120int munmap (void *, size_t);
121
122int mprotect (void *, size_t, int);
123int msync (void *, size_t, int);
124
125int posix_madvise (void *, size_t, int);
126
127int mlock (const void *, size_t);
128int munlock (const void *, size_t);
129int mlockall (int);
130int munlockall (void);
131
132#ifdef _GNU_SOURCE
133void *mremap (void *, size_t, size_t, int, ...);
134int remap_file_pages (void *, size_t, int, size_t, int);
135int memfd_create (const char *, unsigned);
136int mlock2 (const void *, size_t, unsigned);
137#endif
138
139#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
140int madvise (void *, size_t, int);
141int mincore (void *, size_t, unsigned char *);
142#endif
143
144int shm_open (const char *, int, mode_t);
145int shm_unlink (const char *);
146
147#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
148#define mmap64 mmap
149#define off64_t off_t
150#endif
151
152#ifdef __cplusplus
153}
154#endif
155#endif
156#endif
lib/libc/include/wasm32-wasi/sys/param.h deleted-37
......@@ -1,37 +0,0 @@
1#ifndef _SYS_PARAM_H
2#define _SYS_PARAM_H
3
4#define MAXSYMLINKS 20
5#define MAXHOSTNAMELEN 64
6#define MAXNAMLEN 255
7#define MAXPATHLEN 4096
8#define NBBY 8
9#define NGROUPS 32
10#define CANBSIZ 255
11#define NOFILE 256
12#define NCARGS 131072
13#define DEV_BSIZE 512
14#define NOGROUP (-1)
15
16#undef MIN
17#undef MAX
18#define MIN(a,b) (((a)<(b))?(a):(b))
19#define MAX(a,b) (((a)>(b))?(a):(b))
20
21#define __bitop(x,i,o) ((x)[(i)/8] o (1<<(i)%8))
22#define setbit(x,i) __bitop(x,i,|=)
23#define clrbit(x,i) __bitop(x,i,&=~)
24#define isset(x,i) __bitop(x,i,&)
25#define isclr(x,i) !isset(x,i)
26
27#define howmany(n,d) (((n)+((d)-1))/(d))
28#define roundup(n,d) (howmany(n,d)*(d))
29#define powerof2(n) !(((n)-1) & (n))
30
31#if defined(__wasilibc_unmodified_upstream) || defined(_WASI_EMULATED_PROCESS_CLOCKS)
32#include <sys/resource.h>
33#endif
34#include <endian.h>
35#include <limits.h>
36
37#endif
lib/libc/include/wasm32-wasi/sys/poll.h deleted-2
......@@ -1,2 +0,0 @@
1#warning redirecting incorrect #include <sys/poll.h> to <poll.h>
2#include <poll.h>
lib/libc/include/wasm32-wasi/sys/random.h deleted-27
......@@ -1,27 +0,0 @@
1#ifndef _SYS_RANDOM_H
2#define _SYS_RANDOM_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#ifdef __wasilibc_unmodified_upstream /* WASI has no getrandom, but it does have getentropy */
8#define __NEED_size_t
9#define __NEED_ssize_t
10#include <bits/alltypes.h>
11
12#define GRND_NONBLOCK 0x0001
13#define GRND_RANDOM 0x0002
14#define GRND_INSECURE 0x0004
15
16ssize_t getrandom(void *, size_t, unsigned);
17#else
18#define __NEED_size_t
19#include <bits/alltypes.h>
20
21int getentropy(void *, size_t);
22#endif
23
24#ifdef __cplusplus
25}
26#endif
27#endif
lib/libc/include/wasm32-wasi/sys/reg.h deleted-9
......@@ -1,9 +0,0 @@
1#ifndef _SYS_REG_H
2#define _SYS_REG_H
3
4#include <limits.h>
5#include <unistd.h>
6
7#include <bits/reg.h>
8
9#endif
lib/libc/include/wasm32-wasi/sys/resource.h deleted-126
......@@ -1,126 +0,0 @@
1#ifndef _WASI_EMULATED_PROCESS_CLOCKS
2#error WASI lacks process-associated clocks; to enable emulation of the `getrusage` function using \
3the wall clock, which isn't sensitive to whether the program is running or suspended, \
4compile with -D_WASI_EMULATED_PROCESS_CLOCKS and link with -lwasi-emulated-process-clocks
5#else
6#ifndef _SYS_RESOURCE_H
7#define _SYS_RESOURCE_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#include <features.h>
14#include <sys/time.h>
15
16#define __NEED_id_t
17
18#ifdef _GNU_SOURCE
19#define __NEED_pid_t
20#endif
21
22#include <bits/alltypes.h>
23#include <bits/resource.h>
24
25#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
26typedef unsigned long long rlim_t;
27
28struct rlimit {
29 rlim_t rlim_cur;
30 rlim_t rlim_max;
31};
32
33struct rusage {
34 struct timeval ru_utime;
35 struct timeval ru_stime;
36 /* linux extentions, but useful */
37 long ru_maxrss;
38 long ru_ixrss;
39 long ru_idrss;
40 long ru_isrss;
41 long ru_minflt;
42 long ru_majflt;
43 long ru_nswap;
44 long ru_inblock;
45 long ru_oublock;
46 long ru_msgsnd;
47 long ru_msgrcv;
48 long ru_nsignals;
49 long ru_nvcsw;
50 long ru_nivcsw;
51 /* room for more... */
52 long __reserved[16];
53};
54
55int getrlimit (int, struct rlimit *);
56int setrlimit (int, const struct rlimit *);
57int getrusage (int, struct rusage *);
58
59int getpriority (int, id_t);
60int setpriority (int, id_t, int);
61
62#ifdef _GNU_SOURCE
63int prlimit(pid_t, int, const struct rlimit *, struct rlimit *);
64#define prlimit64 prlimit
65#endif
66
67#define PRIO_MIN (-20)
68#define PRIO_MAX 20
69
70#define PRIO_PROCESS 0
71#define PRIO_PGRP 1
72#define PRIO_USER 2
73
74#define RUSAGE_SELF 0
75#define RUSAGE_CHILDREN (-1)
76#define RUSAGE_THREAD 1
77
78#define RLIM_INFINITY (~0ULL)
79#define RLIM_SAVED_CUR RLIM_INFINITY
80#define RLIM_SAVED_MAX RLIM_INFINITY
81
82#define RLIMIT_CPU 0
83#define RLIMIT_FSIZE 1
84#define RLIMIT_DATA 2
85#define RLIMIT_STACK 3
86#define RLIMIT_CORE 4
87#ifndef RLIMIT_RSS
88#define RLIMIT_RSS 5
89#define RLIMIT_NPROC 6
90#define RLIMIT_NOFILE 7
91#define RLIMIT_MEMLOCK 8
92#define RLIMIT_AS 9
93#endif
94#define RLIMIT_LOCKS 10
95#define RLIMIT_SIGPENDING 11
96#define RLIMIT_MSGQUEUE 12
97#define RLIMIT_NICE 13
98#define RLIMIT_RTPRIO 14
99#define RLIMIT_RTTIME 15
100#define RLIMIT_NLIMITS 16
101
102#define RLIM_NLIMITS RLIMIT_NLIMITS
103
104#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
105#define RLIM64_INFINITY RLIM_INFINITY
106#define RLIM64_SAVED_CUR RLIM_SAVED_CUR
107#define RLIM64_SAVED_MAX RLIM_SAVED_MAX
108#define getrlimit64 getrlimit
109#define setrlimit64 setrlimit
110#define rlimit64 rlimit
111#define rlim64_t rlim_t
112#endif
113#else
114#include <__header_sys_resource.h>
115#endif
116
117#if _REDIR_TIME64
118__REDIR(getrusage, __getrusage_time64);
119#endif
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif
126#endif
lib/libc/include/wasm32-wasi/sys/select.h deleted-54
......@@ -1,54 +0,0 @@
1#ifndef _SYS_SELECT_H
2#define _SYS_SELECT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_size_t
10#define __NEED_time_t
11#define __NEED_suseconds_t
12#define __NEED_struct_timeval
13#define __NEED_struct_timespec
14#define __NEED_sigset_t
15
16#include <bits/alltypes.h>
17
18#define FD_SETSIZE 1024
19
20#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
21typedef unsigned long fd_mask;
22#endif
23
24#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
25typedef struct {
26 unsigned long fds_bits[FD_SETSIZE / 8 / sizeof(long)];
27} fd_set;
28
29#define FD_ZERO(s) do { int __i; unsigned long *__b=(s)->fds_bits; for(__i=sizeof (fd_set)/sizeof (long); __i; __i--) *__b++=0; } while(0)
30#define FD_SET(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1UL<<((d)%(8*sizeof(long)))))
31#define FD_CLR(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1UL<<((d)%(8*sizeof(long)))))
32#define FD_ISSET(d, s) !!((s)->fds_bits[(d)/(8*sizeof(long))] & (1UL<<((d)%(8*sizeof(long)))))
33#else
34#include <__fd_set.h>
35#endif
36
37int select (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict);
38int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
39
40#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
41#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
42#define NFDBITS (8*(int)sizeof(long))
43#endif
44#endif
45
46#if _REDIR_TIME64
47__REDIR(select, __select_time64);
48__REDIR(pselect, __pselect_time64);
49#endif
50
51#ifdef __cplusplus
52}
53#endif
54#endif
lib/libc/include/wasm32-wasi/sys/signal.h deleted-2
......@@ -1,2 +0,0 @@
1#warning redirecting incorrect #include <sys/signal.h> to <signal.h>
2#include <signal.h>
lib/libc/include/wasm32-wasi/sys/socket.h deleted-445
......@@ -1,445 +0,0 @@
1#ifndef _SYS_SOCKET_H
2#define _SYS_SOCKET_H
3#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
4#else
5#include <__header_sys_socket.h>
6#endif
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#include <features.h>
12
13#define __NEED_socklen_t
14#define __NEED_sa_family_t
15#define __NEED_size_t
16#define __NEED_ssize_t
17#define __NEED_uid_t
18#define __NEED_pid_t
19#define __NEED_gid_t
20#define __NEED_struct_iovec
21
22#include <bits/alltypes.h>
23
24#include <bits/socket.h>
25
26#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
27struct msghdr {
28 void *msg_name;
29 socklen_t msg_namelen;
30 struct iovec *msg_iov;
31#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN
32 int __pad1;
33#endif
34 int msg_iovlen;
35#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN
36 int __pad1;
37#endif
38 void *msg_control;
39#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN
40 int __pad2;
41#endif
42 socklen_t msg_controllen;
43#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN
44 int __pad2;
45#endif
46 int msg_flags;
47};
48
49struct cmsghdr {
50#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN
51 int __pad1;
52#endif
53 socklen_t cmsg_len;
54#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN
55 int __pad1;
56#endif
57 int cmsg_level;
58 int cmsg_type;
59};
60#else
61#include <__struct_msghdr.h>
62#endif
63
64#ifdef _GNU_SOURCE
65struct ucred {
66 pid_t pid;
67 uid_t uid;
68 gid_t gid;
69};
70
71struct mmsghdr {
72 struct msghdr msg_hdr;
73 unsigned int msg_len;
74};
75
76struct timespec;
77
78int sendmmsg (int, struct mmsghdr *, unsigned int, unsigned int);
79int recvmmsg (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *);
80#endif
81
82struct linger {
83 int l_onoff;
84 int l_linger;
85};
86
87#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
88#define SHUT_RD 0
89#define SHUT_WR 1
90#define SHUT_RDWR 2
91
92#ifndef SOCK_STREAM
93#define SOCK_STREAM 1
94#define SOCK_DGRAM 2
95#endif
96
97#define SOCK_RAW 3
98#define SOCK_RDM 4
99#define SOCK_SEQPACKET 5
100#define SOCK_DCCP 6
101#define SOCK_PACKET 10
102
103#ifndef SOCK_CLOEXEC
104#define SOCK_CLOEXEC 02000000
105#define SOCK_NONBLOCK 04000
106#endif
107
108#define PF_UNSPEC 0
109#define PF_LOCAL 1
110#define PF_UNIX PF_LOCAL
111#define PF_FILE PF_LOCAL
112#define PF_INET 2
113#define PF_AX25 3
114#define PF_IPX 4
115#define PF_APPLETALK 5
116#define PF_NETROM 6
117#define PF_BRIDGE 7
118#define PF_ATMPVC 8
119#define PF_X25 9
120#define PF_INET6 10
121#define PF_ROSE 11
122#define PF_DECnet 12
123#define PF_NETBEUI 13
124#define PF_SECURITY 14
125#define PF_KEY 15
126#define PF_NETLINK 16
127#define PF_ROUTE PF_NETLINK
128#define PF_PACKET 17
129#define PF_ASH 18
130#define PF_ECONET 19
131#define PF_ATMSVC 20
132#define PF_RDS 21
133#define PF_SNA 22
134#define PF_IRDA 23
135#define PF_PPPOX 24
136#define PF_WANPIPE 25
137#define PF_LLC 26
138#define PF_IB 27
139#define PF_MPLS 28
140#define PF_CAN 29
141#define PF_TIPC 30
142#define PF_BLUETOOTH 31
143#define PF_IUCV 32
144#define PF_RXRPC 33
145#define PF_ISDN 34
146#define PF_PHONET 35
147#define PF_IEEE802154 36
148#define PF_CAIF 37
149#define PF_ALG 38
150#define PF_NFC 39
151#define PF_VSOCK 40
152#define PF_KCM 41
153#define PF_QIPCRTR 42
154#define PF_SMC 43
155#define PF_XDP 44
156#define PF_MAX 45
157
158#define AF_UNSPEC PF_UNSPEC
159#define AF_LOCAL PF_LOCAL
160#define AF_UNIX AF_LOCAL
161#define AF_FILE AF_LOCAL
162#define AF_INET PF_INET
163#define AF_AX25 PF_AX25
164#define AF_IPX PF_IPX
165#define AF_APPLETALK PF_APPLETALK
166#define AF_NETROM PF_NETROM
167#define AF_BRIDGE PF_BRIDGE
168#define AF_ATMPVC PF_ATMPVC
169#define AF_X25 PF_X25
170#define AF_INET6 PF_INET6
171#define AF_ROSE PF_ROSE
172#define AF_DECnet PF_DECnet
173#define AF_NETBEUI PF_NETBEUI
174#define AF_SECURITY PF_SECURITY
175#define AF_KEY PF_KEY
176#define AF_NETLINK PF_NETLINK
177#define AF_ROUTE PF_ROUTE
178#define AF_PACKET PF_PACKET
179#define AF_ASH PF_ASH
180#define AF_ECONET PF_ECONET
181#define AF_ATMSVC PF_ATMSVC
182#define AF_RDS PF_RDS
183#define AF_SNA PF_SNA
184#define AF_IRDA PF_IRDA
185#define AF_PPPOX PF_PPPOX
186#define AF_WANPIPE PF_WANPIPE
187#define AF_LLC PF_LLC
188#define AF_IB PF_IB
189#define AF_MPLS PF_MPLS
190#define AF_CAN PF_CAN
191#define AF_TIPC PF_TIPC
192#define AF_BLUETOOTH PF_BLUETOOTH
193#define AF_IUCV PF_IUCV
194#define AF_RXRPC PF_RXRPC
195#define AF_ISDN PF_ISDN
196#define AF_PHONET PF_PHONET
197#define AF_IEEE802154 PF_IEEE802154
198#define AF_CAIF PF_CAIF
199#define AF_ALG PF_ALG
200#define AF_NFC PF_NFC
201#define AF_VSOCK PF_VSOCK
202#define AF_KCM PF_KCM
203#define AF_QIPCRTR PF_QIPCRTR
204#define AF_SMC PF_SMC
205#define AF_XDP PF_XDP
206#define AF_MAX PF_MAX
207
208#ifndef SO_DEBUG
209#define SO_DEBUG 1
210#define SO_REUSEADDR 2
211#define SO_TYPE 3
212#define SO_ERROR 4
213#define SO_DONTROUTE 5
214#define SO_BROADCAST 6
215#define SO_SNDBUF 7
216#define SO_RCVBUF 8
217#define SO_KEEPALIVE 9
218#define SO_OOBINLINE 10
219#define SO_NO_CHECK 11
220#define SO_PRIORITY 12
221#define SO_LINGER 13
222#define SO_BSDCOMPAT 14
223#define SO_REUSEPORT 15
224#define SO_PASSCRED 16
225#define SO_PEERCRED 17
226#define SO_RCVLOWAT 18
227#define SO_SNDLOWAT 19
228#define SO_ACCEPTCONN 30
229#define SO_PEERSEC 31
230#define SO_SNDBUFFORCE 32
231#define SO_RCVBUFFORCE 33
232#define SO_PROTOCOL 38
233#define SO_DOMAIN 39
234#endif
235
236#ifndef SO_RCVTIMEO
237#if __LONG_MAX == 0x7fffffff
238#define SO_RCVTIMEO 66
239#define SO_SNDTIMEO 67
240#else
241#define SO_RCVTIMEO 20
242#define SO_SNDTIMEO 21
243#endif
244#endif
245
246#ifndef SO_TIMESTAMP
247#if __LONG_MAX == 0x7fffffff
248#define SO_TIMESTAMP 63
249#define SO_TIMESTAMPNS 64
250#define SO_TIMESTAMPING 65
251#else
252#define SO_TIMESTAMP 29
253#define SO_TIMESTAMPNS 35
254#define SO_TIMESTAMPING 37
255#endif
256#endif
257
258#define SO_SECURITY_AUTHENTICATION 22
259#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
260#define SO_SECURITY_ENCRYPTION_NETWORK 24
261
262#define SO_BINDTODEVICE 25
263
264#define SO_ATTACH_FILTER 26
265#define SO_DETACH_FILTER 27
266#define SO_GET_FILTER SO_ATTACH_FILTER
267
268#define SO_PEERNAME 28
269#define SCM_TIMESTAMP SO_TIMESTAMP
270#define SO_PASSSEC 34
271#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
272#define SO_MARK 36
273#define SCM_TIMESTAMPING SO_TIMESTAMPING
274#define SO_RXQ_OVFL 40
275#define SO_WIFI_STATUS 41
276#define SCM_WIFI_STATUS SO_WIFI_STATUS
277#define SO_PEEK_OFF 42
278#define SO_NOFCS 43
279#define SO_LOCK_FILTER 44
280#define SO_SELECT_ERR_QUEUE 45
281#define SO_BUSY_POLL 46
282#define SO_MAX_PACING_RATE 47
283#define SO_BPF_EXTENSIONS 48
284#define SO_INCOMING_CPU 49
285#define SO_ATTACH_BPF 50
286#define SO_DETACH_BPF SO_DETACH_FILTER
287#define SO_ATTACH_REUSEPORT_CBPF 51
288#define SO_ATTACH_REUSEPORT_EBPF 52
289#define SO_CNX_ADVICE 53
290#define SCM_TIMESTAMPING_OPT_STATS 54
291#define SO_MEMINFO 55
292#define SO_INCOMING_NAPI_ID 56
293#define SO_COOKIE 57
294#define SCM_TIMESTAMPING_PKTINFO 58
295#define SO_PEERGROUPS 59
296#define SO_ZEROCOPY 60
297#define SO_TXTIME 61
298#define SCM_TXTIME SO_TXTIME
299#define SO_BINDTOIFINDEX 62
300#define SO_DETACH_REUSEPORT_BPF 68
301
302#ifndef SOL_SOCKET
303#define SOL_SOCKET 1
304#endif
305
306#define SOL_IP 0
307#define SOL_IPV6 41
308#define SOL_ICMPV6 58
309
310#define SOL_RAW 255
311#define SOL_DECNET 261
312#define SOL_X25 262
313#define SOL_PACKET 263
314#define SOL_ATM 264
315#define SOL_AAL 265
316#define SOL_IRDA 266
317#define SOL_NETBEUI 267
318#define SOL_LLC 268
319#define SOL_DCCP 269
320#define SOL_NETLINK 270
321#define SOL_TIPC 271
322#define SOL_RXRPC 272
323#define SOL_PPPOL2TP 273
324#define SOL_BLUETOOTH 274
325#define SOL_PNPIPE 275
326#define SOL_RDS 276
327#define SOL_IUCV 277
328#define SOL_CAIF 278
329#define SOL_ALG 279
330#define SOL_NFC 280
331#define SOL_KCM 281
332#define SOL_TLS 282
333#define SOL_XDP 283
334
335#define SOMAXCONN 128
336
337#define MSG_OOB 0x0001
338#define MSG_PEEK 0x0002
339#define MSG_DONTROUTE 0x0004
340#define MSG_CTRUNC 0x0008
341#define MSG_PROXY 0x0010
342#define MSG_TRUNC 0x0020
343#define MSG_DONTWAIT 0x0040
344#define MSG_EOR 0x0080
345#define MSG_WAITALL 0x0100
346#define MSG_FIN 0x0200
347#define MSG_SYN 0x0400
348#define MSG_CONFIRM 0x0800
349#define MSG_RST 0x1000
350#define MSG_ERRQUEUE 0x2000
351#define MSG_NOSIGNAL 0x4000
352#define MSG_MORE 0x8000
353#define MSG_WAITFORONE 0x10000
354#define MSG_BATCH 0x40000
355#define MSG_ZEROCOPY 0x4000000
356#define MSG_FASTOPEN 0x20000000
357#define MSG_CMSG_CLOEXEC 0x40000000
358
359#define __CMSG_LEN(cmsg) (((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
360#define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg))
361#define __MHDR_END(mhdr) ((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen)
362
363#define CMSG_DATA(cmsg) ((unsigned char *) (((struct cmsghdr *)(cmsg)) + 1))
364#define CMSG_NXTHDR(mhdr, cmsg) ((cmsg)->cmsg_len < sizeof (struct cmsghdr) || \
365 __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
366 ? 0 : (struct cmsghdr *)__CMSG_NEXT(cmsg))
367#define CMSG_FIRSTHDR(mhdr) ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)
368
369#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))
370#define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
371#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
372
373#define SCM_RIGHTS 0x01
374#define SCM_CREDENTIALS 0x02
375#endif
376
377#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
378struct sockaddr {
379 sa_family_t sa_family;
380 char sa_data[14];
381};
382#else
383#include <__struct_sockaddr.h>
384#endif
385
386#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
387struct sockaddr_storage {
388 sa_family_t ss_family;
389 char __ss_padding[128-sizeof(long)-sizeof(sa_family_t)];
390 unsigned long __ss_align;
391};
392#else
393#include <__struct_sockaddr_storage.h>
394#endif
395
396#ifdef __wasilibc_unmodified_upstream /* WASI has no socket/socketpair */
397int socket (int, int, int);
398int socketpair (int, int, int, int [2]);
399#endif
400
401int shutdown (int, int);
402
403#ifdef __wasilibc_unmodified_upstream /* WASI has no bind/connect/listen/accept */
404int bind (int, const struct sockaddr *, socklen_t);
405int connect (int, const struct sockaddr *, socklen_t);
406int listen (int, int);
407int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
408int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int);
409#endif
410
411#ifdef __wasilibc_unmodified_upstream /* WASI has no getsockname/getpeername */
412int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
413int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict);
414#endif
415
416ssize_t send (int, const void *, size_t, int);
417ssize_t recv (int, void *, size_t, int);
418#ifdef __wasilibc_unmodified_upstream /* WASI has no sendto/recvfrom */
419ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
420ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
421#endif
422#ifdef __wasilibc_unmodified_upstream /* WASI has no sendmsg/recvmsg */
423ssize_t sendmsg (int, const struct msghdr *, int);
424ssize_t recvmsg (int, struct msghdr *, int);
425#endif
426
427int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict);
428#ifdef __wasilibc_unmodified_upstream /* WASI has no setsockopt */
429int setsockopt (int, int, int, const void *, socklen_t);
430#endif
431
432#ifdef __wasilibc_unmodified_upstream /* WASI has no sockatmark */
433int sockatmark (int);
434#endif
435
436#if _REDIR_TIME64
437#ifdef _GNU_SOURCE
438__REDIR(recvmmsg, __recvmmsg_time64);
439#endif
440#endif
441
442#ifdef __cplusplus
443}
444#endif
445#endif
lib/libc/include/wasm32-wasi/sys/stat.h deleted-143
......@@ -1,143 +0,0 @@
1#ifndef _SYS_STAT_H
2#define _SYS_STAT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_dev_t
10#define __NEED_ino_t
11#define __NEED_mode_t
12#define __NEED_nlink_t
13#define __NEED_uid_t
14#define __NEED_gid_t
15#define __NEED_off_t
16#define __NEED_time_t
17#define __NEED_blksize_t
18#define __NEED_blkcnt_t
19#define __NEED_struct_timespec
20
21#include <bits/alltypes.h>
22
23#include <bits/stat.h>
24
25#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
26#define st_atime st_atim.tv_sec
27#define st_mtime st_mtim.tv_sec
28#define st_ctime st_ctim.tv_sec
29
30#define S_IFMT 0170000
31
32#define S_IFDIR 0040000
33#define S_IFCHR 0020000
34#define S_IFBLK 0060000
35#define S_IFREG 0100000
36#define S_IFIFO 0010000
37#define S_IFLNK 0120000
38#define S_IFSOCK 0140000
39
40#define S_TYPEISMQ(buf) 0
41#define S_TYPEISSEM(buf) 0
42#define S_TYPEISSHM(buf) 0
43#define S_TYPEISTMO(buf) 0
44
45#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
46#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
47#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
48#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
49#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
50#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
51#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
52
53#ifndef S_IRUSR
54#define S_ISUID 04000
55#define S_ISGID 02000
56#define S_ISVTX 01000
57#define S_IRUSR 0400
58#define S_IWUSR 0200
59#define S_IXUSR 0100
60#define S_IRWXU 0700
61#define S_IRGRP 0040
62#define S_IWGRP 0020
63#define S_IXGRP 0010
64#define S_IRWXG 0070
65#define S_IROTH 0004
66#define S_IWOTH 0002
67#define S_IXOTH 0001
68#define S_IRWXO 0007
69#endif
70
71#define UTIME_NOW 0x3fffffff
72#define UTIME_OMIT 0x3ffffffe
73#else
74#include <__header_sys_stat.h>
75#endif
76
77int stat(const char *__restrict, struct stat *__restrict);
78int fstat(int, struct stat *);
79int lstat(const char *__restrict, struct stat *__restrict);
80int fstatat(int, const char *__restrict, struct stat *__restrict, int);
81#ifdef __wasilibc_unmodified_upstream /* WASI has no chmod */
82int chmod(const char *, mode_t);
83int fchmod(int, mode_t);
84int fchmodat(int, const char *, mode_t, int);
85#endif
86#ifdef __wasilibc_unmodified_upstream /* WASI has no umask */
87mode_t umask(mode_t);
88#endif
89int mkdir(const char *, mode_t);
90#ifdef __wasilibc_unmodified_upstream /* WASI has no fifo */
91int mkfifo(const char *, mode_t);
92#endif
93int mkdirat(int, const char *, mode_t);
94#ifdef __wasilibc_unmodified_upstream /* WASI has no fifo */
95int mkfifoat(int, const char *, mode_t);
96#endif
97
98#ifdef __wasilibc_unmodified_upstream /* WASI has no mknod */
99#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
100int mknod(const char *, mode_t, dev_t);
101int mknodat(int, const char *, mode_t, dev_t);
102#endif
103#endif
104
105int futimens(int, const struct timespec [2]);
106int utimensat(int, const char *, const struct timespec [2], int);
107
108#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
109#ifdef __wasilibc_unmodified_upstream /* WASI has no chmod */
110int lchmod(const char *, mode_t);
111#endif
112#define S_IREAD S_IRUSR
113#define S_IWRITE S_IWUSR
114#define S_IEXEC S_IXUSR
115#endif
116
117#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
118#define stat64 stat
119#define fstat64 fstat
120#define lstat64 lstat
121#define fstatat64 fstatat
122#define blkcnt64_t blkcnt_t
123#define fsblkcnt64_t fsblkcnt_t
124#define fsfilcnt64_t fsfilcnt_t
125#define ino64_t ino_t
126#define off64_t off_t
127#endif
128
129#if _REDIR_TIME64
130__REDIR(stat, __stat_time64);
131__REDIR(fstat, __fstat_time64);
132__REDIR(lstat, __lstat_time64);
133__REDIR(fstatat, __fstatat_time64);
134__REDIR(futimens, __futimens_time64);
135__REDIR(utimensat, __utimensat_time64);
136#endif
137
138#ifdef __cplusplus
139}
140#endif
141#endif
142
143
lib/libc/include/wasm32-wasi/sys/stropts.h deleted-1
......@@ -1 +0,0 @@
1#include <stropts.h>
lib/libc/include/wasm32-wasi/sys/syscall.h deleted-10
......@@ -1,10 +0,0 @@
1#ifndef _SYS_SYSCALL_H
2#define _SYS_SYSCALL_H
3
4#ifdef __wasilibc_unmodified_upstream /* WASI has no syscall */
5#include <bits/syscall.h>
6#else
7/* The generic syscall funtion is not yet implemented. */
8#endif
9
10#endif
lib/libc/include/wasm32-wasi/sys/sysinfo.h deleted-36
......@@ -1,36 +0,0 @@
1#ifndef _SYS_SYSINFO_H
2#define _SYS_SYSINFO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define SI_LOAD_SHIFT 16
9
10struct sysinfo {
11 unsigned long uptime;
12 unsigned long loads[3];
13 unsigned long totalram;
14 unsigned long freeram;
15 unsigned long sharedram;
16 unsigned long bufferram;
17 unsigned long totalswap;
18 unsigned long freeswap;
19 unsigned short procs, pad;
20 unsigned long totalhigh;
21 unsigned long freehigh;
22 unsigned mem_unit;
23 char __reserved[256];
24};
25
26int sysinfo (struct sysinfo *);
27int get_nprocs_conf (void);
28int get_nprocs (void);
29long get_phys_pages (void);
30long get_avphys_pages (void);
31
32#ifdef __cplusplus
33}
34#endif
35
36#endif
lib/libc/include/wasm32-wasi/sys/time.h deleted-84
......@@ -1,84 +0,0 @@
1#ifndef _SYS_TIME_H
2#define _SYS_TIME_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#include <sys/select.h>
10
11int gettimeofday (struct timeval *__restrict, void *__restrict);
12
13#ifdef __wasilibc_unmodified_upstream /* WASI has no getitimer */
14#define ITIMER_REAL 0
15#define ITIMER_VIRTUAL 1
16#define ITIMER_PROF 2
17
18struct itimerval {
19 struct timeval it_interval;
20 struct timeval it_value;
21};
22
23int getitimer (int, struct itimerval *);
24int setitimer (int, const struct itimerval *__restrict, struct itimerval *__restrict);
25#endif
26#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
27int utimes (const char *, const struct timeval [2]);
28#endif
29
30#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
31struct timezone {
32 int tz_minuteswest;
33 int tz_dsttime;
34};
35#ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
36int futimes(int, const struct timeval [2]);
37int futimesat(int, const char *, const struct timeval [2]);
38int lutimes(const char *, const struct timeval [2]);
39#endif
40#ifdef __wasilibc_unmodified_upstream /* WASI has no way to set the time */
41int settimeofday(const struct timeval *, const struct timezone *);
42int adjtime (const struct timeval *, struct timeval *);
43#endif
44#define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
45#define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
46#define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \
47 (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec)
48#define timeradd(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
49 ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
50 ((a)->tv_usec -= 1000000, (a)->tv_sec++) )
51#define timersub(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
52 ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
53 ((a)->tv_usec += 1000000, (a)->tv_sec--) )
54#endif
55
56#if defined(_GNU_SOURCE)
57#define TIMEVAL_TO_TIMESPEC(tv, ts) ( \
58 (ts)->tv_sec = (tv)->tv_sec, \
59 (ts)->tv_nsec = (tv)->tv_usec * 1000, \
60 (void)0 )
61#define TIMESPEC_TO_TIMEVAL(tv, ts) ( \
62 (tv)->tv_sec = (ts)->tv_sec, \
63 (tv)->tv_usec = (ts)->tv_nsec / 1000, \
64 (void)0 )
65#endif
66
67#if _REDIR_TIME64
68__REDIR(gettimeofday, __gettimeofday_time64);
69__REDIR(getitimer, __getitimer_time64);
70__REDIR(setitimer, __setitimer_time64);
71__REDIR(utimes, __utimes_time64);
72#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
73__REDIR(futimes, __futimes_time64);
74__REDIR(futimesat, __futimesat_time64);
75__REDIR(lutimes, __lutimes_time64);
76__REDIR(settimeofday, __settimeofday_time64);
77__REDIR(adjtime, __adjtime64);
78#endif
79#endif
80
81#ifdef __cplusplus
82}
83#endif
84#endif
lib/libc/include/wasm32-wasi/sys/timeb.h deleted-28
......@@ -1,28 +0,0 @@
1#ifndef _SYS_TIMEB_H
2#define _SYS_TIMEB_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_time_t
10
11#include <bits/alltypes.h>
12
13struct timeb {
14 time_t time;
15 unsigned short millitm;
16 short timezone, dstflag;
17};
18
19int ftime(struct timeb *);
20
21#if _REDIR_TIME64
22__REDIR(ftime, __ftime64);
23#endif
24
25#ifdef __cplusplus
26}
27#endif
28#endif
lib/libc/include/wasm32-wasi/sys/times.h deleted-34
......@@ -1,34 +0,0 @@
1#ifndef _WASI_EMULATED_PROCESS_CLOCKS
2#error WASI lacks process-associated clocks; to enable emulation of the `times` function using \
3the wall clock, which isn't sensitive to whether the program is running or suspended, \
4compile with -D_WASI_EMULATED_PROCESS_CLOCKS and link with -lwasi-emulated-process-clocks
5#else
6#ifndef _SYS_TIMES_H
7#define _SYS_TIMES_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#define __NEED_clock_t
14#include <bits/alltypes.h>
15
16#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
17struct tms {
18 clock_t tms_utime;
19 clock_t tms_stime;
20 clock_t tms_cutime;
21 clock_t tms_cstime;
22};
23#else
24#include <__struct_tms.h>
25#endif
26
27clock_t times (struct tms *);
28
29#ifdef __cplusplus
30}
31#endif
32
33#endif
34#endif
lib/libc/include/wasm32-wasi/sys/timex.h deleted-103
......@@ -1,103 +0,0 @@
1#ifndef _SYS_TIMEX_H
2#define _SYS_TIMEX_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define __NEED_clockid_t
9
10#include <bits/alltypes.h>
11
12#include <sys/time.h>
13
14struct ntptimeval {
15 struct timeval time;
16 long maxerror, esterror;
17};
18
19struct timex {
20 unsigned modes;
21 long offset, freq, maxerror, esterror;
22 int status;
23 long constant, precision, tolerance;
24 struct timeval time;
25 long tick, ppsfreq, jitter;
26 int shift;
27 long stabil, jitcnt, calcnt, errcnt, stbcnt;
28 int tai;
29 int __padding[11];
30};
31
32#define ADJ_OFFSET 0x0001
33#define ADJ_FREQUENCY 0x0002
34#define ADJ_MAXERROR 0x0004
35#define ADJ_ESTERROR 0x0008
36#define ADJ_STATUS 0x0010
37#define ADJ_TIMECONST 0x0020
38#define ADJ_TAI 0x0080
39#define ADJ_SETOFFSET 0x0100
40#define ADJ_MICRO 0x1000
41#define ADJ_NANO 0x2000
42#define ADJ_TICK 0x4000
43#define ADJ_OFFSET_SINGLESHOT 0x8001
44#define ADJ_OFFSET_SS_READ 0xa001
45
46#define MOD_OFFSET ADJ_OFFSET
47#define MOD_FREQUENCY ADJ_FREQUENCY
48#define MOD_MAXERROR ADJ_MAXERROR
49#define MOD_ESTERROR ADJ_ESTERROR
50#define MOD_STATUS ADJ_STATUS
51#define MOD_TIMECONST ADJ_TIMECONST
52#define MOD_CLKB ADJ_TICK
53#define MOD_CLKA ADJ_OFFSET_SINGLESHOT
54#define MOD_TAI ADJ_TAI
55#define MOD_MICRO ADJ_MICRO
56#define MOD_NANO ADJ_NANO
57
58#define STA_PLL 0x0001
59#define STA_PPSFREQ 0x0002
60#define STA_PPSTIME 0x0004
61#define STA_FLL 0x0008
62
63#define STA_INS 0x0010
64#define STA_DEL 0x0020
65#define STA_UNSYNC 0x0040
66#define STA_FREQHOLD 0x0080
67
68#define STA_PPSSIGNAL 0x0100
69#define STA_PPSJITTER 0x0200
70#define STA_PPSWANDER 0x0400
71#define STA_PPSERROR 0x0800
72
73#define STA_CLOCKERR 0x1000
74#define STA_NANO 0x2000
75#define STA_MODE 0x4000
76#define STA_CLK 0x8000
77
78#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
79 STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
80
81#define TIME_OK 0
82#define TIME_INS 1
83#define TIME_DEL 2
84#define TIME_OOP 3
85#define TIME_WAIT 4
86#define TIME_ERROR 5
87#define TIME_BAD TIME_ERROR
88
89#define MAXTC 6
90
91int adjtimex(struct timex *);
92int clock_adjtime(clockid_t, struct timex *);
93
94#if _REDIR_TIME64
95__REDIR(adjtimex, __adjtimex_time64);
96__REDIR(clock_adjtime, __clock_adjtime64);
97#endif
98
99#ifdef __cplusplus
100}
101#endif
102
103#endif
lib/libc/include/wasm32-wasi/sys/ttydefaults.h deleted-34
......@@ -1,34 +0,0 @@
1#ifndef _SYS_TTYDEFAULTS_H
2#define _SYS_TTYDEFAULTS_H
3
4#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
5#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
6#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
7#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL)
8#define TTYDEF_SPEED (B9600)
9#define CTRL(x) ((x)&037)
10#define CEOF CTRL('d')
11
12#define CEOL '\0'
13#define CSTATUS '\0'
14
15#define CERASE 0177
16#define CINTR CTRL('c')
17#define CKILL CTRL('u')
18#define CMIN 1
19#define CQUIT 034
20#define CSUSP CTRL('z')
21#define CTIME 0
22#define CDSUSP CTRL('y')
23#define CSTART CTRL('q')
24#define CSTOP CTRL('s')
25#define CLNEXT CTRL('v')
26#define CDISCARD CTRL('o')
27#define CWERASE CTRL('w')
28#define CREPRINT CTRL('r')
29#define CEOT CEOF
30#define CBRK CEOL
31#define CRPRNT CREPRINT
32#define CFLUSH CDISCARD
33
34#endif
lib/libc/include/wasm32-wasi/sys/types.h deleted-85
......@@ -1,85 +0,0 @@
1#ifndef _SYS_TYPES_H
2#define _SYS_TYPES_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <features.h>
8
9#define __NEED_ino_t
10#define __NEED_dev_t
11#define __NEED_uid_t
12#define __NEED_gid_t
13#define __NEED_mode_t
14#define __NEED_nlink_t
15#define __NEED_off_t
16#define __NEED_pid_t
17#define __NEED_size_t
18#define __NEED_ssize_t
19#define __NEED_time_t
20#define __NEED_timer_t
21#define __NEED_clockid_t
22
23#define __NEED_blkcnt_t
24#define __NEED_fsblkcnt_t
25#define __NEED_fsfilcnt_t
26
27#define __NEED_id_t
28#define __NEED_key_t
29#define __NEED_clock_t
30#define __NEED_suseconds_t
31#define __NEED_blksize_t
32
33#define __NEED_pthread_t
34#define __NEED_pthread_attr_t
35#define __NEED_pthread_mutexattr_t
36#define __NEED_pthread_condattr_t
37#define __NEED_pthread_rwlockattr_t
38#define __NEED_pthread_barrierattr_t
39#define __NEED_pthread_mutex_t
40#define __NEED_pthread_cond_t
41#define __NEED_pthread_rwlock_t
42#define __NEED_pthread_barrier_t
43#define __NEED_pthread_spinlock_t
44#define __NEED_pthread_key_t
45#define __NEED_pthread_once_t
46#define __NEED_useconds_t
47
48#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
49#define __NEED_int8_t
50#define __NEED_int16_t
51#define __NEED_int32_t
52#define __NEED_int64_t
53#define __NEED_u_int64_t
54#define __NEED_register_t
55#endif
56
57#include <bits/alltypes.h>
58
59#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
60typedef unsigned char u_int8_t;
61typedef unsigned short u_int16_t;
62typedef unsigned u_int32_t;
63typedef char *caddr_t;
64typedef unsigned char u_char;
65typedef unsigned short u_short, ushort;
66typedef unsigned u_int, uint;
67typedef unsigned long u_long, ulong;
68typedef long long quad_t;
69typedef unsigned long long u_quad_t;
70#include <endian.h>
71#include <sys/select.h>
72#endif
73
74#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
75#define blkcnt64_t blkcnt_t
76#define fsblkcnt64_t fsblkcnt_t
77#define fsfilcnt64_t fsfilcnt_t
78#define ino64_t ino_t
79#define off64_t off_t
80#endif
81
82#ifdef __cplusplus
83}
84#endif
85#endif
lib/libc/include/wasm32-wasi/sys/uio.h deleted-48
......@@ -1,48 +0,0 @@
1#ifndef _SYS_UIO_H
2#define _SYS_UIO_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_size_t
11#define __NEED_ssize_t
12#define __NEED_struct_iovec
13
14#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
15#define __NEED_off_t
16#endif
17
18#ifdef _GNU_SOURCE
19#define __NEED_pid_t
20#endif
21
22#include <bits/alltypes.h>
23
24#define UIO_MAXIOV 1024
25
26ssize_t readv (int, const struct iovec *, int);
27ssize_t writev (int, const struct iovec *, int);
28
29#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
30ssize_t preadv (int, const struct iovec *, int, off_t);
31ssize_t pwritev (int, const struct iovec *, int, off_t);
32#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
33#define preadv64 preadv
34#define pwritev64 pwritev
35#define off64_t off_t
36#endif
37#endif
38
39#ifdef _GNU_SOURCE
40ssize_t process_vm_writev(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long);
41ssize_t process_vm_readv(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long);
42#endif
43
44#ifdef __cplusplus
45}
46#endif
47
48#endif
lib/libc/include/wasm32-wasi/sys/un.h deleted-39
......@@ -1,39 +0,0 @@
1#ifndef _SYS_UN_H
2#define _SYS_UN_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_sa_family_t
11#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
12#define __NEED_size_t
13#endif
14
15#include <bits/alltypes.h>
16
17#ifdef __wasilibc_unmodified_upstream /* WASI has no UNIX-domain sockets */
18struct sockaddr_un {
19 sa_family_t sun_family;
20 char sun_path[108];
21};
22#else
23#include <__struct_sockaddr_un.h>
24#endif
25
26#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
27#ifdef __wasilibc_unmodified_upstream /* Declare strlen with the same attributes as <string.h> uses */
28size_t strlen(const char *);
29#else
30size_t strlen(const char *) __attribute__((__nothrow__, __leaf__, __pure__, __nonnull__(1)));
31#endif
32#define SUN_LEN(s) (2+strlen((s)->sun_path))
33#endif
34
35#ifdef __cplusplus
36}
37#endif
38
39#endif
lib/libc/include/wasm32-wasi/sys/utsname.h deleted-29
......@@ -1,29 +0,0 @@
1#ifndef _SYS_UTSNAME_H
2#define _SYS_UTSNAME_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10struct utsname {
11 char sysname[65];
12 char nodename[65];
13 char release[65];
14 char version[65];
15 char machine[65];
16#ifdef _GNU_SOURCE
17 char domainname[65];
18#else
19 char __domainname[65];
20#endif
21};
22
23int uname (struct utsname *);
24
25#ifdef __cplusplus
26}
27#endif
28
29#endif
lib/libc/include/wasm32-wasi/syscall.h deleted-1
......@@ -1 +0,0 @@
1#include <sys/syscall.h>
lib/libc/include/wasm32-wasi/sysexits.h deleted-21
......@@ -1,21 +0,0 @@
1#ifndef _SYSEXITS_H
2#define _SYSEXITS_H
3#define EX_OK 0
4#define EX__BASE 64
5#define EX_USAGE 64
6#define EX_DATAERR 65
7#define EX_NOINPUT 66
8#define EX_NOUSER 67
9#define EX_NOHOST 68
10#define EX_UNAVAILABLE 69
11#define EX_SOFTWARE 70
12#define EX_OSERR 71
13#define EX_OSFILE 72
14#define EX_CANTCREAT 73
15#define EX_IOERR 74
16#define EX_TEMPFAIL 75
17#define EX_PROTOCOL 76
18#define EX_NOPERM 77
19#define EX_CONFIG 78
20#define EX__MAX 78
21#endif
lib/libc/include/wasm32-wasi/tar.h deleted-33
......@@ -1,33 +0,0 @@
1#ifndef _TAR_H
2#define _TAR_H
3
4#define TSUID 04000
5#define TSGID 02000
6#define TSVTX 01000
7#define TUREAD 00400
8#define TUWRITE 00200
9#define TUEXEC 00100
10#define TGREAD 00040
11#define TGWRITE 00020
12#define TGEXEC 00010
13#define TOREAD 00004
14#define TOWRITE 00002
15#define TOEXEC 00001
16
17#define REGTYPE '0'
18#define AREGTYPE '\0'
19#define LNKTYPE '1'
20#define SYMTYPE '2'
21#define CHRTYPE '3'
22#define BLKTYPE '4'
23#define DIRTYPE '5'
24#define FIFOTYPE '6'
25#define CONTTYPE '7'
26
27#define TMAGIC "ustar"
28#define TMAGLEN 6
29
30#define TVERSION "00"
31#define TVERSLEN 2
32
33#endif
lib/libc/include/wasm32-wasi/tgmath.h deleted-270
......@@ -1,270 +0,0 @@
1#ifndef _TGMATH_H
2#define _TGMATH_H
3
4/*
5the return types are only correct with gcc (__GNUC__)
6otherwise they are long double or long double complex
7
8the long double version of a function is never chosen when
9sizeof(double) == sizeof(long double)
10(but the return type is set correctly with gcc)
11*/
12
13#include <math.h>
14#include <complex.h>
15
16#define __IS_FP(x) (sizeof((x)+1ULL) == sizeof((x)+1.0f))
17#define __IS_CX(x) (__IS_FP(x) && sizeof(x) == sizeof((x)+I))
18#define __IS_REAL(x) (__IS_FP(x) && 2*sizeof(x) == sizeof((x)+I))
19
20#define __FLT(x) (__IS_REAL(x) && sizeof(x) == sizeof(float))
21#define __LDBL(x) (__IS_REAL(x) && sizeof(x) == sizeof(long double) && sizeof(long double) != sizeof(double))
22
23#define __FLTCX(x) (__IS_CX(x) && sizeof(x) == sizeof(float complex))
24#define __DBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(double complex))
25#define __LDBLCX(x) (__IS_CX(x) && sizeof(x) == sizeof(long double complex) && sizeof(long double) != sizeof(double))
26
27/* return type */
28
29#ifdef __GNUC__
30/*
31the result must be casted to the right type
32(otherwise the result type is determined by the conversion
33rules applied to all the function return types so it is long
34double or long double complex except for integral functions)
35
36this cannot be done in c99, so the typeof gcc extension is
37used and that the type of ?: depends on wether an operand is
38a null pointer constant or not
39(in c11 _Generic can be used)
40
41the c arguments below must be integer constant expressions
42so they can be in null pointer constants
43(__IS_FP above was carefully chosen this way)
44*/
45/* if c then t else void */
46#define __type1(c,t) __typeof__(*(0?(t*)0:(void*)!(c)))
47/* if c then t1 else t2 */
48#define __type2(c,t1,t2) __typeof__(*(0?(__type1(c,t1)*)0:(__type1(!(c),t2)*)0))
49/* cast to double when x is integral, otherwise use typeof(x) */
50#define __RETCAST(x) ( \
51 __type2(__IS_FP(x), __typeof__(x), double))
52/* 2 args case, should work for complex types (cpow) */
53#define __RETCAST_2(x, y) ( \
54 __type2(__IS_FP(x) && __IS_FP(y), \
55 __typeof__((x)+(y)), \
56 __typeof__((x)+(y)+1.0)))
57/* 3 args case (fma only) */
58#define __RETCAST_3(x, y, z) ( \
59 __type2(__IS_FP(x) && __IS_FP(y) && __IS_FP(z), \
60 __typeof__((x)+(y)+(z)), \
61 __typeof__((x)+(y)+(z)+1.0)))
62/* drop complex from the type of x */
63/* TODO: wrong when sizeof(long double)==sizeof(double) */
64#define __RETCAST_REAL(x) ( \
65 __type2(__IS_FP(x) && sizeof((x)+I) == sizeof(float complex), float, \
66 __type2(sizeof((x)+1.0+I) == sizeof(double complex), double, \
67 long double)))
68/* add complex to the type of x */
69#define __RETCAST_CX(x) (__typeof__(__RETCAST(x)0+I))
70#else
71#define __RETCAST(x)
72#define __RETCAST_2(x, y)
73#define __RETCAST_3(x, y, z)
74#define __RETCAST_REAL(x)
75#define __RETCAST_CX(x)
76#endif
77
78/* function selection */
79
80#define __tg_real_nocast(fun, x) ( \
81 __FLT(x) ? fun ## f (x) : \
82 __LDBL(x) ? fun ## l (x) : \
83 fun(x) )
84
85#define __tg_real(fun, x) (__RETCAST(x)__tg_real_nocast(fun, x))
86
87#define __tg_real_2_1(fun, x, y) (__RETCAST(x)( \
88 __FLT(x) ? fun ## f (x, y) : \
89 __LDBL(x) ? fun ## l (x, y) : \
90 fun(x, y) ))
91
92#define __tg_real_2(fun, x, y) (__RETCAST_2(x, y)( \
93 __FLT(x) && __FLT(y) ? fun ## f (x, y) : \
94 __LDBL((x)+(y)) ? fun ## l (x, y) : \
95 fun(x, y) ))
96
97#define __tg_complex(fun, x) (__RETCAST_CX(x)( \
98 __FLTCX((x)+I) && __IS_FP(x) ? fun ## f (x) : \
99 __LDBLCX((x)+I) ? fun ## l (x) : \
100 fun(x) ))
101
102#define __tg_complex_retreal(fun, x) (__RETCAST_REAL(x)( \
103 __FLTCX((x)+I) && __IS_FP(x) ? fun ## f (x) : \
104 __LDBLCX((x)+I) ? fun ## l (x) : \
105 fun(x) ))
106
107#define __tg_real_complex(fun, x) (__RETCAST(x)( \
108 __FLTCX(x) ? c ## fun ## f (x) : \
109 __DBLCX(x) ? c ## fun (x) : \
110 __LDBLCX(x) ? c ## fun ## l (x) : \
111 __FLT(x) ? fun ## f (x) : \
112 __LDBL(x) ? fun ## l (x) : \
113 fun(x) ))
114
115/* special cases */
116
117#define __tg_real_remquo(x, y, z) (__RETCAST_2(x, y)( \
118 __FLT(x) && __FLT(y) ? remquof(x, y, z) : \
119 __LDBL((x)+(y)) ? remquol(x, y, z) : \
120 remquo(x, y, z) ))
121
122#define __tg_real_fma(x, y, z) (__RETCAST_3(x, y, z)( \
123 __FLT(x) && __FLT(y) && __FLT(z) ? fmaf(x, y, z) : \
124 __LDBL((x)+(y)+(z)) ? fmal(x, y, z) : \
125 fma(x, y, z) ))
126
127#define __tg_real_complex_pow(x, y) (__RETCAST_2(x, y)( \
128 __FLTCX((x)+(y)) && __IS_FP(x) && __IS_FP(y) ? cpowf(x, y) : \
129 __FLTCX((x)+(y)) ? cpow(x, y) : \
130 __DBLCX((x)+(y)) ? cpow(x, y) : \
131 __LDBLCX((x)+(y)) ? cpowl(x, y) : \
132 __FLT(x) && __FLT(y) ? powf(x, y) : \
133 __LDBL((x)+(y)) ? powl(x, y) : \
134 pow(x, y) ))
135
136#define __tg_real_complex_fabs(x) (__RETCAST_REAL(x)( \
137 __FLTCX(x) ? cabsf(x) : \
138 __DBLCX(x) ? cabs(x) : \
139 __LDBLCX(x) ? cabsl(x) : \
140 __FLT(x) ? fabsf(x) : \
141 __LDBL(x) ? fabsl(x) : \
142 fabs(x) ))
143
144/* suppress any macros in math.h or complex.h */
145
146#undef acos
147#undef acosh
148#undef asin
149#undef asinh
150#undef atan
151#undef atan2
152#undef atanh
153#undef carg
154#undef cbrt
155#undef ceil
156#undef cimag
157#undef conj
158#undef copysign
159#undef cos
160#undef cosh
161#undef cproj
162#undef creal
163#undef erf
164#undef erfc
165#undef exp
166#undef exp2
167#undef expm1
168#undef fabs
169#undef fdim
170#undef floor
171#undef fma
172#undef fmax
173#undef fmin
174#undef fmod
175#undef frexp
176#undef hypot
177#undef ilogb
178#undef ldexp
179#undef lgamma
180#undef llrint
181#undef llround
182#undef log
183#undef log10
184#undef log1p
185#undef log2
186#undef logb
187#undef lrint
188#undef lround
189#undef nearbyint
190#undef nextafter
191#undef nexttoward
192#undef pow
193#undef remainder
194#undef remquo
195#undef rint
196#undef round
197#undef scalbln
198#undef scalbn
199#undef sin
200#undef sinh
201#undef sqrt
202#undef tan
203#undef tanh
204#undef tgamma
205#undef trunc
206
207/* tg functions */
208
209#define acos(x) __tg_real_complex(acos, (x))
210#define acosh(x) __tg_real_complex(acosh, (x))
211#define asin(x) __tg_real_complex(asin, (x))
212#define asinh(x) __tg_real_complex(asinh, (x))
213#define atan(x) __tg_real_complex(atan, (x))
214#define atan2(x,y) __tg_real_2(atan2, (x), (y))
215#define atanh(x) __tg_real_complex(atanh, (x))
216#define carg(x) __tg_complex_retreal(carg, (x))
217#define cbrt(x) __tg_real(cbrt, (x))
218#define ceil(x) __tg_real(ceil, (x))
219#define cimag(x) __tg_complex_retreal(cimag, (x))
220#define conj(x) __tg_complex(conj, (x))
221#define copysign(x,y) __tg_real_2(copysign, (x), (y))
222#define cos(x) __tg_real_complex(cos, (x))
223#define cosh(x) __tg_real_complex(cosh, (x))
224#define cproj(x) __tg_complex(cproj, (x))
225#define creal(x) __tg_complex_retreal(creal, (x))
226#define erf(x) __tg_real(erf, (x))
227#define erfc(x) __tg_real(erfc, (x))
228#define exp(x) __tg_real_complex(exp, (x))
229#define exp2(x) __tg_real(exp2, (x))
230#define expm1(x) __tg_real(expm1, (x))
231#define fabs(x) __tg_real_complex_fabs(x)
232#define fdim(x,y) __tg_real_2(fdim, (x), (y))
233#define floor(x) __tg_real(floor, (x))
234#define fma(x,y,z) __tg_real_fma((x), (y), (z))
235#define fmax(x,y) __tg_real_2(fmax, (x), (y))
236#define fmin(x,y) __tg_real_2(fmin, (x), (y))
237#define fmod(x,y) __tg_real_2(fmod, (x), (y))
238#define frexp(x,y) __tg_real_2_1(frexp, (x), (y))
239#define hypot(x,y) __tg_real_2(hypot, (x), (y))
240#define ilogb(x) __tg_real_nocast(ilogb, (x))
241#define ldexp(x,y) __tg_real_2_1(ldexp, (x), (y))
242#define lgamma(x) __tg_real(lgamma, (x))
243#define llrint(x) __tg_real_nocast(llrint, (x))
244#define llround(x) __tg_real_nocast(llround, (x))
245#define log(x) __tg_real_complex(log, (x))
246#define log10(x) __tg_real(log10, (x))
247#define log1p(x) __tg_real(log1p, (x))
248#define log2(x) __tg_real(log2, (x))
249#define logb(x) __tg_real(logb, (x))
250#define lrint(x) __tg_real_nocast(lrint, (x))
251#define lround(x) __tg_real_nocast(lround, (x))
252#define nearbyint(x) __tg_real(nearbyint, (x))
253#define nextafter(x,y) __tg_real_2(nextafter, (x), (y))
254#define nexttoward(x,y) __tg_real_2(nexttoward, (x), (y))
255#define pow(x,y) __tg_real_complex_pow((x), (y))
256#define remainder(x,y) __tg_real_2(remainder, (x), (y))
257#define remquo(x,y,z) __tg_real_remquo((x), (y), (z))
258#define rint(x) __tg_real(rint, (x))
259#define round(x) __tg_real(round, (x))
260#define scalbln(x,y) __tg_real_2_1(scalbln, (x), (y))
261#define scalbn(x,y) __tg_real_2_1(scalbn, (x), (y))
262#define sin(x) __tg_real_complex(sin, (x))
263#define sinh(x) __tg_real_complex(sinh, (x))
264#define sqrt(x) __tg_real_complex(sqrt, (x))
265#define tan(x) __tg_real_complex(tan, (x))
266#define tanh(x) __tg_real_complex(tanh, (x))
267#define tgamma(x) __tg_real(tgamma, (x))
268#define trunc(x) __tg_real(trunc, (x))
269
270#endif
lib/libc/include/wasm32-wasi/threads.h deleted-93
......@@ -1,93 +0,0 @@
1#ifndef _THREADS_H
2#define _THREADS_H
3
4#include <features.h>
5#include <time.h>
6
7#ifdef __cplusplus
8extern "C" {
9typedef unsigned long thrd_t;
10#else
11typedef struct __pthread *thrd_t;
12#define thread_local _Thread_local
13#endif
14
15typedef int once_flag;
16typedef unsigned tss_t;
17typedef int (*thrd_start_t)(void *);
18typedef void (*tss_dtor_t)(void *);
19
20#define __NEED_cnd_t
21#define __NEED_mtx_t
22
23#include <bits/alltypes.h>
24
25#define TSS_DTOR_ITERATIONS 4
26
27enum {
28 thrd_success = 0,
29 thrd_busy = 1,
30 thrd_error = 2,
31 thrd_nomem = 3,
32 thrd_timedout = 4,
33};
34
35enum {
36 mtx_plain = 0,
37 mtx_recursive = 1,
38 mtx_timed = 2,
39};
40
41#define ONCE_FLAG_INIT 0
42
43int thrd_create(thrd_t *, thrd_start_t, void *);
44_Noreturn void thrd_exit(int);
45
46int thrd_detach(thrd_t);
47int thrd_join(thrd_t, int *);
48
49int thrd_sleep(const struct timespec *, struct timespec *);
50void thrd_yield(void);
51
52thrd_t thrd_current(void);
53int thrd_equal(thrd_t, thrd_t);
54#ifndef __cplusplus
55#define thrd_equal(A, B) ((A) == (B))
56#endif
57
58void call_once(once_flag *, void (*)(void));
59
60int mtx_init(mtx_t *, int);
61void mtx_destroy(mtx_t *);
62
63int mtx_lock(mtx_t *);
64int mtx_timedlock(mtx_t *__restrict, const struct timespec *__restrict);
65int mtx_trylock(mtx_t *);
66int mtx_unlock(mtx_t *);
67
68int cnd_init(cnd_t *);
69void cnd_destroy(cnd_t *);
70
71int cnd_broadcast(cnd_t *);
72int cnd_signal(cnd_t *);
73
74int cnd_timedwait(cnd_t *__restrict, mtx_t *__restrict, const struct timespec *__restrict);
75int cnd_wait(cnd_t *, mtx_t *);
76
77int tss_create(tss_t *, tss_dtor_t);
78void tss_delete(tss_t);
79
80int tss_set(tss_t, void *);
81void *tss_get(tss_t);
82
83#if _REDIR_TIME64
84__REDIR(thrd_sleep, __thrd_sleep_time64);
85__REDIR(mtx_timedlock, __mtx_timedlock_time64);
86__REDIR(cnd_timedwait, __cnd_timedwait_time64);
87#endif
88
89#ifdef __cplusplus
90}
91#endif
92
93#endif
lib/libc/include/wasm32-wasi/time.h deleted-202
......@@ -1,202 +0,0 @@
1#ifndef _TIME_H
2#define _TIME_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
11#ifdef __cplusplus
12#define NULL 0L
13#else
14#define NULL ((void*)0)
15#endif
16#else
17#define __need_NULL
18#include <stddef.h>
19#endif
20
21
22#define __NEED_size_t
23#define __NEED_time_t
24#define __NEED_clock_t
25#define __NEED_struct_timespec
26
27#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
28 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
29 || defined(_BSD_SOURCE)
30#define __NEED_clockid_t
31#define __NEED_timer_t
32#define __NEED_pid_t
33#define __NEED_locale_t
34#endif
35
36#include <bits/alltypes.h>
37
38#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
39#define __tm_gmtoff tm_gmtoff
40#define __tm_zone tm_zone
41#endif
42
43#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
44struct tm {
45 int tm_sec;
46 int tm_min;
47 int tm_hour;
48 int tm_mday;
49 int tm_mon;
50 int tm_year;
51 int tm_wday;
52 int tm_yday;
53 int tm_isdst;
54 long __tm_gmtoff;
55 const char *__tm_zone;
56};
57#else
58#include <__header_time.h>
59#endif
60
61#if defined(__wasilibc_unmodified_upstream) || defined(_WASI_EMULATED_PROCESS_CLOCKS)
62clock_t clock (void);
63#else
64__attribute__((__deprecated__(
65"WASI lacks process-associated clocks; to enable emulation of the `clock` function using "
66"the wall clock, which isn't sensitive to whether the program is running or suspended, "
67"compile with -D_WASI_EMULATED_PROCESS_CLOCKS and link with -lwasi-emulated-process-clocks"
68)))
69clock_t clock (void);
70#endif
71time_t time (time_t *);
72double difftime (time_t, time_t);
73time_t mktime (struct tm *);
74size_t strftime (char *__restrict, size_t, const char *__restrict, const struct tm *__restrict);
75struct tm *gmtime (const time_t *);
76struct tm *localtime (const time_t *);
77char *asctime (const struct tm *);
78char *ctime (const time_t *);
79int timespec_get(struct timespec *, int);
80
81#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
82#define CLOCKS_PER_SEC 1000000L
83
84#define TIME_UTC 1
85#endif
86
87#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
88 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
89 || defined(_BSD_SOURCE)
90
91size_t strftime_l (char * __restrict, size_t, const char * __restrict, const struct tm * __restrict, locale_t);
92
93struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
94struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
95char *asctime_r (const struct tm *__restrict, char *__restrict);
96char *ctime_r (const time_t *, char *);
97
98#ifdef __wasilibc_unmodified_upstream /* WASI has no timezone tables */
99void tzset (void);
100#endif
101
102struct itimerspec {
103 struct timespec it_interval;
104 struct timespec it_value;
105};
106
107#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
108#define CLOCK_REALTIME 0
109#define CLOCK_MONOTONIC 1
110#define CLOCK_PROCESS_CPUTIME_ID 2
111#define CLOCK_THREAD_CPUTIME_ID 3
112#define CLOCK_MONOTONIC_RAW 4
113#define CLOCK_REALTIME_COARSE 5
114#define CLOCK_MONOTONIC_COARSE 6
115#define CLOCK_BOOTTIME 7
116#define CLOCK_REALTIME_ALARM 8
117#define CLOCK_BOOTTIME_ALARM 9
118#define CLOCK_SGI_CYCLE 10
119#define CLOCK_TAI 11
120
121#define TIMER_ABSTIME 1
122#endif
123
124int nanosleep (const struct timespec *, struct timespec *);
125int clock_getres (clockid_t, struct timespec *);
126int clock_gettime (clockid_t, struct timespec *);
127#ifdef __wasilibc_unmodified_upstream /* WASI has no clock_settime */
128int clock_settime (clockid_t, const struct timespec *);
129#endif
130int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec *);
131#ifdef __wasilibc_unmodified_upstream /* WASI has no clock_getcpuclockid */
132int clock_getcpuclockid (pid_t, clockid_t *);
133#endif
134
135#ifdef __wasilibc_unmodified_upstream /* WASI has no timers */
136struct sigevent;
137int timer_create (clockid_t, struct sigevent *__restrict, timer_t *__restrict);
138int timer_delete (timer_t);
139int timer_settime (timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict);
140int timer_gettime (timer_t, struct itimerspec *);
141int timer_getoverrun (timer_t);
142#endif
143
144#ifdef __wasilibc_unmodified_upstream /* WASI has no timezone tables */
145extern char *tzname[2];
146#endif
147
148#endif
149
150
151#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
152char *strptime (const char *__restrict, const char *__restrict, struct tm *__restrict);
153#ifdef __wasilibc_unmodified_upstream /* WASI has no timezone tables */
154extern int daylight;
155extern long timezone;
156#endif
157extern int getdate_err;
158struct tm *getdate (const char *);
159#endif
160
161
162#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
163#ifdef __wasilibc_unmodified_upstream /* WASI has no stime */
164int stime(const time_t *);
165#endif
166time_t timegm(struct tm *);
167#endif
168
169#if _REDIR_TIME64
170__REDIR(time, __time64);
171__REDIR(difftime, __difftime64);
172__REDIR(mktime, __mktime64);
173__REDIR(gmtime, __gmtime64);
174__REDIR(localtime, __localtime64);
175__REDIR(ctime, __ctime64);
176__REDIR(timespec_get, __timespec_get_time64);
177#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
178 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
179 || defined(_BSD_SOURCE)
180__REDIR(gmtime_r, __gmtime64_r);
181__REDIR(localtime_r, __localtime64_r);
182__REDIR(ctime_r, __ctime64_r);
183__REDIR(nanosleep, __nanosleep_time64);
184__REDIR(clock_getres, __clock_getres_time64);
185__REDIR(clock_gettime, __clock_gettime64);
186__REDIR(clock_settime, __clock_settime64);
187__REDIR(clock_nanosleep, __clock_nanosleep_time64);
188__REDIR(timer_settime, __timer_settime64);
189__REDIR(timer_gettime, __timer_gettime64);
190#endif
191#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
192__REDIR(stime, __stime64);
193__REDIR(timegm, __timegm_time64);
194#endif
195#endif
196
197#ifdef __cplusplus
198}
199#endif
200
201
202#endif
lib/libc/include/wasm32-wasi/uchar.h deleted-29
......@@ -1,29 +0,0 @@
1#ifndef _UCHAR_H
2#define _UCHAR_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#if __cplusplus < 201103L
9typedef unsigned short char16_t;
10typedef unsigned char32_t;
11#endif
12
13#define __NEED_mbstate_t
14#define __NEED_size_t
15
16#include <features.h>
17#include <bits/alltypes.h>
18
19size_t c16rtomb(char *__restrict, char16_t, mbstate_t *__restrict);
20size_t mbrtoc16(char16_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
21
22size_t c32rtomb(char *__restrict, char32_t, mbstate_t *__restrict);
23size_t mbrtoc32(char32_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
24
25#ifdef __cplusplus
26}
27#endif
28
29#endif
lib/libc/include/wasm32-wasi/unistd.h deleted-571
......@@ -1,571 +0,0 @@
1#ifndef _UNISTD_H
2#define _UNISTD_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define STDIN_FILENO 0
11#define STDOUT_FILENO 1
12#define STDERR_FILENO 2
13
14#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
15#define SEEK_SET 0
16#define SEEK_CUR 1
17#define SEEK_END 2
18#else
19#include <__header_unistd.h>
20#endif
21
22#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
23#ifdef __cplusplus
24#define NULL 0L
25#else
26#define NULL ((void*)0)
27#endif
28#else
29#define __need_NULL
30#include <stddef.h>
31#endif
32
33#define __NEED_size_t
34#define __NEED_ssize_t
35#define __NEED_uid_t
36#define __NEED_gid_t
37#define __NEED_off_t
38#define __NEED_pid_t
39#define __NEED_intptr_t
40#define __NEED_useconds_t
41
42#include <bits/alltypes.h>
43
44#ifdef __wasilibc_unmodified_upstream /* WASI has no pipe */
45int pipe(int [2]);
46int pipe2(int [2], int);
47#endif
48int close(int);
49int posix_close(int, int);
50#ifdef __wasilibc_unmodified_upstream /* WASI has no dup */
51int dup(int);
52int dup2(int, int);
53int dup3(int, int, int);
54#endif
55off_t lseek(int, off_t, int);
56#ifdef __wasilibc_unmodified_upstream /* Optimize the readonly case of lseek */
57#else
58off_t __wasilibc_tell(int);
59
60#ifndef __cplusplus
61/*
62 * Optimize lseek in the case where it's just returning the current offset.
63 * This avoids importing `__wasi_fd_seek` altogether in many common cases.
64 *
65 * But don't do this for C++ because a simple macro wouldn't handle namespaces
66 * correctly:
67 * - User code could qualify the `lseek` call with `::`.
68 * - There may be another `lseek` in scope from a `using` declaration.
69 */
70#define lseek(fd, offset, whence) \
71 ({ \
72 off_t __f = (fd); \
73 off_t __o = (offset); \
74 off_t __w = (whence); \
75 __builtin_constant_p((offset)) && \
76 __builtin_constant_p((whence)) && \
77 __o == 0 && \
78 __w == SEEK_CUR \
79 ? __wasilibc_tell(__f) \
80 : lseek(__f, __o, __w); \
81 })
82#endif
83#endif
84int fsync(int);
85int fdatasync(int);
86
87ssize_t read(int, void *, size_t);
88ssize_t write(int, const void *, size_t);
89ssize_t pread(int, void *, size_t, off_t);
90ssize_t pwrite(int, const void *, size_t, off_t);
91
92#ifdef __wasilibc_unmodified_upstream /* WASI has no chown */
93int chown(const char *, uid_t, gid_t);
94int fchown(int, uid_t, gid_t);
95int lchown(const char *, uid_t, gid_t);
96int fchownat(int, const char *, uid_t, gid_t, int);
97#endif
98
99int link(const char *, const char *);
100int linkat(int, const char *, int, const char *, int);
101int symlink(const char *, const char *);
102int symlinkat(const char *, int, const char *);
103ssize_t readlink(const char *__restrict, char *__restrict, size_t);
104ssize_t readlinkat(int, const char *__restrict, char *__restrict, size_t);
105int unlink(const char *);
106int unlinkat(int, const char *, int);
107int rmdir(const char *);
108int truncate(const char *, off_t);
109int ftruncate(int, off_t);
110
111#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
112#define F_OK 0
113#define R_OK 4
114#define W_OK 2
115#define X_OK 1
116#endif
117
118int access(const char *, int);
119int faccessat(int, const char *, int, int);
120
121#ifdef __wasilibc_unmodified_upstream /* WASI has no fchdir */
122int fchdir(int);
123#endif
124int chdir(const char *);
125char *getcwd(char *, size_t);
126
127#ifdef __wasilibc_unmodified_upstream /* WASI has no signals */
128unsigned alarm(unsigned);
129#endif
130unsigned sleep(unsigned);
131#ifdef __wasilibc_unmodified_upstream /* WASI has no pause */
132int pause(void);
133#endif
134
135#ifdef __wasilibc_unmodified_upstream /* WASI has no fork/exec */
136pid_t fork(void);
137pid_t _Fork(void);
138int execve(const char *, char *const [], char *const []);
139int execv(const char *, char *const []);
140int execle(const char *, const char *, ...);
141int execl(const char *, const char *, ...);
142int execvp(const char *, char *const []);
143int execlp(const char *, const char *, ...);
144int fexecve(int, char *const [], char *const []);
145#endif
146_Noreturn void _exit(int);
147
148#if defined(__wasilibc_unmodified_upstream) || defined(_WASI_EMULATED_GETPID)
149pid_t getpid(void);
150#else
151__attribute__((__deprecated__(
152"WASI lacks process identifiers; to enable emulation of the `getpid` function using "
153"a placeholder value, which doesn't reflect the host PID of the program, "
154"compile with -D_WASI_EMULATED_GETPID and link with -lwasi-emulated-getpid"
155)))
156pid_t getpid(void);
157#endif
158#ifdef __wasilibc_unmodified_upstream /* WASI has no getpid etc. */
159pid_t getppid(void);
160pid_t getpgrp(void);
161pid_t getpgid(pid_t);
162int setpgid(pid_t, pid_t);
163pid_t setsid(void);
164pid_t getsid(pid_t);
165#endif
166#ifdef __wasilibc_unmodified_upstream /* WASI has no ttyname */
167char *ttyname(int);
168int ttyname_r(int, char *, size_t);
169#endif
170int isatty(int);
171#ifdef __wasilibc_unmodified_upstream /* WASI has no process groups */
172pid_t tcgetpgrp(int);
173int tcsetpgrp(int, pid_t);
174#endif
175
176#ifdef __wasilibc_unmodified_upstream /* WASI has no getuid etc. */
177uid_t getuid(void);
178uid_t geteuid(void);
179gid_t getgid(void);
180gid_t getegid(void);
181int getgroups(int, gid_t []);
182int setuid(uid_t);
183int seteuid(uid_t);
184int setgid(gid_t);
185int setegid(gid_t);
186#endif
187
188char *getlogin(void);
189int getlogin_r(char *, size_t);
190int gethostname(char *, size_t);
191char *ctermid(char *);
192
193int getopt(int, char * const [], const char *);
194extern char *optarg;
195extern int optind, opterr, optopt;
196
197long pathconf(const char *, int);
198long fpathconf(int, int);
199long sysconf(int);
200size_t confstr(int, char *, size_t);
201
202#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
203#define F_ULOCK 0
204#define F_LOCK 1
205#define F_TLOCK 2
206#define F_TEST 3
207#ifdef __wasilibc_unmodified_upstream /* WASI has no setreuid */
208int setreuid(uid_t, uid_t);
209int setregid(gid_t, gid_t);
210#endif
211#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
212int lockf(int, int, off_t);
213#endif
214long gethostid(void);
215#ifdef __wasilibc_unmodified_upstream /* WASI has no nice, sync, or setpgrp */
216int nice(int);
217void sync(void);
218pid_t setpgrp(void);
219#endif
220char *crypt(const char *, const char *);
221void encrypt(char *, int);
222void swab(const void *__restrict, void *__restrict, ssize_t);
223#endif
224
225#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \
226 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
227int usleep(unsigned);
228unsigned ualarm(unsigned, unsigned);
229#endif
230
231#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
232#define L_SET 0
233#define L_INCR 1
234#define L_XTND 2
235#ifdef __wasilibc_unmodified_upstream /* WASI has no brk */
236int brk(void *);
237#endif
238void *sbrk(intptr_t);
239#ifdef __wasilibc_unmodified_upstream /* WASI has no processes */
240pid_t vfork(void);
241int vhangup(void);
242int chroot(const char *);
243int getpagesize(void);
244int getdtablesize(void);
245int sethostname(const char *, size_t);
246int getdomainname(char *, size_t);
247int setdomainname(const char *, size_t);
248int setgroups(size_t, const gid_t *);
249char *getpass(const char *);
250int daemon(int, int);
251void setusershell(void);
252void endusershell(void);
253char *getusershell(void);
254int acct(const char *);
255long syscall(long, ...);
256int execvpe(const char *, char *const [], char *const []);
257int issetugid(void);
258#endif
259int getentropy(void *, size_t);
260extern int optreset;
261#endif
262
263#ifdef _GNU_SOURCE
264extern char **environ;
265#ifdef __wasilibc_unmodified_upstream /* WASI has no get/setresuid */
266int setresuid(uid_t, uid_t, uid_t);
267int setresgid(gid_t, gid_t, gid_t);
268int getresuid(uid_t *, uid_t *, uid_t *);
269int getresgid(gid_t *, gid_t *, gid_t *);
270#endif
271#ifdef __wasilibc_unmodified_upstream /* WASI has no cwd */
272char *get_current_dir_name(void);
273#endif
274#ifdef __wasilibc_unmodified_upstream /* WASI has no syncfs */
275int syncfs(int);
276#endif
277#ifdef __wasilibc_unmodified_upstream /* WASI has no eaccess */
278int euidaccess(const char *, int);
279int eaccess(const char *, int);
280ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
281pid_t gettid(void);
282#endif
283#endif
284
285#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
286#define lseek64 lseek
287#define pread64 pread
288#define pwrite64 pwrite
289#ifdef __wasilibc_unmodified_upstream /* WASI has no truncate */
290#define truncate64 truncate
291#endif
292#define ftruncate64 ftruncate
293#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
294#define lockf64 lockf
295#endif
296#define off64_t off_t
297#endif
298
299#define POSIX_CLOSE_RESTART 0
300
301#define _XOPEN_VERSION 700
302#define _XOPEN_UNIX 1
303#define _XOPEN_ENH_I18N 1
304
305#define _POSIX_VERSION 200809L
306#define _POSIX2_VERSION _POSIX_VERSION
307
308#define _POSIX_ADVISORY_INFO _POSIX_VERSION
309#define _POSIX_CHOWN_RESTRICTED 1
310#define _POSIX_IPV6 _POSIX_VERSION
311#ifdef __wasilibc_unmodified_upstream /* WASI has no processes, mmap, or mq */
312#define _POSIX_JOB_CONTROL 1
313#define _POSIX_MAPPED_FILES _POSIX_VERSION
314#define _POSIX_MEMLOCK _POSIX_VERSION
315#define _POSIX_MEMLOCK_RANGE _POSIX_VERSION
316#define _POSIX_MEMORY_PROTECTION _POSIX_VERSION
317#define _POSIX_MESSAGE_PASSING _POSIX_VERSION
318#endif
319#define _POSIX_FSYNC _POSIX_VERSION
320#define _POSIX_NO_TRUNC 1
321#ifdef __wasilibc_unmodified_upstream /* WASI has no raw sockets */
322#define _POSIX_RAW_SOCKETS _POSIX_VERSION
323#endif
324#define _POSIX_REALTIME_SIGNALS _POSIX_VERSION
325#define _POSIX_REGEXP 1
326#ifdef __wasilibc_unmodified_upstream /* WASI has no processes */
327#define _POSIX_SAVED_IDS 1
328#define _POSIX_SHELL 1
329#define _POSIX_SPAWN _POSIX_VERSION
330#endif
331#define _POSIX_VDISABLE 0
332
333#define _POSIX_THREADS _POSIX_VERSION
334#define _POSIX_THREAD_PROCESS_SHARED _POSIX_VERSION
335#define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION
336#define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION
337#define _POSIX_THREAD_ATTR_STACKSIZE _POSIX_VERSION
338#define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION
339#define _POSIX_THREAD_CPUTIME _POSIX_VERSION
340#define _POSIX_TIMERS _POSIX_VERSION
341#define _POSIX_TIMEOUTS _POSIX_VERSION
342#define _POSIX_MONOTONIC_CLOCK _POSIX_VERSION
343#define _POSIX_CPUTIME _POSIX_VERSION
344#define _POSIX_CLOCK_SELECTION _POSIX_VERSION
345#define _POSIX_BARRIERS _POSIX_VERSION
346#define _POSIX_SPIN_LOCKS _POSIX_VERSION
347#define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION
348#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX async I/O, semaphores, or shared memory */
349#define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION
350#define _POSIX_SEMAPHORES _POSIX_VERSION
351#define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_VERSION
352#endif
353
354#define _POSIX2_C_BIND _POSIX_VERSION
355
356#include <bits/posix.h>
357
358
359
360#define _PC_LINK_MAX 0
361#define _PC_MAX_CANON 1
362#define _PC_MAX_INPUT 2
363#define _PC_NAME_MAX 3
364#define _PC_PATH_MAX 4
365#define _PC_PIPE_BUF 5
366#define _PC_CHOWN_RESTRICTED 6
367#define _PC_NO_TRUNC 7
368#define _PC_VDISABLE 8
369#define _PC_SYNC_IO 9
370#define _PC_ASYNC_IO 10
371#define _PC_PRIO_IO 11
372#define _PC_SOCK_MAXBUF 12
373#define _PC_FILESIZEBITS 13
374#define _PC_REC_INCR_XFER_SIZE 14
375#define _PC_REC_MAX_XFER_SIZE 15
376#define _PC_REC_MIN_XFER_SIZE 16
377#define _PC_REC_XFER_ALIGN 17
378#define _PC_ALLOC_SIZE_MIN 18
379#define _PC_SYMLINK_MAX 19
380#define _PC_2_SYMLINKS 20
381
382#define _SC_ARG_MAX 0
383#define _SC_CHILD_MAX 1
384#define _SC_CLK_TCK 2
385#define _SC_NGROUPS_MAX 3
386#define _SC_OPEN_MAX 4
387#define _SC_STREAM_MAX 5
388#define _SC_TZNAME_MAX 6
389#define _SC_JOB_CONTROL 7
390#define _SC_SAVED_IDS 8
391#define _SC_REALTIME_SIGNALS 9
392#define _SC_PRIORITY_SCHEDULING 10
393#define _SC_TIMERS 11
394#define _SC_ASYNCHRONOUS_IO 12
395#define _SC_PRIORITIZED_IO 13
396#define _SC_SYNCHRONIZED_IO 14
397#define _SC_FSYNC 15
398#define _SC_MAPPED_FILES 16
399#define _SC_MEMLOCK 17
400#define _SC_MEMLOCK_RANGE 18
401#define _SC_MEMORY_PROTECTION 19
402#define _SC_MESSAGE_PASSING 20
403#define _SC_SEMAPHORES 21
404#define _SC_SHARED_MEMORY_OBJECTS 22
405#define _SC_AIO_LISTIO_MAX 23
406#define _SC_AIO_MAX 24
407#define _SC_AIO_PRIO_DELTA_MAX 25
408#define _SC_DELAYTIMER_MAX 26
409#define _SC_MQ_OPEN_MAX 27
410#define _SC_MQ_PRIO_MAX 28
411#define _SC_VERSION 29
412#define _SC_PAGE_SIZE 30
413#define _SC_PAGESIZE 30 /* !! */
414#define _SC_RTSIG_MAX 31
415#define _SC_SEM_NSEMS_MAX 32
416#define _SC_SEM_VALUE_MAX 33
417#define _SC_SIGQUEUE_MAX 34
418#define _SC_TIMER_MAX 35
419#define _SC_BC_BASE_MAX 36
420#define _SC_BC_DIM_MAX 37
421#define _SC_BC_SCALE_MAX 38
422#define _SC_BC_STRING_MAX 39
423#define _SC_COLL_WEIGHTS_MAX 40
424#define _SC_EXPR_NEST_MAX 42
425#define _SC_LINE_MAX 43
426#define _SC_RE_DUP_MAX 44
427#define _SC_2_VERSION 46
428#define _SC_2_C_BIND 47
429#define _SC_2_C_DEV 48
430#define _SC_2_FORT_DEV 49
431#define _SC_2_FORT_RUN 50
432#define _SC_2_SW_DEV 51
433#define _SC_2_LOCALEDEF 52
434#define _SC_UIO_MAXIOV 60 /* !! */
435#define _SC_IOV_MAX 60
436#define _SC_THREADS 67
437#define _SC_THREAD_SAFE_FUNCTIONS 68
438#define _SC_GETGR_R_SIZE_MAX 69
439#define _SC_GETPW_R_SIZE_MAX 70
440#define _SC_LOGIN_NAME_MAX 71
441#define _SC_TTY_NAME_MAX 72
442#define _SC_THREAD_DESTRUCTOR_ITERATIONS 73
443#define _SC_THREAD_KEYS_MAX 74
444#define _SC_THREAD_STACK_MIN 75
445#define _SC_THREAD_THREADS_MAX 76
446#define _SC_THREAD_ATTR_STACKADDR 77
447#define _SC_THREAD_ATTR_STACKSIZE 78
448#define _SC_THREAD_PRIORITY_SCHEDULING 79
449#define _SC_THREAD_PRIO_INHERIT 80
450#define _SC_THREAD_PRIO_PROTECT 81
451#define _SC_THREAD_PROCESS_SHARED 82
452#define _SC_NPROCESSORS_CONF 83
453#define _SC_NPROCESSORS_ONLN 84
454#define _SC_PHYS_PAGES 85
455#define _SC_AVPHYS_PAGES 86
456#define _SC_ATEXIT_MAX 87
457#define _SC_PASS_MAX 88
458#define _SC_XOPEN_VERSION 89
459#define _SC_XOPEN_XCU_VERSION 90
460#define _SC_XOPEN_UNIX 91
461#define _SC_XOPEN_CRYPT 92
462#define _SC_XOPEN_ENH_I18N 93
463#define _SC_XOPEN_SHM 94
464#define _SC_2_CHAR_TERM 95
465#define _SC_2_UPE 97
466#define _SC_XOPEN_XPG2 98
467#define _SC_XOPEN_XPG3 99
468#define _SC_XOPEN_XPG4 100
469#define _SC_NZERO 109
470#define _SC_XBS5_ILP32_OFF32 125
471#define _SC_XBS5_ILP32_OFFBIG 126
472#define _SC_XBS5_LP64_OFF64 127
473#define _SC_XBS5_LPBIG_OFFBIG 128
474#define _SC_XOPEN_LEGACY 129
475#define _SC_XOPEN_REALTIME 130
476#define _SC_XOPEN_REALTIME_THREADS 131
477#define _SC_ADVISORY_INFO 132
478#define _SC_BARRIERS 133
479#define _SC_CLOCK_SELECTION 137
480#define _SC_CPUTIME 138
481#define _SC_THREAD_CPUTIME 139
482#define _SC_MONOTONIC_CLOCK 149
483#define _SC_READER_WRITER_LOCKS 153
484#define _SC_SPIN_LOCKS 154
485#define _SC_REGEXP 155
486#define _SC_SHELL 157
487#define _SC_SPAWN 159
488#define _SC_SPORADIC_SERVER 160
489#define _SC_THREAD_SPORADIC_SERVER 161
490#define _SC_TIMEOUTS 164
491#define _SC_TYPED_MEMORY_OBJECTS 165
492#define _SC_2_PBS 168
493#define _SC_2_PBS_ACCOUNTING 169
494#define _SC_2_PBS_LOCATE 170
495#define _SC_2_PBS_MESSAGE 171
496#define _SC_2_PBS_TRACK 172
497#define _SC_SYMLOOP_MAX 173
498#define _SC_STREAMS 174
499#define _SC_2_PBS_CHECKPOINT 175
500#define _SC_V6_ILP32_OFF32 176
501#define _SC_V6_ILP32_OFFBIG 177
502#define _SC_V6_LP64_OFF64 178
503#define _SC_V6_LPBIG_OFFBIG 179
504#define _SC_HOST_NAME_MAX 180
505#define _SC_TRACE 181
506#define _SC_TRACE_EVENT_FILTER 182
507#define _SC_TRACE_INHERIT 183
508#define _SC_TRACE_LOG 184
509
510#define _SC_IPV6 235
511#define _SC_RAW_SOCKETS 236
512#define _SC_V7_ILP32_OFF32 237
513#define _SC_V7_ILP32_OFFBIG 238
514#define _SC_V7_LP64_OFF64 239
515#define _SC_V7_LPBIG_OFFBIG 240
516#define _SC_SS_REPL_MAX 241
517#define _SC_TRACE_EVENT_NAME_MAX 242
518#define _SC_TRACE_NAME_MAX 243
519#define _SC_TRACE_SYS_MAX 244
520#define _SC_TRACE_USER_EVENT_MAX 245
521#define _SC_XOPEN_STREAMS 246
522#define _SC_THREAD_ROBUST_PRIO_INHERIT 247
523#define _SC_THREAD_ROBUST_PRIO_PROTECT 248
524
525#define _CS_PATH 0
526#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 1
527#define _CS_GNU_LIBC_VERSION 2
528#define _CS_GNU_LIBPTHREAD_VERSION 3
529#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS 4
530#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 5
531
532#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 1116
533#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 1117
534#define _CS_POSIX_V6_ILP32_OFF32_LIBS 1118
535#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS 1119
536#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 1120
537#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 1121
538#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 1122
539#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS 1123
540#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 1124
541#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 1125
542#define _CS_POSIX_V6_LP64_OFF64_LIBS 1126
543#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS 1127
544#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 1128
545#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 1129
546#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 1130
547#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS 1131
548#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1132
549#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 1133
550#define _CS_POSIX_V7_ILP32_OFF32_LIBS 1134
551#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS 1135
552#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 1136
553#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 1137
554#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 1138
555#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS 1139
556#define _CS_POSIX_V7_LP64_OFF64_CFLAGS 1140
557#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 1141
558#define _CS_POSIX_V7_LP64_OFF64_LIBS 1142
559#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS 1143
560#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 1144
561#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 1145
562#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 1146
563#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS 1147
564#define _CS_V6_ENV 1148
565#define _CS_V7_ENV 1149
566
567#ifdef __cplusplus
568}
569#endif
570
571#endif
lib/libc/include/wasm32-wasi/utime.h deleted-29
......@@ -1,29 +0,0 @@
1#ifndef _UTIME_H
2#define _UTIME_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_time_t
11
12#include <bits/alltypes.h>
13
14struct utimbuf {
15 time_t actime;
16 time_t modtime;
17};
18
19int utime (const char *, const struct utimbuf *);
20
21#if _REDIR_TIME64
22__REDIR(utime, __utime64);
23#endif
24
25#ifdef __cplusplus
26}
27#endif
28
29#endif
lib/libc/include/wasm32-wasi/values.h deleted-39
......@@ -1,39 +0,0 @@
1#ifndef _VALUES_H
2#define _VALUES_H
3
4#include <limits.h>
5
6#define CHARBITS (sizeof(char) * 8)
7#define SHORTBITS (sizeof(short) * 8)
8#define INTBITS (sizeof(int) * 8)
9#define LONGBITS (sizeof(long) * 8)
10#define PTRBITS (sizeof(char *) * 8)
11#define DOUBLEBITS (sizeof(double) * 8)
12#define FLOATBITS (sizeof(float) * 8)
13
14#define MINSHORT SHRT_MIN
15#define MININT INT_MIN
16#define MINLONG LONG_MIN
17
18#define MAXSHORT SHRT_MAX
19#define MAXINT INT_MAX
20#define MAXLONG LONG_MAX
21
22#define HIBITS MINSHORT
23#define HIBITL MINLONG
24
25#include <float.h>
26
27#define MAXDOUBLE DBL_MAX
28#undef MAXFLOAT
29#define MAXFLOAT FLT_MAX
30#define MINDOUBLE DBL_MIN
31#define MINFLOAT FLT_MIN
32#define DMINEXP DBL_MIN_EXP
33#define FMINEXP FLT_MIN_EXP
34#define DMAXEXP DBL_MAX_EXP
35#define FMAXEXP FLT_MAX_EXP
36
37#define BITSPERBYTE CHAR_BIT
38
39#endif
lib/libc/include/wasm32-wasi/wasi/api.h deleted-2280
......@@ -1,2280 +0,0 @@
1/**
2 * THIS FILE IS AUTO-GENERATED from the following files:
3 * wasi_snapshot_preview1.witx
4 *
5 * To regenerate this file execute:
6 *
7 * cargo run --manifest-path tools/wasi-headers/Cargo.toml generate-libc
8 *
9 * Modifications to this file will cause CI to fail, the code generator tool
10 * must be modified to change this file.
11 *
12 * @file
13 * This file describes the [WASI] interface, consisting of functions, types,
14 * and defined values (macros).
15 *
16 * The interface described here is greatly inspired by [CloudABI]'s clean,
17 * thoughtfully-designed, capability-oriented, POSIX-style API.
18 *
19 * [CloudABI]: https://github.com/NuxiNL/cloudlibc
20 * [WASI]: https://github.com/WebAssembly/WASI/
21 */
22
23#ifndef __wasi_api_h
24#define __wasi_api_h
25
26#ifndef __wasi__
27#error <wasi/api.h> is only supported on WASI platforms.
28#endif
29
30#ifndef __wasm32__
31#error <wasi/api.h> only supports wasm32; doesn't yet support wasm64
32#endif
33
34#include <stddef.h>
35#include <stdint.h>
36
37_Static_assert(_Alignof(int8_t) == 1, "non-wasi data layout");
38_Static_assert(_Alignof(uint8_t) == 1, "non-wasi data layout");
39_Static_assert(_Alignof(int16_t) == 2, "non-wasi data layout");
40_Static_assert(_Alignof(uint16_t) == 2, "non-wasi data layout");
41_Static_assert(_Alignof(int32_t) == 4, "non-wasi data layout");
42_Static_assert(_Alignof(uint32_t) == 4, "non-wasi data layout");
43_Static_assert(_Alignof(int64_t) == 8, "non-wasi data layout");
44_Static_assert(_Alignof(uint64_t) == 8, "non-wasi data layout");
45_Static_assert(_Alignof(void*) == 4, "non-wasi data layout");
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51// TODO: Encoding this in witx.
52#define __WASI_DIRCOOKIE_START (UINT64_C(0))
53typedef __SIZE_TYPE__ __wasi_size_t;
54
55_Static_assert(sizeof(__wasi_size_t) == 4, "witx calculated size");
56_Static_assert(_Alignof(__wasi_size_t) == 4, "witx calculated align");
57
58/**
59 * Non-negative file size or length of a region within a file.
60 */
61typedef uint64_t __wasi_filesize_t;
62
63_Static_assert(sizeof(__wasi_filesize_t) == 8, "witx calculated size");
64_Static_assert(_Alignof(__wasi_filesize_t) == 8, "witx calculated align");
65
66/**
67 * Timestamp in nanoseconds.
68 */
69typedef uint64_t __wasi_timestamp_t;
70
71_Static_assert(sizeof(__wasi_timestamp_t) == 8, "witx calculated size");
72_Static_assert(_Alignof(__wasi_timestamp_t) == 8, "witx calculated align");
73
74/**
75 * Identifiers for clocks.
76 */
77typedef uint32_t __wasi_clockid_t;
78
79/**
80 * The clock measuring real time. Time value zero corresponds with
81 * 1970-01-01T00:00:00Z.
82 */
83#define __WASI_CLOCKID_REALTIME (UINT32_C(0))
84
85/**
86 * The store-wide monotonic clock, which is defined as a clock measuring
87 * real time, whose value cannot be adjusted and which cannot have negative
88 * clock jumps. The epoch of this clock is undefined. The absolute time
89 * value of this clock therefore has no meaning.
90 */
91#define __WASI_CLOCKID_MONOTONIC (UINT32_C(1))
92
93/**
94 * The CPU-time clock associated with the current process.
95 */
96#define __WASI_CLOCKID_PROCESS_CPUTIME_ID (UINT32_C(2))
97
98/**
99 * The CPU-time clock associated with the current thread.
100 */
101#define __WASI_CLOCKID_THREAD_CPUTIME_ID (UINT32_C(3))
102
103_Static_assert(sizeof(__wasi_clockid_t) == 4, "witx calculated size");
104_Static_assert(_Alignof(__wasi_clockid_t) == 4, "witx calculated align");
105
106/**
107 * Error codes returned by functions.
108 * Not all of these error codes are returned by the functions provided by this
109 * API; some are used in higher-level library layers, and others are provided
110 * merely for alignment with POSIX.
111 */
112typedef uint16_t __wasi_errno_t;
113
114/**
115 * No error occurred. System call completed successfully.
116 */
117#define __WASI_ERRNO_SUCCESS (UINT16_C(0))
118
119/**
120 * Argument list too long.
121 */
122#define __WASI_ERRNO_2BIG (UINT16_C(1))
123
124/**
125 * Permission denied.
126 */
127#define __WASI_ERRNO_ACCES (UINT16_C(2))
128
129/**
130 * Address in use.
131 */
132#define __WASI_ERRNO_ADDRINUSE (UINT16_C(3))
133
134/**
135 * Address not available.
136 */
137#define __WASI_ERRNO_ADDRNOTAVAIL (UINT16_C(4))
138
139/**
140 * Address family not supported.
141 */
142#define __WASI_ERRNO_AFNOSUPPORT (UINT16_C(5))
143
144/**
145 * Resource unavailable, or operation would block.
146 */
147#define __WASI_ERRNO_AGAIN (UINT16_C(6))
148
149/**
150 * Connection already in progress.
151 */
152#define __WASI_ERRNO_ALREADY (UINT16_C(7))
153
154/**
155 * Bad file descriptor.
156 */
157#define __WASI_ERRNO_BADF (UINT16_C(8))
158
159/**
160 * Bad message.
161 */
162#define __WASI_ERRNO_BADMSG (UINT16_C(9))
163
164/**
165 * Device or resource busy.
166 */
167#define __WASI_ERRNO_BUSY (UINT16_C(10))
168
169/**
170 * Operation canceled.
171 */
172#define __WASI_ERRNO_CANCELED (UINT16_C(11))
173
174/**
175 * No child processes.
176 */
177#define __WASI_ERRNO_CHILD (UINT16_C(12))
178
179/**
180 * Connection aborted.
181 */
182#define __WASI_ERRNO_CONNABORTED (UINT16_C(13))
183
184/**
185 * Connection refused.
186 */
187#define __WASI_ERRNO_CONNREFUSED (UINT16_C(14))
188
189/**
190 * Connection reset.
191 */
192#define __WASI_ERRNO_CONNRESET (UINT16_C(15))
193
194/**
195 * Resource deadlock would occur.
196 */
197#define __WASI_ERRNO_DEADLK (UINT16_C(16))
198
199/**
200 * Destination address required.
201 */
202#define __WASI_ERRNO_DESTADDRREQ (UINT16_C(17))
203
204/**
205 * Mathematics argument out of domain of function.
206 */
207#define __WASI_ERRNO_DOM (UINT16_C(18))
208
209/**
210 * Reserved.
211 */
212#define __WASI_ERRNO_DQUOT (UINT16_C(19))
213
214/**
215 * File exists.
216 */
217#define __WASI_ERRNO_EXIST (UINT16_C(20))
218
219/**
220 * Bad address.
221 */
222#define __WASI_ERRNO_FAULT (UINT16_C(21))
223
224/**
225 * File too large.
226 */
227#define __WASI_ERRNO_FBIG (UINT16_C(22))
228
229/**
230 * Host is unreachable.
231 */
232#define __WASI_ERRNO_HOSTUNREACH (UINT16_C(23))
233
234/**
235 * Identifier removed.
236 */
237#define __WASI_ERRNO_IDRM (UINT16_C(24))
238
239/**
240 * Illegal byte sequence.
241 */
242#define __WASI_ERRNO_ILSEQ (UINT16_C(25))
243
244/**
245 * Operation in progress.
246 */
247#define __WASI_ERRNO_INPROGRESS (UINT16_C(26))
248
249/**
250 * Interrupted function.
251 */
252#define __WASI_ERRNO_INTR (UINT16_C(27))
253
254/**
255 * Invalid argument.
256 */
257#define __WASI_ERRNO_INVAL (UINT16_C(28))
258
259/**
260 * I/O error.
261 */
262#define __WASI_ERRNO_IO (UINT16_C(29))
263
264/**
265 * Socket is connected.
266 */
267#define __WASI_ERRNO_ISCONN (UINT16_C(30))
268
269/**
270 * Is a directory.
271 */
272#define __WASI_ERRNO_ISDIR (UINT16_C(31))
273
274/**
275 * Too many levels of symbolic links.
276 */
277#define __WASI_ERRNO_LOOP (UINT16_C(32))
278
279/**
280 * File descriptor value too large.
281 */
282#define __WASI_ERRNO_MFILE (UINT16_C(33))
283
284/**
285 * Too many links.
286 */
287#define __WASI_ERRNO_MLINK (UINT16_C(34))
288
289/**
290 * Message too large.
291 */
292#define __WASI_ERRNO_MSGSIZE (UINT16_C(35))
293
294/**
295 * Reserved.
296 */
297#define __WASI_ERRNO_MULTIHOP (UINT16_C(36))
298
299/**
300 * Filename too long.
301 */
302#define __WASI_ERRNO_NAMETOOLONG (UINT16_C(37))
303
304/**
305 * Network is down.
306 */
307#define __WASI_ERRNO_NETDOWN (UINT16_C(38))
308
309/**
310 * Connection aborted by network.
311 */
312#define __WASI_ERRNO_NETRESET (UINT16_C(39))
313
314/**
315 * Network unreachable.
316 */
317#define __WASI_ERRNO_NETUNREACH (UINT16_C(40))
318
319/**
320 * Too many files open in system.
321 */
322#define __WASI_ERRNO_NFILE (UINT16_C(41))
323
324/**
325 * No buffer space available.
326 */
327#define __WASI_ERRNO_NOBUFS (UINT16_C(42))
328
329/**
330 * No such device.
331 */
332#define __WASI_ERRNO_NODEV (UINT16_C(43))
333
334/**
335 * No such file or directory.
336 */
337#define __WASI_ERRNO_NOENT (UINT16_C(44))
338
339/**
340 * Executable file format error.
341 */
342#define __WASI_ERRNO_NOEXEC (UINT16_C(45))
343
344/**
345 * No locks available.
346 */
347#define __WASI_ERRNO_NOLCK (UINT16_C(46))
348
349/**
350 * Reserved.
351 */
352#define __WASI_ERRNO_NOLINK (UINT16_C(47))
353
354/**
355 * Not enough space.
356 */
357#define __WASI_ERRNO_NOMEM (UINT16_C(48))
358
359/**
360 * No message of the desired type.
361 */
362#define __WASI_ERRNO_NOMSG (UINT16_C(49))
363
364/**
365 * Protocol not available.
366 */
367#define __WASI_ERRNO_NOPROTOOPT (UINT16_C(50))
368
369/**
370 * No space left on device.
371 */
372#define __WASI_ERRNO_NOSPC (UINT16_C(51))
373
374/**
375 * Function not supported.
376 */
377#define __WASI_ERRNO_NOSYS (UINT16_C(52))
378
379/**
380 * The socket is not connected.
381 */
382#define __WASI_ERRNO_NOTCONN (UINT16_C(53))
383
384/**
385 * Not a directory or a symbolic link to a directory.
386 */
387#define __WASI_ERRNO_NOTDIR (UINT16_C(54))
388
389/**
390 * Directory not empty.
391 */
392#define __WASI_ERRNO_NOTEMPTY (UINT16_C(55))
393
394/**
395 * State not recoverable.
396 */
397#define __WASI_ERRNO_NOTRECOVERABLE (UINT16_C(56))
398
399/**
400 * Not a socket.
401 */
402#define __WASI_ERRNO_NOTSOCK (UINT16_C(57))
403
404/**
405 * Not supported, or operation not supported on socket.
406 */
407#define __WASI_ERRNO_NOTSUP (UINT16_C(58))
408
409/**
410 * Inappropriate I/O control operation.
411 */
412#define __WASI_ERRNO_NOTTY (UINT16_C(59))
413
414/**
415 * No such device or address.
416 */
417#define __WASI_ERRNO_NXIO (UINT16_C(60))
418
419/**
420 * Value too large to be stored in data type.
421 */
422#define __WASI_ERRNO_OVERFLOW (UINT16_C(61))
423
424/**
425 * Previous owner died.
426 */
427#define __WASI_ERRNO_OWNERDEAD (UINT16_C(62))
428
429/**
430 * Operation not permitted.
431 */
432#define __WASI_ERRNO_PERM (UINT16_C(63))
433
434/**
435 * Broken pipe.
436 */
437#define __WASI_ERRNO_PIPE (UINT16_C(64))
438
439/**
440 * Protocol error.
441 */
442#define __WASI_ERRNO_PROTO (UINT16_C(65))
443
444/**
445 * Protocol not supported.
446 */
447#define __WASI_ERRNO_PROTONOSUPPORT (UINT16_C(66))
448
449/**
450 * Protocol wrong type for socket.
451 */
452#define __WASI_ERRNO_PROTOTYPE (UINT16_C(67))
453
454/**
455 * Result too large.
456 */
457#define __WASI_ERRNO_RANGE (UINT16_C(68))
458
459/**
460 * Read-only file system.
461 */
462#define __WASI_ERRNO_ROFS (UINT16_C(69))
463
464/**
465 * Invalid seek.
466 */
467#define __WASI_ERRNO_SPIPE (UINT16_C(70))
468
469/**
470 * No such process.
471 */
472#define __WASI_ERRNO_SRCH (UINT16_C(71))
473
474/**
475 * Reserved.
476 */
477#define __WASI_ERRNO_STALE (UINT16_C(72))
478
479/**
480 * Connection timed out.
481 */
482#define __WASI_ERRNO_TIMEDOUT (UINT16_C(73))
483
484/**
485 * Text file busy.
486 */
487#define __WASI_ERRNO_TXTBSY (UINT16_C(74))
488
489/**
490 * Cross-device link.
491 */
492#define __WASI_ERRNO_XDEV (UINT16_C(75))
493
494/**
495 * Extension: Capabilities insufficient.
496 */
497#define __WASI_ERRNO_NOTCAPABLE (UINT16_C(76))
498
499_Static_assert(sizeof(__wasi_errno_t) == 2, "witx calculated size");
500_Static_assert(_Alignof(__wasi_errno_t) == 2, "witx calculated align");
501
502/**
503 * File descriptor rights, determining which actions may be performed.
504 */
505typedef uint64_t __wasi_rights_t;
506
507/**
508 * The right to invoke `fd_datasync`.
509 * If `path_open` is set, includes the right to invoke
510 * `path_open` with `fdflags::dsync`.
511 */
512#define __WASI_RIGHTS_FD_DATASYNC ((__wasi_rights_t)(1 << 0))
513
514/**
515 * The right to invoke `fd_read` and `sock_recv`.
516 * If `rights::fd_seek` is set, includes the right to invoke `fd_pread`.
517 */
518#define __WASI_RIGHTS_FD_READ ((__wasi_rights_t)(1 << 1))
519
520/**
521 * The right to invoke `fd_seek`. This flag implies `rights::fd_tell`.
522 */
523#define __WASI_RIGHTS_FD_SEEK ((__wasi_rights_t)(1 << 2))
524
525/**
526 * The right to invoke `fd_fdstat_set_flags`.
527 */
528#define __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS ((__wasi_rights_t)(1 << 3))
529
530/**
531 * The right to invoke `fd_sync`.
532 * If `path_open` is set, includes the right to invoke
533 * `path_open` with `fdflags::rsync` and `fdflags::dsync`.
534 */
535#define __WASI_RIGHTS_FD_SYNC ((__wasi_rights_t)(1 << 4))
536
537/**
538 * The right to invoke `fd_seek` in such a way that the file offset
539 * remains unaltered (i.e., `whence::cur` with offset zero), or to
540 * invoke `fd_tell`.
541 */
542#define __WASI_RIGHTS_FD_TELL ((__wasi_rights_t)(1 << 5))
543
544/**
545 * The right to invoke `fd_write` and `sock_send`.
546 * If `rights::fd_seek` is set, includes the right to invoke `fd_pwrite`.
547 */
548#define __WASI_RIGHTS_FD_WRITE ((__wasi_rights_t)(1 << 6))
549
550/**
551 * The right to invoke `fd_advise`.
552 */
553#define __WASI_RIGHTS_FD_ADVISE ((__wasi_rights_t)(1 << 7))
554
555/**
556 * The right to invoke `fd_allocate`.
557 */
558#define __WASI_RIGHTS_FD_ALLOCATE ((__wasi_rights_t)(1 << 8))
559
560/**
561 * The right to invoke `path_create_directory`.
562 */
563#define __WASI_RIGHTS_PATH_CREATE_DIRECTORY ((__wasi_rights_t)(1 << 9))
564
565/**
566 * If `path_open` is set, the right to invoke `path_open` with `oflags::creat`.
567 */
568#define __WASI_RIGHTS_PATH_CREATE_FILE ((__wasi_rights_t)(1 << 10))
569
570/**
571 * The right to invoke `path_link` with the file descriptor as the
572 * source directory.
573 */
574#define __WASI_RIGHTS_PATH_LINK_SOURCE ((__wasi_rights_t)(1 << 11))
575
576/**
577 * The right to invoke `path_link` with the file descriptor as the
578 * target directory.
579 */
580#define __WASI_RIGHTS_PATH_LINK_TARGET ((__wasi_rights_t)(1 << 12))
581
582/**
583 * The right to invoke `path_open`.
584 */
585#define __WASI_RIGHTS_PATH_OPEN ((__wasi_rights_t)(1 << 13))
586
587/**
588 * The right to invoke `fd_readdir`.
589 */
590#define __WASI_RIGHTS_FD_READDIR ((__wasi_rights_t)(1 << 14))
591
592/**
593 * The right to invoke `path_readlink`.
594 */
595#define __WASI_RIGHTS_PATH_READLINK ((__wasi_rights_t)(1 << 15))
596
597/**
598 * The right to invoke `path_rename` with the file descriptor as the source directory.
599 */
600#define __WASI_RIGHTS_PATH_RENAME_SOURCE ((__wasi_rights_t)(1 << 16))
601
602/**
603 * The right to invoke `path_rename` with the file descriptor as the target directory.
604 */
605#define __WASI_RIGHTS_PATH_RENAME_TARGET ((__wasi_rights_t)(1 << 17))
606
607/**
608 * The right to invoke `path_filestat_get`.
609 */
610#define __WASI_RIGHTS_PATH_FILESTAT_GET ((__wasi_rights_t)(1 << 18))
611
612/**
613 * The right to change a file's size (there is no `path_filestat_set_size`).
614 * If `path_open` is set, includes the right to invoke `path_open` with `oflags::trunc`.
615 */
616#define __WASI_RIGHTS_PATH_FILESTAT_SET_SIZE ((__wasi_rights_t)(1 << 19))
617
618/**
619 * The right to invoke `path_filestat_set_times`.
620 */
621#define __WASI_RIGHTS_PATH_FILESTAT_SET_TIMES ((__wasi_rights_t)(1 << 20))
622
623/**
624 * The right to invoke `fd_filestat_get`.
625 */
626#define __WASI_RIGHTS_FD_FILESTAT_GET ((__wasi_rights_t)(1 << 21))
627
628/**
629 * The right to invoke `fd_filestat_set_size`.
630 */
631#define __WASI_RIGHTS_FD_FILESTAT_SET_SIZE ((__wasi_rights_t)(1 << 22))
632
633/**
634 * The right to invoke `fd_filestat_set_times`.
635 */
636#define __WASI_RIGHTS_FD_FILESTAT_SET_TIMES ((__wasi_rights_t)(1 << 23))
637
638/**
639 * The right to invoke `path_symlink`.
640 */
641#define __WASI_RIGHTS_PATH_SYMLINK ((__wasi_rights_t)(1 << 24))
642
643/**
644 * The right to invoke `path_remove_directory`.
645 */
646#define __WASI_RIGHTS_PATH_REMOVE_DIRECTORY ((__wasi_rights_t)(1 << 25))
647
648/**
649 * The right to invoke `path_unlink_file`.
650 */
651#define __WASI_RIGHTS_PATH_UNLINK_FILE ((__wasi_rights_t)(1 << 26))
652
653/**
654 * If `rights::fd_read` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_read`.
655 * If `rights::fd_write` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_write`.
656 */
657#define __WASI_RIGHTS_POLL_FD_READWRITE ((__wasi_rights_t)(1 << 27))
658
659/**
660 * The right to invoke `sock_shutdown`.
661 */
662#define __WASI_RIGHTS_SOCK_SHUTDOWN ((__wasi_rights_t)(1 << 28))
663
664/**
665 * A file descriptor handle.
666 */
667typedef int __wasi_fd_t;
668
669_Static_assert(sizeof(__wasi_fd_t) == 4, "witx calculated size");
670_Static_assert(_Alignof(__wasi_fd_t) == 4, "witx calculated align");
671
672/**
673 * A region of memory for scatter/gather reads.
674 */
675typedef struct __wasi_iovec_t {
676 /**
677 * The address of the buffer to be filled.
678 */
679 uint8_t * buf;
680
681 /**
682 * The length of the buffer to be filled.
683 */
684 __wasi_size_t buf_len;
685
686} __wasi_iovec_t;
687
688_Static_assert(sizeof(__wasi_iovec_t) == 8, "witx calculated size");
689_Static_assert(_Alignof(__wasi_iovec_t) == 4, "witx calculated align");
690_Static_assert(offsetof(__wasi_iovec_t, buf) == 0, "witx calculated offset");
691_Static_assert(offsetof(__wasi_iovec_t, buf_len) == 4, "witx calculated offset");
692
693/**
694 * A region of memory for scatter/gather writes.
695 */
696typedef struct __wasi_ciovec_t {
697 /**
698 * The address of the buffer to be written.
699 */
700 const uint8_t * buf;
701
702 /**
703 * The length of the buffer to be written.
704 */
705 __wasi_size_t buf_len;
706
707} __wasi_ciovec_t;
708
709_Static_assert(sizeof(__wasi_ciovec_t) == 8, "witx calculated size");
710_Static_assert(_Alignof(__wasi_ciovec_t) == 4, "witx calculated align");
711_Static_assert(offsetof(__wasi_ciovec_t, buf) == 0, "witx calculated offset");
712_Static_assert(offsetof(__wasi_ciovec_t, buf_len) == 4, "witx calculated offset");
713
714/**
715 * Relative offset within a file.
716 */
717typedef int64_t __wasi_filedelta_t;
718
719_Static_assert(sizeof(__wasi_filedelta_t) == 8, "witx calculated size");
720_Static_assert(_Alignof(__wasi_filedelta_t) == 8, "witx calculated align");
721
722/**
723 * The position relative to which to set the offset of the file descriptor.
724 */
725typedef uint8_t __wasi_whence_t;
726
727/**
728 * Seek relative to start-of-file.
729 */
730#define __WASI_WHENCE_SET (UINT8_C(0))
731
732/**
733 * Seek relative to current position.
734 */
735#define __WASI_WHENCE_CUR (UINT8_C(1))
736
737/**
738 * Seek relative to end-of-file.
739 */
740#define __WASI_WHENCE_END (UINT8_C(2))
741
742_Static_assert(sizeof(__wasi_whence_t) == 1, "witx calculated size");
743_Static_assert(_Alignof(__wasi_whence_t) == 1, "witx calculated align");
744
745/**
746 * A reference to the offset of a directory entry.
747 *
748 * The value 0 signifies the start of the directory.
749 */
750typedef uint64_t __wasi_dircookie_t;
751
752_Static_assert(sizeof(__wasi_dircookie_t) == 8, "witx calculated size");
753_Static_assert(_Alignof(__wasi_dircookie_t) == 8, "witx calculated align");
754
755/**
756 * The type for the `dirent::d_namlen` field of `dirent` struct.
757 */
758typedef uint32_t __wasi_dirnamlen_t;
759
760_Static_assert(sizeof(__wasi_dirnamlen_t) == 4, "witx calculated size");
761_Static_assert(_Alignof(__wasi_dirnamlen_t) == 4, "witx calculated align");
762
763/**
764 * File serial number that is unique within its file system.
765 */
766typedef uint64_t __wasi_inode_t;
767
768_Static_assert(sizeof(__wasi_inode_t) == 8, "witx calculated size");
769_Static_assert(_Alignof(__wasi_inode_t) == 8, "witx calculated align");
770
771/**
772 * The type of a file descriptor or file.
773 */
774typedef uint8_t __wasi_filetype_t;
775
776/**
777 * The type of the file descriptor or file is unknown or is different from any of the other types specified.
778 */
779#define __WASI_FILETYPE_UNKNOWN (UINT8_C(0))
780
781/**
782 * The file descriptor or file refers to a block device inode.
783 */
784#define __WASI_FILETYPE_BLOCK_DEVICE (UINT8_C(1))
785
786/**
787 * The file descriptor or file refers to a character device inode.
788 */
789#define __WASI_FILETYPE_CHARACTER_DEVICE (UINT8_C(2))
790
791/**
792 * The file descriptor or file refers to a directory inode.
793 */
794#define __WASI_FILETYPE_DIRECTORY (UINT8_C(3))
795
796/**
797 * The file descriptor or file refers to a regular file inode.
798 */
799#define __WASI_FILETYPE_REGULAR_FILE (UINT8_C(4))
800
801/**
802 * The file descriptor or file refers to a datagram socket.
803 */
804#define __WASI_FILETYPE_SOCKET_DGRAM (UINT8_C(5))
805
806/**
807 * The file descriptor or file refers to a byte-stream socket.
808 */
809#define __WASI_FILETYPE_SOCKET_STREAM (UINT8_C(6))
810
811/**
812 * The file refers to a symbolic link inode.
813 */
814#define __WASI_FILETYPE_SYMBOLIC_LINK (UINT8_C(7))
815
816_Static_assert(sizeof(__wasi_filetype_t) == 1, "witx calculated size");
817_Static_assert(_Alignof(__wasi_filetype_t) == 1, "witx calculated align");
818
819/**
820 * A directory entry.
821 */
822typedef struct __wasi_dirent_t {
823 /**
824 * The offset of the next directory entry stored in this directory.
825 */
826 __wasi_dircookie_t d_next;
827
828 /**
829 * The serial number of the file referred to by this directory entry.
830 */
831 __wasi_inode_t d_ino;
832
833 /**
834 * The length of the name of the directory entry.
835 */
836 __wasi_dirnamlen_t d_namlen;
837
838 /**
839 * The type of the file referred to by this directory entry.
840 */
841 __wasi_filetype_t d_type;
842
843} __wasi_dirent_t;
844
845_Static_assert(sizeof(__wasi_dirent_t) == 24, "witx calculated size");
846_Static_assert(_Alignof(__wasi_dirent_t) == 8, "witx calculated align");
847_Static_assert(offsetof(__wasi_dirent_t, d_next) == 0, "witx calculated offset");
848_Static_assert(offsetof(__wasi_dirent_t, d_ino) == 8, "witx calculated offset");
849_Static_assert(offsetof(__wasi_dirent_t, d_namlen) == 16, "witx calculated offset");
850_Static_assert(offsetof(__wasi_dirent_t, d_type) == 20, "witx calculated offset");
851
852/**
853 * File or memory access pattern advisory information.
854 */
855typedef uint8_t __wasi_advice_t;
856
857/**
858 * The application has no advice to give on its behavior with respect to the specified data.
859 */
860#define __WASI_ADVICE_NORMAL (UINT8_C(0))
861
862/**
863 * The application expects to access the specified data sequentially from lower offsets to higher offsets.
864 */
865#define __WASI_ADVICE_SEQUENTIAL (UINT8_C(1))
866
867/**
868 * The application expects to access the specified data in a random order.
869 */
870#define __WASI_ADVICE_RANDOM (UINT8_C(2))
871
872/**
873 * The application expects to access the specified data in the near future.
874 */
875#define __WASI_ADVICE_WILLNEED (UINT8_C(3))
876
877/**
878 * The application expects that it will not access the specified data in the near future.
879 */
880#define __WASI_ADVICE_DONTNEED (UINT8_C(4))
881
882/**
883 * The application expects to access the specified data once and then not reuse it thereafter.
884 */
885#define __WASI_ADVICE_NOREUSE (UINT8_C(5))
886
887_Static_assert(sizeof(__wasi_advice_t) == 1, "witx calculated size");
888_Static_assert(_Alignof(__wasi_advice_t) == 1, "witx calculated align");
889
890/**
891 * File descriptor flags.
892 */
893typedef uint16_t __wasi_fdflags_t;
894
895/**
896 * Append mode: Data written to the file is always appended to the file's end.
897 */
898#define __WASI_FDFLAGS_APPEND ((__wasi_fdflags_t)(1 << 0))
899
900/**
901 * Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
902 */
903#define __WASI_FDFLAGS_DSYNC ((__wasi_fdflags_t)(1 << 1))
904
905/**
906 * Non-blocking mode.
907 */
908#define __WASI_FDFLAGS_NONBLOCK ((__wasi_fdflags_t)(1 << 2))
909
910/**
911 * Synchronized read I/O operations.
912 */
913#define __WASI_FDFLAGS_RSYNC ((__wasi_fdflags_t)(1 << 3))
914
915/**
916 * Write according to synchronized I/O file integrity completion. In
917 * addition to synchronizing the data stored in the file, the implementation
918 * may also synchronously update the file's metadata.
919 */
920#define __WASI_FDFLAGS_SYNC ((__wasi_fdflags_t)(1 << 4))
921
922/**
923 * File descriptor attributes.
924 */
925typedef struct __wasi_fdstat_t {
926 /**
927 * File type.
928 */
929 __wasi_filetype_t fs_filetype;
930
931 /**
932 * File descriptor flags.
933 */
934 __wasi_fdflags_t fs_flags;
935
936 /**
937 * Rights that apply to this file descriptor.
938 */
939 __wasi_rights_t fs_rights_base;
940
941 /**
942 * Maximum set of rights that may be installed on new file descriptors that
943 * are created through this file descriptor, e.g., through `path_open`.
944 */
945 __wasi_rights_t fs_rights_inheriting;
946
947} __wasi_fdstat_t;
948
949_Static_assert(sizeof(__wasi_fdstat_t) == 24, "witx calculated size");
950_Static_assert(_Alignof(__wasi_fdstat_t) == 8, "witx calculated align");
951_Static_assert(offsetof(__wasi_fdstat_t, fs_filetype) == 0, "witx calculated offset");
952_Static_assert(offsetof(__wasi_fdstat_t, fs_flags) == 2, "witx calculated offset");
953_Static_assert(offsetof(__wasi_fdstat_t, fs_rights_base) == 8, "witx calculated offset");
954_Static_assert(offsetof(__wasi_fdstat_t, fs_rights_inheriting) == 16, "witx calculated offset");
955
956/**
957 * Identifier for a device containing a file system. Can be used in combination
958 * with `inode` to uniquely identify a file or directory in the filesystem.
959 */
960typedef uint64_t __wasi_device_t;
961
962_Static_assert(sizeof(__wasi_device_t) == 8, "witx calculated size");
963_Static_assert(_Alignof(__wasi_device_t) == 8, "witx calculated align");
964
965/**
966 * Which file time attributes to adjust.
967 */
968typedef uint16_t __wasi_fstflags_t;
969
970/**
971 * Adjust the last data access timestamp to the value stored in `filestat::atim`.
972 */
973#define __WASI_FSTFLAGS_ATIM ((__wasi_fstflags_t)(1 << 0))
974
975/**
976 * Adjust the last data access timestamp to the time of clock `clockid::realtime`.
977 */
978#define __WASI_FSTFLAGS_ATIM_NOW ((__wasi_fstflags_t)(1 << 1))
979
980/**
981 * Adjust the last data modification timestamp to the value stored in `filestat::mtim`.
982 */
983#define __WASI_FSTFLAGS_MTIM ((__wasi_fstflags_t)(1 << 2))
984
985/**
986 * Adjust the last data modification timestamp to the time of clock `clockid::realtime`.
987 */
988#define __WASI_FSTFLAGS_MTIM_NOW ((__wasi_fstflags_t)(1 << 3))
989
990/**
991 * Flags determining the method of how paths are resolved.
992 */
993typedef uint32_t __wasi_lookupflags_t;
994
995/**
996 * As long as the resolved path corresponds to a symbolic link, it is expanded.
997 */
998#define __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW ((__wasi_lookupflags_t)(1 << 0))
999
1000/**
1001 * Open flags used by `path_open`.
1002 */
1003typedef uint16_t __wasi_oflags_t;
1004
1005/**
1006 * Create file if it does not exist.
1007 */
1008#define __WASI_OFLAGS_CREAT ((__wasi_oflags_t)(1 << 0))
1009
1010/**
1011 * Fail if not a directory.
1012 */
1013#define __WASI_OFLAGS_DIRECTORY ((__wasi_oflags_t)(1 << 1))
1014
1015/**
1016 * Fail if file already exists.
1017 */
1018#define __WASI_OFLAGS_EXCL ((__wasi_oflags_t)(1 << 2))
1019
1020/**
1021 * Truncate file to size 0.
1022 */
1023#define __WASI_OFLAGS_TRUNC ((__wasi_oflags_t)(1 << 3))
1024
1025/**
1026 * Number of hard links to an inode.
1027 */
1028typedef uint64_t __wasi_linkcount_t;
1029
1030_Static_assert(sizeof(__wasi_linkcount_t) == 8, "witx calculated size");
1031_Static_assert(_Alignof(__wasi_linkcount_t) == 8, "witx calculated align");
1032
1033/**
1034 * File attributes.
1035 */
1036typedef struct __wasi_filestat_t {
1037 /**
1038 * Device ID of device containing the file.
1039 */
1040 __wasi_device_t dev;
1041
1042 /**
1043 * File serial number.
1044 */
1045 __wasi_inode_t ino;
1046
1047 /**
1048 * File type.
1049 */
1050 __wasi_filetype_t filetype;
1051
1052 /**
1053 * Number of hard links to the file.
1054 */
1055 __wasi_linkcount_t nlink;
1056
1057 /**
1058 * For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link.
1059 */
1060 __wasi_filesize_t size;
1061
1062 /**
1063 * Last data access timestamp.
1064 */
1065 __wasi_timestamp_t atim;
1066
1067 /**
1068 * Last data modification timestamp.
1069 */
1070 __wasi_timestamp_t mtim;
1071
1072 /**
1073 * Last file status change timestamp.
1074 */
1075 __wasi_timestamp_t ctim;
1076
1077} __wasi_filestat_t;
1078
1079_Static_assert(sizeof(__wasi_filestat_t) == 64, "witx calculated size");
1080_Static_assert(_Alignof(__wasi_filestat_t) == 8, "witx calculated align");
1081_Static_assert(offsetof(__wasi_filestat_t, dev) == 0, "witx calculated offset");
1082_Static_assert(offsetof(__wasi_filestat_t, ino) == 8, "witx calculated offset");
1083_Static_assert(offsetof(__wasi_filestat_t, filetype) == 16, "witx calculated offset");
1084_Static_assert(offsetof(__wasi_filestat_t, nlink) == 24, "witx calculated offset");
1085_Static_assert(offsetof(__wasi_filestat_t, size) == 32, "witx calculated offset");
1086_Static_assert(offsetof(__wasi_filestat_t, atim) == 40, "witx calculated offset");
1087_Static_assert(offsetof(__wasi_filestat_t, mtim) == 48, "witx calculated offset");
1088_Static_assert(offsetof(__wasi_filestat_t, ctim) == 56, "witx calculated offset");
1089
1090/**
1091 * User-provided value that may be attached to objects that is retained when
1092 * extracted from the implementation.
1093 */
1094typedef uint64_t __wasi_userdata_t;
1095
1096_Static_assert(sizeof(__wasi_userdata_t) == 8, "witx calculated size");
1097_Static_assert(_Alignof(__wasi_userdata_t) == 8, "witx calculated align");
1098
1099/**
1100 * Type of a subscription to an event or its occurrence.
1101 */
1102typedef uint8_t __wasi_eventtype_t;
1103
1104/**
1105 * The time value of clock `subscription_clock::id` has
1106 * reached timestamp `subscription_clock::timeout`.
1107 */
1108#define __WASI_EVENTTYPE_CLOCK (UINT8_C(0))
1109
1110/**
1111 * File descriptor `subscription_fd_readwrite::file_descriptor` has data
1112 * available for reading. This event always triggers for regular files.
1113 */
1114#define __WASI_EVENTTYPE_FD_READ (UINT8_C(1))
1115
1116/**
1117 * File descriptor `subscription_fd_readwrite::file_descriptor` has capacity
1118 * available for writing. This event always triggers for regular files.
1119 */
1120#define __WASI_EVENTTYPE_FD_WRITE (UINT8_C(2))
1121
1122_Static_assert(sizeof(__wasi_eventtype_t) == 1, "witx calculated size");
1123_Static_assert(_Alignof(__wasi_eventtype_t) == 1, "witx calculated align");
1124
1125/**
1126 * The state of the file descriptor subscribed to with
1127 * `eventtype::fd_read` or `eventtype::fd_write`.
1128 */
1129typedef uint16_t __wasi_eventrwflags_t;
1130
1131/**
1132 * The peer of this socket has closed or disconnected.
1133 */
1134#define __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP ((__wasi_eventrwflags_t)(1 << 0))
1135
1136/**
1137 * The contents of an `event` when type is `eventtype::fd_read` or
1138 * `eventtype::fd_write`.
1139 */
1140typedef struct __wasi_event_fd_readwrite_t {
1141 /**
1142 * The number of bytes available for reading or writing.
1143 */
1144 __wasi_filesize_t nbytes;
1145
1146 /**
1147 * The state of the file descriptor.
1148 */
1149 __wasi_eventrwflags_t flags;
1150
1151} __wasi_event_fd_readwrite_t;
1152
1153_Static_assert(sizeof(__wasi_event_fd_readwrite_t) == 16, "witx calculated size");
1154_Static_assert(_Alignof(__wasi_event_fd_readwrite_t) == 8, "witx calculated align");
1155_Static_assert(offsetof(__wasi_event_fd_readwrite_t, nbytes) == 0, "witx calculated offset");
1156_Static_assert(offsetof(__wasi_event_fd_readwrite_t, flags) == 8, "witx calculated offset");
1157
1158/**
1159 * An event that occurred.
1160 */
1161typedef struct __wasi_event_t {
1162 /**
1163 * User-provided value that got attached to `subscription::userdata`.
1164 */
1165 __wasi_userdata_t userdata;
1166
1167 /**
1168 * If non-zero, an error that occurred while processing the subscription request.
1169 */
1170 __wasi_errno_t error;
1171
1172 /**
1173 * The type of event that occured
1174 */
1175 __wasi_eventtype_t type;
1176
1177 /**
1178 * The contents of the event, if it is an `eventtype::fd_read` or
1179 * `eventtype::fd_write`. `eventtype::clock` events ignore this field.
1180 */
1181 __wasi_event_fd_readwrite_t fd_readwrite;
1182
1183} __wasi_event_t;
1184
1185_Static_assert(sizeof(__wasi_event_t) == 32, "witx calculated size");
1186_Static_assert(_Alignof(__wasi_event_t) == 8, "witx calculated align");
1187_Static_assert(offsetof(__wasi_event_t, userdata) == 0, "witx calculated offset");
1188_Static_assert(offsetof(__wasi_event_t, error) == 8, "witx calculated offset");
1189_Static_assert(offsetof(__wasi_event_t, type) == 10, "witx calculated offset");
1190_Static_assert(offsetof(__wasi_event_t, fd_readwrite) == 16, "witx calculated offset");
1191
1192/**
1193 * Flags determining how to interpret the timestamp provided in
1194 * `subscription_clock::timeout`.
1195 */
1196typedef uint16_t __wasi_subclockflags_t;
1197
1198/**
1199 * If set, treat the timestamp provided in
1200 * `subscription_clock::timeout` as an absolute timestamp of clock
1201 * `subscription_clock::id`. If clear, treat the timestamp
1202 * provided in `subscription_clock::timeout` relative to the
1203 * current time value of clock `subscription_clock::id`.
1204 */
1205#define __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME ((__wasi_subclockflags_t)(1 << 0))
1206
1207/**
1208 * The contents of a `subscription` when type is `eventtype::clock`.
1209 */
1210typedef struct __wasi_subscription_clock_t {
1211 /**
1212 * The clock against which to compare the timestamp.
1213 */
1214 __wasi_clockid_t id;
1215
1216 /**
1217 * The absolute or relative timestamp.
1218 */
1219 __wasi_timestamp_t timeout;
1220
1221 /**
1222 * The amount of time that the implementation may wait additionally
1223 * to coalesce with other events.
1224 */
1225 __wasi_timestamp_t precision;
1226
1227 /**
1228 * Flags specifying whether the timeout is absolute or relative
1229 */
1230 __wasi_subclockflags_t flags;
1231
1232} __wasi_subscription_clock_t;
1233
1234_Static_assert(sizeof(__wasi_subscription_clock_t) == 32, "witx calculated size");
1235_Static_assert(_Alignof(__wasi_subscription_clock_t) == 8, "witx calculated align");
1236_Static_assert(offsetof(__wasi_subscription_clock_t, id) == 0, "witx calculated offset");
1237_Static_assert(offsetof(__wasi_subscription_clock_t, timeout) == 8, "witx calculated offset");
1238_Static_assert(offsetof(__wasi_subscription_clock_t, precision) == 16, "witx calculated offset");
1239_Static_assert(offsetof(__wasi_subscription_clock_t, flags) == 24, "witx calculated offset");
1240
1241/**
1242 * The contents of a `subscription` when type is type is
1243 * `eventtype::fd_read` or `eventtype::fd_write`.
1244 */
1245typedef struct __wasi_subscription_fd_readwrite_t {
1246 /**
1247 * The file descriptor on which to wait for it to become ready for reading or writing.
1248 */
1249 __wasi_fd_t file_descriptor;
1250
1251} __wasi_subscription_fd_readwrite_t;
1252
1253_Static_assert(sizeof(__wasi_subscription_fd_readwrite_t) == 4, "witx calculated size");
1254_Static_assert(_Alignof(__wasi_subscription_fd_readwrite_t) == 4, "witx calculated align");
1255_Static_assert(offsetof(__wasi_subscription_fd_readwrite_t, file_descriptor) == 0, "witx calculated offset");
1256
1257/**
1258 * The contents of a `subscription`.
1259 */
1260typedef union __wasi_subscription_u_u_t {
1261 __wasi_subscription_clock_t clock;
1262 __wasi_subscription_fd_readwrite_t fd_read;
1263 __wasi_subscription_fd_readwrite_t fd_write;
1264} __wasi_subscription_u_u_t;
1265typedef struct __wasi_subscription_u_t {
1266 uint8_t tag;
1267 __wasi_subscription_u_u_t u;
1268} __wasi_subscription_u_t;
1269
1270_Static_assert(sizeof(__wasi_subscription_u_t) == 40, "witx calculated size");
1271_Static_assert(_Alignof(__wasi_subscription_u_t) == 8, "witx calculated align");
1272
1273/**
1274 * Subscription to an event.
1275 */
1276typedef struct __wasi_subscription_t {
1277 /**
1278 * User-provided value that is attached to the subscription in the
1279 * implementation and returned through `event::userdata`.
1280 */
1281 __wasi_userdata_t userdata;
1282
1283 /**
1284 * The type of the event to which to subscribe, and its contents
1285 */
1286 __wasi_subscription_u_t u;
1287
1288} __wasi_subscription_t;
1289
1290_Static_assert(sizeof(__wasi_subscription_t) == 48, "witx calculated size");
1291_Static_assert(_Alignof(__wasi_subscription_t) == 8, "witx calculated align");
1292_Static_assert(offsetof(__wasi_subscription_t, userdata) == 0, "witx calculated offset");
1293_Static_assert(offsetof(__wasi_subscription_t, u) == 8, "witx calculated offset");
1294
1295/**
1296 * Exit code generated by a process when exiting.
1297 */
1298typedef uint32_t __wasi_exitcode_t;
1299
1300_Static_assert(sizeof(__wasi_exitcode_t) == 4, "witx calculated size");
1301_Static_assert(_Alignof(__wasi_exitcode_t) == 4, "witx calculated align");
1302
1303/**
1304 * Signal condition.
1305 */
1306typedef uint8_t __wasi_signal_t;
1307
1308/**
1309 * No signal. Note that POSIX has special semantics for `kill(pid, 0)`,
1310 * so this value is reserved.
1311 */
1312#define __WASI_SIGNAL_NONE (UINT8_C(0))
1313
1314/**
1315 * Hangup.
1316 * Action: Terminates the process.
1317 */
1318#define __WASI_SIGNAL_HUP (UINT8_C(1))
1319
1320/**
1321 * Terminate interrupt signal.
1322 * Action: Terminates the process.
1323 */
1324#define __WASI_SIGNAL_INT (UINT8_C(2))
1325
1326/**
1327 * Terminal quit signal.
1328 * Action: Terminates the process.
1329 */
1330#define __WASI_SIGNAL_QUIT (UINT8_C(3))
1331
1332/**
1333 * Illegal instruction.
1334 * Action: Terminates the process.
1335 */
1336#define __WASI_SIGNAL_ILL (UINT8_C(4))
1337
1338/**
1339 * Trace/breakpoint trap.
1340 * Action: Terminates the process.
1341 */
1342#define __WASI_SIGNAL_TRAP (UINT8_C(5))
1343
1344/**
1345 * Process abort signal.
1346 * Action: Terminates the process.
1347 */
1348#define __WASI_SIGNAL_ABRT (UINT8_C(6))
1349
1350/**
1351 * Access to an undefined portion of a memory object.
1352 * Action: Terminates the process.
1353 */
1354#define __WASI_SIGNAL_BUS (UINT8_C(7))
1355
1356/**
1357 * Erroneous arithmetic operation.
1358 * Action: Terminates the process.
1359 */
1360#define __WASI_SIGNAL_FPE (UINT8_C(8))
1361
1362/**
1363 * Kill.
1364 * Action: Terminates the process.
1365 */
1366#define __WASI_SIGNAL_KILL (UINT8_C(9))
1367
1368/**
1369 * User-defined signal 1.
1370 * Action: Terminates the process.
1371 */
1372#define __WASI_SIGNAL_USR1 (UINT8_C(10))
1373
1374/**
1375 * Invalid memory reference.
1376 * Action: Terminates the process.
1377 */
1378#define __WASI_SIGNAL_SEGV (UINT8_C(11))
1379
1380/**
1381 * User-defined signal 2.
1382 * Action: Terminates the process.
1383 */
1384#define __WASI_SIGNAL_USR2 (UINT8_C(12))
1385
1386/**
1387 * Write on a pipe with no one to read it.
1388 * Action: Ignored.
1389 */
1390#define __WASI_SIGNAL_PIPE (UINT8_C(13))
1391
1392/**
1393 * Alarm clock.
1394 * Action: Terminates the process.
1395 */
1396#define __WASI_SIGNAL_ALRM (UINT8_C(14))
1397
1398/**
1399 * Termination signal.
1400 * Action: Terminates the process.
1401 */
1402#define __WASI_SIGNAL_TERM (UINT8_C(15))
1403
1404/**
1405 * Child process terminated, stopped, or continued.
1406 * Action: Ignored.
1407 */
1408#define __WASI_SIGNAL_CHLD (UINT8_C(16))
1409
1410/**
1411 * Continue executing, if stopped.
1412 * Action: Continues executing, if stopped.
1413 */
1414#define __WASI_SIGNAL_CONT (UINT8_C(17))
1415
1416/**
1417 * Stop executing.
1418 * Action: Stops executing.
1419 */
1420#define __WASI_SIGNAL_STOP (UINT8_C(18))
1421
1422/**
1423 * Terminal stop signal.
1424 * Action: Stops executing.
1425 */
1426#define __WASI_SIGNAL_TSTP (UINT8_C(19))
1427
1428/**
1429 * Background process attempting read.
1430 * Action: Stops executing.
1431 */
1432#define __WASI_SIGNAL_TTIN (UINT8_C(20))
1433
1434/**
1435 * Background process attempting write.
1436 * Action: Stops executing.
1437 */
1438#define __WASI_SIGNAL_TTOU (UINT8_C(21))
1439
1440/**
1441 * High bandwidth data is available at a socket.
1442 * Action: Ignored.
1443 */
1444#define __WASI_SIGNAL_URG (UINT8_C(22))
1445
1446/**
1447 * CPU time limit exceeded.
1448 * Action: Terminates the process.
1449 */
1450#define __WASI_SIGNAL_XCPU (UINT8_C(23))
1451
1452/**
1453 * File size limit exceeded.
1454 * Action: Terminates the process.
1455 */
1456#define __WASI_SIGNAL_XFSZ (UINT8_C(24))
1457
1458/**
1459 * Virtual timer expired.
1460 * Action: Terminates the process.
1461 */
1462#define __WASI_SIGNAL_VTALRM (UINT8_C(25))
1463
1464/**
1465 * Profiling timer expired.
1466 * Action: Terminates the process.
1467 */
1468#define __WASI_SIGNAL_PROF (UINT8_C(26))
1469
1470/**
1471 * Window changed.
1472 * Action: Ignored.
1473 */
1474#define __WASI_SIGNAL_WINCH (UINT8_C(27))
1475
1476/**
1477 * I/O possible.
1478 * Action: Terminates the process.
1479 */
1480#define __WASI_SIGNAL_POLL (UINT8_C(28))
1481
1482/**
1483 * Power failure.
1484 * Action: Terminates the process.
1485 */
1486#define __WASI_SIGNAL_PWR (UINT8_C(29))
1487
1488/**
1489 * Bad system call.
1490 * Action: Terminates the process.
1491 */
1492#define __WASI_SIGNAL_SYS (UINT8_C(30))
1493
1494_Static_assert(sizeof(__wasi_signal_t) == 1, "witx calculated size");
1495_Static_assert(_Alignof(__wasi_signal_t) == 1, "witx calculated align");
1496
1497/**
1498 * Flags provided to `sock_recv`.
1499 */
1500typedef uint16_t __wasi_riflags_t;
1501
1502/**
1503 * Returns the message without removing it from the socket's receive queue.
1504 */
1505#define __WASI_RIFLAGS_RECV_PEEK ((__wasi_riflags_t)(1 << 0))
1506
1507/**
1508 * On byte-stream sockets, block until the full amount of data can be returned.
1509 */
1510#define __WASI_RIFLAGS_RECV_WAITALL ((__wasi_riflags_t)(1 << 1))
1511
1512/**
1513 * Flags returned by `sock_recv`.
1514 */
1515typedef uint16_t __wasi_roflags_t;
1516
1517/**
1518 * Returned by `sock_recv`: Message data has been truncated.
1519 */
1520#define __WASI_ROFLAGS_RECV_DATA_TRUNCATED ((__wasi_roflags_t)(1 << 0))
1521
1522/**
1523 * Flags provided to `sock_send`. As there are currently no flags
1524 * defined, it must be set to zero.
1525 */
1526typedef uint16_t __wasi_siflags_t;
1527
1528_Static_assert(sizeof(__wasi_siflags_t) == 2, "witx calculated size");
1529_Static_assert(_Alignof(__wasi_siflags_t) == 2, "witx calculated align");
1530
1531/**
1532 * Which channels on a socket to shut down.
1533 */
1534typedef uint8_t __wasi_sdflags_t;
1535
1536/**
1537 * Disables further receive operations.
1538 */
1539#define __WASI_SDFLAGS_RD ((__wasi_sdflags_t)(1 << 0))
1540
1541/**
1542 * Disables further send operations.
1543 */
1544#define __WASI_SDFLAGS_WR ((__wasi_sdflags_t)(1 << 1))
1545
1546/**
1547 * Identifiers for preopened capabilities.
1548 */
1549typedef uint8_t __wasi_preopentype_t;
1550
1551/**
1552 * A pre-opened directory.
1553 */
1554#define __WASI_PREOPENTYPE_DIR (UINT8_C(0))
1555
1556_Static_assert(sizeof(__wasi_preopentype_t) == 1, "witx calculated size");
1557_Static_assert(_Alignof(__wasi_preopentype_t) == 1, "witx calculated align");
1558
1559/**
1560 * The contents of a $prestat when type is `preopentype::dir`.
1561 */
1562typedef struct __wasi_prestat_dir_t {
1563 /**
1564 * The length of the directory name for use with `fd_prestat_dir_name`.
1565 */
1566 __wasi_size_t pr_name_len;
1567
1568} __wasi_prestat_dir_t;
1569
1570_Static_assert(sizeof(__wasi_prestat_dir_t) == 4, "witx calculated size");
1571_Static_assert(_Alignof(__wasi_prestat_dir_t) == 4, "witx calculated align");
1572_Static_assert(offsetof(__wasi_prestat_dir_t, pr_name_len) == 0, "witx calculated offset");
1573
1574/**
1575 * Information about a pre-opened capability.
1576 */
1577typedef union __wasi_prestat_u_t {
1578 __wasi_prestat_dir_t dir;
1579} __wasi_prestat_u_t;
1580typedef struct __wasi_prestat_t {
1581 uint8_t tag;
1582 __wasi_prestat_u_t u;
1583} __wasi_prestat_t;
1584
1585_Static_assert(sizeof(__wasi_prestat_t) == 8, "witx calculated size");
1586_Static_assert(_Alignof(__wasi_prestat_t) == 4, "witx calculated align");
1587
1588/**
1589 * @defgroup wasi_snapshot_preview1
1590 * @{
1591 */
1592
1593/**
1594 * Read command-line argument data.
1595 * The size of the array should match that returned by `args_sizes_get`
1596 */
1597__wasi_errno_t __wasi_args_get(
1598 uint8_t * * argv,
1599 uint8_t * argv_buf
1600) __attribute__((__warn_unused_result__));
1601/**
1602 * Return command-line argument data sizes.
1603 * @return
1604 * Returns the number of arguments and the size of the argument string
1605 * data, or an error.
1606 */
1607__wasi_errno_t __wasi_args_sizes_get(
1608 __wasi_size_t *retptr0,
1609 __wasi_size_t *retptr1
1610) __attribute__((__warn_unused_result__));
1611/**
1612 * Read environment variable data.
1613 * The sizes of the buffers should match that returned by `environ_sizes_get`.
1614 */
1615__wasi_errno_t __wasi_environ_get(
1616 uint8_t * * environ,
1617 uint8_t * environ_buf
1618) __attribute__((__warn_unused_result__));
1619/**
1620 * Return environment variable data sizes.
1621 * @return
1622 * Returns the number of environment variable arguments and the size of the
1623 * environment variable data.
1624 */
1625__wasi_errno_t __wasi_environ_sizes_get(
1626 __wasi_size_t *retptr0,
1627 __wasi_size_t *retptr1
1628) __attribute__((__warn_unused_result__));
1629/**
1630 * Return the resolution of a clock.
1631 * Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks,
1632 * return `errno::inval`.
1633 * Note: This is similar to `clock_getres` in POSIX.
1634 * @return
1635 * The resolution of the clock, or an error if one happened.
1636 */
1637__wasi_errno_t __wasi_clock_res_get(
1638 /**
1639 * The clock for which to return the resolution.
1640 */
1641 __wasi_clockid_t id,
1642 __wasi_timestamp_t *retptr0
1643) __attribute__((__warn_unused_result__));
1644/**
1645 * Return the time value of a clock.
1646 * Note: This is similar to `clock_gettime` in POSIX.
1647 * @return
1648 * The time value of the clock.
1649 */
1650__wasi_errno_t __wasi_clock_time_get(
1651 /**
1652 * The clock for which to return the time.
1653 */
1654 __wasi_clockid_t id,
1655 /**
1656 * The maximum lag (exclusive) that the returned time value may have, compared to its actual value.
1657 */
1658 __wasi_timestamp_t precision,
1659 __wasi_timestamp_t *retptr0
1660) __attribute__((__warn_unused_result__));
1661/**
1662 * Provide file advisory information on a file descriptor.
1663 * Note: This is similar to `posix_fadvise` in POSIX.
1664 */
1665__wasi_errno_t __wasi_fd_advise(
1666 __wasi_fd_t fd,
1667 /**
1668 * The offset within the file to which the advisory applies.
1669 */
1670 __wasi_filesize_t offset,
1671 /**
1672 * The length of the region to which the advisory applies.
1673 */
1674 __wasi_filesize_t len,
1675 /**
1676 * The advice.
1677 */
1678 __wasi_advice_t advice
1679) __attribute__((__warn_unused_result__));
1680/**
1681 * Force the allocation of space in a file.
1682 * Note: This is similar to `posix_fallocate` in POSIX.
1683 */
1684__wasi_errno_t __wasi_fd_allocate(
1685 __wasi_fd_t fd,
1686 /**
1687 * The offset at which to start the allocation.
1688 */
1689 __wasi_filesize_t offset,
1690 /**
1691 * The length of the area that is allocated.
1692 */
1693 __wasi_filesize_t len
1694) __attribute__((__warn_unused_result__));
1695/**
1696 * Close a file descriptor.
1697 * Note: This is similar to `close` in POSIX.
1698 */
1699__wasi_errno_t __wasi_fd_close(
1700 __wasi_fd_t fd
1701) __attribute__((__warn_unused_result__));
1702/**
1703 * Synchronize the data of a file to disk.
1704 * Note: This is similar to `fdatasync` in POSIX.
1705 */
1706__wasi_errno_t __wasi_fd_datasync(
1707 __wasi_fd_t fd
1708) __attribute__((__warn_unused_result__));
1709/**
1710 * Get the attributes of a file descriptor.
1711 * Note: This returns similar flags to `fsync(fd, F_GETFL)` in POSIX, as well as additional fields.
1712 * @return
1713 * The buffer where the file descriptor's attributes are stored.
1714 */
1715__wasi_errno_t __wasi_fd_fdstat_get(
1716 __wasi_fd_t fd,
1717 __wasi_fdstat_t *retptr0
1718) __attribute__((__warn_unused_result__));
1719/**
1720 * Adjust the flags associated with a file descriptor.
1721 * Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX.
1722 */
1723__wasi_errno_t __wasi_fd_fdstat_set_flags(
1724 __wasi_fd_t fd,
1725 /**
1726 * The desired values of the file descriptor flags.
1727 */
1728 __wasi_fdflags_t flags
1729) __attribute__((__warn_unused_result__));
1730/**
1731 * Adjust the rights associated with a file descriptor.
1732 * This can only be used to remove rights, and returns `errno::notcapable` if called in a way that would attempt to add rights
1733 */
1734__wasi_errno_t __wasi_fd_fdstat_set_rights(
1735 __wasi_fd_t fd,
1736 /**
1737 * The desired rights of the file descriptor.
1738 */
1739 __wasi_rights_t fs_rights_base,
1740 __wasi_rights_t fs_rights_inheriting
1741) __attribute__((__warn_unused_result__));
1742/**
1743 * Return the attributes of an open file.
1744 * @return
1745 * The buffer where the file's attributes are stored.
1746 */
1747__wasi_errno_t __wasi_fd_filestat_get(
1748 __wasi_fd_t fd,
1749 __wasi_filestat_t *retptr0
1750) __attribute__((__warn_unused_result__));
1751/**
1752 * Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.
1753 * Note: This is similar to `ftruncate` in POSIX.
1754 */
1755__wasi_errno_t __wasi_fd_filestat_set_size(
1756 __wasi_fd_t fd,
1757 /**
1758 * The desired file size.
1759 */
1760 __wasi_filesize_t size
1761) __attribute__((__warn_unused_result__));
1762/**
1763 * Adjust the timestamps of an open file or directory.
1764 * Note: This is similar to `futimens` in POSIX.
1765 */
1766__wasi_errno_t __wasi_fd_filestat_set_times(
1767 __wasi_fd_t fd,
1768 /**
1769 * The desired values of the data access timestamp.
1770 */
1771 __wasi_timestamp_t atim,
1772 /**
1773 * The desired values of the data modification timestamp.
1774 */
1775 __wasi_timestamp_t mtim,
1776 /**
1777 * A bitmask indicating which timestamps to adjust.
1778 */
1779 __wasi_fstflags_t fst_flags
1780) __attribute__((__warn_unused_result__));
1781/**
1782 * Read from a file descriptor, without using and updating the file descriptor's offset.
1783 * Note: This is similar to `preadv` in POSIX.
1784 * @return
1785 * The number of bytes read.
1786 */
1787__wasi_errno_t __wasi_fd_pread(
1788 __wasi_fd_t fd,
1789 /**
1790 * List of scatter/gather vectors in which to store data.
1791 */
1792 const __wasi_iovec_t *iovs,
1793 /**
1794 * The length of the array pointed to by `iovs`.
1795 */
1796 size_t iovs_len,
1797 /**
1798 * The offset within the file at which to read.
1799 */
1800 __wasi_filesize_t offset,
1801 __wasi_size_t *retptr0
1802) __attribute__((__warn_unused_result__));
1803/**
1804 * Return a description of the given preopened file descriptor.
1805 * @return
1806 * The buffer where the description is stored.
1807 */
1808__wasi_errno_t __wasi_fd_prestat_get(
1809 __wasi_fd_t fd,
1810 __wasi_prestat_t *retptr0
1811) __attribute__((__warn_unused_result__));
1812/**
1813 * Return a description of the given preopened file descriptor.
1814 */
1815__wasi_errno_t __wasi_fd_prestat_dir_name(
1816 __wasi_fd_t fd,
1817 /**
1818 * A buffer into which to write the preopened directory name.
1819 */
1820 uint8_t * path,
1821 __wasi_size_t path_len
1822) __attribute__((__warn_unused_result__));
1823/**
1824 * Write to a file descriptor, without using and updating the file descriptor's offset.
1825 * Note: This is similar to `pwritev` in POSIX.
1826 * @return
1827 * The number of bytes written.
1828 */
1829__wasi_errno_t __wasi_fd_pwrite(
1830 __wasi_fd_t fd,
1831 /**
1832 * List of scatter/gather vectors from which to retrieve data.
1833 */
1834 const __wasi_ciovec_t *iovs,
1835 /**
1836 * The length of the array pointed to by `iovs`.
1837 */
1838 size_t iovs_len,
1839 /**
1840 * The offset within the file at which to write.
1841 */
1842 __wasi_filesize_t offset,
1843 __wasi_size_t *retptr0
1844) __attribute__((__warn_unused_result__));
1845/**
1846 * Read from a file descriptor.
1847 * Note: This is similar to `readv` in POSIX.
1848 * @return
1849 * The number of bytes read.
1850 */
1851__wasi_errno_t __wasi_fd_read(
1852 __wasi_fd_t fd,
1853 /**
1854 * List of scatter/gather vectors to which to store data.
1855 */
1856 const __wasi_iovec_t *iovs,
1857 /**
1858 * The length of the array pointed to by `iovs`.
1859 */
1860 size_t iovs_len,
1861 __wasi_size_t *retptr0
1862) __attribute__((__warn_unused_result__));
1863/**
1864 * Read directory entries from a directory.
1865 * When successful, the contents of the output buffer consist of a sequence of
1866 * directory entries. Each directory entry consists of a `dirent` object,
1867 * followed by `dirent::d_namlen` bytes holding the name of the directory
1868 * entry.
1869 * This function fills the output buffer as much as possible, potentially
1870 * truncating the last directory entry. This allows the caller to grow its
1871 * read buffer size in case it's too small to fit a single large directory
1872 * entry, or skip the oversized directory entry.
1873 * @return
1874 * The number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached.
1875 */
1876__wasi_errno_t __wasi_fd_readdir(
1877 __wasi_fd_t fd,
1878 /**
1879 * The buffer where directory entries are stored
1880 */
1881 uint8_t * buf,
1882 __wasi_size_t buf_len,
1883 /**
1884 * The location within the directory to start reading
1885 */
1886 __wasi_dircookie_t cookie,
1887 __wasi_size_t *retptr0
1888) __attribute__((__warn_unused_result__));
1889/**
1890 * Atomically replace a file descriptor by renumbering another file descriptor.
1891 * Due to the strong focus on thread safety, this environment does not provide
1892 * a mechanism to duplicate or renumber a file descriptor to an arbitrary
1893 * number, like `dup2()`. This would be prone to race conditions, as an actual
1894 * file descriptor with the same number could be allocated by a different
1895 * thread at the same time.
1896 * This function provides a way to atomically renumber file descriptors, which
1897 * would disappear if `dup2()` were to be removed entirely.
1898 */
1899__wasi_errno_t __wasi_fd_renumber(
1900 __wasi_fd_t fd,
1901 /**
1902 * The file descriptor to overwrite.
1903 */
1904 __wasi_fd_t to
1905) __attribute__((__warn_unused_result__));
1906/**
1907 * Move the offset of a file descriptor.
1908 * Note: This is similar to `lseek` in POSIX.
1909 * @return
1910 * The new offset of the file descriptor, relative to the start of the file.
1911 */
1912__wasi_errno_t __wasi_fd_seek(
1913 __wasi_fd_t fd,
1914 /**
1915 * The number of bytes to move.
1916 */
1917 __wasi_filedelta_t offset,
1918 /**
1919 * The base from which the offset is relative.
1920 */
1921 __wasi_whence_t whence,
1922 __wasi_filesize_t *retptr0
1923) __attribute__((__warn_unused_result__));
1924/**
1925 * Synchronize the data and metadata of a file to disk.
1926 * Note: This is similar to `fsync` in POSIX.
1927 */
1928__wasi_errno_t __wasi_fd_sync(
1929 __wasi_fd_t fd
1930) __attribute__((__warn_unused_result__));
1931/**
1932 * Return the current offset of a file descriptor.
1933 * Note: This is similar to `lseek(fd, 0, SEEK_CUR)` in POSIX.
1934 * @return
1935 * The current offset of the file descriptor, relative to the start of the file.
1936 */
1937__wasi_errno_t __wasi_fd_tell(
1938 __wasi_fd_t fd,
1939 __wasi_filesize_t *retptr0
1940) __attribute__((__warn_unused_result__));
1941/**
1942 * Write to a file descriptor.
1943 * Note: This is similar to `writev` in POSIX.
1944 */
1945__wasi_errno_t __wasi_fd_write(
1946 __wasi_fd_t fd,
1947 /**
1948 * List of scatter/gather vectors from which to retrieve data.
1949 */
1950 const __wasi_ciovec_t *iovs,
1951 /**
1952 * The length of the array pointed to by `iovs`.
1953 */
1954 size_t iovs_len,
1955 __wasi_size_t *retptr0
1956) __attribute__((__warn_unused_result__));
1957/**
1958 * Create a directory.
1959 * Note: This is similar to `mkdirat` in POSIX.
1960 */
1961__wasi_errno_t __wasi_path_create_directory(
1962 __wasi_fd_t fd,
1963 /**
1964 * The path at which to create the directory.
1965 */
1966 const char *path
1967) __attribute__((__warn_unused_result__));
1968/**
1969 * Return the attributes of a file or directory.
1970 * Note: This is similar to `stat` in POSIX.
1971 * @return
1972 * The buffer where the file's attributes are stored.
1973 */
1974__wasi_errno_t __wasi_path_filestat_get(
1975 __wasi_fd_t fd,
1976 /**
1977 * Flags determining the method of how the path is resolved.
1978 */
1979 __wasi_lookupflags_t flags,
1980 /**
1981 * The path of the file or directory to inspect.
1982 */
1983 const char *path,
1984 __wasi_filestat_t *retptr0
1985) __attribute__((__warn_unused_result__));
1986/**
1987 * Adjust the timestamps of a file or directory.
1988 * Note: This is similar to `utimensat` in POSIX.
1989 */
1990__wasi_errno_t __wasi_path_filestat_set_times(
1991 __wasi_fd_t fd,
1992 /**
1993 * Flags determining the method of how the path is resolved.
1994 */
1995 __wasi_lookupflags_t flags,
1996 /**
1997 * The path of the file or directory to operate on.
1998 */
1999 const char *path,
2000 /**
2001 * The desired values of the data access timestamp.
2002 */
2003 __wasi_timestamp_t atim,
2004 /**
2005 * The desired values of the data modification timestamp.
2006 */
2007 __wasi_timestamp_t mtim,
2008 /**
2009 * A bitmask indicating which timestamps to adjust.
2010 */
2011 __wasi_fstflags_t fst_flags
2012) __attribute__((__warn_unused_result__));
2013/**
2014 * Create a hard link.
2015 * Note: This is similar to `linkat` in POSIX.
2016 */
2017__wasi_errno_t __wasi_path_link(
2018 __wasi_fd_t old_fd,
2019 /**
2020 * Flags determining the method of how the path is resolved.
2021 */
2022 __wasi_lookupflags_t old_flags,
2023 /**
2024 * The source path from which to link.
2025 */
2026 const char *old_path,
2027 /**
2028 * The working directory at which the resolution of the new path starts.
2029 */
2030 __wasi_fd_t new_fd,
2031 /**
2032 * The destination path at which to create the hard link.
2033 */
2034 const char *new_path
2035) __attribute__((__warn_unused_result__));
2036/**
2037 * Open a file or directory.
2038 * The returned file descriptor is not guaranteed to be the lowest-numbered
2039 * file descriptor not currently open; it is randomized to prevent
2040 * applications from depending on making assumptions about indexes, since this
2041 * is error-prone in multi-threaded contexts. The returned file descriptor is
2042 * guaranteed to be less than 2**31.
2043 * Note: This is similar to `openat` in POSIX.
2044 * @return
2045 * The file descriptor of the file that has been opened.
2046 */
2047__wasi_errno_t __wasi_path_open(
2048 __wasi_fd_t fd,
2049 /**
2050 * Flags determining the method of how the path is resolved.
2051 */
2052 __wasi_lookupflags_t dirflags,
2053 /**
2054 * The relative path of the file or directory to open, relative to the
2055 * `path_open::fd` directory.
2056 */
2057 const char *path,
2058 /**
2059 * The method by which to open the file.
2060 */
2061 __wasi_oflags_t oflags,
2062 /**
2063 * The initial rights of the newly created file descriptor. The
2064 * implementation is allowed to return a file descriptor with fewer rights
2065 * than specified, if and only if those rights do not apply to the type of
2066 * file being opened.
2067 * The *base* rights are rights that will apply to operations using the file
2068 * descriptor itself, while the *inheriting* rights are rights that apply to
2069 * file descriptors derived from it.
2070 */
2071 __wasi_rights_t fs_rights_base,
2072 __wasi_rights_t fs_rights_inheriting,
2073 __wasi_fdflags_t fdflags,
2074 __wasi_fd_t *retptr0
2075) __attribute__((__warn_unused_result__));
2076/**
2077 * Read the contents of a symbolic link.
2078 * Note: This is similar to `readlinkat` in POSIX.
2079 * @return
2080 * The number of bytes placed in the buffer.
2081 */
2082__wasi_errno_t __wasi_path_readlink(
2083 __wasi_fd_t fd,
2084 /**
2085 * The path of the symbolic link from which to read.
2086 */
2087 const char *path,
2088 /**
2089 * The buffer to which to write the contents of the symbolic link.
2090 */
2091 uint8_t * buf,
2092 __wasi_size_t buf_len,
2093 __wasi_size_t *retptr0
2094) __attribute__((__warn_unused_result__));
2095/**
2096 * Remove a directory.
2097 * Return `errno::notempty` if the directory is not empty.
2098 * Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
2099 */
2100__wasi_errno_t __wasi_path_remove_directory(
2101 __wasi_fd_t fd,
2102 /**
2103 * The path to a directory to remove.
2104 */
2105 const char *path
2106) __attribute__((__warn_unused_result__));
2107/**
2108 * Rename a file or directory.
2109 * Note: This is similar to `renameat` in POSIX.
2110 */
2111__wasi_errno_t __wasi_path_rename(
2112 __wasi_fd_t fd,
2113 /**
2114 * The source path of the file or directory to rename.
2115 */
2116 const char *old_path,
2117 /**
2118 * The working directory at which the resolution of the new path starts.
2119 */
2120 __wasi_fd_t new_fd,
2121 /**
2122 * The destination path to which to rename the file or directory.
2123 */
2124 const char *new_path
2125) __attribute__((__warn_unused_result__));
2126/**
2127 * Create a symbolic link.
2128 * Note: This is similar to `symlinkat` in POSIX.
2129 */
2130__wasi_errno_t __wasi_path_symlink(
2131 /**
2132 * The contents of the symbolic link.
2133 */
2134 const char *old_path,
2135 __wasi_fd_t fd,
2136 /**
2137 * The destination path at which to create the symbolic link.
2138 */
2139 const char *new_path
2140) __attribute__((__warn_unused_result__));
2141/**
2142 * Unlink a file.
2143 * Return `errno::isdir` if the path refers to a directory.
2144 * Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
2145 */
2146__wasi_errno_t __wasi_path_unlink_file(
2147 __wasi_fd_t fd,
2148 /**
2149 * The path to a file to unlink.
2150 */
2151 const char *path
2152) __attribute__((__warn_unused_result__));
2153/**
2154 * Concurrently poll for the occurrence of a set of events.
2155 * @return
2156 * The number of events stored.
2157 */
2158__wasi_errno_t __wasi_poll_oneoff(
2159 /**
2160 * The events to which to subscribe.
2161 */
2162 const __wasi_subscription_t * in,
2163 /**
2164 * The events that have occurred.
2165 */
2166 __wasi_event_t * out,
2167 /**
2168 * Both the number of subscriptions and events.
2169 */
2170 __wasi_size_t nsubscriptions,
2171 __wasi_size_t *retptr0
2172) __attribute__((__warn_unused_result__));
2173/**
2174 * Terminate the process normally. An exit code of 0 indicates successful
2175 * termination of the program. The meanings of other values is dependent on
2176 * the environment.
2177 */
2178_Noreturn void __wasi_proc_exit(
2179 /**
2180 * The exit code returned by the process.
2181 */
2182 __wasi_exitcode_t rval
2183);
2184/**
2185 * Send a signal to the process of the calling thread.
2186 * Note: This is similar to `raise` in POSIX.
2187 */
2188__wasi_errno_t __wasi_proc_raise(
2189 /**
2190 * The signal condition to trigger.
2191 */
2192 __wasi_signal_t sig
2193) __attribute__((__warn_unused_result__));
2194/**
2195 * Temporarily yield execution of the calling thread.
2196 * Note: This is similar to `sched_yield` in POSIX.
2197 */
2198__wasi_errno_t __wasi_sched_yield(
2199 void
2200) __attribute__((__warn_unused_result__));
2201/**
2202 * Write high-quality random data into a buffer.
2203 * This function blocks when the implementation is unable to immediately
2204 * provide sufficient high-quality random data.
2205 * This function may execute slowly, so when large mounts of random data are
2206 * required, it's advisable to use this function to seed a pseudo-random
2207 * number generator, rather than to provide the random data directly.
2208 */
2209__wasi_errno_t __wasi_random_get(
2210 /**
2211 * The buffer to fill with random data.
2212 */
2213 uint8_t * buf,
2214 __wasi_size_t buf_len
2215) __attribute__((__warn_unused_result__));
2216/**
2217 * Receive a message from a socket.
2218 * Note: This is similar to `recv` in POSIX, though it also supports reading
2219 * the data into multiple buffers in the manner of `readv`.
2220 * @return
2221 * Number of bytes stored in ri_data and message flags.
2222 */
2223__wasi_errno_t __wasi_sock_recv(
2224 __wasi_fd_t fd,
2225 /**
2226 * List of scatter/gather vectors to which to store data.
2227 */
2228 const __wasi_iovec_t *ri_data,
2229 /**
2230 * The length of the array pointed to by `ri_data`.
2231 */
2232 size_t ri_data_len,
2233 /**
2234 * Message flags.
2235 */
2236 __wasi_riflags_t ri_flags,
2237 __wasi_size_t *retptr0,
2238 __wasi_roflags_t *retptr1
2239) __attribute__((__warn_unused_result__));
2240/**
2241 * Send a message on a socket.
2242 * Note: This is similar to `send` in POSIX, though it also supports writing
2243 * the data from multiple buffers in the manner of `writev`.
2244 * @return
2245 * Number of bytes transmitted.
2246 */
2247__wasi_errno_t __wasi_sock_send(
2248 __wasi_fd_t fd,
2249 /**
2250 * List of scatter/gather vectors to which to retrieve data
2251 */
2252 const __wasi_ciovec_t *si_data,
2253 /**
2254 * The length of the array pointed to by `si_data`.
2255 */
2256 size_t si_data_len,
2257 /**
2258 * Message flags.
2259 */
2260 __wasi_siflags_t si_flags,
2261 __wasi_size_t *retptr0
2262) __attribute__((__warn_unused_result__));
2263/**
2264 * Shut down socket send and receive channels.
2265 * Note: This is similar to `shutdown` in POSIX.
2266 */
2267__wasi_errno_t __wasi_sock_shutdown(
2268 __wasi_fd_t fd,
2269 /**
2270 * Which channels on the socket to shut down.
2271 */
2272 __wasi_sdflags_t how
2273) __attribute__((__warn_unused_result__));
2274/** @} */
2275
2276#ifdef __cplusplus
2277}
2278#endif
2279
2280#endif
lib/libc/include/wasm32-wasi/wasi/libc-environ.h deleted-19
......@@ -1,19 +0,0 @@
1#ifndef __wasi_libc_environ_h
2#define __wasi_libc_environ_h
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8/// Initialize the global environment variable state. Only needs to be
9/// called once; most users should call `__wasilibc_ensure_environ` instead.
10void __wasilibc_initialize_environ(void);
11
12/// If `__wasilibc_initialize_environ` has not yet been called, call it.
13void __wasilibc_ensure_environ(void);
14
15#ifdef __cplusplus
16}
17#endif
18
19#endif
lib/libc/include/wasm32-wasi/wasi/libc-find-relpath.h deleted-79
......@@ -1,79 +0,0 @@
1#ifndef __wasi_libc_find_relpath_h
2#define __wasi_libc_find_relpath_h
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8/**
9 * Look up the given `path`, relative to the cwd, in the preopened directory
10 * map. If a suitable entry is found, then the file descriptor for that entry
11 * is returned. Additionally the absolute path of the directory's file
12 * descriptor is returned in `abs_prefix` and the relative portion that needs
13 * to be opened is stored in `*relative_path`.
14 *
15 * The `relative_path` argument must be a pointer to a buffer valid for
16 * `relative_path_len` bytes, and this may be used as storage for the relative
17 * portion of the path being returned through `*relative_path`.
18 *
19 * See documentation on `__wasilibc_find_abspath` for more info about what the
20 * paths look like.
21 *
22 * Returns -1 on failure. Errno is set to either:
23 *
24 * * ENOMEM - failed to allocate memory for internal routines.
25 * * ENOENT - the `path` could not be found relative to any preopened dir.
26 * * ERANGE - the `relative_path` buffer is too small to hold the relative path.
27 */
28int __wasilibc_find_relpath(const char *path,
29 const char **__restrict__ abs_prefix,
30 char **relative_path,
31 size_t relative_path_len);
32
33/**
34 * Look up the given `path`, which is interpreted as absolute, in the preopened
35 * directory map. If a suitable entry is found, then the file descriptor for
36 * that entry is returned. Additionally the relative portion of the path to
37 * where the fd is opened is returned through `relative_path`, the absolute
38 * prefix which was matched is stored to `abs_prefix`, and `relative_path` may
39 * be an interior pointer to the `abspath` string.
40 *
41 * The `abs_prefix` returned string will not contain a leading `/`. Note that
42 * this may be the empty string. Additionally the returned `relative_path` will
43 * not contain a leading `/`. The `relative_path` return will not return an
44 * empty string, it will return `"."` instead if it would otherwise do so.
45 *
46 * Returns -1 on failure. Errno is set to either:
47 *
48 * * ENOMEM - failed to allocate memory for internal routines.
49 * * ENOENT - the `path` could not be found relative to any preopened dir.
50 */
51int __wasilibc_find_abspath(const char *abspath,
52 const char **__restrict__ abs_prefix,
53 const char **__restrict__ relative_path);
54
55/**
56 * Same as `__wasilibc_find_relpath`, except that this function will interpret
57 * `relative` as a malloc'd buffer that will be `realloc`'d to the appropriate
58 * size to contain the relative path.
59 *
60 * Note that this is a weak symbol and if it's not defined you can use
61 * `__wasilibc_find_relpath`. The weak-nature of this symbols means that if it's
62 * not otherwise included in the compilation then `chdir` wasn't used an there's
63 * no need for this symbol.
64 *
65 * See documentation on `__wasilibc_find_relpath` for more information.
66 */
67int __wasilibc_find_relpath_alloc(
68 const char *path,
69 const char **abs,
70 char **relative,
71 size_t *relative_len,
72 int can_realloc
73) __attribute__((weak));
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif
lib/libc/include/wasm32-wasi/wasi/libc-nocwd.h deleted-58
......@@ -1,58 +0,0 @@
1#ifndef __wasi_libc_nocwd_h
2#define __wasi_libc_nocwd_h
3
4/*
5 * In order to support AT_FDCWD, we need to wrap the *at functions to handle
6 * it by calling back into the non-at versions which perform libpreopen
7 * queries. These __wasilibc_nocwd_* forms are the underlying calls which
8 * assume AT_FDCWD has already been resolved.
9 */
10
11#define __need_size_t
12#include <stddef.h>
13#include <__typedef_ssize_t.h>
14#include <__typedef_mode_t.h>
15#include <__typedef_DIR.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21struct timespec;
22struct stat;
23struct dirent;
24
25int __wasilibc_nocwd___wasilibc_unlinkat(int, const char *)
26 __attribute__((__warn_unused_result__));
27int __wasilibc_nocwd___wasilibc_rmdirat(int, const char *)
28 __attribute__((__warn_unused_result__));
29int __wasilibc_nocwd_linkat(int, const char *, int, const char *, int)
30 __attribute__((__warn_unused_result__));
31int __wasilibc_nocwd_symlinkat(const char *, int, const char *)
32 __attribute__((__warn_unused_result__));
33ssize_t __wasilibc_nocwd_readlinkat(int, const char *__restrict, char *__restrict, size_t)
34 __attribute__((__warn_unused_result__));
35int __wasilibc_nocwd_faccessat(int, const char *, int, int)
36 __attribute__((__warn_unused_result__));
37int __wasilibc_nocwd_renameat(int, const char *, int, const char *)
38 __attribute__((__warn_unused_result__));
39int __wasilibc_nocwd_openat_nomode(int, const char *, int)
40 __attribute__((__warn_unused_result__));
41int __wasilibc_nocwd_fstatat(int, const char *__restrict, struct stat *__restrict, int)
42 __attribute__((__warn_unused_result__));
43int __wasilibc_nocwd_mkdirat_nomode(int, const char *)
44 __attribute__((__warn_unused_result__));
45int __wasilibc_nocwd_utimensat(int, const char *, const struct timespec [2], int)
46 __attribute__((__warn_unused_result__));
47DIR *__wasilibc_nocwd_opendirat(int, const char *)
48 __attribute__((__warn_unused_result__));
49int __wasilibc_nocwd_scandirat(int, const char *, struct dirent ***,
50 int (*)(const struct dirent *),
51 int (*)(const struct dirent **, const struct dirent **))
52 __attribute__((__warn_unused_result__));
53
54#ifdef __cplusplus
55}
56#endif
57
58#endif
lib/libc/include/wasm32-wasi/wasi/libc.h deleted-65
......@@ -1,65 +0,0 @@
1#ifndef __wasi_libc_h
2#define __wasi_libc_h
3
4#include <__typedef_off_t.h>
5#include <__struct_timespec.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11struct stat;
12struct timespec;
13
14/// Register the given pre-opened file descriptor under the given path.
15///
16/// This function does not take ownership of `prefix` (it makes its own copy).
17int __wasilibc_register_preopened_fd(int fd, const char *prefix);
18
19/// Renumber `fd` to `newfd`; similar to `dup2` but does a move rather than a
20/// copy.
21int __wasilibc_fd_renumber(int fd, int newfd)
22 __attribute__((__warn_unused_result__));
23
24/// Like `unlinkat`, but without depending on `__wasi_path_remove_directory`.
25int __wasilibc_unlinkat(int fd, const char *path)
26 __attribute__((__warn_unused_result__));
27
28/// An `*at` version of rmdir.
29int __wasilibc_rmdirat(int fd, const char *path)
30 __attribute__((__warn_unused_result__));
31
32/// Like `open`, but without the varargs in the signature.
33int __wasilibc_open_nomode(const char *path, int oflag);
34
35/// Like `openat`, but without the varargs in the signature.
36int __wasilibc_openat_nomode(int fd, const char *path, int oflag);
37
38/// Return the current file offset. Like `lseek(fd, 0, SEEK_CUR)`, but without
39/// depending on `lseek`.
40off_t __wasilibc_tell(int fd)
41 __attribute__((__warn_unused_result__));
42
43/* Non-`at` forms of various `*at` functions. */
44int __wasilibc_access(const char *pathname, int mode, int flags)
45 __attribute__((__warn_unused_result__));
46int __wasilibc_stat(const char *__restrict pathname, struct stat *__restrict statbuf, int flags)
47 __attribute__((__warn_unused_result__));
48int __wasilibc_utimens(const char *pathname, const struct timespec times[2], int flags)
49 __attribute__((__warn_unused_result__));
50int __wasilibc_link(const char *oldpath, const char *newpath, int flags)
51 __attribute__((__warn_unused_result__));
52int __wasilibc_link_oldat(int olddirfd, const char *oldpath, const char *newpath, int flags)
53 __attribute__((__warn_unused_result__));
54int __wasilibc_link_newat(const char *oldpath, int newdirfd, const char *newpath, int flags)
55 __attribute__((__warn_unused_result__));
56int __wasilibc_rename_oldat(int olddirfd, const char *oldpath, const char *newpath)
57 __attribute__((__warn_unused_result__));
58int __wasilibc_rename_newat(const char *oldpath, int newdirfd, const char *newpath)
59 __attribute__((__warn_unused_result__));
60
61#ifdef __cplusplus
62}
63#endif
64
65#endif
lib/libc/include/wasm32-wasi/wchar.h deleted-212
......@@ -1,212 +0,0 @@
1#ifndef _WCHAR_H
2#define _WCHAR_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_FILE
11#define __NEED___isoc_va_list
12#define __NEED_size_t
13#define __NEED_wchar_t
14#define __NEED_wint_t
15#define __NEED_mbstate_t
16
17#ifdef __wasilibc_unmodified_upstream /* WASI doesn't need to define FILE as a complete type */
18#if __STDC_VERSION__ < 201112L
19#define __NEED_struct__IO_FILE
20#endif
21#endif
22
23#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
24 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
25#define __NEED_locale_t
26#define __NEED_va_list
27#endif
28
29#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
30#define __NEED_wctype_t
31#endif
32
33#include <bits/alltypes.h>
34
35#if L'\0'-1 > 0
36#define WCHAR_MAX (0xffffffffu+L'\0')
37#define WCHAR_MIN (0+L'\0')
38#else
39#define WCHAR_MAX (0x7fffffff+L'\0')
40#define WCHAR_MIN (-1-0x7fffffff+L'\0')
41#endif
42
43#ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
44#ifdef __cplusplus
45#define NULL 0L
46#else
47#define NULL ((void*)0)
48#endif
49#else
50#define __need_NULL
51#include <stddef.h>
52#endif
53
54#undef WEOF
55#define WEOF 0xffffffffU
56
57wchar_t *wcscpy (wchar_t *__restrict, const wchar_t *__restrict);
58wchar_t *wcsncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
59
60wchar_t *wcscat (wchar_t *__restrict, const wchar_t *__restrict);
61wchar_t *wcsncat (wchar_t *__restrict, const wchar_t *__restrict, size_t);
62
63int wcscmp (const wchar_t *, const wchar_t *);
64int wcsncmp (const wchar_t *, const wchar_t *, size_t);
65
66int wcscoll(const wchar_t *, const wchar_t *);
67size_t wcsxfrm (wchar_t *__restrict, const wchar_t *__restrict, size_t);
68
69wchar_t *wcschr (const wchar_t *, wchar_t);
70wchar_t *wcsrchr (const wchar_t *, wchar_t);
71
72size_t wcscspn (const wchar_t *, const wchar_t *);
73size_t wcsspn (const wchar_t *, const wchar_t *);
74wchar_t *wcspbrk (const wchar_t *, const wchar_t *);
75
76wchar_t *wcstok (wchar_t *__restrict, const wchar_t *__restrict, wchar_t **__restrict);
77
78size_t wcslen (const wchar_t *);
79
80wchar_t *wcsstr (const wchar_t *__restrict, const wchar_t *__restrict);
81wchar_t *wcswcs (const wchar_t *, const wchar_t *);
82
83wchar_t *wmemchr (const wchar_t *, wchar_t, size_t);
84int wmemcmp (const wchar_t *, const wchar_t *, size_t);
85wchar_t *wmemcpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
86wchar_t *wmemmove (wchar_t *, const wchar_t *, size_t);
87wchar_t *wmemset (wchar_t *, wchar_t, size_t);
88
89wint_t btowc (int);
90int wctob (wint_t);
91
92int mbsinit (const mbstate_t *);
93size_t mbrtowc (wchar_t *__restrict, const char *__restrict, size_t, mbstate_t *__restrict);
94size_t wcrtomb (char *__restrict, wchar_t, mbstate_t *__restrict);
95
96size_t mbrlen (const char *__restrict, size_t, mbstate_t *__restrict);
97
98size_t mbsrtowcs (wchar_t *__restrict, const char **__restrict, size_t, mbstate_t *__restrict);
99size_t wcsrtombs (char *__restrict, const wchar_t **__restrict, size_t, mbstate_t *__restrict);
100
101float wcstof (const wchar_t *__restrict, wchar_t **__restrict);
102double wcstod (const wchar_t *__restrict, wchar_t **__restrict);
103long double wcstold (const wchar_t *__restrict, wchar_t **__restrict);
104
105long wcstol (const wchar_t *__restrict, wchar_t **__restrict, int);
106unsigned long wcstoul (const wchar_t *__restrict, wchar_t **__restrict, int);
107
108long long wcstoll (const wchar_t *__restrict, wchar_t **__restrict, int);
109unsigned long long wcstoull (const wchar_t *__restrict, wchar_t **__restrict, int);
110
111
112
113int fwide (FILE *, int);
114
115
116int wprintf (const wchar_t *__restrict, ...);
117int fwprintf (FILE *__restrict, const wchar_t *__restrict, ...);
118int swprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, ...);
119
120int vwprintf (const wchar_t *__restrict, __isoc_va_list);
121int vfwprintf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
122int vswprintf (wchar_t *__restrict, size_t, const wchar_t *__restrict, __isoc_va_list);
123
124int wscanf (const wchar_t *__restrict, ...);
125int fwscanf (FILE *__restrict, const wchar_t *__restrict, ...);
126int swscanf (const wchar_t *__restrict, const wchar_t *__restrict, ...);
127
128int vwscanf (const wchar_t *__restrict, __isoc_va_list);
129int vfwscanf (FILE *__restrict, const wchar_t *__restrict, __isoc_va_list);
130int vswscanf (const wchar_t *__restrict, const wchar_t *__restrict, __isoc_va_list);
131
132wint_t fgetwc (FILE *);
133wint_t getwc (FILE *);
134wint_t getwchar (void);
135
136wint_t fputwc (wchar_t, FILE *);
137wint_t putwc (wchar_t, FILE *);
138wint_t putwchar (wchar_t);
139
140wchar_t *fgetws (wchar_t *__restrict, int, FILE *__restrict);
141int fputws (const wchar_t *__restrict, FILE *__restrict);
142
143wint_t ungetwc (wint_t, FILE *);
144
145struct tm;
146size_t wcsftime (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict);
147
148#undef iswdigit
149
150#if defined(_GNU_SOURCE)
151wint_t fgetwc_unlocked (FILE *);
152wint_t getwc_unlocked (FILE *);
153wint_t getwchar_unlocked (void);
154wint_t fputwc_unlocked (wchar_t, FILE *);
155wint_t putwc_unlocked (wchar_t, FILE *);
156wint_t putwchar_unlocked (wchar_t);
157wchar_t *fgetws_unlocked (wchar_t *__restrict, int, FILE *__restrict);
158int fputws_unlocked (const wchar_t *__restrict, FILE *__restrict);
159#endif
160
161#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
162size_t wcsftime_l (wchar_t *__restrict, size_t, const wchar_t *__restrict, const struct tm *__restrict, locale_t);
163#endif
164
165#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
166 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
167FILE *open_wmemstream(wchar_t **, size_t *);
168size_t mbsnrtowcs(wchar_t *__restrict, const char **__restrict, size_t, size_t, mbstate_t *__restrict);
169size_t wcsnrtombs(char *__restrict, const wchar_t **__restrict, size_t, size_t, mbstate_t *__restrict);
170wchar_t *wcsdup(const wchar_t *);
171size_t wcsnlen (const wchar_t *, size_t);
172wchar_t *wcpcpy (wchar_t *__restrict, const wchar_t *__restrict);
173wchar_t *wcpncpy (wchar_t *__restrict, const wchar_t *__restrict, size_t);
174int wcscasecmp(const wchar_t *, const wchar_t *);
175int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t);
176int wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
177int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t, locale_t);
178int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
179size_t wcsxfrm_l(wchar_t *__restrict, const wchar_t *__restrict, size_t, locale_t);
180#endif
181
182#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
183int wcwidth (wchar_t);
184int wcswidth (const wchar_t *, size_t);
185int iswalnum(wint_t);
186int iswalpha(wint_t);
187int iswblank(wint_t);
188int iswcntrl(wint_t);
189int iswdigit(wint_t);
190int iswgraph(wint_t);
191int iswlower(wint_t);
192int iswprint(wint_t);
193int iswpunct(wint_t);
194int iswspace(wint_t);
195int iswupper(wint_t);
196int iswxdigit(wint_t);
197int iswctype(wint_t, wctype_t);
198wint_t towlower(wint_t);
199wint_t towupper(wint_t);
200wctype_t wctype(const char *);
201
202#ifndef __cplusplus
203#undef iswdigit
204#define iswdigit(a) (0 ? iswdigit(a) : ((unsigned)(a)-'0') < 10)
205#endif
206#endif
207
208#ifdef __cplusplus
209}
210#endif
211
212#endif
lib/libc/include/wasm32-wasi/wctype.h deleted-79
......@@ -1,79 +0,0 @@
1#ifndef _WCTYPE_H
2#define _WCTYPE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <features.h>
9
10#define __NEED_wint_t
11#define __NEED_wctype_t
12
13#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
14 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
15#define __NEED_locale_t
16#endif
17
18#include <bits/alltypes.h>
19
20typedef const int * wctrans_t;
21
22#undef WEOF
23#define WEOF 0xffffffffU
24
25#undef iswdigit
26
27int iswalnum(wint_t);
28int iswalpha(wint_t);
29int iswblank(wint_t);
30int iswcntrl(wint_t);
31int iswdigit(wint_t);
32int iswgraph(wint_t);
33int iswlower(wint_t);
34int iswprint(wint_t);
35int iswpunct(wint_t);
36int iswspace(wint_t);
37int iswupper(wint_t);
38int iswxdigit(wint_t);
39int iswctype(wint_t, wctype_t);
40wint_t towctrans(wint_t, wctrans_t);
41wint_t towlower(wint_t);
42wint_t towupper(wint_t);
43wctrans_t wctrans(const char *);
44wctype_t wctype(const char *);
45
46#ifndef __cplusplus
47#undef iswdigit
48#define iswdigit(a) (0 ? iswdigit(a) : ((unsigned)(a)-'0') < 10)
49#endif
50
51#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
52 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
53
54int iswalnum_l(wint_t, locale_t);
55int iswalpha_l(wint_t, locale_t);
56int iswblank_l(wint_t, locale_t);
57int iswcntrl_l(wint_t, locale_t);
58int iswdigit_l(wint_t, locale_t);
59int iswgraph_l(wint_t, locale_t);
60int iswlower_l(wint_t, locale_t);
61int iswprint_l(wint_t, locale_t);
62int iswpunct_l(wint_t, locale_t);
63int iswspace_l(wint_t, locale_t);
64int iswupper_l(wint_t, locale_t);
65int iswxdigit_l(wint_t, locale_t);
66int iswctype_l(wint_t, wctype_t, locale_t);
67wint_t towlower_l(wint_t, locale_t);
68wint_t towupper_l(wint_t, locale_t);
69wint_t towctrans_l(wint_t, wctrans_t, locale_t);
70wctrans_t wctrans_l(const char *, locale_t);
71wctype_t wctype_l(const char *, locale_t);
72
73#endif
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif
src/Compilation.zig+21
......@@ -21,6 +21,7 @@ const musl = @import("musl.zig");
2121const mingw = @import("mingw.zig");
2222const libunwind = @import("libunwind.zig");
2323const libcxx = @import("libcxx.zig");
24const wasi_libc = @import("wasi_libc.zig");
2425const fatal = @import("main.zig").fatal;
2526const Module = @import("Module.zig");
2627const Cache = @import("Cache.zig");
......@@ -202,6 +203,8 @@ const Job = union(enum) {
202203 /// needed when not linking libc and using LLVM for code generation because it generates
203204 /// calls to, for example, memcpy and memset.
204205 zig_libc: void,
206 /// WASI libc sysroot
207 wasi_libc_sysroot: void,
205208
206209 /// Use stage1 C++ code to compile zig code into an object file.
207210 stage1_module: void,
......@@ -276,6 +279,7 @@ pub const MiscTask = enum {
276279 libcxx,
277280 libcxxabi,
278281 libtsan,
282 wasi_libc_sysroot,
279283 compiler_rt,
280284 libssp,
281285 zig_libc,
......@@ -1414,6 +1418,9 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
14141418 },
14151419 });
14161420 }
1421 if (comp.wantBuildWASILibcSysrootFromSource()) {
1422 try comp.work_queue.write(&[_]Job{.{ .wasi_libc_sysroot = {} }});
1423 }
14171424 if (comp.wantBuildMinGWFromSource()) {
14181425 const static_lib_jobs = [_]Job{
14191426 .{ .mingw_crt_file = .mingw32_lib },
......@@ -2139,6 +2146,16 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
21392146 );
21402147 };
21412148 },
2149 .wasi_libc_sysroot => {
2150 wasi_libc.buildWASILibcSysroot(self) catch |err| {
2151 // TODO Surface more error details.
2152 try self.setMiscFailure(
2153 .wasi_libc_sysroot,
2154 "unable to build WASI libc sysroot: {s}",
2155 .{@errorName(err)},
2156 );
2157 };
2158 },
21422159 .compiler_rt_lib => {
21432160 self.buildOutputFromZig(
21442161 "compiler_rt.zig",
......@@ -3285,6 +3302,10 @@ fn wantBuildMuslFromSource(comp: Compilation) bool {
32853302 !comp.getTarget().isWasm();
32863303}
32873304
3305fn wantBuildWASILibcSysrootFromSource(comp: Compilation) bool {
3306 return comp.wantBuildLibCFromSource() and comp.getTarget().isWasm();
3307}
3308
32883309fn wantBuildMinGWFromSource(comp: Compilation) bool {
32893310 return comp.wantBuildLibCFromSource() and comp.getTarget().isMinGW();
32903311}
src/target.zig+1
......@@ -57,6 +57,7 @@ pub const available_libcs = [_]ArchOsAbi{
5757 .{ .arch = .sparc, .os = .linux, .abi = .gnu },
5858 .{ .arch = .sparcv9, .os = .linux, .abi = .gnu },
5959 .{ .arch = .wasm32, .os = .freestanding, .abi = .musl },
60 .{ .arch = .wasm32, .os = .wasi, .abi = .musl },
6061 .{ .arch = .x86_64, .os = .linux, .abi = .gnu },
6162 .{ .arch = .x86_64, .os = .linux, .abi = .gnux32 },
6263 .{ .arch = .x86_64, .os = .linux, .abi = .musl },
src/wasi_libc.zig created+12
......@@ -0,0 +1,12 @@
1const std = @import("std");
2
3const Compilation = @import("Compilation.zig");
4const build_options = @import("build_options");
5
6pub fn buildWASILibcSysroot(comp: *Compilation) !void {
7 if (!build_options.have_llvm) {
8 return error.ZigCompilerNotBuiltWithLLVMExtensions;
9 }
10
11 return error.TODOBuildWASILibcSysroot;
12}