summaryrefslogtreecommitdiffstats
path: root/libc-bottom-half/headers
diff options
context:
space:
mode:
Diffstat (limited to 'libc-bottom-half/headers')
-rw-r--r--libc-bottom-half/headers/private/_/limits.h1
-rw-r--r--libc-bottom-half/headers/private/_/struct/timespec.h1
-rw-r--r--libc-bottom-half/headers/private/_/struct/timeval.h1
-rw-r--r--libc-bottom-half/headers/private/_/types.h9
-rw-r--r--libc-bottom-half/headers/private/assert.h7
-rw-r--r--libc-bottom-half/headers/private/common/crt.h0
-rw-r--r--libc-bottom-half/headers/private/errno.h2
-rw-r--r--libc-bottom-half/headers/private/fcntl.h2
-rw-r--r--libc-bottom-half/headers/private/sched.h0
-rw-r--r--libc-bottom-half/headers/private/stdarg.h2
-rw-r--r--libc-bottom-half/headers/private/stdint.h12
-rw-r--r--libc-bottom-half/headers/private/stdio.h3
-rw-r--r--libc-bottom-half/headers/private/stdlib.h8
-rw-r--r--libc-bottom-half/headers/private/string.h2
-rw-r--r--libc-bottom-half/headers/private/sys/mman.h2
-rw-r--r--libc-bottom-half/headers/private/threads.h3
-rw-r--r--libc-bottom-half/headers/public/__errno.h20
-rw-r--r--libc-bottom-half/headers/public/__errno_values.h86
-rw-r--r--libc-bottom-half/headers/public/__fd_set.h76
-rw-r--r--libc-bottom-half/headers/public/__function___isatty.h14
-rw-r--r--libc-bottom-half/headers/public/__functions_malloc.h26
-rw-r--r--libc-bottom-half/headers/public/__functions_memcpy.h20
-rw-r--r--libc-bottom-half/headers/public/__header_dirent.h45
-rw-r--r--libc-bottom-half/headers/public/__header_fcntl.h61
-rw-r--r--libc-bottom-half/headers/public/__header_inttypes.h182
-rw-r--r--libc-bottom-half/headers/public/__header_netinet_in.h30
-rw-r--r--libc-bottom-half/headers/public/__header_poll.h27
-rw-r--r--libc-bottom-half/headers/public/__header_stdlib.h21
-rw-r--r--libc-bottom-half/headers/public/__header_string.h23
-rw-r--r--libc-bottom-half/headers/public/__header_sys_ioctl.h17
-rw-r--r--libc-bottom-half/headers/public/__header_sys_resource.h19
-rw-r--r--libc-bottom-half/headers/public/__header_sys_socket.h41
-rw-r--r--libc-bottom-half/headers/public/__header_sys_stat.h15
-rw-r--r--libc-bottom-half/headers/public/__header_time.h33
-rw-r--r--libc-bottom-half/headers/public/__header_unistd.h28
-rw-r--r--libc-bottom-half/headers/public/__macro_FD_SETSIZE.h6
-rw-r--r--libc-bottom-half/headers/public/__macro_PAGESIZE.h16
-rw-r--r--libc-bottom-half/headers/public/__mode_t.h38
-rw-r--r--libc-bottom-half/headers/public/__seek.h10
-rw-r--r--libc-bottom-half/headers/public/__struct_dirent.h14
-rw-r--r--libc-bottom-half/headers/public/__struct_in6_addr.h8
-rw-r--r--libc-bottom-half/headers/public/__struct_in_addr.h10
-rw-r--r--libc-bottom-half/headers/public/__struct_iovec.h12
-rw-r--r--libc-bottom-half/headers/public/__struct_msghdr.h16
-rw-r--r--libc-bottom-half/headers/public/__struct_pollfd.h10
-rw-r--r--libc-bottom-half/headers/public/__struct_rusage.h12
-rw-r--r--libc-bottom-half/headers/public/__struct_sockaddr.h14
-rw-r--r--libc-bottom-half/headers/public/__struct_sockaddr_in.h17
-rw-r--r--libc-bottom-half/headers/public/__struct_sockaddr_in6.h19
-rw-r--r--libc-bottom-half/headers/public/__struct_sockaddr_storage.h14
-rw-r--r--libc-bottom-half/headers/public/__struct_sockaddr_un.h13
-rw-r--r--libc-bottom-half/headers/public/__struct_stat.h35
-rw-r--r--libc-bottom-half/headers/public/__struct_timespec.h12
-rw-r--r--libc-bottom-half/headers/public/__struct_timeval.h13
-rw-r--r--libc-bottom-half/headers/public/__struct_tm.h19
-rw-r--r--libc-bottom-half/headers/public/__struct_tms.h13
-rw-r--r--libc-bottom-half/headers/public/__typedef_DIR.h6
-rw-r--r--libc-bottom-half/headers/public/__typedef_blkcnt_t.h7
-rw-r--r--libc-bottom-half/headers/public/__typedef_blksize_t.h6
-rw-r--r--libc-bottom-half/headers/public/__typedef_clock_t.h7
-rw-r--r--libc-bottom-half/headers/public/__typedef_clockid_t.h6
-rw-r--r--libc-bottom-half/headers/public/__typedef_dev_t.h7
-rw-r--r--libc-bottom-half/headers/public/__typedef_fd_set.h14
-rw-r--r--libc-bottom-half/headers/public/__typedef_gid_t.h6
-rw-r--r--libc-bottom-half/headers/public/__typedef_in_addr_t.h6
-rw-r--r--libc-bottom-half/headers/public/__typedef_in_port_t.h6
-rw-r--r--libc-bottom-half/headers/public/__typedef_ino_t.h7
-rw-r--r--libc-bottom-half/headers/public/__typedef_mode_t.h6
-rw-r--r--libc-bottom-half/headers/public/__typedef_nfds_t.h6
-rw-r--r--libc-bottom-half/headers/public/__typedef_nlink_t.h7
-rw-r--r--libc-bottom-half/headers/public/__typedef_off_t.h7
-rw-r--r--libc-bottom-half/headers/public/__typedef_sa_family_t.h6
-rw-r--r--libc-bottom-half/headers/public/__typedef_sigset_t.h7
-rw-r--r--libc-bottom-half/headers/public/__typedef_socklen_t.h6
-rw-r--r--libc-bottom-half/headers/public/__typedef_ssize_t.h7
-rw-r--r--libc-bottom-half/headers/public/__typedef_suseconds_t.h8
-rw-r--r--libc-bottom-half/headers/public/__typedef_time_t.h7
-rw-r--r--libc-bottom-half/headers/public/__typedef_uid_t.h6
-rw-r--r--libc-bottom-half/headers/public/dirent.h10
-rw-r--r--libc-bottom-half/headers/public/errno.h7
-rw-r--r--libc-bottom-half/headers/public/fcntl.h10
-rw-r--r--libc-bottom-half/headers/public/inttypes.h10
-rw-r--r--libc-bottom-half/headers/public/netinet/in.h6
-rw-r--r--libc-bottom-half/headers/public/poll.h10
-rw-r--r--libc-bottom-half/headers/public/stdlib.h10
-rw-r--r--libc-bottom-half/headers/public/string.h10
-rw-r--r--libc-bottom-half/headers/public/sys/ioctl.h10
-rw-r--r--libc-bottom-half/headers/public/sys/resource.h10
-rw-r--r--libc-bottom-half/headers/public/sys/select.h18
-rw-r--r--libc-bottom-half/headers/public/sys/socket.h6
-rw-r--r--libc-bottom-half/headers/public/sys/stat.h10
-rw-r--r--libc-bottom-half/headers/public/sys/time.h6
-rw-r--r--libc-bottom-half/headers/public/sys/times.h6
-rw-r--r--libc-bottom-half/headers/public/sys/types.h16
-rw-r--r--libc-bottom-half/headers/public/sys/uio.h6
-rw-r--r--libc-bottom-half/headers/public/sys/un.h6
-rw-r--r--libc-bottom-half/headers/public/time.h10
-rw-r--r--libc-bottom-half/headers/public/unistd.h10
-rw-r--r--libc-bottom-half/headers/public/wasi/api.h2115
-rw-r--r--libc-bottom-half/headers/public/wasi/libc-environ.h36
-rw-r--r--libc-bottom-half/headers/public/wasi/libc-find-relpath.h79
-rw-r--r--libc-bottom-half/headers/public/wasi/libc-nocwd.h58
-rw-r--r--libc-bottom-half/headers/public/wasi/libc.h65
-rw-r--r--libc-bottom-half/headers/public/wchar.h9
104 files changed, 3860 insertions, 0 deletions
diff --git a/libc-bottom-half/headers/private/_/limits.h b/libc-bottom-half/headers/private/_/limits.h
new file mode 100644
index 0000000..1e189a1
--- /dev/null
+++ b/libc-bottom-half/headers/private/_/limits.h
@@ -0,0 +1 @@
+#include <limits.h>
diff --git a/libc-bottom-half/headers/private/_/struct/timespec.h b/libc-bottom-half/headers/private/_/struct/timespec.h
new file mode 100644
index 0000000..fbe602a
--- /dev/null
+++ b/libc-bottom-half/headers/private/_/struct/timespec.h
@@ -0,0 +1 @@
+#include <__struct_timespec.h>
diff --git a/libc-bottom-half/headers/private/_/struct/timeval.h b/libc-bottom-half/headers/private/_/struct/timeval.h
new file mode 100644
index 0000000..9cabfd7
--- /dev/null
+++ b/libc-bottom-half/headers/private/_/struct/timeval.h
@@ -0,0 +1 @@
+#include <__struct_timeval.h>
diff --git a/libc-bottom-half/headers/private/_/types.h b/libc-bottom-half/headers/private/_/types.h
new file mode 100644
index 0000000..42b17e5
--- /dev/null
+++ b/libc-bottom-half/headers/private/_/types.h
@@ -0,0 +1,9 @@
+#include <_/cdefs.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdarg.h>
+#include <sys/types.h>
+
+typedef uint64_t __uint64_t;
+#define _UINT64_C UINT64_C
diff --git a/libc-bottom-half/headers/private/assert.h b/libc-bottom-half/headers/private/assert.h
new file mode 100644
index 0000000..8e19ff4
--- /dev/null
+++ b/libc-bottom-half/headers/private/assert.h
@@ -0,0 +1,7 @@
+#include <stdlib.h>
+
+#ifndef __cplusplus
+#define static_assert _Static_assert
+#endif
+
+#define assert(x) ((void)((x) || (abort(), 0)))
diff --git a/libc-bottom-half/headers/private/common/crt.h b/libc-bottom-half/headers/private/common/crt.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libc-bottom-half/headers/private/common/crt.h
diff --git a/libc-bottom-half/headers/private/errno.h b/libc-bottom-half/headers/private/errno.h
new file mode 100644
index 0000000..3b37313
--- /dev/null
+++ b/libc-bottom-half/headers/private/errno.h
@@ -0,0 +1,2 @@
+#include_next <errno.h>
+#define EOPNOTSUPP ENOTSUP
diff --git a/libc-bottom-half/headers/private/fcntl.h b/libc-bottom-half/headers/private/fcntl.h
new file mode 100644
index 0000000..3210418
--- /dev/null
+++ b/libc-bottom-half/headers/private/fcntl.h
@@ -0,0 +1,2 @@
+#include_next <fcntl.h>
+#include <_/types.h>
diff --git a/libc-bottom-half/headers/private/sched.h b/libc-bottom-half/headers/private/sched.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libc-bottom-half/headers/private/sched.h
diff --git a/libc-bottom-half/headers/private/stdarg.h b/libc-bottom-half/headers/private/stdarg.h
new file mode 100644
index 0000000..e019608
--- /dev/null
+++ b/libc-bottom-half/headers/private/stdarg.h
@@ -0,0 +1,2 @@
+#include_next <stdarg.h>
+#include <_/cdefs.h>
diff --git a/libc-bottom-half/headers/private/stdint.h b/libc-bottom-half/headers/private/stdint.h
new file mode 100644
index 0000000..1fed338
--- /dev/null
+++ b/libc-bottom-half/headers/private/stdint.h
@@ -0,0 +1,12 @@
+#include_next <stdint.h>
+
+#define __need_size_t
+#include <stddef.h>
+
+#include <__typedef_clock_t.h>
+#include <__typedef_time_t.h>
+#include <__typedef_blksize_t.h>
+#include <__typedef_off_t.h>
+#include <__typedef_ssize_t.h>
+#include <__typedef_suseconds_t.h>
+#include <__typedef_nlink_t.h>
diff --git a/libc-bottom-half/headers/private/stdio.h b/libc-bottom-half/headers/private/stdio.h
new file mode 100644
index 0000000..b135b6a
--- /dev/null
+++ b/libc-bottom-half/headers/private/stdio.h
@@ -0,0 +1,3 @@
+#include <_/cdefs.h>
+int snprintf(char *str, size_t size, const char *format, ...);
+int rename(const char *oldpath, const char *newpath);
diff --git a/libc-bottom-half/headers/private/stdlib.h b/libc-bottom-half/headers/private/stdlib.h
new file mode 100644
index 0000000..8c2b395
--- /dev/null
+++ b/libc-bottom-half/headers/private/stdlib.h
@@ -0,0 +1,8 @@
+#define __need_size_t
+#define __need_wchar_t
+#define __need_NULL
+#include <stddef.h>
+
+#include_next <stdlib.h>
+
+int clearenv(void);
diff --git a/libc-bottom-half/headers/private/string.h b/libc-bottom-half/headers/private/string.h
new file mode 100644
index 0000000..1c4ce19
--- /dev/null
+++ b/libc-bottom-half/headers/private/string.h
@@ -0,0 +1,2 @@
+#include_next <string.h>
+#include <_/cdefs.h>
diff --git a/libc-bottom-half/headers/private/sys/mman.h b/libc-bottom-half/headers/private/sys/mman.h
new file mode 100644
index 0000000..bdd5401
--- /dev/null
+++ b/libc-bottom-half/headers/private/sys/mman.h
@@ -0,0 +1,2 @@
+#include_next <sys/mman.h>
+#include <_/types.h>
diff --git a/libc-bottom-half/headers/private/threads.h b/libc-bottom-half/headers/private/threads.h
new file mode 100644
index 0000000..b51ef0d
--- /dev/null
+++ b/libc-bottom-half/headers/private/threads.h
@@ -0,0 +1,3 @@
+#ifndef __cplusplus
+#define thread_local _Thread_local
+#endif
diff --git a/libc-bottom-half/headers/public/__errno.h b/libc-bottom-half/headers/public/__errno.h
new file mode 100644
index 0000000..4fd983a
--- /dev/null
+++ b/libc-bottom-half/headers/public/__errno.h
@@ -0,0 +1,20 @@
+#ifndef __wasilibc___errno_h
+#define __wasilibc___errno_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+extern thread_local int errno;
+#else
+extern _Thread_local int errno;
+#endif
+
+#define errno errno
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__errno_values.h b/libc-bottom-half/headers/public/__errno_values.h
new file mode 100644
index 0000000..6d6d412
--- /dev/null
+++ b/libc-bottom-half/headers/public/__errno_values.h
@@ -0,0 +1,86 @@
+#ifndef __wasilibc___errno_values_h
+#define __wasilibc___errno_values_h
+
+#include <wasi/api.h>
+
+#define E2BIG __WASI_ERRNO_2BIG
+#define EACCES __WASI_ERRNO_ACCES
+#define EADDRINUSE __WASI_ERRNO_ADDRINUSE
+#define EADDRNOTAVAIL __WASI_ERRNO_ADDRNOTAVAIL
+#define EAFNOSUPPORT __WASI_ERRNO_AFNOSUPPORT
+#define EAGAIN __WASI_ERRNO_AGAIN
+#define EALREADY __WASI_ERRNO_ALREADY
+#define EBADF __WASI_ERRNO_BADF
+#define EBADMSG __WASI_ERRNO_BADMSG
+#define EBUSY __WASI_ERRNO_BUSY
+#define ECANCELED __WASI_ERRNO_CANCELED
+#define ECHILD __WASI_ERRNO_CHILD
+#define ECONNABORTED __WASI_ERRNO_CONNABORTED
+#define ECONNREFUSED __WASI_ERRNO_CONNREFUSED
+#define ECONNRESET __WASI_ERRNO_CONNRESET
+#define EDEADLK __WASI_ERRNO_DEADLK
+#define EDESTADDRREQ __WASI_ERRNO_DESTADDRREQ
+#define EDOM __WASI_ERRNO_DOM
+#define EDQUOT __WASI_ERRNO_DQUOT
+#define EEXIST __WASI_ERRNO_EXIST
+#define EFAULT __WASI_ERRNO_FAULT
+#define EFBIG __WASI_ERRNO_FBIG
+#define EHOSTUNREACH __WASI_ERRNO_HOSTUNREACH
+#define EIDRM __WASI_ERRNO_IDRM
+#define EILSEQ __WASI_ERRNO_ILSEQ
+#define EINPROGRESS __WASI_ERRNO_INPROGRESS
+#define EINTR __WASI_ERRNO_INTR
+#define EINVAL __WASI_ERRNO_INVAL
+#define EIO __WASI_ERRNO_IO
+#define EISCONN __WASI_ERRNO_ISCONN
+#define EISDIR __WASI_ERRNO_ISDIR
+#define ELOOP __WASI_ERRNO_LOOP
+#define EMFILE __WASI_ERRNO_MFILE
+#define EMLINK __WASI_ERRNO_MLINK
+#define EMSGSIZE __WASI_ERRNO_MSGSIZE
+#define EMULTIHOP __WASI_ERRNO_MULTIHOP
+#define ENAMETOOLONG __WASI_ERRNO_NAMETOOLONG
+#define ENETDOWN __WASI_ERRNO_NETDOWN
+#define ENETRESET __WASI_ERRNO_NETRESET
+#define ENETUNREACH __WASI_ERRNO_NETUNREACH
+#define ENFILE __WASI_ERRNO_NFILE
+#define ENOBUFS __WASI_ERRNO_NOBUFS
+#define ENODEV __WASI_ERRNO_NODEV
+#define ENOENT __WASI_ERRNO_NOENT
+#define ENOEXEC __WASI_ERRNO_NOEXEC
+#define ENOLCK __WASI_ERRNO_NOLCK
+#define ENOLINK __WASI_ERRNO_NOLINK
+#define ENOMEM __WASI_ERRNO_NOMEM
+#define ENOMSG __WASI_ERRNO_NOMSG
+#define ENOPROTOOPT __WASI_ERRNO_NOPROTOOPT
+#define ENOSPC __WASI_ERRNO_NOSPC
+#define ENOSYS __WASI_ERRNO_NOSYS
+#define ENOTCONN __WASI_ERRNO_NOTCONN
+#define ENOTDIR __WASI_ERRNO_NOTDIR
+#define ENOTEMPTY __WASI_ERRNO_NOTEMPTY
+#define ENOTRECOVERABLE __WASI_ERRNO_NOTRECOVERABLE
+#define ENOTSOCK __WASI_ERRNO_NOTSOCK
+#define ENOTSUP __WASI_ERRNO_NOTSUP
+#define ENOTTY __WASI_ERRNO_NOTTY
+#define ENXIO __WASI_ERRNO_NXIO
+#define EOVERFLOW __WASI_ERRNO_OVERFLOW
+#define EOWNERDEAD __WASI_ERRNO_OWNERDEAD
+#define EPERM __WASI_ERRNO_PERM
+#define EPIPE __WASI_ERRNO_PIPE
+#define EPROTO __WASI_ERRNO_PROTO
+#define EPROTONOSUPPORT __WASI_ERRNO_PROTONOSUPPORT
+#define EPROTOTYPE __WASI_ERRNO_PROTOTYPE
+#define ERANGE __WASI_ERRNO_RANGE
+#define EROFS __WASI_ERRNO_ROFS
+#define ESPIPE __WASI_ERRNO_SPIPE
+#define ESRCH __WASI_ERRNO_SRCH
+#define ESTALE __WASI_ERRNO_STALE
+#define ETIMEDOUT __WASI_ERRNO_TIMEDOUT
+#define ETXTBSY __WASI_ERRNO_TXTBSY
+#define EXDEV __WASI_ERRNO_XDEV
+#define ENOTCAPABLE __WASI_ERRNO_NOTCAPABLE
+
+#define EOPNOTSUPP ENOTSUP
+#define EWOULDBLOCK EAGAIN
+
+#endif
diff --git a/libc-bottom-half/headers/public/__fd_set.h b/libc-bottom-half/headers/public/__fd_set.h
new file mode 100644
index 0000000..7be0b9f
--- /dev/null
+++ b/libc-bottom-half/headers/public/__fd_set.h
@@ -0,0 +1,76 @@
+#ifndef __wasilibc___fd_set_h
+#define __wasilibc___fd_set_h
+
+#include <__typedef_fd_set.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static __inline void FD_CLR(int __fd, fd_set *__set) {
+ size_t __n = __set->__nfds;
+ for (int *__p = __set->__fds, *__e = __p + __n;
+ __p < __e; ++__p)
+ {
+ if (*__p == __fd) {
+ *__p = __e[-1];
+ __set->__nfds = __n - 1;
+ return;
+ }
+ }
+}
+
+static __inline
+#ifdef __cplusplus
+bool
+#else
+_Bool
+#endif
+FD_ISSET(int __fd, const fd_set *__set)
+{
+ size_t __n = __set->__nfds;
+ for (const int *__p = __set->__fds, *__e = __p + __n;
+ __p < __e; ++__p)
+ {
+ if (*__p == __fd) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static __inline void FD_SET(int __fd, fd_set *__set) {
+ size_t __n = __set->__nfds;
+ for (const int *__p = __set->__fds, *__e = __p + __n;
+ __p < __e; ++__p)
+ {
+ if (*__p == __fd) {
+ return;
+ }
+ }
+ __set->__nfds = __n + 1;
+ __set->__fds[__n] = __fd;
+}
+
+static __inline void FD_ZERO(fd_set *__set) {
+ __set->__nfds = 0;
+}
+
+static __inline void FD_COPY(const fd_set *__restrict __from,
+ fd_set *__restrict __to) {
+ size_t __n = __from->__nfds;
+ __to->__nfds = __n;
+ __builtin_memcpy(__to->__fds, __from->__fds, __n * sizeof(int));
+}
+
+#define FD_CLR(fd, set) (FD_CLR((fd), (set)))
+#define FD_ISSET(fd, set) (FD_ISSET((fd), (set)))
+#define FD_SET(fd, set) (FD_SET((fd), (set)))
+#define FD_ZERO(set) (FD_ZERO((set)))
+#define FD_COPY(from, to) (FD_COPY((from), (to)))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__function___isatty.h b/libc-bottom-half/headers/public/__function___isatty.h
new file mode 100644
index 0000000..7c04645
--- /dev/null
+++ b/libc-bottom-half/headers/public/__function___isatty.h
@@ -0,0 +1,14 @@
+#ifndef __wasilibc___function___isatty_h
+#define __wasilibc___function___isatty_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int __isatty(int fd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__functions_malloc.h b/libc-bottom-half/headers/public/__functions_malloc.h
new file mode 100644
index 0000000..d516bc3
--- /dev/null
+++ b/libc-bottom-half/headers/public/__functions_malloc.h
@@ -0,0 +1,26 @@
+#ifndef __wasilibc___functions_malloc_h
+#define __wasilibc___functions_malloc_h
+
+#define __need_size_t
+#define __need_wchar_t
+#define __need_NULL
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void *malloc(size_t __size) __attribute__((__malloc__, __warn_unused_result__));
+void free(void *__ptr);
+void *calloc(size_t __nmemb, size_t __size) __attribute__((__malloc__, __warn_unused_result__));
+void *realloc(void *__ptr, size_t __size) __attribute__((__warn_unused_result__));
+
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+void *reallocarray(void *__ptr, size_t __nmemb, size_t __size) __attribute__((__warn_unused_result__));
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__functions_memcpy.h b/libc-bottom-half/headers/public/__functions_memcpy.h
new file mode 100644
index 0000000..253b065
--- /dev/null
+++ b/libc-bottom-half/headers/public/__functions_memcpy.h
@@ -0,0 +1,20 @@
+#ifndef __wasilibc___functions_memcpy_h
+#define __wasilibc___functions_memcpy_h
+
+#define __need_size_t
+#define __need_NULL
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void *memcpy(void *__restrict__ __dst, const void *__restrict__ __src, size_t __n) __attribute__((__nothrow__, __leaf__, __nonnull__(1, 2)));
+void *memmove(void *__dst, const void *__src, size_t __n) __attribute__((__nothrow__, __leaf__, __nonnull__(1, 2)));
+void *memset(void *__dst, int __c, size_t __n) __attribute__((__nothrow__, __leaf__, __nonnull__(1)));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_dirent.h b/libc-bottom-half/headers/public/__header_dirent.h
new file mode 100644
index 0000000..ccf3def
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_dirent.h
@@ -0,0 +1,45 @@
+#ifndef __wasilibc___header_dirent_h
+#define __wasilibc___header_dirent_h
+
+#include <wasi/api.h>
+
+#define DT_BLK __WASI_FILETYPE_BLOCK_DEVICE
+#define DT_CHR __WASI_FILETYPE_CHARACTER_DEVICE
+#define DT_DIR __WASI_FILETYPE_DIRECTORY
+#define DT_FIFO __WASI_FILETYPE_SOCKET_STREAM
+#define DT_LNK __WASI_FILETYPE_SYMBOLIC_LINK
+#define DT_REG __WASI_FILETYPE_REGULAR_FILE
+#define DT_UNKNOWN __WASI_FILETYPE_UNKNOWN
+
+#define IFTODT(x) (__wasilibc_iftodt(x))
+#define DTTOIF(x) (__wasilibc_dttoif(x))
+
+int __wasilibc_iftodt(int x);
+int __wasilibc_dttoif(int x);
+
+#include <__struct_dirent.h>
+#include <__typedef_DIR.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int closedir(DIR *);
+DIR *opendir(const char *);
+DIR *fdopendir(int);
+int fdclosedir(DIR *);
+struct dirent *readdir(DIR *);
+void rewinddir(DIR *);
+void seekdir(DIR *, long);
+long telldir(DIR *);
+DIR *opendirat(int, const char *);
+void rewinddir(DIR *);
+int scandirat(int, const char *, struct dirent ***,
+ int (*)(const struct dirent *),
+ int (*)(const struct dirent **, const struct dirent **));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_fcntl.h b/libc-bottom-half/headers/public/__header_fcntl.h
new file mode 100644
index 0000000..04252ac
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_fcntl.h
@@ -0,0 +1,61 @@
+#ifndef __wasilibc___header_fcntl_h
+#define __wasilibc___header_fcntl_h
+
+#include <wasi/api.h>
+#include <__seek.h>
+#include <__mode_t.h>
+
+#define O_APPEND __WASI_FDFLAGS_APPEND
+#define O_DSYNC __WASI_FDFLAGS_DSYNC
+#define O_NONBLOCK __WASI_FDFLAGS_NONBLOCK
+#define O_RSYNC __WASI_FDFLAGS_RSYNC
+#define O_SYNC __WASI_FDFLAGS_SYNC
+#define O_CREAT (__WASI_OFLAGS_CREAT << 12)
+#define O_DIRECTORY (__WASI_OFLAGS_DIRECTORY << 12)
+#define O_EXCL (__WASI_OFLAGS_EXCL << 12)
+#define O_TRUNC (__WASI_OFLAGS_TRUNC << 12)
+
+#define O_NOFOLLOW (0x01000000)
+#define O_EXEC (0x02000000)
+#define O_RDONLY (0x04000000)
+#define O_SEARCH (0x08000000)
+#define O_WRONLY (0x10000000)
+
+/*
+ * O_CLOEXEC is defined to be zero, as WASI has no exec-style functions.
+ */
+#define O_CLOEXEC (0)
+
+/*
+ * O_TTY_INIT is defined to be zero, meaning that WASI implementations are
+ * expected to always initialize a terminal the first time it's opened.
+ */
+#define O_TTY_INIT (0)
+
+#define O_NOCTTY (0)
+
+#define O_RDWR (O_RDONLY | O_WRONLY)
+#define O_ACCMODE (O_EXEC | O_RDWR | O_SEARCH)
+
+#define POSIX_FADV_DONTNEED __WASI_ADVICE_DONTNEED
+#define POSIX_FADV_NOREUSE __WASI_ADVICE_NOREUSE
+#define POSIX_FADV_NORMAL __WASI_ADVICE_NORMAL
+#define POSIX_FADV_RANDOM __WASI_ADVICE_RANDOM
+#define POSIX_FADV_SEQUENTIAL __WASI_ADVICE_SEQUENTIAL
+#define POSIX_FADV_WILLNEED __WASI_ADVICE_WILLNEED
+
+#define F_GETFD (1)
+#define F_SETFD (2)
+#define F_GETFL (3)
+#define F_SETFL (4)
+
+#define FD_CLOEXEC (1)
+
+#define AT_EACCESS (0x0)
+#define AT_SYMLINK_NOFOLLOW (0x1)
+#define AT_SYMLINK_FOLLOW (0x2)
+#define AT_REMOVEDIR (0x4)
+
+#define AT_FDCWD (-2)
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_inttypes.h b/libc-bottom-half/headers/public/__header_inttypes.h
new file mode 100644
index 0000000..47c5c9b
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_inttypes.h
@@ -0,0 +1,182 @@
+#ifndef __wasilibc___include_inttypes_h
+#define __wasilibc___include_inttypes_h
+
+#include <stdint.h>
+
+#define __need_wchar_t
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct { intmax_t quot, rem; } imaxdiv_t;
+
+intmax_t imaxabs(intmax_t);
+imaxdiv_t imaxdiv(intmax_t, intmax_t);
+intmax_t strtoimax(const char *__restrict, char **__restrict, int);
+uintmax_t strtoumax(const char *__restrict, char **__restrict, int);
+intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int);
+uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int);
+
+#define PRId16 __INT16_FMTd__
+#define PRIi16 __INT16_FMTi__
+#define PRId32 __INT32_FMTd__
+#define PRIi32 __INT32_FMTi__
+#define PRId64 __INT64_FMTd__
+#define PRIi64 __INT64_FMTi__
+#define PRId8 __INT8_FMTd__
+#define PRIi8 __INT8_FMTi__
+#define PRIdMAX __INTMAX_FMTd__
+#define PRIiMAX __INTMAX_FMTi__
+#define PRIdPTR __INTPTR_FMTd__
+#define PRIiPTR __INTPTR_FMTi__
+#define PRIdFAST16 __INT_FAST16_FMTd__
+#define PRIiFAST16 __INT_FAST16_FMTi__
+#define PRIdFAST32 __INT_FAST32_FMTd__
+#define PRIiFAST32 __INT_FAST32_FMTi__
+#define PRIdFAST64 __INT_FAST64_FMTd__
+#define PRIiFAST64 __INT_FAST64_FMTi__
+#define PRIdFAST8 __INT_FAST8_FMTd__
+#define PRIiFAST8 __INT_FAST8_FMTi__
+#define PRIdLEAST16 __INT_LEAST16_FMTd__
+#define PRIiLEAST16 __INT_LEAST16_FMTi__
+#define PRIdLEAST32 __INT_LEAST32_FMTd__
+#define PRIiLEAST32 __INT_LEAST32_FMTi__
+#define PRIdLEAST64 __INT_LEAST64_FMTd__
+#define PRIiLEAST64 __INT_LEAST64_FMTi__
+#define PRIdLEAST8 __INT_LEAST8_FMTd__
+#define PRIiLEAST8 __INT_LEAST8_FMTi__
+#define PRIX16 __UINT16_FMTX__
+#define PRIo16 __UINT16_FMTo__
+#define PRIu16 __UINT16_FMTu__
+#define PRIx16 __UINT16_FMTx__
+#define PRIX32 __UINT32_FMTX__
+#define PRIo32 __UINT32_FMTo__
+#define PRIu32 __UINT32_FMTu__
+#define PRIx32 __UINT32_FMTx__
+#define PRIX64 __UINT64_FMTX__
+#define PRIo64 __UINT64_FMTo__
+#define PRIu64 __UINT64_FMTu__
+#define PRIx64 __UINT64_FMTx__
+#define PRIX8 __UINT8_FMTX__
+#define PRIo8 __UINT8_FMTo__
+#define PRIu8 __UINT8_FMTu__
+#define PRIx8 __UINT8_FMTx__
+#define PRIXMAX __UINTMAX_FMTX__
+#define PRIoMAX __UINTMAX_FMTo__
+#define PRIuMAX __UINTMAX_FMTu__
+#define PRIxMAX __UINTMAX_FMTx__
+#define PRIXPTR __UINTPTR_FMTX__
+#define PRIoPTR __UINTPTR_FMTo__
+#define PRIuPTR __UINTPTR_FMTu__
+#define PRIxPTR __UINTPTR_FMTx__
+#define PRIXFAST16 __UINT_FAST16_FMTX__
+#define PRIoFAST16 __UINT_FAST16_FMTo__
+#define PRIuFAST16 __UINT_FAST16_FMTu__
+#define PRIxFAST16 __UINT_FAST16_FMTx__
+#define PRIXFAST32 __UINT_FAST32_FMTX__
+#define PRIoFAST32 __UINT_FAST32_FMTo__
+#define PRIuFAST32 __UINT_FAST32_FMTu__
+#define PRIxFAST32 __UINT_FAST32_FMTx__
+#define PRIXFAST64 __UINT_FAST64_FMTX__
+#define PRIoFAST64 __UINT_FAST64_FMTo__
+#define PRIuFAST64 __UINT_FAST64_FMTu__
+#define PRIxFAST64 __UINT_FAST64_FMTx__
+#define PRIXFAST8 __UINT_FAST8_FMTX__
+#define PRIoFAST8 __UINT_FAST8_FMTo__
+#define PRIuFAST8 __UINT_FAST8_FMTu__
+#define PRIxFAST8 __UINT_FAST8_FMTx__
+#define PRIXLEAST16 __UINT_LEAST16_FMTX__
+#define PRIoLEAST16 __UINT_LEAST16_FMTo__
+#define PRIuLEAST16 __UINT_LEAST16_FMTu__
+#define PRIxLEAST16 __UINT_LEAST16_FMTx__
+#define PRIXLEAST32 __UINT_LEAST32_FMTX__
+#define PRIoLEAST32 __UINT_LEAST32_FMTo__
+#define PRIuLEAST32 __UINT_LEAST32_FMTu__
+#define PRIxLEAST32 __UINT_LEAST32_FMTx__
+#define PRIXLEAST64 __UINT_LEAST64_FMTX__
+#define PRIoLEAST64 __UINT_LEAST64_FMTo__
+#define PRIuLEAST64 __UINT_LEAST64_FMTu__
+#define PRIxLEAST64 __UINT_LEAST64_FMTx__
+#define PRIXLEAST8 __UINT_LEAST8_FMTX__
+#define PRIoLEAST8 __UINT_LEAST8_FMTo__
+#define PRIuLEAST8 __UINT_LEAST8_FMTu__
+#define PRIxLEAST8 __UINT_LEAST8_FMTx__
+
+#define SCNd16 __INT16_FMTd__
+#define SCNi16 __INT16_FMTi__
+#define SCNd32 __INT32_FMTd__
+#define SCNi32 __INT32_FMTi__
+#define SCNd64 __INT64_FMTd__
+#define SCNi64 __INT64_FMTi__
+#define SCNd8 __INT8_FMTd__
+#define SCNi8 __INT8_FMTi__
+#define SCNdMAX __INTMAX_FMTd__
+#define SCNiMAX __INTMAX_FMTi__
+#define SCNdPTR __INTPTR_FMTd__
+#define SCNiPTR __INTPTR_FMTi__
+#define SCNdFAST16 __INT_FAST16_FMTd__
+#define SCNiFAST16 __INT_FAST16_FMTi__
+#define SCNdFAST32 __INT_FAST32_FMTd__
+#define SCNiFAST32 __INT_FAST32_FMTi__
+#define SCNdFAST64 __INT_FAST64_FMTd__
+#define SCNiFAST64 __INT_FAST64_FMTi__
+#define SCNdFAST8 __INT_FAST8_FMTd__
+#define SCNiFAST8 __INT_FAST8_FMTi__
+#define SCNdLEAST16 __INT_LEAST16_FMTd__
+#define SCNiLEAST16 __INT_LEAST16_FMTi__
+#define SCNdLEAST32 __INT_LEAST32_FMTd__
+#define SCNiLEAST32 __INT_LEAST32_FMTi__
+#define SCNdLEAST64 __INT_LEAST64_FMTd__
+#define SCNiLEAST64 __INT_LEAST64_FMTi__
+#define SCNdLEAST8 __INT_LEAST8_FMTd__
+#define SCNiLEAST8 __INT_LEAST8_FMTi__
+#define SCNo16 __UINT16_FMTo__
+#define SCNu16 __UINT16_FMTu__
+#define SCNx16 __UINT16_FMTx__
+#define SCNo32 __UINT32_FMTo__
+#define SCNu32 __UINT32_FMTu__
+#define SCNx32 __UINT32_FMTx__
+#define SCNo64 __UINT64_FMTo__
+#define SCNu64 __UINT64_FMTu__
+#define SCNx64 __UINT64_FMTx__
+#define SCNo8 __UINT8_FMTo__
+#define SCNu8 __UINT8_FMTu__
+#define SCNx8 __UINT8_FMTx__
+#define SCNoMAX __UINTMAX_FMTo__
+#define SCNuMAX __UINTMAX_FMTu__
+#define SCNxMAX __UINTMAX_FMTx__
+#define SCNoPTR __UINTPTR_FMTo__
+#define SCNuPTR __UINTPTR_FMTu__
+#define SCNxPTR __UINTPTR_FMTx__
+#define SCNoFAST16 __UINT_FAST16_FMTo__
+#define SCNuFAST16 __UINT_FAST16_FMTu__
+#define SCNxFAST16 __UINT_FAST16_FMTx__
+#define SCNoFAST32 __UINT_FAST32_FMTo__
+#define SCNuFAST32 __UINT_FAST32_FMTu__
+#define SCNxFAST32 __UINT_FAST32_FMTx__
+#define SCNoFAST64 __UINT_FAST64_FMTo__
+#define SCNuFAST64 __UINT_FAST64_FMTu__
+#define SCNxFAST64 __UINT_FAST64_FMTx__
+#define SCNoFAST8 __UINT_FAST8_FMTo__
+#define SCNuFAST8 __UINT_FAST8_FMTu__
+#define SCNxFAST8 __UINT_FAST8_FMTx__
+#define SCNoLEAST16 __UINT_LEAST16_FMTo__
+#define SCNuLEAST16 __UINT_LEAST16_FMTu__
+#define SCNxLEAST16 __UINT_LEAST16_FMTx__
+#define SCNoLEAST32 __UINT_LEAST32_FMTo__
+#define SCNuLEAST32 __UINT_LEAST32_FMTu__
+#define SCNxLEAST32 __UINT_LEAST32_FMTx__
+#define SCNoLEAST64 __UINT_LEAST64_FMTo__
+#define SCNuLEAST64 __UINT_LEAST64_FMTu__
+#define SCNxLEAST64 __UINT_LEAST64_FMTx__
+#define SCNoLEAST8 __UINT_LEAST8_FMTo__
+#define SCNuLEAST8 __UINT_LEAST8_FMTu__
+#define SCNxLEAST8 __UINT_LEAST8_FMTx__
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_netinet_in.h b/libc-bottom-half/headers/public/__header_netinet_in.h
new file mode 100644
index 0000000..30359c8
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_netinet_in.h
@@ -0,0 +1,30 @@
+#ifndef __wasilibc___header_netinet_in_h
+#define __wasilibc___header_netinet_in_h
+
+#include <__struct_in_addr.h>
+#include <__struct_in6_addr.h>
+#include <__struct_sockaddr_in.h>
+#include <__struct_sockaddr_in6.h>
+
+#define IPPROTO_IP 0
+#define IPPROTO_ICMP 1
+#define IPPROTO_TCP 6
+#define IPPROTO_UDP 17
+#define IPPROTO_IPV6 41
+#define IPPROTO_RAW 255
+
+#define IN6ADDR_ANY_INIT { { \
+ 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00 \
+} }
+
+#define IN6ADDR_LOOPBACK_INIT { { \
+ 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x00, \
+ 0x00, 0x00, 0x00, 0x01 \
+} }
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_poll.h b/libc-bottom-half/headers/public/__header_poll.h
new file mode 100644
index 0000000..23b36f2
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_poll.h
@@ -0,0 +1,27 @@
+#ifndef __wasilibc___header_poll_h
+#define __wasilibc___header_poll_h
+
+#include <__struct_pollfd.h>
+#include <__typedef_nfds_t.h>
+
+#define POLLRDNORM 0x1
+#define POLLWRNORM 0x2
+
+#define POLLIN POLLRDNORM
+#define POLLOUT POLLWRNORM
+
+#define POLLERR 0x1000
+#define POLLHUP 0x2000
+#define POLLNVAL 0x4000
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int poll(struct pollfd[], nfds_t, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_stdlib.h b/libc-bottom-half/headers/public/__header_stdlib.h
new file mode 100644
index 0000000..a6c49a5
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_stdlib.h
@@ -0,0 +1,21 @@
+#ifndef __wasilibc___header_stdlib_h
+#define __wasilibc___header_stdlib_h
+
+#define __need_size_t
+#include <stddef.h>
+
+#include <__functions_malloc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void abort(void) __attribute__((__noreturn__));
+void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
+void _Exit(int) __attribute__((__noreturn__));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_string.h b/libc-bottom-half/headers/public/__header_string.h
new file mode 100644
index 0000000..eb98a8a
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_string.h
@@ -0,0 +1,23 @@
+#ifndef __wasilibc___header_string_h
+#define __wasilibc___header_string_h
+
+#define __need_size_t
+#define __need_NULL
+#include <stddef.h>
+
+#include <__functions_memcpy.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+size_t strlen(const char *) __attribute__((__nothrow__, __leaf__, __pure__, __nonnull__(1)));
+char *strdup(const char *) __attribute__((__nothrow__, __nonnull__(1)));
+int strcmp(const char *, const char *) __attribute__((__nothrow__, __pure__, __nonnull__(1, 2)));
+void *memchr(const void *, int, size_t) __attribute__((__nothrow__, __pure__, __nonnull__(1)));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_sys_ioctl.h b/libc-bottom-half/headers/public/__header_sys_ioctl.h
new file mode 100644
index 0000000..f2cf4ee
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_sys_ioctl.h
@@ -0,0 +1,17 @@
+#ifndef __wasilibc___header_sys_ioctl_h
+#define __wasilibc___header_sys_ioctl_h
+
+#define FIONREAD 1
+#define FIONBIO 2
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int ioctl(int, int, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_sys_resource.h b/libc-bottom-half/headers/public/__header_sys_resource.h
new file mode 100644
index 0000000..bae9d5a
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_sys_resource.h
@@ -0,0 +1,19 @@
+#ifndef __wasilibc___header_sys_resource_h
+#define __wasilibc___header_sys_resource_h
+
+#include <__struct_rusage.h>
+
+#define RUSAGE_SELF 1
+#define RUSAGE_CHILDREN 2
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int getrusage(int who, struct rusage *usage);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_sys_socket.h b/libc-bottom-half/headers/public/__header_sys_socket.h
new file mode 100644
index 0000000..9fa8684
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_sys_socket.h
@@ -0,0 +1,41 @@
+#ifndef __wasilibc___header_sys_socket_h
+#define __wasilibc___header_sys_socket_h
+
+#include <__struct_msghdr.h>
+#include <__struct_sockaddr.h>
+#include <__struct_sockaddr_storage.h>
+
+#include <wasi/api.h>
+
+#define SHUT_RD __WASI_SDFLAGS_RD
+#define SHUT_WR __WASI_SDFLAGS_WR
+#define SHUT_RDWR (SHUT_RD | SHUT_WR)
+
+#define MSG_PEEK __WASI_RIFLAGS_RECV_PEEK
+#define MSG_WAITALL __WASI_RIFLAGS_RECV_WAITALL
+#define MSG_TRUNC __WASI_RIFLAGS_RECV_DATA_TRUNCATED
+
+#define SOCK_DGRAM __WASI_FILETYPE_SOCKET_DGRAM
+#define SOCK_STREAM __WASI_FILETYPE_SOCKET_STREAM
+
+#define SOCK_NONBLOCK (0x00004000)
+#define SOCK_CLOEXEC (0x00002000)
+
+#define SOL_SOCKET 0x7fffffff
+
+#define SO_TYPE 3
+
+#define AF_UNSPEC 0
+#define AF_INET 1
+#define AF_INET6 2
+#define AF_UNIX 3
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_sys_stat.h b/libc-bottom-half/headers/public/__header_sys_stat.h
new file mode 100644
index 0000000..f965cf3
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_sys_stat.h
@@ -0,0 +1,15 @@
+#ifndef __wasilibc___header_sys_stat_h
+#define __wasilibc___header_sys_stat_h
+
+#include <__struct_stat.h>
+
+#define st_atime st_atim.tv_sec
+#define st_mtime st_mtim.tv_sec
+#define st_ctime st_ctim.tv_sec
+
+#include <__mode_t.h>
+
+#define UTIME_NOW (-1)
+#define UTIME_OMIT (-2)
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_time.h b/libc-bottom-half/headers/public/__header_time.h
new file mode 100644
index 0000000..2a2ff91
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_time.h
@@ -0,0 +1,33 @@
+#ifndef __wasilibc___header_time_h
+#define __wasilibc___header_time_h
+
+#define __need_size_t
+#define __need_NULL
+#include <stddef.h>
+
+#include <__typedef_time_t.h>
+#include <__struct_timespec.h>
+#include <__struct_tm.h>
+#include <__typedef_clockid_t.h>
+
+#include <wasi/api.h>
+
+#define TIMER_ABSTIME __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME
+
+extern const struct __clockid _CLOCK_MONOTONIC;
+#define CLOCK_MONOTONIC (&_CLOCK_MONOTONIC)
+extern const struct __clockid _CLOCK_REALTIME;
+#define CLOCK_REALTIME (&_CLOCK_REALTIME)
+
+/*
+ * TIME_UTC is the only standardized time base value.
+ */
+#define TIME_UTC 1
+
+/*
+ * Note that XSI specifies CLOCKS_PER_SEC to be 1000000, rather than
+ * 1000000000; the clock API is providing more precision than XSI specifies.
+ */
+#define CLOCKS_PER_SEC ((clock_t)1000000000)
+
+#endif
diff --git a/libc-bottom-half/headers/public/__header_unistd.h b/libc-bottom-half/headers/public/__header_unistd.h
new file mode 100644
index 0000000..6b80d63
--- /dev/null
+++ b/libc-bottom-half/headers/public/__header_unistd.h
@@ -0,0 +1,28 @@
+#ifndef __wasilibc___header_unistd_h
+#define __wasilibc___header_unistd_h
+
+struct stat;
+
+#include <__seek.h>
+
+#define F_OK (0)
+#define X_OK (1)
+#define W_OK (2)
+#define R_OK (4)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int close(int fd);
+int faccessat(int, const char *, int, int);
+int fstatat(int, const char *__restrict, struct stat *__restrict, int);
+int renameat(int, const char *, int, const char *);
+int openat(int, const char *, int, ...);
+void *sbrk(intptr_t increment);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/__macro_FD_SETSIZE.h b/libc-bottom-half/headers/public/__macro_FD_SETSIZE.h
new file mode 100644
index 0000000..bb88e45
--- /dev/null
+++ b/libc-bottom-half/headers/public/__macro_FD_SETSIZE.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___macro_FD_SETSIZE_h
+#define __wasilibc___macro_FD_SETSIZE_h
+
+#define FD_SETSIZE 1024
+
+#endif
diff --git a/libc-bottom-half/headers/public/__macro_PAGESIZE.h b/libc-bottom-half/headers/public/__macro_PAGESIZE.h
new file mode 100644
index 0000000..d892220
--- /dev/null
+++ b/libc-bottom-half/headers/public/__macro_PAGESIZE.h
@@ -0,0 +1,16 @@
+#ifndef __wasilibc___macro_PAGESIZE_h
+#define __wasilibc___macro_PAGESIZE_h
+
+/*
+ * The page size in WebAssembly is fixed at 64 KiB. If this ever changes,
+ * it's expected that applications will need to opt in, so we can change
+ * this.
+ *
+ * If this ever needs to be a value outside the range of an `int`, the
+ * `getpagesize` function which returns this value will need special
+ * consideration. POSIX has deprecated `getpagesize` in favor of
+ * `sysconf(_SC_PAGESIZE)` which does not have this problem.
+ */
+#define PAGESIZE (0x10000)
+
+#endif
diff --git a/libc-bottom-half/headers/public/__mode_t.h b/libc-bottom-half/headers/public/__mode_t.h
new file mode 100644
index 0000000..c0beef5
--- /dev/null
+++ b/libc-bottom-half/headers/public/__mode_t.h
@@ -0,0 +1,38 @@
+#ifndef __wasilibc___mode_t_h
+#define __wasilibc___mode_t_h
+
+#define S_IFMT \
+ (S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK)
+#define S_IFBLK (0x6000)
+#define S_IFCHR (0x2000)
+#define S_IFDIR (0x4000)
+#define S_IFLNK (0xa000)
+#define S_IFREG (0x8000)
+#define S_IFSOCK (0xc000)
+#define S_IFIFO (0xc000)
+
+#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK)
+#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR)
+#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
+#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO)
+#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK)
+#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
+#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK)
+
+#define S_IXOTH (0x1)
+#define S_IWOTH (0x2)
+#define S_IROTH (0x4)
+#define S_IRWXO (S_IXOTH | S_IWOTH | S_IROTH)
+#define S_IXGRP (0x8)
+#define S_IWGRP (0x10)
+#define S_IRGRP (0x20)
+#define S_IRWXG (S_IXGRP | S_IWGRP | S_IRGRP)
+#define S_IXUSR (0x40)
+#define S_IWUSR (0x80)
+#define S_IRUSR (0x100)
+#define S_IRWXU (S_IXUSR | S_IWUSR | S_IRUSR)
+#define S_ISVTX (0x200)
+#define S_ISGID (0x400)
+#define S_ISUID (0x800)
+
+#endif
diff --git a/libc-bottom-half/headers/public/__seek.h b/libc-bottom-half/headers/public/__seek.h
new file mode 100644
index 0000000..8824adb
--- /dev/null
+++ b/libc-bottom-half/headers/public/__seek.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc___seek_h
+#define __wasilibc___seek_h
+
+#include <wasi/api.h>
+
+#define SEEK_CUR __WASI_WHENCE_CUR
+#define SEEK_END __WASI_WHENCE_END
+#define SEEK_SET __WASI_WHENCE_SET
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_dirent.h b/libc-bottom-half/headers/public/__struct_dirent.h
new file mode 100644
index 0000000..9d2ece8
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_dirent.h
@@ -0,0 +1,14 @@
+#ifndef __wasilibc___struct_dirent_h
+#define __wasilibc___struct_dirent_h
+
+#include <__typedef_ino_t.h>
+
+#define _DIRENT_HAVE_D_TYPE
+
+struct dirent {
+ ino_t d_ino;
+ unsigned char d_type;
+ char d_name[];
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_in6_addr.h b/libc-bottom-half/headers/public/__struct_in6_addr.h
new file mode 100644
index 0000000..cf2fafe
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_in6_addr.h
@@ -0,0 +1,8 @@
+#ifndef __wasilibc___struct_in6_addr_h
+#define __wasilibc___struct_in6_addr_h
+
+struct in6_addr {
+ _Alignas(int32_t) unsigned char s6_addr[16];
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_in_addr.h b/libc-bottom-half/headers/public/__struct_in_addr.h
new file mode 100644
index 0000000..881ffa6
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_in_addr.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc___struct_in_addr_h
+#define __wasilibc___struct_in_addr_h
+
+#include <__typedef_in_addr_t.h>
+
+struct in_addr {
+ in_addr_t s_addr;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_iovec.h b/libc-bottom-half/headers/public/__struct_iovec.h
new file mode 100644
index 0000000..da3e1c7
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_iovec.h
@@ -0,0 +1,12 @@
+#ifndef __wasilibc___struct_iovec_h
+#define __wasilibc___struct_iovec_h
+
+#define __need_size_t
+#include <stddef.h>
+
+struct iovec {
+ void *iov_base;
+ size_t iov_len;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_msghdr.h b/libc-bottom-half/headers/public/__struct_msghdr.h
new file mode 100644
index 0000000..0c0877d
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_msghdr.h
@@ -0,0 +1,16 @@
+#ifndef __wasilibc___struct_msghdr_h
+#define __wasilibc___struct_msghdr_h
+
+#include <__typedef_socklen_t.h>
+
+struct msghdr {
+ void *msg_name;
+ socklen_t msg_namelen;
+ struct iovec *msg_iov;
+ int msg_iovlen;
+ void *msg_control;
+ socklen_t msg_controllen;
+ int msg_flags;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_pollfd.h b/libc-bottom-half/headers/public/__struct_pollfd.h
new file mode 100644
index 0000000..45874c5
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_pollfd.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc___struct_pollfd_h
+#define __wasilibc___struct_pollfd_h
+
+struct pollfd {
+ int fd;
+ short events;
+ short revents;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_rusage.h b/libc-bottom-half/headers/public/__struct_rusage.h
new file mode 100644
index 0000000..69fe2fe
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_rusage.h
@@ -0,0 +1,12 @@
+#ifndef __wasilibc___struct_rusage_h
+#define __wasilibc___struct_rusage_h
+
+#include <__struct_timeval.h>
+
+/* TODO: Add more features here. */
+struct rusage {
+ struct timeval ru_utime;
+ struct timeval ru_stime;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_sockaddr.h b/libc-bottom-half/headers/public/__struct_sockaddr.h
new file mode 100644
index 0000000..9891b90
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_sockaddr.h
@@ -0,0 +1,14 @@
+#ifndef __wasilibc___struct_sockaddr_h
+#define __wasilibc___struct_sockaddr_h
+
+#define __need_STDDEF_H_misc
+#include <stddef.h>
+
+#include <__typedef_sa_family_t.h>
+
+struct sockaddr {
+ __attribute__((aligned(__BIGGEST_ALIGNMENT__))) sa_family_t sa_family;
+ char sa_data[0];
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_sockaddr_in.h b/libc-bottom-half/headers/public/__struct_sockaddr_in.h
new file mode 100644
index 0000000..73dc5c6
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_sockaddr_in.h
@@ -0,0 +1,17 @@
+#ifndef __wasilibc___struct_sockaddr_in_h
+#define __wasilibc___struct_sockaddr_in_h
+
+#define __need_STDDEF_H_misc
+#include <stddef.h>
+
+#include <__typedef_sa_family_t.h>
+#include <__typedef_in_port_t.h>
+#include <__struct_in_addr.h>
+
+struct sockaddr_in {
+ _Alignas(max_align_t) sa_family_t sin_family;
+ in_port_t sin_port;
+ struct in_addr sin_addr;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_sockaddr_in6.h b/libc-bottom-half/headers/public/__struct_sockaddr_in6.h
new file mode 100644
index 0000000..a220f91
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_sockaddr_in6.h
@@ -0,0 +1,19 @@
+#ifndef __wasilibc___struct_sockaddr_in6_h
+#define __wasilibc___struct_sockaddr_in6_h
+
+#define __need_STDDEF_H_misc
+#include <stddef.h>
+
+#include <__typedef_sa_family_t.h>
+#include <__typedef_in_port_t.h>
+#include <__struct_in6_addr.h>
+
+struct sockaddr_in6 {
+ _Alignas(max_align_t) sa_family_t sin6_family;
+ in_port_t sin6_port;
+ unsigned sin6_flowinfo;
+ struct in6_addr sin6_addr;
+ unsigned sin6_scope_id;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_sockaddr_storage.h b/libc-bottom-half/headers/public/__struct_sockaddr_storage.h
new file mode 100644
index 0000000..1ae26a7
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_sockaddr_storage.h
@@ -0,0 +1,14 @@
+#ifndef __wasilibc___struct_sockaddr_storage_h
+#define __wasilibc___struct_sockaddr_storage_h
+
+#define __need_STDDEF_H_misc
+#include <stddef.h>
+
+#include <__typedef_sa_family_t.h>
+
+struct sockaddr_storage {
+ _Alignas(max_align_t) sa_family_t ss_family;
+ char __ss_data[32];
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_sockaddr_un.h b/libc-bottom-half/headers/public/__struct_sockaddr_un.h
new file mode 100644
index 0000000..a5be6e5
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_sockaddr_un.h
@@ -0,0 +1,13 @@
+#ifndef __wasilibc___struct_sockaddr_un_h
+#define __wasilibc___struct_sockaddr_un_h
+
+#define __need_STDDEF_H_misc
+#include <stddef.h>
+
+#include <__typedef_sa_family_t.h>
+
+struct sockaddr_un {
+ _Alignas(max_align_t) sa_family_t sun_family;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_stat.h b/libc-bottom-half/headers/public/__struct_stat.h
new file mode 100644
index 0000000..5e345da
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_stat.h
@@ -0,0 +1,35 @@
+#ifndef __wasilibc___struct_stat_h
+#define __wasilibc___struct_stat_h
+
+#include <__typedef_dev_t.h>
+#include <__typedef_ino_t.h>
+#include <__typedef_nlink_t.h>
+#include <__typedef_mode_t.h>
+#include <__typedef_uid_t.h>
+#include <__typedef_gid_t.h>
+#include <__typedef_off_t.h>
+#include <__typedef_blksize_t.h>
+#include <__typedef_blkcnt_t.h>
+#include <__struct_timespec.h>
+
+struct stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ nlink_t st_nlink;
+
+ mode_t st_mode;
+ uid_t st_uid;
+ gid_t st_gid;
+ unsigned int __pad0;
+ dev_t st_rdev;
+ off_t st_size;
+ blksize_t st_blksize;
+ blkcnt_t st_blocks;
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ long long __reserved[3];
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_timespec.h b/libc-bottom-half/headers/public/__struct_timespec.h
new file mode 100644
index 0000000..10d83f9
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_timespec.h
@@ -0,0 +1,12 @@
+#ifndef __wasilibc___struct_timespec_h
+#define __wasilibc___struct_timespec_h
+
+#include <__typedef_time_t.h>
+
+/* As specified in POSIX. */
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_timeval.h b/libc-bottom-half/headers/public/__struct_timeval.h
new file mode 100644
index 0000000..b09f1a9
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_timeval.h
@@ -0,0 +1,13 @@
+#ifndef __wasilibc___struct_timeval_h
+#define __wasilibc___struct_timeval_h
+
+#include <__typedef_time_t.h>
+#include <__typedef_suseconds_t.h>
+
+/* As specified in POSIX. */
+struct timeval {
+ time_t tv_sec;
+ suseconds_t tv_usec;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_tm.h b/libc-bottom-half/headers/public/__struct_tm.h
new file mode 100644
index 0000000..3c83dc5
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_tm.h
@@ -0,0 +1,19 @@
+#ifndef __wasilibc___struct_tm_h
+#define __wasilibc___struct_tm_h
+
+struct tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ int __tm_gmtoff;
+ const char *__tm_zone;
+ int __tm_nsec;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__struct_tms.h b/libc-bottom-half/headers/public/__struct_tms.h
new file mode 100644
index 0000000..9914097
--- /dev/null
+++ b/libc-bottom-half/headers/public/__struct_tms.h
@@ -0,0 +1,13 @@
+#ifndef __wasilibc___struct_tms_h
+#define __wasilibc___struct_tms_h
+
+#include <__typedef_clock_t.h>
+
+struct tms {
+ clock_t tms_utime;
+ clock_t tms_stime;
+ clock_t tms_cutime;
+ clock_t tms_cstime;
+};
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_DIR.h b/libc-bottom-half/headers/public/__typedef_DIR.h
new file mode 100644
index 0000000..f07cfc1
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_DIR.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___typedef_DIR_h
+#define __wasilibc___typedef_DIR_h
+
+typedef struct _DIR DIR;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_blkcnt_t.h b/libc-bottom-half/headers/public/__typedef_blkcnt_t.h
new file mode 100644
index 0000000..e8d7b3d
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_blkcnt_t.h
@@ -0,0 +1,7 @@
+#ifndef __wasilibc___typedef_blkcnt_t_h
+#define __wasilibc___typedef_blkcnt_t_h
+
+/* Define these as 64-bit signed integers to support files larger than 2 GiB. */
+typedef long long blkcnt_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_blksize_t.h b/libc-bottom-half/headers/public/__typedef_blksize_t.h
new file mode 100644
index 0000000..8816e0a
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_blksize_t.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___typedef_blksize_t_h
+#define __wasilibc___typedef_blksize_t_h
+
+typedef long blksize_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_clock_t.h b/libc-bottom-half/headers/public/__typedef_clock_t.h
new file mode 100644
index 0000000..68cb588
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_clock_t.h
@@ -0,0 +1,7 @@
+#ifndef __wasilibc___typedef_clock_t_h
+#define __wasilibc___typedef_clock_t_h
+
+/* Define this as a 64-bit signed integer to avoid wraparounds. */
+typedef long long clock_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_clockid_t.h b/libc-bottom-half/headers/public/__typedef_clockid_t.h
new file mode 100644
index 0000000..6de4244
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_clockid_t.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___typedef_clockid_t_h
+#define __wasilibc___typedef_clockid_t_h
+
+typedef const struct __clockid *clockid_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_dev_t.h b/libc-bottom-half/headers/public/__typedef_dev_t.h
new file mode 100644
index 0000000..353e94f
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_dev_t.h
@@ -0,0 +1,7 @@
+#ifndef __wasilibc___typedef_dev_t_h
+#define __wasilibc___typedef_dev_t_h
+
+/* Define these as 64-bit integers to support billions of devices. */
+typedef unsigned long long dev_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_fd_set.h b/libc-bottom-half/headers/public/__typedef_fd_set.h
new file mode 100644
index 0000000..35ea958
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_fd_set.h
@@ -0,0 +1,14 @@
+#ifndef __wasilibc___typedef_fd_set_h
+#define __wasilibc___typedef_fd_set_h
+
+#define __need_size_t
+#include <stddef.h>
+
+#include <__macro_FD_SETSIZE.h>
+
+typedef struct {
+ size_t __nfds;
+ int __fds[FD_SETSIZE];
+} fd_set;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_gid_t.h b/libc-bottom-half/headers/public/__typedef_gid_t.h
new file mode 100644
index 0000000..6eb82f2
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_gid_t.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___typedef_gid_t_h
+#define __wasilibc___typedef_gid_t_h
+
+typedef unsigned gid_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_in_addr_t.h b/libc-bottom-half/headers/public/__typedef_in_addr_t.h
new file mode 100644
index 0000000..68ab512
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_in_addr_t.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___typedef_in_addr_t_h
+#define __wasilibc___typedef_in_addr_t_h
+
+typedef unsigned in_addr_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_in_port_t.h b/libc-bottom-half/headers/public/__typedef_in_port_t.h
new file mode 100644
index 0000000..890a2c8
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_in_port_t.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___typedef_in_port_t_h
+#define __wasilibc___typedef_in_port_t_h
+
+typedef unsigned short in_port_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_ino_t.h b/libc-bottom-half/headers/public/__typedef_ino_t.h
new file mode 100644
index 0000000..f3e11e4
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_ino_t.h
@@ -0,0 +1,7 @@
+#ifndef __wasilibc___typedef_ino_t_h
+#define __wasilibc___typedef_ino_t_h
+
+/* Define these as 64-bit integers to support billions of inodes. */
+typedef unsigned long long ino_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_mode_t.h b/libc-bottom-half/headers/public/__typedef_mode_t.h
new file mode 100644
index 0000000..51b927d
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_mode_t.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___typedef_mode_t_h
+#define __wasilibc___typedef_mode_t_h
+
+typedef unsigned mode_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_nfds_t.h b/libc-bottom-half/headers/public/__typedef_nfds_t.h
new file mode 100644
index 0000000..ea0a93e
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_nfds_t.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___typedef_nfds_t_h
+#define __wasilibc___typedef_nfds_t_h
+
+typedef unsigned long nfds_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_nlink_t.h b/libc-bottom-half/headers/public/__typedef_nlink_t.h
new file mode 100644
index 0000000..ae34c79
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_nlink_t.h
@@ -0,0 +1,7 @@
+#ifndef __wasilibc___typedef_nlink_t_h
+#define __wasilibc___typedef_nlink_t_h
+
+/* Define these as 64-bit unsigned integers to support billions of links. */
+typedef unsigned long long nlink_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_off_t.h b/libc-bottom-half/headers/public/__typedef_off_t.h
new file mode 100644
index 0000000..115ffdd
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_off_t.h
@@ -0,0 +1,7 @@
+#ifndef __wasilibc___typedef_off_t_h
+#define __wasilibc___typedef_off_t_h
+
+/* Define these as 64-bit signed integers to support files larger than 2 GiB. */
+typedef long long off_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_sa_family_t.h b/libc-bottom-half/headers/public/__typedef_sa_family_t.h
new file mode 100644
index 0000000..0ad18c9
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_sa_family_t.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___typedef_sa_family_t_h
+#define __wasilibc___typedef_sa_family_t_h
+
+typedef unsigned short sa_family_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_sigset_t.h b/libc-bottom-half/headers/public/__typedef_sigset_t.h
new file mode 100644
index 0000000..f7e4867
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_sigset_t.h
@@ -0,0 +1,7 @@
+#ifndef __wasilibc___typedef_sigset_t_h
+#define __wasilibc___typedef_sigset_t_h
+
+/* TODO: This is just a placeholder for now. Keep this in sync with musl. */
+typedef unsigned char sigset_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_socklen_t.h b/libc-bottom-half/headers/public/__typedef_socklen_t.h
new file mode 100644
index 0000000..bd68e55
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_socklen_t.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___typedef_socklen_t_h
+#define __wasilibc___typedef_socklen_t_h
+
+typedef unsigned socklen_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_ssize_t.h b/libc-bottom-half/headers/public/__typedef_ssize_t.h
new file mode 100644
index 0000000..25dc15a
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_ssize_t.h
@@ -0,0 +1,7 @@
+#ifndef __wasilibc___typedef_ssize_t_h
+#define __wasilibc___typedef_ssize_t_h
+
+/* This is defined to be the same size as size_t. */
+typedef long ssize_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_suseconds_t.h b/libc-bottom-half/headers/public/__typedef_suseconds_t.h
new file mode 100644
index 0000000..92667e2
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_suseconds_t.h
@@ -0,0 +1,8 @@
+#ifndef __wasilibc___typedef_suseconds_t_h
+#define __wasilibc___typedef_suseconds_t_h
+
+/* Define this to be 64-bit as its main use is in struct timeval where the
+ extra space would otherwise be padding. */
+typedef long long suseconds_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_time_t.h b/libc-bottom-half/headers/public/__typedef_time_t.h
new file mode 100644
index 0000000..6ee0f86
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_time_t.h
@@ -0,0 +1,7 @@
+#ifndef __wasilibc___typedef_time_t_h
+#define __wasilibc___typedef_time_t_h
+
+/* Define this as a 64-bit signed integer to avoid the 2038 bug. */
+typedef long long time_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/__typedef_uid_t.h b/libc-bottom-half/headers/public/__typedef_uid_t.h
new file mode 100644
index 0000000..c9da300
--- /dev/null
+++ b/libc-bottom-half/headers/public/__typedef_uid_t.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc___typedef_uid_t_h
+#define __wasilibc___typedef_uid_t_h
+
+typedef unsigned uid_t;
+
+#endif
diff --git a/libc-bottom-half/headers/public/dirent.h b/libc-bottom-half/headers/public/dirent.h
new file mode 100644
index 0000000..ce1364a
--- /dev/null
+++ b/libc-bottom-half/headers/public/dirent.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc_dirent_h
+#define __wasilibc_dirent_h
+
+/*
+ * Include the real implementation, which is factored into a separate file so
+ * that it can be reused by other libc dirent implementations.
+ */
+#include <__header_dirent.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/errno.h b/libc-bottom-half/headers/public/errno.h
new file mode 100644
index 0000000..f3914ee
--- /dev/null
+++ b/libc-bottom-half/headers/public/errno.h
@@ -0,0 +1,7 @@
+#ifndef __wasilibc_errno_h
+#define __wasilibc_errno_h
+
+#include <__errno.h>
+#include <__errno_values.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/fcntl.h b/libc-bottom-half/headers/public/fcntl.h
new file mode 100644
index 0000000..0ca3e86
--- /dev/null
+++ b/libc-bottom-half/headers/public/fcntl.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc_fcntl_h
+#define __wasilibc_fcntl_h
+
+/*
+ * Include the real implementation, which is factored into a separate file so
+ * that it can be reused by other libc fcntl implementations.
+ */
+#include <__header_fcntl.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/inttypes.h b/libc-bottom-half/headers/public/inttypes.h
new file mode 100644
index 0000000..a237857
--- /dev/null
+++ b/libc-bottom-half/headers/public/inttypes.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc_inttypes_h
+#define __wasilibc_inttypes_h
+
+/*
+ * Include the real implementation, which is factored into a separate file so
+ * that it can be reused by other libc stdlib implementations.
+ */
+#include <__header_inttypes.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/netinet/in.h b/libc-bottom-half/headers/public/netinet/in.h
new file mode 100644
index 0000000..b27bffe
--- /dev/null
+++ b/libc-bottom-half/headers/public/netinet/in.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc_netinet_in_h
+#define __wasilibc_netinet_in_h
+
+#include <__header_netinet_in.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/poll.h b/libc-bottom-half/headers/public/poll.h
new file mode 100644
index 0000000..22f4b6c
--- /dev/null
+++ b/libc-bottom-half/headers/public/poll.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc_poll_h
+#define __wasilibc_poll_h
+
+/*
+ * Include the real implementation, which is factored into a separate file so
+ * that it can be reused by other libc poll implementations.
+ */
+#include <__header_poll.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/stdlib.h b/libc-bottom-half/headers/public/stdlib.h
new file mode 100644
index 0000000..8425cb8
--- /dev/null
+++ b/libc-bottom-half/headers/public/stdlib.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc_stdlib_h
+#define __wasilibc_stdlib_h
+
+/*
+ * Include the real implementation, which is factored into a separate file so
+ * that it can be reused by other libc stdlib implementations.
+ */
+#include <__functions_malloc.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/string.h b/libc-bottom-half/headers/public/string.h
new file mode 100644
index 0000000..fee51ef
--- /dev/null
+++ b/libc-bottom-half/headers/public/string.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc_string_h
+#define __wasilibc_string_h
+
+/*
+ * Include the real implementation, which is factored into a separate file so
+ * that it can be reused by other libc string implementations.
+ */
+#include <__header_string.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/sys/ioctl.h b/libc-bottom-half/headers/public/sys/ioctl.h
new file mode 100644
index 0000000..085b314
--- /dev/null
+++ b/libc-bottom-half/headers/public/sys/ioctl.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc_sys_ioctl_h
+#define __wasilibc_sys_ioctl_h
+
+/*
+ * Include the real implementation, which is factored into a separate file so
+ * that it can be reused by other libc ioctl implementations.
+ */
+#include <__header_sys_ioctl.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/sys/resource.h b/libc-bottom-half/headers/public/sys/resource.h
new file mode 100644
index 0000000..5896861
--- /dev/null
+++ b/libc-bottom-half/headers/public/sys/resource.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc_sys_resource_h
+#define __wasilibc_sys_resource_h
+
+/*
+ * Include the real implementation, which is factored into a separate file so
+ * that it can be reused by other libc resource implementations.
+ */
+#include <__header_sys_resource.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/sys/select.h b/libc-bottom-half/headers/public/sys/select.h
new file mode 100644
index 0000000..7570f14
--- /dev/null
+++ b/libc-bottom-half/headers/public/sys/select.h
@@ -0,0 +1,18 @@
+#ifndef __wasilibc_sys_select_h
+#define __wasilibc_sys_select_h
+
+#include <__fd_set.h>
+#include <__struct_timespec.h>
+#include <__struct_timeval.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/sys/socket.h b/libc-bottom-half/headers/public/sys/socket.h
new file mode 100644
index 0000000..874f605
--- /dev/null
+++ b/libc-bottom-half/headers/public/sys/socket.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc_sys_socket_h
+#define __wasilibc_sys_socket_h
+
+#include <__header_sys_socket.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/sys/stat.h b/libc-bottom-half/headers/public/sys/stat.h
new file mode 100644
index 0000000..586b41f
--- /dev/null
+++ b/libc-bottom-half/headers/public/sys/stat.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc_sys_stat_h
+#define __wasilibc_sys_stat_h
+
+/*
+ * Include the real implementation, which is factored into a separate file so
+ * that it can be reused by other libc stat implementations.
+ */
+#include <__header_sys_stat.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/sys/time.h b/libc-bottom-half/headers/public/sys/time.h
new file mode 100644
index 0000000..3ee0b3b
--- /dev/null
+++ b/libc-bottom-half/headers/public/sys/time.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc_sys_time_h
+#define __wasilibc_sys_time_h
+
+#include <__struct_timeval.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/sys/times.h b/libc-bottom-half/headers/public/sys/times.h
new file mode 100644
index 0000000..986bc0d
--- /dev/null
+++ b/libc-bottom-half/headers/public/sys/times.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc_sys_times_h
+#define __wasilibc_sys_times_h
+
+#include <__struct_tms.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/sys/types.h b/libc-bottom-half/headers/public/sys/types.h
new file mode 100644
index 0000000..3bce96f
--- /dev/null
+++ b/libc-bottom-half/headers/public/sys/types.h
@@ -0,0 +1,16 @@
+#ifndef __wasilibc_sys_types_h
+#define __wasilibc_sys_types_h
+
+#define __need_size_t
+#include <stddef.h>
+
+#include <__typedef_clock_t.h>
+#include <__typedef_time_t.h>
+#include <__typedef_blksize_t.h>
+#include <__typedef_off_t.h>
+#include <__typedef_ssize_t.h>
+#include <__typedef_suseconds_t.h>
+#include <__typedef_nlink_t.h>
+#include <__typedef_clockid_t.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/sys/uio.h b/libc-bottom-half/headers/public/sys/uio.h
new file mode 100644
index 0000000..bb502a1
--- /dev/null
+++ b/libc-bottom-half/headers/public/sys/uio.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc_sys_uio_h
+#define __wasilibc_sys_uio_h
+
+#include <__struct_iovec.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/sys/un.h b/libc-bottom-half/headers/public/sys/un.h
new file mode 100644
index 0000000..997e613
--- /dev/null
+++ b/libc-bottom-half/headers/public/sys/un.h
@@ -0,0 +1,6 @@
+#ifndef __wasilibc_sys_un_h
+#define __wasilibc_sys_un_h
+
+#include <__struct_sockaddr_un.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/time.h b/libc-bottom-half/headers/public/time.h
new file mode 100644
index 0000000..646e599
--- /dev/null
+++ b/libc-bottom-half/headers/public/time.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc_time_h
+#define __wasilibc_time_h
+
+/*
+ * Include the real implementation, which is factored into a separate file so
+ * that it can be reused by other libc time implementations.
+ */
+#include <__header_time.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/unistd.h b/libc-bottom-half/headers/public/unistd.h
new file mode 100644
index 0000000..5f8edfa
--- /dev/null
+++ b/libc-bottom-half/headers/public/unistd.h
@@ -0,0 +1,10 @@
+#ifndef __wasilibc_unistd_h
+#define __wasilibc_unistd_h
+
+/*
+ * Include the real implementation, which is factored into a separate file so
+ * that it can be reused by other libc unistd implementations.
+ */
+#include <__header_unistd.h>
+
+#endif
diff --git a/libc-bottom-half/headers/public/wasi/api.h b/libc-bottom-half/headers/public/wasi/api.h
new file mode 100644
index 0000000..1ab7699
--- /dev/null
+++ b/libc-bottom-half/headers/public/wasi/api.h
@@ -0,0 +1,2115 @@
+/**
+ * <wasi/api.h>. This file contains declarations describing the WASI ABI
+ * as of "snapshot preview1". It was originally auto-generated from
+ * wasi_snapshot_preview1.witx, however WASI is in the process of
+ * transitioning to a new IDL and header file generator, and this file
+ * is temporarily being manually maintained.
+ *
+ * @file
+ * This file describes the [WASI] interface, consisting of functions, types,
+ * and defined values (macros).
+ *
+ * The interface described here is greatly inspired by [CloudABI]'s clean,
+ * thoughtfully-designed, capability-oriented, POSIX-style API.
+ *
+ * [CloudABI]: https://github.com/NuxiNL/cloudlibc
+ * [WASI]: https://github.com/WebAssembly/WASI/
+ */
+
+#ifndef __wasi_api_h
+#define __wasi_api_h
+
+#ifndef __wasi__
+#error <wasi/api.h> is only supported on WASI platforms.
+#endif
+
+#ifndef __wasm32__
+#error <wasi/api.h> only supports wasm32; doesn't yet support wasm64
+#endif
+
+#include <stddef.h>
+#include <stdint.h>
+
+_Static_assert(_Alignof(int8_t) == 1, "non-wasi data layout");
+_Static_assert(_Alignof(uint8_t) == 1, "non-wasi data layout");
+_Static_assert(_Alignof(int16_t) == 2, "non-wasi data layout");
+_Static_assert(_Alignof(uint16_t) == 2, "non-wasi data layout");
+_Static_assert(_Alignof(int32_t) == 4, "non-wasi data layout");
+_Static_assert(_Alignof(uint32_t) == 4, "non-wasi data layout");
+_Static_assert(_Alignof(int64_t) == 8, "non-wasi data layout");
+_Static_assert(_Alignof(uint64_t) == 8, "non-wasi data layout");
+_Static_assert(_Alignof(void*) == 4, "non-wasi data layout");
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// TODO: Encoding this in witx.
+#define __WASI_DIRCOOKIE_START (UINT64_C(0))
+typedef __SIZE_TYPE__ __wasi_size_t;
+
+_Static_assert(sizeof(__wasi_size_t) == 4, "witx calculated size");
+_Static_assert(_Alignof(__wasi_size_t) == 4, "witx calculated align");
+
+/**
+ * Non-negative file size or length of a region within a file.
+ */
+typedef uint64_t __wasi_filesize_t;
+
+_Static_assert(sizeof(__wasi_filesize_t) == 8, "witx calculated size");
+_Static_assert(_Alignof(__wasi_filesize_t) == 8, "witx calculated align");
+
+/**
+ * Timestamp in nanoseconds.
+ */
+typedef uint64_t __wasi_timestamp_t;
+
+_Static_assert(sizeof(__wasi_timestamp_t) == 8, "witx calculated size");
+_Static_assert(_Alignof(__wasi_timestamp_t) == 8, "witx calculated align");
+
+/**
+ * Identifiers for clocks.
+ */
+typedef uint32_t __wasi_clockid_t;
+
+/**
+ * The clock measuring real time. Time value zero corresponds with
+ * 1970-01-01T00:00:00Z.
+ */
+#define __WASI_CLOCKID_REALTIME (UINT32_C(0))
+
+/**
+ * The store-wide monotonic clock, which is defined as a clock measuring
+ * real time, whose value cannot be adjusted and which cannot have negative
+ * clock jumps. The epoch of this clock is undefined. The absolute time
+ * value of this clock therefore has no meaning.
+ */
+#define __WASI_CLOCKID_MONOTONIC (UINT32_C(1))
+
+/**
+ * The CPU-time clock associated with the current process.
+ */
+#define __WASI_CLOCKID_PROCESS_CPUTIME_ID (UINT32_C(2))
+
+/**
+ * The CPU-time clock associated with the current thread.
+ */
+#define __WASI_CLOCKID_THREAD_CPUTIME_ID (UINT32_C(3))
+
+_Static_assert(sizeof(__wasi_clockid_t) == 4, "witx calculated size");
+_Static_assert(_Alignof(__wasi_clockid_t) == 4, "witx calculated align");
+
+/**
+ * Error codes returned by functions.
+ * Not all of these error codes are returned by the functions provided by this
+ * API; some are used in higher-level library layers, and others are provided
+ * merely for alignment with POSIX.
+ */
+typedef uint16_t __wasi_errno_t;
+
+/**
+ * No error occurred. System call completed successfully.
+ */
+#define __WASI_ERRNO_SUCCESS (UINT16_C(0))
+
+/**
+ * Argument list too long.
+ */
+#define __WASI_ERRNO_2BIG (UINT16_C(1))
+
+/**
+ * Permission denied.
+ */
+#define __WASI_ERRNO_ACCES (UINT16_C(2))
+
+/**
+ * Address in use.
+ */
+#define __WASI_ERRNO_ADDRINUSE (UINT16_C(3))
+
+/**
+ * Address not available.
+ */
+#define __WASI_ERRNO_ADDRNOTAVAIL (UINT16_C(4))
+
+/**
+ * Address family not supported.
+ */
+#define __WASI_ERRNO_AFNOSUPPORT (UINT16_C(5))
+
+/**
+ * Resource unavailable, or operation would block.
+ */
+#define __WASI_ERRNO_AGAIN (UINT16_C(6))
+
+/**
+ * Connection already in progress.
+ */
+#define __WASI_ERRNO_ALREADY (UINT16_C(7))
+
+/**
+ * Bad file descriptor.
+ */
+#define __WASI_ERRNO_BADF (UINT16_C(8))
+
+/**
+ * Bad message.
+ */
+#define __WASI_ERRNO_BADMSG (UINT16_C(9))
+
+/**
+ * Device or resource busy.
+ */
+#define __WASI_ERRNO_BUSY (UINT16_C(10))
+
+/**
+ * Operation canceled.
+ */
+#define __WASI_ERRNO_CANCELED (UINT16_C(11))
+
+/**
+ * No child processes.
+ */
+#define __WASI_ERRNO_CHILD (UINT16_C(12))
+
+/**
+ * Connection aborted.
+ */
+#define __WASI_ERRNO_CONNABORTED (UINT16_C(13))
+
+/**
+ * Connection refused.
+ */
+#define __WASI_ERRNO_CONNREFUSED (UINT16_C(14))
+
+/**
+ * Connection reset.
+ */
+#define __WASI_ERRNO_CONNRESET (UINT16_C(15))
+
+/**
+ * Resource deadlock would occur.
+ */
+#define __WASI_ERRNO_DEADLK (UINT16_C(16))
+
+/**
+ * Destination address required.
+ */
+#define __WASI_ERRNO_DESTADDRREQ (UINT16_C(17))
+
+/**
+ * Mathematics argument out of domain of function.
+ */
+#define __WASI_ERRNO_DOM (UINT16_C(18))
+
+/**
+ * Reserved.
+ */
+#define __WASI_ERRNO_DQUOT (UINT16_C(19))
+
+/**
+ * File exists.
+ */
+#define __WASI_ERRNO_EXIST (UINT16_C(20))
+
+/**
+ * Bad address.
+ */
+#define __WASI_ERRNO_FAULT (UINT16_C(21))
+
+/**
+ * File too large.
+ */
+#define __WASI_ERRNO_FBIG (UINT16_C(22))
+
+/**
+ * Host is unreachable.
+ */
+#define __WASI_ERRNO_HOSTUNREACH (UINT16_C(23))
+
+/**
+ * Identifier removed.
+ */
+#define __WASI_ERRNO_IDRM (UINT16_C(24))
+
+/**
+ * Illegal byte sequence.
+ */
+#define __WASI_ERRNO_ILSEQ (UINT16_C(25))
+
+/**
+ * Operation in progress.
+ */
+#define __WASI_ERRNO_INPROGRESS (UINT16_C(26))
+
+/**
+ * Interrupted function.
+ */
+#define __WASI_ERRNO_INTR (UINT16_C(27))
+
+/**
+ * Invalid argument.
+ */
+#define __WASI_ERRNO_INVAL (UINT16_C(28))
+
+/**
+ * I/O error.
+ */
+#define __WASI_ERRNO_IO (UINT16_C(29))
+
+/**
+ * Socket is connected.
+ */
+#define __WASI_ERRNO_ISCONN (UINT16_C(30))
+
+/**
+ * Is a directory.
+ */
+#define __WASI_ERRNO_ISDIR (UINT16_C(31))
+
+/**
+ * Too many levels of symbolic links.
+ */
+#define __WASI_ERRNO_LOOP (UINT16_C(32))
+
+/**
+ * File descriptor value too large.
+ */
+#define __WASI_ERRNO_MFILE (UINT16_C(33))
+
+/**
+ * Too many links.
+ */
+#define __WASI_ERRNO_MLINK (UINT16_C(34))
+
+/**
+ * Message too large.
+ */
+#define __WASI_ERRNO_MSGSIZE (UINT16_C(35))
+
+/**
+ * Reserved.
+ */
+#define __WASI_ERRNO_MULTIHOP (UINT16_C(36))
+
+/**
+ * Filename too long.
+ */
+#define __WASI_ERRNO_NAMETOOLONG (UINT16_C(37))
+
+/**
+ * Network is down.
+ */
+#define __WASI_ERRNO_NETDOWN (UINT16_C(38))
+
+/**
+ * Connection aborted by network.
+ */
+#define __WASI_ERRNO_NETRESET (UINT16_C(39))
+
+/**
+ * Network unreachable.
+ */
+#define __WASI_ERRNO_NETUNREACH (UINT16_C(40))
+
+/**
+ * Too many files open in system.
+ */
+#define __WASI_ERRNO_NFILE (UINT16_C(41))
+
+/**
+ * No buffer space available.
+ */
+#define __WASI_ERRNO_NOBUFS (UINT16_C(42))
+
+/**
+ * No such device.
+ */
+#define __WASI_ERRNO_NODEV (UINT16_C(43))
+
+/**
+ * No such file or directory.
+ */
+#define __WASI_ERRNO_NOENT (UINT16_C(44))
+
+/**
+ * Executable file format error.
+ */
+#define __WASI_ERRNO_NOEXEC (UINT16_C(45))
+
+/**
+ * No locks available.
+ */
+#define __WASI_ERRNO_NOLCK (UINT16_C(46))
+
+/**
+ * Reserved.
+ */
+#define __WASI_ERRNO_NOLINK (UINT16_C(47))
+
+/**
+ * Not enough space.
+ */
+#define __WASI_ERRNO_NOMEM (UINT16_C(48))
+
+/**
+ * No message of the desired type.
+ */
+#define __WASI_ERRNO_NOMSG (UINT16_C(49))
+
+/**
+ * Protocol not available.
+ */
+#define __WASI_ERRNO_NOPROTOOPT (UINT16_C(50))
+
+/**
+ * No space left on device.
+ */
+#define __WASI_ERRNO_NOSPC (UINT16_C(51))
+
+/**
+ * Function not supported.
+ */
+#define __WASI_ERRNO_NOSYS (UINT16_C(52))
+
+/**
+ * The socket is not connected.
+ */
+#define __WASI_ERRNO_NOTCONN (UINT16_C(53))
+
+/**
+ * Not a directory or a symbolic link to a directory.
+ */
+#define __WASI_ERRNO_NOTDIR (UINT16_C(54))
+
+/**
+ * Directory not empty.
+ */
+#define __WASI_ERRNO_NOTEMPTY (UINT16_C(55))
+
+/**
+ * State not recoverable.
+ */
+#define __WASI_ERRNO_NOTRECOVERABLE (UINT16_C(56))
+
+/**
+ * Not a socket.
+ */
+#define __WASI_ERRNO_NOTSOCK (UINT16_C(57))
+
+/**
+ * Not supported, or operation not supported on socket.
+ */
+#define __WASI_ERRNO_NOTSUP (UINT16_C(58))
+
+/**
+ * Inappropriate I/O control operation.
+ */
+#define __WASI_ERRNO_NOTTY (UINT16_C(59))
+
+/**
+ * No such device or address.
+ */
+#define __WASI_ERRNO_NXIO (UINT16_C(60))
+
+/**
+ * Value too large to be stored in data type.
+ */
+#define __WASI_ERRNO_OVERFLOW (UINT16_C(61))
+
+/**
+ * Previous owner died.
+ */
+#define __WASI_ERRNO_OWNERDEAD (UINT16_C(62))
+
+/**
+ * Operation not permitted.
+ */
+#define __WASI_ERRNO_PERM (UINT16_C(63))
+
+/**
+ * Broken pipe.
+ */
+#define __WASI_ERRNO_PIPE (UINT16_C(64))
+
+/**
+ * Protocol error.
+ */
+#define __WASI_ERRNO_PROTO (UINT16_C(65))
+
+/**
+ * Protocol not supported.
+ */
+#define __WASI_ERRNO_PROTONOSUPPORT (UINT16_C(66))
+
+/**
+ * Protocol wrong type for socket.
+ */
+#define __WASI_ERRNO_PROTOTYPE (UINT16_C(67))
+
+/**
+ * Result too large.
+ */
+#define __WASI_ERRNO_RANGE (UINT16_C(68))
+
+/**
+ * Read-only file system.
+ */
+#define __WASI_ERRNO_ROFS (UINT16_C(69))
+
+/**
+ * Invalid seek.
+ */
+#define __WASI_ERRNO_SPIPE (UINT16_C(70))
+
+/**
+ * No such process.
+ */
+#define __WASI_ERRNO_SRCH (UINT16_C(71))
+
+/**
+ * Reserved.
+ */
+#define __WASI_ERRNO_STALE (UINT16_C(72))
+
+/**
+ * Connection timed out.
+ */
+#define __WASI_ERRNO_TIMEDOUT (UINT16_C(73))
+
+/**
+ * Text file busy.
+ */
+#define __WASI_ERRNO_TXTBSY (UINT16_C(74))
+
+/**
+ * Cross-device link.
+ */
+#define __WASI_ERRNO_XDEV (UINT16_C(75))
+
+/**
+ * Extension: Capabilities insufficient.
+ */
+#define __WASI_ERRNO_NOTCAPABLE (UINT16_C(76))
+
+_Static_assert(sizeof(__wasi_errno_t) == 2, "witx calculated size");
+_Static_assert(_Alignof(__wasi_errno_t) == 2, "witx calculated align");
+
+/**
+ * File descriptor rights, determining which actions may be performed.
+ */
+typedef uint64_t __wasi_rights_t;
+
+/**
+ * The right to invoke `fd_datasync`.
+ * If `path_open` is set, includes the right to invoke
+ * `path_open` with `fdflags::dsync`.
+ */
+#define __WASI_RIGHTS_FD_DATASYNC ((__wasi_rights_t)(1 << 0))
+
+/**
+ * The right to invoke `fd_read` and `sock_recv`.
+ * If `rights::fd_seek` is set, includes the right to invoke `fd_pread`.
+ */
+#define __WASI_RIGHTS_FD_READ ((__wasi_rights_t)(1 << 1))
+
+/**
+ * The right to invoke `fd_seek`. This flag implies `rights::fd_tell`.
+ */
+#define __WASI_RIGHTS_FD_SEEK ((__wasi_rights_t)(1 << 2))
+
+/**
+ * The right to invoke `fd_fdstat_set_flags`.
+ */
+#define __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS ((__wasi_rights_t)(1 << 3))
+
+/**
+ * The right to invoke `fd_sync`.
+ * If `path_open` is set, includes the right to invoke
+ * `path_open` with `fdflags::rsync` and `fdflags::dsync`.
+ */
+#define __WASI_RIGHTS_FD_SYNC ((__wasi_rights_t)(1 << 4))
+
+/**
+ * The right to invoke `fd_seek` in such a way that the file offset
+ * remains unaltered (i.e., `whence::cur` with offset zero), or to
+ * invoke `fd_tell`.
+ */
+#define __WASI_RIGHTS_FD_TELL ((__wasi_rights_t)(1 << 5))
+
+/**
+ * The right to invoke `fd_write` and `sock_send`.
+ * If `rights::fd_seek` is set, includes the right to invoke `fd_pwrite`.
+ */
+#define __WASI_RIGHTS_FD_WRITE ((__wasi_rights_t)(1 << 6))
+
+/**
+ * The right to invoke `fd_advise`.
+ */
+#define __WASI_RIGHTS_FD_ADVISE ((__wasi_rights_t)(1 << 7))
+
+/**
+ * The right to invoke `fd_allocate`.
+ */
+#define __WASI_RIGHTS_FD_ALLOCATE ((__wasi_rights_t)(1 << 8))
+
+/**
+ * The right to invoke `path_create_directory`.
+ */
+#define __WASI_RIGHTS_PATH_CREATE_DIRECTORY ((__wasi_rights_t)(1 << 9))
+
+/**
+ * If `path_open` is set, the right to invoke `path_open` with `oflags::creat`.
+ */
+#define __WASI_RIGHTS_PATH_CREATE_FILE ((__wasi_rights_t)(1 << 10))
+
+/**
+ * The right to invoke `path_link` with the file descriptor as the
+ * source directory.
+ */
+#define __WASI_RIGHTS_PATH_LINK_SOURCE ((__wasi_rights_t)(1 << 11))
+
+/**
+ * The right to invoke `path_link` with the file descriptor as the
+ * target directory.
+ */
+#define __WASI_RIGHTS_PATH_LINK_TARGET ((__wasi_rights_t)(1 << 12))
+
+/**
+ * The right to invoke `path_open`.
+ */
+#define __WASI_RIGHTS_PATH_OPEN ((__wasi_rights_t)(1 << 13))
+
+/**
+ * The right to invoke `fd_readdir`.
+ */
+#define __WASI_RIGHTS_FD_READDIR ((__wasi_rights_t)(1 << 14))
+
+/**
+ * The right to invoke `path_readlink`.
+ */
+#define __WASI_RIGHTS_PATH_READLINK ((__wasi_rights_t)(1 << 15))
+
+/**
+ * The right to invoke `path_rename` with the file descriptor as the source directory.
+ */
+#define __WASI_RIGHTS_PATH_RENAME_SOURCE ((__wasi_rights_t)(1 << 16))
+
+/**
+ * The right to invoke `path_rename` with the file descriptor as the target directory.
+ */
+#define __WASI_RIGHTS_PATH_RENAME_TARGET ((__wasi_rights_t)(1 << 17))
+
+/**
+ * The right to invoke `path_filestat_get`.
+ */
+#define __WASI_RIGHTS_PATH_FILESTAT_GET ((__wasi_rights_t)(1 << 18))
+
+/**
+ * The right to change a file's size (there is no `path_filestat_set_size`).
+ * If `path_open` is set, includes the right to invoke `path_open` with `oflags::trunc`.
+ */
+#define __WASI_RIGHTS_PATH_FILESTAT_SET_SIZE ((__wasi_rights_t)(1 << 19))
+
+/**
+ * The right to invoke `path_filestat_set_times`.
+ */
+#define __WASI_RIGHTS_PATH_FILESTAT_SET_TIMES ((__wasi_rights_t)(1 << 20))
+
+/**
+ * The right to invoke `fd_filestat_get`.
+ */
+#define __WASI_RIGHTS_FD_FILESTAT_GET ((__wasi_rights_t)(1 << 21))
+
+/**
+ * The right to invoke `fd_filestat_set_size`.
+ */
+#define __WASI_RIGHTS_FD_FILESTAT_SET_SIZE ((__wasi_rights_t)(1 << 22))
+
+/**
+ * The right to invoke `fd_filestat_set_times`.
+ */
+#define __WASI_RIGHTS_FD_FILESTAT_SET_TIMES ((__wasi_rights_t)(1 << 23))
+
+/**
+ * The right to invoke `path_symlink`.
+ */
+#define __WASI_RIGHTS_PATH_SYMLINK ((__wasi_rights_t)(1 << 24))
+
+/**
+ * The right to invoke `path_remove_directory`.
+ */
+#define __WASI_RIGHTS_PATH_REMOVE_DIRECTORY ((__wasi_rights_t)(1 << 25))
+
+/**
+ * The right to invoke `path_unlink_file`.
+ */
+#define __WASI_RIGHTS_PATH_UNLINK_FILE ((__wasi_rights_t)(1 << 26))
+
+/**
+ * If `rights::fd_read` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_read`.
+ * If `rights::fd_write` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_write`.
+ */
+#define __WASI_RIGHTS_POLL_FD_READWRITE ((__wasi_rights_t)(1 << 27))
+
+/**
+ * The right to invoke `sock_shutdown`.
+ */
+#define __WASI_RIGHTS_SOCK_SHUTDOWN ((__wasi_rights_t)(1 << 28))
+
+/**
+ * The right to invoke `sock_accept`.
+ */
+#define __WASI_RIGHTS_SOCK_ACCEPT ((__wasi_rights_t)(1 << 29))
+
+/**
+ * A file descriptor handle.
+ */
+typedef int __wasi_fd_t;
+
+_Static_assert(sizeof(__wasi_fd_t) == 4, "witx calculated size");
+_Static_assert(_Alignof(__wasi_fd_t) == 4, "witx calculated align");
+
+/**
+ * A region of memory for scatter/gather reads.
+ */
+typedef struct __wasi_iovec_t {
+ /**
+ * The address of the buffer to be filled.
+ */
+ uint8_t * buf;
+
+ /**
+ * The length of the buffer to be filled.
+ */
+ __wasi_size_t buf_len;
+
+} __wasi_iovec_t;
+
+_Static_assert(sizeof(__wasi_iovec_t) == 8, "witx calculated size");
+_Static_assert(_Alignof(__wasi_iovec_t) == 4, "witx calculated align");
+_Static_assert(offsetof(__wasi_iovec_t, buf) == 0, "witx calculated offset");
+_Static_assert(offsetof(__wasi_iovec_t, buf_len) == 4, "witx calculated offset");
+
+/**
+ * A region of memory for scatter/gather writes.
+ */
+typedef struct __wasi_ciovec_t {
+ /**
+ * The address of the buffer to be written.
+ */
+ const uint8_t * buf;
+
+ /**
+ * The length of the buffer to be written.
+ */
+ __wasi_size_t buf_len;
+
+} __wasi_ciovec_t;
+
+_Static_assert(sizeof(__wasi_ciovec_t) == 8, "witx calculated size");
+_Static_assert(_Alignof(__wasi_ciovec_t) == 4, "witx calculated align");
+_Static_assert(offsetof(__wasi_ciovec_t, buf) == 0, "witx calculated offset");
+_Static_assert(offsetof(__wasi_ciovec_t, buf_len) == 4, "witx calculated offset");
+
+/**
+ * Relative offset within a file.
+ */
+typedef int64_t __wasi_filedelta_t;
+
+_Static_assert(sizeof(__wasi_filedelta_t) == 8, "witx calculated size");
+_Static_assert(_Alignof(__wasi_filedelta_t) == 8, "witx calculated align");
+
+/**
+ * The position relative to which to set the offset of the file descriptor.
+ */
+typedef uint8_t __wasi_whence_t;
+
+/**
+ * Seek relative to start-of-file.
+ */
+#define __WASI_WHENCE_SET (UINT8_C(0))
+
+/**
+ * Seek relative to current position.
+ */
+#define __WASI_WHENCE_CUR (UINT8_C(1))
+
+/**
+ * Seek relative to end-of-file.
+ */
+#define __WASI_WHENCE_END (UINT8_C(2))
+
+_Static_assert(sizeof(__wasi_whence_t) == 1, "witx calculated size");
+_Static_assert(_Alignof(__wasi_whence_t) == 1, "witx calculated align");
+
+/**
+ * A reference to the offset of a directory entry.
+ *
+ * The value 0 signifies the start of the directory.
+ */
+typedef uint64_t __wasi_dircookie_t;
+
+_Static_assert(sizeof(__wasi_dircookie_t) == 8, "witx calculated size");
+_Static_assert(_Alignof(__wasi_dircookie_t) == 8, "witx calculated align");
+
+/**
+ * The type for the `dirent::d_namlen` field of `dirent` struct.
+ */
+typedef uint32_t __wasi_dirnamlen_t;
+
+_Static_assert(sizeof(__wasi_dirnamlen_t) == 4, "witx calculated size");
+_Static_assert(_Alignof(__wasi_dirnamlen_t) == 4, "witx calculated align");
+
+/**
+ * File serial number that is unique within its file system.
+ */
+typedef uint64_t __wasi_inode_t;
+
+_Static_assert(sizeof(__wasi_inode_t) == 8, "witx calculated size");
+_Static_assert(_Alignof(__wasi_inode_t) == 8, "witx calculated align");
+
+/**
+ * The type of a file descriptor or file.
+ */
+typedef uint8_t __wasi_filetype_t;
+
+/**
+ * The type of the file descriptor or file is unknown or is different from any of the other types specified.
+ */
+#define __WASI_FILETYPE_UNKNOWN (UINT8_C(0))
+
+/**
+ * The file descriptor or file refers to a block device inode.
+ */
+#define __WASI_FILETYPE_BLOCK_DEVICE (UINT8_C(1))
+
+/**
+ * The file descriptor or file refers to a character device inode.
+ */
+#define __WASI_FILETYPE_CHARACTER_DEVICE (UINT8_C(2))
+
+/**
+ * The file descriptor or file refers to a directory inode.
+ */
+#define __WASI_FILETYPE_DIRECTORY (UINT8_C(3))
+
+/**
+ * The file descriptor or file refers to a regular file inode.
+ */
+#define __WASI_FILETYPE_REGULAR_FILE (UINT8_C(4))
+
+/**
+ * The file descriptor or file refers to a datagram socket.
+ */
+#define __WASI_FILETYPE_SOCKET_DGRAM (UINT8_C(5))
+
+/**
+ * The file descriptor or file refers to a byte-stream socket.
+ */
+#define __WASI_FILETYPE_SOCKET_STREAM (UINT8_C(6))
+
+/**
+ * The file refers to a symbolic link inode.
+ */
+#define __WASI_FILETYPE_SYMBOLIC_LINK (UINT8_C(7))
+
+_Static_assert(sizeof(__wasi_filetype_t) == 1, "witx calculated size");
+_Static_assert(_Alignof(__wasi_filetype_t) == 1, "witx calculated align");
+
+/**
+ * A directory entry.
+ */
+typedef struct __wasi_dirent_t {
+ /**
+ * The offset of the next directory entry stored in this directory.
+ */
+ __wasi_dircookie_t d_next;
+
+ /**
+ * The serial number of the file referred to by this directory entry.
+ */
+ __wasi_inode_t d_ino;
+
+ /**
+ * The length of the name of the directory entry.
+ */
+ __wasi_dirnamlen_t d_namlen;
+
+ /**
+ * The type of the file referred to by this directory entry.
+ */
+ __wasi_filetype_t d_type;
+
+} __wasi_dirent_t;
+
+_Static_assert(sizeof(__wasi_dirent_t) == 24, "witx calculated size");
+_Static_assert(_Alignof(__wasi_dirent_t) == 8, "witx calculated align");
+_Static_assert(offsetof(__wasi_dirent_t, d_next) == 0, "witx calculated offset");
+_Static_assert(offsetof(__wasi_dirent_t, d_ino) == 8, "witx calculated offset");
+_Static_assert(offsetof(__wasi_dirent_t, d_namlen) == 16, "witx calculated offset");
+_Static_assert(offsetof(__wasi_dirent_t, d_type) == 20, "witx calculated offset");
+
+/**
+ * File or memory access pattern advisory information.
+ */
+typedef uint8_t __wasi_advice_t;
+
+/**
+ * The application has no advice to give on its behavior with respect to the specified data.
+ */
+#define __WASI_ADVICE_NORMAL (UINT8_C(0))
+
+/**
+ * The application expects to access the specified data sequentially from lower offsets to higher offsets.
+ */
+#define __WASI_ADVICE_SEQUENTIAL (UINT8_C(1))
+
+/**
+ * The application expects to access the specified data in a random order.
+ */
+#define __WASI_ADVICE_RANDOM (UINT8_C(2))
+
+/**
+ * The application expects to access the specified data in the near future.
+ */
+#define __WASI_ADVICE_WILLNEED (UINT8_C(3))
+
+/**
+ * The application expects that it will not access the specified data in the near future.
+ */
+#define __WASI_ADVICE_DONTNEED (UINT8_C(4))
+
+/**
+ * The application expects to access the specified data once and then not reuse it thereafter.
+ */
+#define __WASI_ADVICE_NOREUSE (UINT8_C(5))
+
+_Static_assert(sizeof(__wasi_advice_t) == 1, "witx calculated size");
+_Static_assert(_Alignof(__wasi_advice_t) == 1, "witx calculated align");
+
+/**
+ * File descriptor flags.
+ */
+typedef uint16_t __wasi_fdflags_t;
+
+/**
+ * Append mode: Data written to the file is always appended to the file's end.
+ */
+#define __WASI_FDFLAGS_APPEND ((__wasi_fdflags_t)(1 << 0))
+
+/**
+ * Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
+ */
+#define __WASI_FDFLAGS_DSYNC ((__wasi_fdflags_t)(1 << 1))
+
+/**
+ * Non-blocking mode.
+ */
+#define __WASI_FDFLAGS_NONBLOCK ((__wasi_fdflags_t)(1 << 2))
+
+/**
+ * Synchronized read I/O operations.
+ */
+#define __WASI_FDFLAGS_RSYNC ((__wasi_fdflags_t)(1 << 3))
+
+/**
+ * Write according to synchronized I/O file integrity completion. In
+ * addition to synchronizing the data stored in the file, the implementation
+ * may also synchronously update the file's metadata.
+ */
+#define __WASI_FDFLAGS_SYNC ((__wasi_fdflags_t)(1 << 4))
+
+/**
+ * File descriptor attributes.
+ */
+typedef struct __wasi_fdstat_t {
+ /**
+ * File type.
+ */
+ __wasi_filetype_t fs_filetype;
+
+ /**
+ * File descriptor flags.
+ */
+ __wasi_fdflags_t fs_flags;
+
+ /**
+ * Rights that apply to this file descriptor.
+ */
+ __wasi_rights_t fs_rights_base;
+
+ /**
+ * Maximum set of rights that may be installed on new file descriptors that
+ * are created through this file descriptor, e.g., through `path_open`.
+ */
+ __wasi_rights_t fs_rights_inheriting;
+
+} __wasi_fdstat_t;
+
+_Static_assert(sizeof(__wasi_fdstat_t) == 24, "witx calculated size");
+_Static_assert(_Alignof(__wasi_fdstat_t) == 8, "witx calculated align");
+_Static_assert(offsetof(__wasi_fdstat_t, fs_filetype) == 0, "witx calculated offset");
+_Static_assert(offsetof(__wasi_fdstat_t, fs_flags) == 2, "witx calculated offset");
+_Static_assert(offsetof(__wasi_fdstat_t, fs_rights_base) == 8, "witx calculated offset");
+_Static_assert(offsetof(__wasi_fdstat_t, fs_rights_inheriting) == 16, "witx calculated offset");
+
+/**
+ * Identifier for a device containing a file system. Can be used in combination
+ * with `inode` to uniquely identify a file or directory in the filesystem.
+ */
+typedef uint64_t __wasi_device_t;
+
+_Static_assert(sizeof(__wasi_device_t) == 8, "witx calculated size");
+_Static_assert(_Alignof(__wasi_device_t) == 8, "witx calculated align");
+
+/**
+ * Which file time attributes to adjust.
+ */
+typedef uint16_t __wasi_fstflags_t;
+
+/**
+ * Adjust the last data access timestamp to the value stored in `filestat::atim`.
+ */
+#define __WASI_FSTFLAGS_ATIM ((__wasi_fstflags_t)(1 << 0))
+
+/**
+ * Adjust the last data access timestamp to the time of clock `clockid::realtime`.
+ */
+#define __WASI_FSTFLAGS_ATIM_NOW ((__wasi_fstflags_t)(1 << 1))
+
+/**
+ * Adjust the last data modification timestamp to the value stored in `filestat::mtim`.
+ */
+#define __WASI_FSTFLAGS_MTIM ((__wasi_fstflags_t)(1 << 2))
+
+/**
+ * Adjust the last data modification timestamp to the time of clock `clockid::realtime`.
+ */
+#define __WASI_FSTFLAGS_MTIM_NOW ((__wasi_fstflags_t)(1 << 3))
+
+/**
+ * Flags determining the method of how paths are resolved.
+ */
+typedef uint32_t __wasi_lookupflags_t;
+
+/**
+ * As long as the resolved path corresponds to a symbolic link, it is expanded.
+ */
+#define __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW ((__wasi_lookupflags_t)(1 << 0))
+
+/**
+ * Open flags used by `path_open`.
+ */
+typedef uint16_t __wasi_oflags_t;
+
+/**
+ * Create file if it does not exist.
+ */
+#define __WASI_OFLAGS_CREAT ((__wasi_oflags_t)(1 << 0))
+
+/**
+ * Fail if not a directory.
+ */
+#define __WASI_OFLAGS_DIRECTORY ((__wasi_oflags_t)(1 << 1))
+
+/**
+ * Fail if file already exists.
+ */
+#define __WASI_OFLAGS_EXCL ((__wasi_oflags_t)(1 << 2))
+
+/**
+ * Truncate file to size 0.
+ */
+#define __WASI_OFLAGS_TRUNC ((__wasi_oflags_t)(1 << 3))
+
+/**
+ * Number of hard links to an inode.
+ */
+typedef uint64_t __wasi_linkcount_t;
+
+_Static_assert(sizeof(__wasi_linkcount_t) == 8, "witx calculated size");
+_Static_assert(_Alignof(__wasi_linkcount_t) == 8, "witx calculated align");
+
+/**
+ * File attributes.
+ */
+typedef struct __wasi_filestat_t {
+ /**
+ * Device ID of device containing the file.
+ */
+ __wasi_device_t dev;
+
+ /**
+ * File serial number.
+ */
+ __wasi_inode_t ino;
+
+ /**
+ * File type.
+ */
+ __wasi_filetype_t filetype;
+
+ /**
+ * Number of hard links to the file.
+ */
+ __wasi_linkcount_t nlink;
+
+ /**
+ * For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link.
+ */
+ __wasi_filesize_t size;
+
+ /**
+ * Last data access timestamp.
+ */
+ __wasi_timestamp_t atim;
+
+ /**
+ * Last data modification timestamp.
+ */
+ __wasi_timestamp_t mtim;
+
+ /**
+ * Last file status change timestamp.
+ */
+ __wasi_timestamp_t ctim;
+
+} __wasi_filestat_t;
+
+_Static_assert(sizeof(__wasi_filestat_t) == 64, "witx calculated size");
+_Static_assert(_Alignof(__wasi_filestat_t) == 8, "witx calculated align");
+_Static_assert(offsetof(__wasi_filestat_t, dev) == 0, "witx calculated offset");
+_Static_assert(offsetof(__wasi_filestat_t, ino) == 8, "witx calculated offset");
+_Static_assert(offsetof(__wasi_filestat_t, filetype) == 16, "witx calculated offset");
+_Static_assert(offsetof(__wasi_filestat_t, nlink) == 24, "witx calculated offset");
+_Static_assert(offsetof(__wasi_filestat_t, size) == 32, "witx calculated offset");
+_Static_assert(offsetof(__wasi_filestat_t, atim) == 40, "witx calculated offset");
+_Static_assert(offsetof(__wasi_filestat_t, mtim) == 48, "witx calculated offset");
+_Static_assert(offsetof(__wasi_filestat_t, ctim) == 56, "witx calculated offset");
+
+/**
+ * User-provided value that may be attached to objects that is retained when
+ * extracted from the implementation.
+ */
+typedef uint64_t __wasi_userdata_t;
+
+_Static_assert(sizeof(__wasi_userdata_t) == 8, "witx calculated size");
+_Static_assert(_Alignof(__wasi_userdata_t) == 8, "witx calculated align");
+
+/**
+ * Type of a subscription to an event or its occurrence.
+ */
+typedef uint8_t __wasi_eventtype_t;
+
+/**
+ * The time value of clock `subscription_clock::id` has
+ * reached timestamp `subscription_clock::timeout`.
+ */
+#define __WASI_EVENTTYPE_CLOCK (UINT8_C(0))
+
+/**
+ * File descriptor `subscription_fd_readwrite::file_descriptor` has data
+ * available for reading. This event always triggers for regular files.
+ */
+#define __WASI_EVENTTYPE_FD_READ (UINT8_C(1))
+
+/**
+ * File descriptor `subscription_fd_readwrite::file_descriptor` has capacity
+ * available for writing. This event always triggers for regular files.
+ */
+#define __WASI_EVENTTYPE_FD_WRITE (UINT8_C(2))
+
+_Static_assert(sizeof(__wasi_eventtype_t) == 1, "witx calculated size");
+_Static_assert(_Alignof(__wasi_eventtype_t) == 1, "witx calculated align");
+
+/**
+ * The state of the file descriptor subscribed to with
+ * `eventtype::fd_read` or `eventtype::fd_write`.
+ */
+typedef uint16_t __wasi_eventrwflags_t;
+
+/**
+ * The peer of this socket has closed or disconnected.
+ */
+#define __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP ((__wasi_eventrwflags_t)(1 << 0))
+
+/**
+ * The contents of an `event` when type is `eventtype::fd_read` or
+ * `eventtype::fd_write`.
+ */
+typedef struct __wasi_event_fd_readwrite_t {
+ /**
+ * The number of bytes available for reading or writing.
+ */
+ __wasi_filesize_t nbytes;
+
+ /**
+ * The state of the file descriptor.
+ */
+ __wasi_eventrwflags_t flags;
+
+} __wasi_event_fd_readwrite_t;
+
+_Static_assert(sizeof(__wasi_event_fd_readwrite_t) == 16, "witx calculated size");
+_Static_assert(_Alignof(__wasi_event_fd_readwrite_t) == 8, "witx calculated align");
+_Static_assert(offsetof(__wasi_event_fd_readwrite_t, nbytes) == 0, "witx calculated offset");
+_Static_assert(offsetof(__wasi_event_fd_readwrite_t, flags) == 8, "witx calculated offset");
+
+/**
+ * An event that occurred.
+ */
+typedef struct __wasi_event_t {
+ /**
+ * User-provided value that got attached to `subscription::userdata`.
+ */
+ __wasi_userdata_t userdata;
+
+ /**
+ * If non-zero, an error that occurred while processing the subscription request.
+ */
+ __wasi_errno_t error;
+
+ /**
+ * The type of event that occured
+ */
+ __wasi_eventtype_t type;
+
+ /**
+ * The contents of the event, if it is an `eventtype::fd_read` or
+ * `eventtype::fd_write`. `eventtype::clock` events ignore this field.
+ */
+ __wasi_event_fd_readwrite_t fd_readwrite;
+
+} __wasi_event_t;
+
+_Static_assert(sizeof(__wasi_event_t) == 32, "witx calculated size");
+_Static_assert(_Alignof(__wasi_event_t) == 8, "witx calculated align");
+_Static_assert(offsetof(__wasi_event_t, userdata) == 0, "witx calculated offset");
+_Static_assert(offsetof(__wasi_event_t, error) == 8, "witx calculated offset");
+_Static_assert(offsetof(__wasi_event_t, type) == 10, "witx calculated offset");
+_Static_assert(offsetof(__wasi_event_t, fd_readwrite) == 16, "witx calculated offset");
+
+/**
+ * Flags determining how to interpret the timestamp provided in
+ * `subscription_clock::timeout`.
+ */
+typedef uint16_t __wasi_subclockflags_t;
+
+/**
+ * If set, treat the timestamp provided in
+ * `subscription_clock::timeout` as an absolute timestamp of clock
+ * `subscription_clock::id`. If clear, treat the timestamp
+ * provided in `subscription_clock::timeout` relative to the
+ * current time value of clock `subscription_clock::id`.
+ */
+#define __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME ((__wasi_subclockflags_t)(1 << 0))
+
+/**
+ * The contents of a `subscription` when type is `eventtype::clock`.
+ */
+typedef struct __wasi_subscription_clock_t {
+ /**
+ * The clock against which to compare the timestamp.
+ */
+ __wasi_clockid_t id;
+
+ /**
+ * The absolute or relative timestamp.
+ */
+ __wasi_timestamp_t timeout;
+
+ /**
+ * The amount of time that the implementation may wait additionally
+ * to coalesce with other events.
+ */
+ __wasi_timestamp_t precision;
+
+ /**
+ * Flags specifying whether the timeout is absolute or relative
+ */
+ __wasi_subclockflags_t flags;
+
+} __wasi_subscription_clock_t;
+
+_Static_assert(sizeof(__wasi_subscription_clock_t) == 32, "witx calculated size");
+_Static_assert(_Alignof(__wasi_subscription_clock_t) == 8, "witx calculated align");
+_Static_assert(offsetof(__wasi_subscription_clock_t, id) == 0, "witx calculated offset");
+_Static_assert(offsetof(__wasi_subscription_clock_t, timeout) == 8, "witx calculated offset");
+_Static_assert(offsetof(__wasi_subscription_clock_t, precision) == 16, "witx calculated offset");
+_Static_assert(offsetof(__wasi_subscription_clock_t, flags) == 24, "witx calculated offset");
+
+/**
+ * The contents of a `subscription` when type is type is
+ * `eventtype::fd_read` or `eventtype::fd_write`.
+ */
+typedef struct __wasi_subscription_fd_readwrite_t {
+ /**
+ * The file descriptor on which to wait for it to become ready for reading or writing.
+ */
+ __wasi_fd_t file_descriptor;
+
+} __wasi_subscription_fd_readwrite_t;
+
+_Static_assert(sizeof(__wasi_subscription_fd_readwrite_t) == 4, "witx calculated size");
+_Static_assert(_Alignof(__wasi_subscription_fd_readwrite_t) == 4, "witx calculated align");
+_Static_assert(offsetof(__wasi_subscription_fd_readwrite_t, file_descriptor) == 0, "witx calculated offset");
+
+/**
+ * The contents of a `subscription`.
+ */
+typedef union __wasi_subscription_u_u_t {
+ __wasi_subscription_clock_t clock;
+ __wasi_subscription_fd_readwrite_t fd_read;
+ __wasi_subscription_fd_readwrite_t fd_write;
+} __wasi_subscription_u_u_t;
+typedef struct __wasi_subscription_u_t {
+ uint8_t tag;
+ __wasi_subscription_u_u_t u;
+} __wasi_subscription_u_t;
+
+_Static_assert(sizeof(__wasi_subscription_u_t) == 40, "witx calculated size");
+_Static_assert(_Alignof(__wasi_subscription_u_t) == 8, "witx calculated align");
+
+/**
+ * Subscription to an event.
+ */
+typedef struct __wasi_subscription_t {
+ /**
+ * User-provided value that is attached to the subscription in the
+ * implementation and returned through `event::userdata`.
+ */
+ __wasi_userdata_t userdata;
+
+ /**
+ * The type of the event to which to subscribe, and its contents
+ */
+ __wasi_subscription_u_t u;
+
+} __wasi_subscription_t;
+
+_Static_assert(sizeof(__wasi_subscription_t) == 48, "witx calculated size");
+_Static_assert(_Alignof(__wasi_subscription_t) == 8, "witx calculated align");
+_Static_assert(offsetof(__wasi_subscription_t, userdata) == 0, "witx calculated offset");
+_Static_assert(offsetof(__wasi_subscription_t, u) == 8, "witx calculated offset");
+
+/**
+ * Exit code generated by a process when exiting.
+ */
+typedef uint32_t __wasi_exitcode_t;
+
+_Static_assert(sizeof(__wasi_exitcode_t) == 4, "witx calculated size");
+_Static_assert(_Alignof(__wasi_exitcode_t) == 4, "witx calculated align");
+
+/**
+ * Flags provided to `sock_recv`.
+ */
+typedef uint16_t __wasi_riflags_t;
+
+/**
+ * Returns the message without removing it from the socket's receive queue.
+ */
+#define __WASI_RIFLAGS_RECV_PEEK ((__wasi_riflags_t)(1 << 0))
+
+/**
+ * On byte-stream sockets, block until the full amount of data can be returned.
+ */
+#define __WASI_RIFLAGS_RECV_WAITALL ((__wasi_riflags_t)(1 << 1))
+
+/**
+ * Flags returned by `sock_recv`.
+ */
+typedef uint16_t __wasi_roflags_t;
+
+/**
+ * Returned by `sock_recv`: Message data has been truncated.
+ */
+#define __WASI_ROFLAGS_RECV_DATA_TRUNCATED ((__wasi_roflags_t)(1 << 0))
+
+/**
+ * Flags provided to `sock_send`. As there are currently no flags
+ * defined, it must be set to zero.
+ */
+typedef uint16_t __wasi_siflags_t;
+
+_Static_assert(sizeof(__wasi_siflags_t) == 2, "witx calculated size");
+_Static_assert(_Alignof(__wasi_siflags_t) == 2, "witx calculated align");
+
+/**
+ * Which channels on a socket to shut down.
+ */
+typedef uint8_t __wasi_sdflags_t;
+
+/**
+ * Disables further receive operations.
+ */
+#define __WASI_SDFLAGS_RD ((__wasi_sdflags_t)(1 << 0))
+
+/**
+ * Disables further send operations.
+ */
+#define __WASI_SDFLAGS_WR ((__wasi_sdflags_t)(1 << 1))
+
+/**
+ * Identifiers for preopened capabilities.
+ */
+typedef uint8_t __wasi_preopentype_t;
+
+/**
+ * A pre-opened directory.
+ */
+#define __WASI_PREOPENTYPE_DIR (UINT8_C(0))
+
+_Static_assert(sizeof(__wasi_preopentype_t) == 1, "witx calculated size");
+_Static_assert(_Alignof(__wasi_preopentype_t) == 1, "witx calculated align");
+
+/**
+ * The contents of a $prestat when type is `preopentype::dir`.
+ */
+typedef struct __wasi_prestat_dir_t {
+ /**
+ * The length of the directory name for use with `fd_prestat_dir_name`.
+ */
+ __wasi_size_t pr_name_len;
+
+} __wasi_prestat_dir_t;
+
+_Static_assert(sizeof(__wasi_prestat_dir_t) == 4, "witx calculated size");
+_Static_assert(_Alignof(__wasi_prestat_dir_t) == 4, "witx calculated align");
+_Static_assert(offsetof(__wasi_prestat_dir_t, pr_name_len) == 0, "witx calculated offset");
+
+/**
+ * Information about a pre-opened capability.
+ */
+typedef union __wasi_prestat_u_t {
+ __wasi_prestat_dir_t dir;
+} __wasi_prestat_u_t;
+typedef struct __wasi_prestat_t {
+ uint8_t tag;
+ __wasi_prestat_u_t u;
+} __wasi_prestat_t;
+
+_Static_assert(sizeof(__wasi_prestat_t) == 8, "witx calculated size");
+_Static_assert(_Alignof(__wasi_prestat_t) == 4, "witx calculated align");
+
+/**
+ * @defgroup wasi_snapshot_preview1
+ * @{
+ */
+
+/**
+ * Read command-line argument data.
+ * The size of the array should match that returned by `args_sizes_get`.
+ * Each argument is expected to be `\0` terminated.
+ */
+__wasi_errno_t __wasi_args_get(
+ uint8_t * * argv,
+ uint8_t * argv_buf
+) __attribute__((__warn_unused_result__));
+/**
+ * Return command-line argument data sizes.
+ * @return
+ * Returns the number of arguments and the size of the argument string
+ * data, or an error.
+ */
+__wasi_errno_t __wasi_args_sizes_get(
+ __wasi_size_t *retptr0,
+ __wasi_size_t *retptr1
+) __attribute__((__warn_unused_result__));
+/**
+ * Read environment variable data.
+ * The sizes of the buffers should match that returned by `environ_sizes_get`.
+ * Key/value pairs are expected to be joined with `=`s, and terminated with `\0`s.
+ */
+__wasi_errno_t __wasi_environ_get(
+ uint8_t * * environ,
+ uint8_t * environ_buf
+) __attribute__((__warn_unused_result__));
+/**
+ * Return environment variable data sizes.
+ * @return
+ * Returns the number of environment variable arguments and the size of the
+ * environment variable data.
+ */
+__wasi_errno_t __wasi_environ_sizes_get(
+ __wasi_size_t *retptr0,
+ __wasi_size_t *retptr1
+) __attribute__((__warn_unused_result__));
+/**
+ * Return the resolution of a clock.
+ * Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks,
+ * return `errno::inval`.
+ * Note: This is similar to `clock_getres` in POSIX.
+ * @return
+ * The resolution of the clock, or an error if one happened.
+ */
+__wasi_errno_t __wasi_clock_res_get(
+ /**
+ * The clock for which to return the resolution.
+ */
+ __wasi_clockid_t id,
+ __wasi_timestamp_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Return the time value of a clock.
+ * Note: This is similar to `clock_gettime` in POSIX.
+ * @return
+ * The time value of the clock.
+ */
+__wasi_errno_t __wasi_clock_time_get(
+ /**
+ * The clock for which to return the time.
+ */
+ __wasi_clockid_t id,
+ /**
+ * The maximum lag (exclusive) that the returned time value may have, compared to its actual value.
+ */
+ __wasi_timestamp_t precision,
+ __wasi_timestamp_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Provide file advisory information on a file descriptor.
+ * Note: This is similar to `posix_fadvise` in POSIX.
+ */
+__wasi_errno_t __wasi_fd_advise(
+ __wasi_fd_t fd,
+ /**
+ * The offset within the file to which the advisory applies.
+ */
+ __wasi_filesize_t offset,
+ /**
+ * The length of the region to which the advisory applies.
+ */
+ __wasi_filesize_t len,
+ /**
+ * The advice.
+ */
+ __wasi_advice_t advice
+) __attribute__((__warn_unused_result__));
+/**
+ * Force the allocation of space in a file.
+ * Note: This is similar to `posix_fallocate` in POSIX.
+ */
+__wasi_errno_t __wasi_fd_allocate(
+ __wasi_fd_t fd,
+ /**
+ * The offset at which to start the allocation.
+ */
+ __wasi_filesize_t offset,
+ /**
+ * The length of the area that is allocated.
+ */
+ __wasi_filesize_t len
+) __attribute__((__warn_unused_result__));
+/**
+ * Close a file descriptor.
+ * Note: This is similar to `close` in POSIX.
+ */
+__wasi_errno_t __wasi_fd_close(
+ __wasi_fd_t fd
+) __attribute__((__warn_unused_result__));
+/**
+ * Synchronize the data of a file to disk.
+ * Note: This is similar to `fdatasync` in POSIX.
+ */
+__wasi_errno_t __wasi_fd_datasync(
+ __wasi_fd_t fd
+) __attribute__((__warn_unused_result__));
+/**
+ * Get the attributes of a file descriptor.
+ * Note: This returns similar flags to `fsync(fd, F_GETFL)` in POSIX, as well as additional fields.
+ * @return
+ * The buffer where the file descriptor's attributes are stored.
+ */
+__wasi_errno_t __wasi_fd_fdstat_get(
+ __wasi_fd_t fd,
+ __wasi_fdstat_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Adjust the flags associated with a file descriptor.
+ * Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX.
+ */
+__wasi_errno_t __wasi_fd_fdstat_set_flags(
+ __wasi_fd_t fd,
+ /**
+ * The desired values of the file descriptor flags.
+ */
+ __wasi_fdflags_t flags
+) __attribute__((__warn_unused_result__));
+/**
+ * Adjust the rights associated with a file descriptor.
+ * This can only be used to remove rights, and returns `errno::notcapable` if called in a way that would attempt to add rights
+ */
+__wasi_errno_t __wasi_fd_fdstat_set_rights(
+ __wasi_fd_t fd,
+ /**
+ * The desired rights of the file descriptor.
+ */
+ __wasi_rights_t fs_rights_base,
+ __wasi_rights_t fs_rights_inheriting
+) __attribute__((__warn_unused_result__));
+/**
+ * Return the attributes of an open file.
+ * @return
+ * The buffer where the file's attributes are stored.
+ */
+__wasi_errno_t __wasi_fd_filestat_get(
+ __wasi_fd_t fd,
+ __wasi_filestat_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.
+ * Note: This is similar to `ftruncate` in POSIX.
+ */
+__wasi_errno_t __wasi_fd_filestat_set_size(
+ __wasi_fd_t fd,
+ /**
+ * The desired file size.
+ */
+ __wasi_filesize_t size
+) __attribute__((__warn_unused_result__));
+/**
+ * Adjust the timestamps of an open file or directory.
+ * Note: This is similar to `futimens` in POSIX.
+ */
+__wasi_errno_t __wasi_fd_filestat_set_times(
+ __wasi_fd_t fd,
+ /**
+ * The desired values of the data access timestamp.
+ */
+ __wasi_timestamp_t atim,
+ /**
+ * The desired values of the data modification timestamp.
+ */
+ __wasi_timestamp_t mtim,
+ /**
+ * A bitmask indicating which timestamps to adjust.
+ */
+ __wasi_fstflags_t fst_flags
+) __attribute__((__warn_unused_result__));
+/**
+ * Read from a file descriptor, without using and updating the file descriptor's offset.
+ * Note: This is similar to `preadv` in POSIX.
+ * @return
+ * The number of bytes read.
+ */
+__wasi_errno_t __wasi_fd_pread(
+ __wasi_fd_t fd,
+ /**
+ * List of scatter/gather vectors in which to store data.
+ */
+ const __wasi_iovec_t *iovs,
+ /**
+ * The length of the array pointed to by `iovs`.
+ */
+ size_t iovs_len,
+ /**
+ * The offset within the file at which to read.
+ */
+ __wasi_filesize_t offset,
+ __wasi_size_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Return a description of the given preopened file descriptor.
+ * @return
+ * The buffer where the description is stored.
+ */
+__wasi_errno_t __wasi_fd_prestat_get(
+ __wasi_fd_t fd,
+ __wasi_prestat_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Return a description of the given preopened file descriptor.
+ */
+__wasi_errno_t __wasi_fd_prestat_dir_name(
+ __wasi_fd_t fd,
+ /**
+ * A buffer into which to write the preopened directory name.
+ */
+ uint8_t * path,
+ __wasi_size_t path_len
+) __attribute__((__warn_unused_result__));
+/**
+ * Write to a file descriptor, without using and updating the file descriptor's offset.
+ * Note: This is similar to `pwritev` in POSIX.
+ * @return
+ * The number of bytes written.
+ */
+__wasi_errno_t __wasi_fd_pwrite(
+ __wasi_fd_t fd,
+ /**
+ * List of scatter/gather vectors from which to retrieve data.
+ */
+ const __wasi_ciovec_t *iovs,
+ /**
+ * The length of the array pointed to by `iovs`.
+ */
+ size_t iovs_len,
+ /**
+ * The offset within the file at which to write.
+ */
+ __wasi_filesize_t offset,
+ __wasi_size_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Read from a file descriptor.
+ * Note: This is similar to `readv` in POSIX.
+ * @return
+ * The number of bytes read.
+ */
+__wasi_errno_t __wasi_fd_read(
+ __wasi_fd_t fd,
+ /**
+ * List of scatter/gather vectors to which to store data.
+ */
+ const __wasi_iovec_t *iovs,
+ /**
+ * The length of the array pointed to by `iovs`.
+ */
+ size_t iovs_len,
+ __wasi_size_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Read directory entries from a directory.
+ * When successful, the contents of the output buffer consist of a sequence of
+ * directory entries. Each directory entry consists of a `dirent` object,
+ * followed by `dirent::d_namlen` bytes holding the name of the directory
+ * entry.
+ * This function fills the output buffer as much as possible, potentially
+ * truncating the last directory entry. This allows the caller to grow its
+ * read buffer size in case it's too small to fit a single large directory
+ * entry, or skip the oversized directory entry.
+ * @return
+ * 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.
+ */
+__wasi_errno_t __wasi_fd_readdir(
+ __wasi_fd_t fd,
+ /**
+ * The buffer where directory entries are stored
+ */
+ uint8_t * buf,
+ __wasi_size_t buf_len,
+ /**
+ * The location within the directory to start reading
+ */
+ __wasi_dircookie_t cookie,
+ __wasi_size_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Atomically replace a file descriptor by renumbering another file descriptor.
+ * Due to the strong focus on thread safety, this environment does not provide
+ * a mechanism to duplicate or renumber a file descriptor to an arbitrary
+ * number, like `dup2()`. This would be prone to race conditions, as an actual
+ * file descriptor with the same number could be allocated by a different
+ * thread at the same time.
+ * This function provides a way to atomically renumber file descriptors, which
+ * would disappear if `dup2()` were to be removed entirely.
+ */
+__wasi_errno_t __wasi_fd_renumber(
+ __wasi_fd_t fd,
+ /**
+ * The file descriptor to overwrite.
+ */
+ __wasi_fd_t to
+) __attribute__((__warn_unused_result__));
+/**
+ * Move the offset of a file descriptor.
+ * Note: This is similar to `lseek` in POSIX.
+ * @return
+ * The new offset of the file descriptor, relative to the start of the file.
+ */
+__wasi_errno_t __wasi_fd_seek(
+ __wasi_fd_t fd,
+ /**
+ * The number of bytes to move.
+ */
+ __wasi_filedelta_t offset,
+ /**
+ * The base from which the offset is relative.
+ */
+ __wasi_whence_t whence,
+ __wasi_filesize_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Synchronize the data and metadata of a file to disk.
+ * Note: This is similar to `fsync` in POSIX.
+ */
+__wasi_errno_t __wasi_fd_sync(
+ __wasi_fd_t fd
+) __attribute__((__warn_unused_result__));
+/**
+ * Return the current offset of a file descriptor.
+ * Note: This is similar to `lseek(fd, 0, SEEK_CUR)` in POSIX.
+ * @return
+ * The current offset of the file descriptor, relative to the start of the file.
+ */
+__wasi_errno_t __wasi_fd_tell(
+ __wasi_fd_t fd,
+ __wasi_filesize_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Write to a file descriptor.
+ * Note: This is similar to `writev` in POSIX.
+ */
+__wasi_errno_t __wasi_fd_write(
+ __wasi_fd_t fd,
+ /**
+ * List of scatter/gather vectors from which to retrieve data.
+ */
+ const __wasi_ciovec_t *iovs,
+ /**
+ * The length of the array pointed to by `iovs`.
+ */
+ size_t iovs_len,
+ __wasi_size_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Create a directory.
+ * Note: This is similar to `mkdirat` in POSIX.
+ */
+__wasi_errno_t __wasi_path_create_directory(
+ __wasi_fd_t fd,
+ /**
+ * The path at which to create the directory.
+ */
+ const char *path
+) __attribute__((__warn_unused_result__));
+/**
+ * Return the attributes of a file or directory.
+ * Note: This is similar to `stat` in POSIX.
+ * @return
+ * The buffer where the file's attributes are stored.
+ */
+__wasi_errno_t __wasi_path_filestat_get(
+ __wasi_fd_t fd,
+ /**
+ * Flags determining the method of how the path is resolved.
+ */
+ __wasi_lookupflags_t flags,
+ /**
+ * The path of the file or directory to inspect.
+ */
+ const char *path,
+ __wasi_filestat_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Adjust the timestamps of a file or directory.
+ * Note: This is similar to `utimensat` in POSIX.
+ */
+__wasi_errno_t __wasi_path_filestat_set_times(
+ __wasi_fd_t fd,
+ /**
+ * Flags determining the method of how the path is resolved.
+ */
+ __wasi_lookupflags_t flags,
+ /**
+ * The path of the file or directory to operate on.
+ */
+ const char *path,
+ /**
+ * The desired values of the data access timestamp.
+ */
+ __wasi_timestamp_t atim,
+ /**
+ * The desired values of the data modification timestamp.
+ */
+ __wasi_timestamp_t mtim,
+ /**
+ * A bitmask indicating which timestamps to adjust.
+ */
+ __wasi_fstflags_t fst_flags
+) __attribute__((__warn_unused_result__));
+/**
+ * Create a hard link.
+ * Note: This is similar to `linkat` in POSIX.
+ */
+__wasi_errno_t __wasi_path_link(
+ __wasi_fd_t old_fd,
+ /**
+ * Flags determining the method of how the path is resolved.
+ */
+ __wasi_lookupflags_t old_flags,
+ /**
+ * The source path from which to link.
+ */
+ const char *old_path,
+ /**
+ * The working directory at which the resolution of the new path starts.
+ */
+ __wasi_fd_t new_fd,
+ /**
+ * The destination path at which to create the hard link.
+ */
+ const char *new_path
+) __attribute__((__warn_unused_result__));
+/**
+ * Open a file or directory.
+ * The returned file descriptor is not guaranteed to be the lowest-numbered
+ * file descriptor not currently open; it is randomized to prevent
+ * applications from depending on making assumptions about indexes, since this
+ * is error-prone in multi-threaded contexts. The returned file descriptor is
+ * guaranteed to be less than 2**31.
+ * Note: This is similar to `openat` in POSIX.
+ * @return
+ * The file descriptor of the file that has been opened.
+ */
+__wasi_errno_t __wasi_path_open(
+ __wasi_fd_t fd,
+ /**
+ * Flags determining the method of how the path is resolved.
+ */
+ __wasi_lookupflags_t dirflags,
+ /**
+ * The relative path of the file or directory to open, relative to the
+ * `path_open::fd` directory.
+ */
+ const char *path,
+ /**
+ * The method by which to open the file.
+ */
+ __wasi_oflags_t oflags,
+ /**
+ * The initial rights of the newly created file descriptor. The
+ * implementation is allowed to return a file descriptor with fewer rights
+ * than specified, if and only if those rights do not apply to the type of
+ * file being opened.
+ * The *base* rights are rights that will apply to operations using the file
+ * descriptor itself, while the *inheriting* rights are rights that apply to
+ * file descriptors derived from it.
+ */
+ __wasi_rights_t fs_rights_base,
+ __wasi_rights_t fs_rights_inheriting,
+ __wasi_fdflags_t fdflags,
+ __wasi_fd_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Read the contents of a symbolic link.
+ * Note: This is similar to `readlinkat` in POSIX.
+ * @return
+ * The number of bytes placed in the buffer.
+ */
+__wasi_errno_t __wasi_path_readlink(
+ __wasi_fd_t fd,
+ /**
+ * The path of the symbolic link from which to read.
+ */
+ const char *path,
+ /**
+ * The buffer to which to write the contents of the symbolic link.
+ */
+ uint8_t * buf,
+ __wasi_size_t buf_len,
+ __wasi_size_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Remove a directory.
+ * Return `errno::notempty` if the directory is not empty.
+ * Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.
+ */
+__wasi_errno_t __wasi_path_remove_directory(
+ __wasi_fd_t fd,
+ /**
+ * The path to a directory to remove.
+ */
+ const char *path
+) __attribute__((__warn_unused_result__));
+/**
+ * Rename a file or directory.
+ * Note: This is similar to `renameat` in POSIX.
+ */
+__wasi_errno_t __wasi_path_rename(
+ __wasi_fd_t fd,
+ /**
+ * The source path of the file or directory to rename.
+ */
+ const char *old_path,
+ /**
+ * The working directory at which the resolution of the new path starts.
+ */
+ __wasi_fd_t new_fd,
+ /**
+ * The destination path to which to rename the file or directory.
+ */
+ const char *new_path
+) __attribute__((__warn_unused_result__));
+/**
+ * Create a symbolic link.
+ * Note: This is similar to `symlinkat` in POSIX.
+ */
+__wasi_errno_t __wasi_path_symlink(
+ /**
+ * The contents of the symbolic link.
+ */
+ const char *old_path,
+ __wasi_fd_t fd,
+ /**
+ * The destination path at which to create the symbolic link.
+ */
+ const char *new_path
+) __attribute__((__warn_unused_result__));
+/**
+ * Unlink a file.
+ * Return `errno::isdir` if the path refers to a directory.
+ * Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.
+ */
+__wasi_errno_t __wasi_path_unlink_file(
+ __wasi_fd_t fd,
+ /**
+ * The path to a file to unlink.
+ */
+ const char *path
+) __attribute__((__warn_unused_result__));
+/**
+ * Concurrently poll for the occurrence of a set of events.
+ * @return
+ * The number of events stored.
+ */
+__wasi_errno_t __wasi_poll_oneoff(
+ /**
+ * The events to which to subscribe.
+ */
+ const __wasi_subscription_t * in,
+ /**
+ * The events that have occurred.
+ */
+ __wasi_event_t * out,
+ /**
+ * Both the number of subscriptions and events.
+ */
+ __wasi_size_t nsubscriptions,
+ __wasi_size_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Terminate the process normally. An exit code of 0 indicates successful
+ * termination of the program. The meanings of other values is dependent on
+ * the environment.
+ */
+_Noreturn void __wasi_proc_exit(
+ /**
+ * The exit code returned by the process.
+ */
+ __wasi_exitcode_t rval
+);
+/**
+ * Temporarily yield execution of the calling thread.
+ * Note: This is similar to `sched_yield` in POSIX.
+ */
+__wasi_errno_t __wasi_sched_yield(
+ void
+) __attribute__((__warn_unused_result__));
+/**
+ * Write high-quality random data into a buffer.
+ * This function blocks when the implementation is unable to immediately
+ * provide sufficient high-quality random data.
+ * This function may execute slowly, so when large mounts of random data are
+ * required, it's advisable to use this function to seed a pseudo-random
+ * number generator, rather than to provide the random data directly.
+ */
+__wasi_errno_t __wasi_random_get(
+ /**
+ * The buffer to fill with random data.
+ */
+ uint8_t * buf,
+ __wasi_size_t buf_len
+) __attribute__((__warn_unused_result__));
+/**
+ * Accept a new incoming connection.
+ * Note: This is similar to `accept` in POSIX.
+ * @return
+ * New socket connection
+ */
+__wasi_errno_t __wasi_sock_accept(
+ /**
+ * The listening socket.
+ */
+ __wasi_fd_t fd,
+ /**
+ * The desired values of the file descriptor flags.
+ */
+ __wasi_fdflags_t flags,
+ __wasi_fd_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Receive a message from a socket.
+ * Note: This is similar to `recv` in POSIX, though it also supports reading
+ * the data into multiple buffers in the manner of `readv`.
+ * @return
+ * Number of bytes stored in ri_data and message flags.
+ */
+__wasi_errno_t __wasi_sock_recv(
+ __wasi_fd_t fd,
+ /**
+ * List of scatter/gather vectors to which to store data.
+ */
+ const __wasi_iovec_t *ri_data,
+ /**
+ * The length of the array pointed to by `ri_data`.
+ */
+ size_t ri_data_len,
+ /**
+ * Message flags.
+ */
+ __wasi_riflags_t ri_flags,
+ __wasi_size_t *retptr0,
+ __wasi_roflags_t *retptr1
+) __attribute__((__warn_unused_result__));
+/**
+ * Send a message on a socket.
+ * Note: This is similar to `send` in POSIX, though it also supports writing
+ * the data from multiple buffers in the manner of `writev`.
+ * @return
+ * Number of bytes transmitted.
+ */
+__wasi_errno_t __wasi_sock_send(
+ __wasi_fd_t fd,
+ /**
+ * List of scatter/gather vectors to which to retrieve data
+ */
+ const __wasi_ciovec_t *si_data,
+ /**
+ * The length of the array pointed to by `si_data`.
+ */
+ size_t si_data_len,
+ /**
+ * Message flags.
+ */
+ __wasi_siflags_t si_flags,
+ __wasi_size_t *retptr0
+) __attribute__((__warn_unused_result__));
+/**
+ * Shut down socket send and receive channels.
+ * Note: This is similar to `shutdown` in POSIX.
+ */
+__wasi_errno_t __wasi_sock_shutdown(
+ __wasi_fd_t fd,
+ /**
+ * Which channels on the socket to shut down.
+ */
+ __wasi_sdflags_t how
+) __attribute__((__warn_unused_result__));
+/** @} */
+
+#ifdef _REENTRANT
+/**
+ * Request a new thread to be created by the host.
+ *
+ * The host will create a new instance of the current module sharing its
+ * memory, find an exported entry function--`wasi_thread_start`--, and call the
+ * entry function with `start_arg` in the new thread.
+ *
+ * @see https://github.com/WebAssembly/wasi-threads/#readme
+ */
+__wasi_errno_t __wasi_thread_spawn(
+ /**
+ * A pointer to an opaque struct to be passed to the module's entry
+ * function.
+ */
+ void *start_arg
+) __attribute__((__warn_unused_result__));
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/wasi/libc-environ.h b/libc-bottom-half/headers/public/wasi/libc-environ.h
new file mode 100644
index 0000000..f84ba8e
--- /dev/null
+++ b/libc-bottom-half/headers/public/wasi/libc-environ.h
@@ -0,0 +1,36 @@
+#ifndef __wasi_libc_environ_h
+#define __wasi_libc_environ_h
+
+/// This header file is a WASI-libc-specific interface, and is not needed by
+/// most programs. Most programs should just use the standard `getenv` and
+/// related APIs, which take care of all of the details automatically.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/// Initialize the global environment variable state. Only needs to be
+/// called once; most users should call `__wasilibc_ensure_environ` instead.
+void __wasilibc_initialize_environ(void);
+
+/// If `__wasilibc_initialize_environ` has not yet been called, call it.
+void __wasilibc_ensure_environ(void);
+
+/// De-initialize the global environment variable state, so that subsequent
+/// calls to `__wasilibc_ensure_environ` call `__wasilibc_initialize_environ`.
+void __wasilibc_deinitialize_environ(void);
+
+/// Call `__wasilibc_initialize_environ` only if `environ` and `_environ` are
+/// referenced in the program.
+void __wasilibc_maybe_reinitialize_environ_eagerly(void);
+
+/// Return the value of the `environ` variable. Using `environ` directly
+/// requires eager initialization of the environment variables. Using this
+/// function instead of `environ` allows initialization to happen lazily.
+char **__wasilibc_get_environ(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/wasi/libc-find-relpath.h b/libc-bottom-half/headers/public/wasi/libc-find-relpath.h
new file mode 100644
index 0000000..32dbb03
--- /dev/null
+++ b/libc-bottom-half/headers/public/wasi/libc-find-relpath.h
@@ -0,0 +1,79 @@
+#ifndef __wasi_libc_find_relpath_h
+#define __wasi_libc_find_relpath_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Look up the given `path`, relative to the cwd, in the preopened directory
+ * map. If a suitable entry is found, then the file descriptor for that entry
+ * is returned. Additionally the absolute path of the directory's file
+ * descriptor is returned in `abs_prefix` and the relative portion that needs
+ * to be opened is stored in `*relative_path`.
+ *
+ * The `relative_path` argument must be a pointer to a buffer valid for
+ * `relative_path_len` bytes, and this may be used as storage for the relative
+ * portion of the path being returned through `*relative_path`.
+ *
+ * See documentation on `__wasilibc_find_abspath` for more info about what the
+ * paths look like.
+ *
+ * Returns -1 on failure. Errno is set to either:
+ *
+ * * ENOMEM - failed to allocate memory for internal routines.
+ * * ENOENT - the `path` could not be found relative to any preopened dir.
+ * * ERANGE - the `relative_path` buffer is too small to hold the relative path.
+ */
+int __wasilibc_find_relpath(const char *path,
+ const char **__restrict__ abs_prefix,
+ char **relative_path,
+ size_t relative_path_len);
+
+/**
+ * Look up the given `path`, which is interpreted as absolute, in the preopened
+ * directory map. If a suitable entry is found, then the file descriptor for
+ * that entry is returned. Additionally the relative portion of the path to
+ * where the fd is opened is returned through `relative_path`, the absolute
+ * prefix which was matched is stored to `abs_prefix`, and `relative_path` may
+ * be an interior pointer to the `abspath` string.
+ *
+ * The `abs_prefix` returned string will not contain a leading `/`. Note that
+ * this may be the empty string. Additionally the returned `relative_path` will
+ * not contain a leading `/`. The `relative_path` return will not return an
+ * empty string, it will return `"."` instead if it would otherwise do so.
+ *
+ * Returns -1 on failure. Errno is set to either:
+ *
+ * * ENOMEM - failed to allocate memory for internal routines.
+ * * ENOENT - the `path` could not be found relative to any preopened dir.
+ */
+int __wasilibc_find_abspath(const char *abspath,
+ const char **__restrict__ abs_prefix,
+ const char **__restrict__ relative_path);
+
+/**
+ * Same as `__wasilibc_find_relpath`, except that this function will interpret
+ * `relative` as a malloc'd buffer that will be `realloc`'d to the appropriate
+ * size to contain the relative path.
+ *
+ * Note that this is a weak symbol and if it's not defined you can use
+ * `__wasilibc_find_relpath`. The weak-nature of this symbols means that if it's
+ * not otherwise included in the compilation then `chdir` wasn't used an there's
+ * no need for this symbol.
+ *
+ * See documentation on `__wasilibc_find_relpath` for more information.
+ */
+int __wasilibc_find_relpath_alloc(
+ const char *path,
+ const char **abs,
+ char **relative,
+ size_t *relative_len,
+ int can_realloc
+) __attribute__((__weak__));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/wasi/libc-nocwd.h b/libc-bottom-half/headers/public/wasi/libc-nocwd.h
new file mode 100644
index 0000000..a988503
--- /dev/null
+++ b/libc-bottom-half/headers/public/wasi/libc-nocwd.h
@@ -0,0 +1,58 @@
+#ifndef __wasi_libc_nocwd_h
+#define __wasi_libc_nocwd_h
+
+/*
+ * In order to support AT_FDCWD, we need to wrap the *at functions to handle
+ * it by calling back into the non-at versions which perform libpreopen
+ * queries. These __wasilibc_nocwd_* forms are the underlying calls which
+ * assume AT_FDCWD has already been resolved.
+ */
+
+#define __need_size_t
+#include <stddef.h>
+#include <__typedef_ssize_t.h>
+#include <__typedef_mode_t.h>
+#include <__typedef_DIR.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct timespec;
+struct stat;
+struct dirent;
+
+int __wasilibc_nocwd___wasilibc_unlinkat(int, const char *)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_nocwd___wasilibc_rmdirat(int, const char *)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_nocwd_linkat(int, const char *, int, const char *, int)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_nocwd_symlinkat(const char *, int, const char *)
+ __attribute__((__warn_unused_result__));
+ssize_t __wasilibc_nocwd_readlinkat(int, const char *__restrict, char *__restrict, size_t)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_nocwd_faccessat(int, const char *, int, int)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_nocwd_renameat(int, const char *, int, const char *)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_nocwd_openat_nomode(int, const char *, int)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_nocwd_fstatat(int, const char *__restrict, struct stat *__restrict, int)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_nocwd_mkdirat_nomode(int, const char *)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_nocwd_utimensat(int, const char *, const struct timespec [2], int)
+ __attribute__((__warn_unused_result__));
+DIR *__wasilibc_nocwd_opendirat(int, const char *)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_nocwd_scandirat(int, const char *, struct dirent ***,
+ int (*)(const struct dirent *),
+ int (*)(const struct dirent **, const struct dirent **))
+ __attribute__((__warn_unused_result__));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/wasi/libc.h b/libc-bottom-half/headers/public/wasi/libc.h
new file mode 100644
index 0000000..b50518b
--- /dev/null
+++ b/libc-bottom-half/headers/public/wasi/libc.h
@@ -0,0 +1,65 @@
+#ifndef __wasi_libc_h
+#define __wasi_libc_h
+
+#include <__typedef_off_t.h>
+#include <__struct_timespec.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct stat;
+struct timespec;
+
+/// Register the given pre-opened file descriptor under the given path.
+///
+/// This function does not take ownership of `prefix` (it makes its own copy).
+int __wasilibc_register_preopened_fd(int fd, const char *prefix);
+
+/// Renumber `fd` to `newfd`; similar to `dup2` but does a move rather than a
+/// copy.
+int __wasilibc_fd_renumber(int fd, int newfd)
+ __attribute__((__warn_unused_result__));
+
+/// Like `unlinkat`, but without depending on `__wasi_path_remove_directory`.
+int __wasilibc_unlinkat(int fd, const char *path)
+ __attribute__((__warn_unused_result__));
+
+/// An `*at` version of rmdir.
+int __wasilibc_rmdirat(int fd, const char *path)
+ __attribute__((__warn_unused_result__));
+
+/// Like `open`, but without the varargs in the signature.
+int __wasilibc_open_nomode(const char *path, int oflag);
+
+/// Like `openat`, but without the varargs in the signature.
+int __wasilibc_openat_nomode(int fd, const char *path, int oflag);
+
+/// Return the current file offset. Like `lseek(fd, 0, SEEK_CUR)`, but without
+/// depending on `lseek`.
+off_t __wasilibc_tell(int fd)
+ __attribute__((__warn_unused_result__));
+
+/* Non-`at` forms of various `*at` functions. */
+int __wasilibc_access(const char *pathname, int mode, int flags)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_stat(const char *__restrict pathname, struct stat *__restrict statbuf, int flags)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_utimens(const char *pathname, const struct timespec times[2], int flags)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_link(const char *oldpath, const char *newpath, int flags)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_link_oldat(int olddirfd, const char *oldpath, const char *newpath, int flags)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_link_newat(const char *oldpath, int newdirfd, const char *newpath, int flags)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_rename_oldat(int olddirfd, const char *oldpath, const char *newpath)
+ __attribute__((__warn_unused_result__));
+int __wasilibc_rename_newat(const char *oldpath, int newdirfd, const char *newpath)
+ __attribute__((__warn_unused_result__));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libc-bottom-half/headers/public/wchar.h b/libc-bottom-half/headers/public/wchar.h
new file mode 100644
index 0000000..f43d72f
--- /dev/null
+++ b/libc-bottom-half/headers/public/wchar.h
@@ -0,0 +1,9 @@
+#ifndef __wasilibc_wchar_h
+#define __wasilibc_wchar_h
+
+#define __need_size_t
+#define __need_wchar_t
+#define __need_NULL
+#include <stddef.h>
+
+#endif