From 3f4c43b0aac48903b52c7d44b3f89f83064c7d19 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 11 Apr 2024 15:50:05 +0200 Subject: [PATCH 1/3] Update wasi-libc to d03829489904d38c624f6de9983190f1e5e7c9c5 --- lib/libc/include/wasm-wasi-musl/__errno.h | 5 - .../include/wasm-wasi-musl/__header_dirent.h | 13 +- .../wasm-wasi-musl/__header_sys_socket.h | 46 +- lib/libc/include/wasm-wasi-musl/__mode_t.h | 2 +- .../wasm-wasi-musl/__struct_sockaddr.h | 3 - .../wasm-wasi-musl/__struct_sockaddr_in.h | 5 +- .../wasm-wasi-musl/__struct_sockaddr_in6.h | 5 +- .../__struct_sockaddr_storage.h | 5 +- .../wasm-wasi-musl/__struct_sockaddr_un.h | 5 +- .../include/wasm-wasi-musl/__wasi_snapshot.h | 0 lib/libc/include/wasm-wasi-musl/bits/setjmp.h | 1 + lib/libc/include/wasm-wasi-musl/setjmp.h | 55 + lib/libc/include/wasm-wasi-musl/stdlib.h | 2 - lib/libc/include/wasm-wasi-musl/sys/socket.h | 18 +- lib/libc/include/wasm-wasi-musl/sys/stat.h | 2 - lib/libc/include/wasm-wasi-musl/sys/statvfs.h | 56 + lib/libc/include/wasm-wasi-musl/unistd.h | 2 + lib/libc/include/wasm-wasi-musl/wasi/libc.h | 6 + lib/libc/wasi/emmalloc/emmalloc.c | 15 +- .../cloudlibc/src/libc/poll/poll.c | 47 +- .../cloudlibc/src/libc/sys/ioctl/ioctl.c | 57 +- .../cloudlibc/src/libc/sys/select/pselect.c | 102 +- .../cloudlibc/src/libc/unistd/close.c | 16 - .../wasi/libc-bottom-half/crt/crt1-command.c | 6 +- .../headers/private/wasi/descriptor_table.h | 127 + .../headers/private/wasi/sockets_utils.h | 53 + .../wasi/libc-bottom-half/signal/signal.c | 4 +- .../libc-bottom-half/sources/__main_void.c | 10 + .../sources/__wasilibc_fd_renumber.c | 94 + .../sources/{accept.c => accept-wasip1.c} | 0 .../wasi/libc-bottom-half/sources/posix.c | 41 + .../wasi/libc-bottom-half/sources/preopens.c | 48 - lib/libc/wasi/libc-top-half/musl/.mailmap | 1 - .../musl/arch/wasm32/bits/setjmp.h | 1 + .../wasi/libc-top-half/musl/include/aio.h | 73 - .../libc-top-half/musl/include/alltypes.h.in | 118 - .../wasi/libc-top-half/musl/include/dlfcn.h | 12 +- .../wasi/libc-top-half/musl/include/elf.h | 3296 ----------------- .../wasi/libc-top-half/musl/include/grp.h | 53 - .../wasi/libc-top-half/musl/include/lastlog.h | 1 - .../wasi/libc-top-half/musl/include/libintl.h | 33 - .../wasi/libc-top-half/musl/include/link.h | 53 - .../wasi/libc-top-half/musl/include/mntent.h | 43 - .../libc-top-half/musl/include/net/ethernet.h | 55 - .../wasi/libc-top-half/musl/include/net/if.h | 141 - .../libc-top-half/musl/include/net/if_arp.h | 142 - .../libc-top-half/musl/include/net/route.h | 124 - .../wasi/libc-top-half/musl/include/netdb.h | 156 - .../musl/include/netinet/ether.h | 22 - .../musl/include/netinet/if_ether.h | 149 - .../wasi/libc-top-half/musl/include/paths.h | 31 - .../wasi/libc-top-half/musl/include/pthread.h | 250 -- .../wasi/libc-top-half/musl/include/pty.h | 18 - .../wasi/libc-top-half/musl/include/pwd.h | 50 - .../wasi/libc-top-half/musl/include/resolv.h | 142 - .../libc-top-half/musl/include/scsi/scsi.h | 150 - .../musl/include/scsi/scsi_ioctl.h | 11 - .../wasi/libc-top-half/musl/include/scsi/sg.h | 129 - .../wasi/libc-top-half/musl/include/setjmp.h | 10 +- .../wasi/libc-top-half/musl/include/shadow.h | 44 - .../wasi/libc-top-half/musl/include/spawn.h | 83 - .../wasi/libc-top-half/musl/include/stdarg.h | 21 - .../wasi/libc-top-half/musl/include/stddef.h | 27 - .../wasi/libc-top-half/musl/include/stdlib.h | 2 - .../libc-top-half/musl/include/sys/acct.h | 72 - .../libc-top-half/musl/include/sys/auxv.h | 17 - .../libc-top-half/musl/include/sys/cachectl.h | 22 - .../libc-top-half/musl/include/sys/epoll.h | 69 - .../libc-top-half/musl/include/sys/fanotify.h | 111 - .../libc-top-half/musl/include/sys/fsuid.h | 20 - .../libc-top-half/musl/include/sys/inotify.h | 58 - .../wasi/libc-top-half/musl/include/sys/io.h | 17 - .../wasi/libc-top-half/musl/include/sys/ipc.h | 42 - .../wasi/libc-top-half/musl/include/sys/kd.h | 1 - .../libc-top-half/musl/include/sys/klog.h | 14 - .../musl/include/sys/membarrier.h | 21 - .../libc-top-half/musl/include/sys/mount.h | 75 - .../wasi/libc-top-half/musl/include/sys/msg.h | 53 - .../libc-top-half/musl/include/sys/mtio.h | 188 - .../musl/include/sys/personality.h | 49 - .../libc-top-half/musl/include/sys/prctl.h | 186 - .../libc-top-half/musl/include/sys/procfs.h | 63 - .../libc-top-half/musl/include/sys/ptrace.h | 147 - .../libc-top-half/musl/include/sys/quota.h | 102 - .../libc-top-half/musl/include/sys/reboot.h | 20 - .../wasi/libc-top-half/musl/include/sys/sem.h | 72 - .../libc-top-half/musl/include/sys/sendfile.h | 22 - .../wasi/libc-top-half/musl/include/sys/shm.h | 70 - .../libc-top-half/musl/include/sys/signalfd.h | 49 - .../libc-top-half/musl/include/sys/socket.h | 18 +- .../musl/include/sys/soundcard.h | 1 - .../libc-top-half/musl/include/sys/stat.h | 2 - .../libc-top-half/musl/include/sys/statfs.h | 32 - .../libc-top-half/musl/include/sys/swap.h | 21 - .../libc-top-half/musl/include/sys/syslog.h | 1 - .../musl/include/sys/sysmacros.h | 15 - .../libc-top-half/musl/include/sys/termios.h | 2 - .../libc-top-half/musl/include/sys/timerfd.h | 32 - .../libc-top-half/musl/include/sys/ucontext.h | 1 - .../libc-top-half/musl/include/sys/user.h | 16 - .../wasi/libc-top-half/musl/include/sys/vfs.h | 1 - .../wasi/libc-top-half/musl/include/sys/vt.h | 1 - .../libc-top-half/musl/include/sys/wait.h | 67 - .../libc-top-half/musl/include/sys/xattr.h | 32 - .../wasi/libc-top-half/musl/include/syslog.h | 100 - .../wasi/libc-top-half/musl/include/termios.h | 50 - .../libc-top-half/musl/include/ucontext.h | 25 - .../wasi/libc-top-half/musl/include/ulimit.h | 17 - .../wasi/libc-top-half/musl/include/utmp.h | 52 - .../wasi/libc-top-half/musl/include/utmpx.h | 67 - .../wasi/libc-top-half/musl/include/wait.h | 2 - .../wasi/libc-top-half/musl/include/wordexp.h | 41 - .../libc-top-half/musl/src/include/pthread.h | 31 - .../libc-top-half/musl/src/include/resolv.h | 12 - .../libc-top-half/musl/src/include/sys/auxv.h | 10 - .../musl/src/include/sys/membarrier.h | 9 - .../musl/src/internal/locale_impl.h | 8 + .../wasi/libc-top-half/musl/src/ipc/ipc.h | 24 - .../musl/src/malloc/mallocng/glue.h | 93 - .../musl/src/malloc/mallocng/meta.h | 288 -- .../musl/src/malloc/oldmalloc/malloc_impl.h | 39 - .../libc-top-half/musl/src/misc/realpath.c | 156 + .../wasi/libc-top-half/musl/src/passwd/nscd.h | 44 - .../wasi/libc-top-half/musl/src/passwd/pwf.h | 15 - .../libc-top-half/musl/src/process/fdop.h | 17 - src/wasi_libc.zig | 3 +- 126 files changed, 863 insertions(+), 8334 deletions(-) create mode 100644 lib/libc/include/wasm-wasi-musl/__wasi_snapshot.h create mode 100644 lib/libc/include/wasm-wasi-musl/bits/setjmp.h create mode 100644 lib/libc/include/wasm-wasi-musl/setjmp.h create mode 100644 lib/libc/include/wasm-wasi-musl/sys/statvfs.h create mode 100644 lib/libc/wasi/libc-bottom-half/headers/private/wasi/descriptor_table.h create mode 100644 lib/libc/wasi/libc-bottom-half/headers/private/wasi/sockets_utils.h rename lib/libc/wasi/libc-bottom-half/sources/{accept.c => accept-wasip1.c} (100%) delete mode 100644 lib/libc/wasi/libc-top-half/musl/.mailmap create mode 100644 lib/libc/wasi/libc-top-half/musl/arch/wasm32/bits/setjmp.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/aio.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/alltypes.h.in delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/elf.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/grp.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/lastlog.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/libintl.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/link.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/mntent.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/net/ethernet.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/net/if.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/net/if_arp.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/net/route.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/netdb.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/netinet/ether.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/netinet/if_ether.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/paths.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/pthread.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/pty.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/pwd.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/resolv.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/scsi/scsi.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/scsi/scsi_ioctl.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/scsi/sg.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/shadow.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/spawn.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/stdarg.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/stddef.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/acct.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/auxv.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/cachectl.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/epoll.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/fanotify.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/fsuid.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/inotify.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/io.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/ipc.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/kd.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/klog.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/membarrier.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/mount.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/msg.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/mtio.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/personality.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/prctl.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/procfs.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/ptrace.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/quota.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/reboot.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/sem.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/sendfile.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/shm.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/signalfd.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/soundcard.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/statfs.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/swap.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/syslog.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/sysmacros.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/termios.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/timerfd.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/ucontext.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/user.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/vfs.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/vt.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/wait.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/sys/xattr.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/syslog.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/termios.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/ucontext.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/ulimit.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/utmp.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/utmpx.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/wait.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/include/wordexp.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/src/include/pthread.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/src/include/resolv.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/src/include/sys/auxv.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/src/include/sys/membarrier.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/src/ipc/ipc.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/glue.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/meta.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc_impl.h create mode 100644 lib/libc/wasi/libc-top-half/musl/src/misc/realpath.c delete mode 100644 lib/libc/wasi/libc-top-half/musl/src/passwd/nscd.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/src/passwd/pwf.h delete mode 100644 lib/libc/wasi/libc-top-half/musl/src/process/fdop.h diff --git a/lib/libc/include/wasm-wasi-musl/__errno.h b/lib/libc/include/wasm-wasi-musl/__errno.h index 4fd983ad7c44..008245d9788e 100644 --- a/lib/libc/include/wasm-wasi-musl/__errno.h +++ b/lib/libc/include/wasm-wasi-musl/__errno.h @@ -5,16 +5,11 @@ 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/lib/libc/include/wasm-wasi-musl/__header_dirent.h b/lib/libc/include/wasm-wasi-musl/__header_dirent.h index ccf3deffd9e6..027fc07a9945 100644 --- a/lib/libc/include/wasm-wasi-musl/__header_dirent.h +++ b/lib/libc/include/wasm-wasi-musl/__header_dirent.h @@ -11,12 +11,16 @@ #define DT_REG __WASI_FILETYPE_REGULAR_FILE #define DT_UNKNOWN __WASI_FILETYPE_UNKNOWN +// DT_SOCK is not supported in WASI Preview 1 (but will be in Preview 2). We +// define it regardless so that libc++'s `` implementation builds. +// The exact value is mostly arbitrary, but chosen so it doesn't conflict with +// any of the existing `__WASI_FILETYPE_*` flags. We do not expect any new +// flags to be added to WASI Preview 1, so that should be sufficient. +#define DT_SOCK 20 + #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> @@ -24,6 +28,9 @@ int __wasilibc_dttoif(int x); extern "C" { #endif +int __wasilibc_iftodt(int x); +int __wasilibc_dttoif(int x); + int closedir(DIR *); DIR *opendir(const char *); DIR *fdopendir(int); diff --git a/lib/libc/include/wasm-wasi-musl/__header_sys_socket.h b/lib/libc/include/wasm-wasi-musl/__header_sys_socket.h index 9fa8684f830e..fa98ccac2943 100644 --- a/lib/libc/include/wasm-wasi-musl/__header_sys_socket.h +++ b/lib/libc/include/wasm-wasi-musl/__header_sys_socket.h @@ -1,6 +1,7 @@ #ifndef __wasilibc___header_sys_socket_h #define __wasilibc___header_sys_socket_h +#include <__wasi_snapshot.h> #include <__struct_msghdr.h> #include <__struct_sockaddr.h> #include <__struct_sockaddr_storage.h> @@ -11,9 +12,42 @@ #define SHUT_WR __WASI_SDFLAGS_WR #define SHUT_RDWR (SHUT_RD | SHUT_WR) +#ifdef __wasilibc_use_wasip2 +#define MSG_DONTWAIT 0x0040 +#define MSG_NOSIGNAL 0x4000 +#define MSG_PEEK 0x0002 +#define MSG_WAITALL 0x0100 +#define MSG_TRUNC 0x0020 + +#define SOL_IP 0 +#define SOL_TCP 6 +#define SOL_UDP 17 +#define SOL_IPV6 41 + +#define SOMAXCONN 128 + +#define SO_REUSEADDR 2 +#define SO_ERROR 4 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_KEEPALIVE 9 +#define SO_ACCEPTCONN 30 +#define SO_PROTOCOL 38 +#define SO_DOMAIN 39 + +#if __LONG_MAX == 0x7fffffff +#define SO_RCVTIMEO 66 +#define SO_SNDTIMEO 67 +#else +#define SO_RCVTIMEO 20 +#define SO_SNDTIMEO 21 +#endif + +#else // __wasilibc_use_wasip2 #define MSG_PEEK __WASI_RIFLAGS_RECV_PEEK #define MSG_WAITALL __WASI_RIFLAGS_RECV_WAITALL -#define MSG_TRUNC __WASI_RIFLAGS_RECV_DATA_TRUNCATED +#define MSG_TRUNC __WASI_ROFLAGS_RECV_DATA_TRUNCATED +#endif // __wasilibc_use_wasip2 #define SOCK_DGRAM __WASI_FILETYPE_SOCKET_DGRAM #define SOCK_STREAM __WASI_FILETYPE_SOCKET_STREAM @@ -25,9 +59,13 @@ #define SO_TYPE 3 -#define AF_UNSPEC 0 -#define AF_INET 1 -#define AF_INET6 2 +#define PF_UNSPEC 0 +#define PF_INET 1 +#define PF_INET6 2 + +#define AF_UNSPEC PF_UNSPEC +#define AF_INET PF_INET +#define AF_INET6 PF_INET6 #define AF_UNIX 3 #ifdef __cplusplus diff --git a/lib/libc/include/wasm-wasi-musl/__mode_t.h b/lib/libc/include/wasm-wasi-musl/__mode_t.h index c0beef5370bd..d2dbe0471533 100644 --- a/lib/libc/include/wasm-wasi-musl/__mode_t.h +++ b/lib/libc/include/wasm-wasi-musl/__mode_t.h @@ -9,7 +9,7 @@ #define S_IFLNK (0xa000) #define S_IFREG (0x8000) #define S_IFSOCK (0xc000) -#define S_IFIFO (0xc000) +#define S_IFIFO (0x1000) #define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) #define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) diff --git a/lib/libc/include/wasm-wasi-musl/__struct_sockaddr.h b/lib/libc/include/wasm-wasi-musl/__struct_sockaddr.h index 9891b90bea4f..2e14d95258f5 100644 --- a/lib/libc/include/wasm-wasi-musl/__struct_sockaddr.h +++ b/lib/libc/include/wasm-wasi-musl/__struct_sockaddr.h @@ -1,9 +1,6 @@ #ifndef __wasilibc___struct_sockaddr_h #define __wasilibc___struct_sockaddr_h -#define __need_STDDEF_H_misc -#include - #include <__typedef_sa_family_t.h> struct sockaddr { diff --git a/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_in.h b/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_in.h index 73dc5c6ba38d..5d4ce51becc4 100644 --- a/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_in.h +++ b/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_in.h @@ -1,15 +1,12 @@ #ifndef __wasilibc___struct_sockaddr_in_h #define __wasilibc___struct_sockaddr_in_h -#define __need_STDDEF_H_misc -#include - #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; + __attribute__((aligned(__BIGGEST_ALIGNMENT__))) sa_family_t sin_family; in_port_t sin_port; struct in_addr sin_addr; }; diff --git a/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_in6.h b/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_in6.h index a220f913771c..98703dcbeb65 100644 --- a/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_in6.h +++ b/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_in6.h @@ -1,15 +1,12 @@ #ifndef __wasilibc___struct_sockaddr_in6_h #define __wasilibc___struct_sockaddr_in6_h -#define __need_STDDEF_H_misc -#include - #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; + __attribute__((aligned(__BIGGEST_ALIGNMENT__))) sa_family_t sin6_family; in_port_t sin6_port; unsigned sin6_flowinfo; struct in6_addr sin6_addr; diff --git a/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_storage.h b/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_storage.h index 1ae26a7ffce0..b4ebad2fed1e 100644 --- a/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_storage.h +++ b/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_storage.h @@ -1,13 +1,10 @@ #ifndef __wasilibc___struct_sockaddr_storage_h #define __wasilibc___struct_sockaddr_storage_h -#define __need_STDDEF_H_misc -#include - #include <__typedef_sa_family_t.h> struct sockaddr_storage { - _Alignas(max_align_t) sa_family_t ss_family; + __attribute__((aligned(__BIGGEST_ALIGNMENT__))) sa_family_t ss_family; char __ss_data[32]; }; diff --git a/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_un.h b/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_un.h index a5be6e5d86b5..637119495a23 100644 --- a/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_un.h +++ b/lib/libc/include/wasm-wasi-musl/__struct_sockaddr_un.h @@ -1,13 +1,10 @@ #ifndef __wasilibc___struct_sockaddr_un_h #define __wasilibc___struct_sockaddr_un_h -#define __need_STDDEF_H_misc -#include - #include <__typedef_sa_family_t.h> struct sockaddr_un { - _Alignas(max_align_t) sa_family_t sun_family; + __attribute__((aligned(__BIGGEST_ALIGNMENT__))) sa_family_t sun_family; }; #endif diff --git a/lib/libc/include/wasm-wasi-musl/__wasi_snapshot.h b/lib/libc/include/wasm-wasi-musl/__wasi_snapshot.h new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/lib/libc/include/wasm-wasi-musl/bits/setjmp.h b/lib/libc/include/wasm-wasi-musl/bits/setjmp.h new file mode 100644 index 000000000000..63973a800116 --- /dev/null +++ b/lib/libc/include/wasm-wasi-musl/bits/setjmp.h @@ -0,0 +1 @@ +typedef unsigned long __jmp_buf[8]; diff --git a/lib/libc/include/wasm-wasi-musl/setjmp.h b/lib/libc/include/wasm-wasi-musl/setjmp.h new file mode 100644 index 000000000000..b57999ed61e8 --- /dev/null +++ b/lib/libc/include/wasm-wasi-musl/setjmp.h @@ -0,0 +1,55 @@ +#ifndef _SETJMP_H +#define _SETJMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef __wasilibc_unmodified_upstream +/* WASI has no setjmp */ +#if !defined(__wasm_exception_handling__) +#error Setjmp/longjmp support requires Exception handling support, which is [not yet standardized](https://github.com/WebAssembly/proposals?tab=readme-ov-file#phase-3---implementation-phase-cg--wg). To enable it, compile with `-mllvm -wasm-enable-sjlj` and use an engine that implements the Exception handling proposal. +#endif +#endif +#include + +typedef struct __jmp_buf_tag { + __jmp_buf __jb; + unsigned long __fl; + unsigned long __ss[128/sizeof(long)]; +} jmp_buf[1]; + +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) +#define __setjmp_attr __attribute__((__returns_twice__)) +#else +#define __setjmp_attr +#endif + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +typedef jmp_buf sigjmp_buf; +int sigsetjmp (sigjmp_buf, int) __setjmp_attr; +_Noreturn void siglongjmp (sigjmp_buf, int); +#endif + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +int _setjmp (jmp_buf) __setjmp_attr; +_Noreturn void _longjmp (jmp_buf, int); +#endif + +int setjmp (jmp_buf) __setjmp_attr; +_Noreturn void longjmp (jmp_buf, int); + +#define setjmp setjmp + +#undef __setjmp_attr + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/libc/include/wasm-wasi-musl/stdlib.h b/lib/libc/include/wasm-wasi-musl/stdlib.h index 1bcb9ab0aa24..553e9aeabff7 100644 --- a/lib/libc/include/wasm-wasi-musl/stdlib.h +++ b/lib/libc/include/wasm-wasi-musl/stdlib.h @@ -128,9 +128,7 @@ int rand_r (unsigned *); #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ || defined(_BSD_SOURCE) -#ifdef __wasilibc_unmodified_upstream /* WASI has no absolute paths */ char *realpath (const char *__restrict, char *__restrict); -#endif long int random (void); void srandom (unsigned int); char *initstate (unsigned int, char *, size_t); diff --git a/lib/libc/include/wasm-wasi-musl/sys/socket.h b/lib/libc/include/wasm-wasi-musl/sys/socket.h index 4d574c6627e0..29189e39eb84 100644 --- a/lib/libc/include/wasm-wasi-musl/sys/socket.h +++ b/lib/libc/include/wasm-wasi-musl/sys/socket.h @@ -1,5 +1,8 @@ #ifndef _SYS_SOCKET_H #define _SYS_SOCKET_H + +#include <__wasi_snapshot.h> + #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ #else #include <__header_sys_socket.h> @@ -395,30 +398,33 @@ struct sockaddr_storage { #include <__struct_sockaddr_storage.h> #endif -#ifdef __wasilibc_unmodified_upstream /* WASI has no socket/socketpair */ +#if (defined __wasilibc_unmodified_upstream) || (defined __wasilibc_use_wasip2) int socket (int, int, int); +#endif + +#ifdef __wasilibc_unmodified_upstream /* WASI has no socketpair */ int socketpair (int, int, int, int [2]); #endif int shutdown (int, int); -#ifdef __wasilibc_unmodified_upstream /* WASI has no bind/connect/listen/accept */ -int bind (int, const struct sockaddr *, socklen_t); +#if (defined __wasilibc_unmodified_upstream) || (defined __wasilibc_use_wasip2) int connect (int, const struct sockaddr *, socklen_t); +int bind (int, const struct sockaddr *, socklen_t); int listen (int, int); #endif int accept (int, struct sockaddr *__restrict, socklen_t *__restrict); int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int); -#ifdef __wasilibc_unmodified_upstream /* WASI has no getsockname/getpeername */ +#if (defined __wasilibc_unmodified_upstream) || (defined __wasilibc_use_wasip2) int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict); int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict); #endif ssize_t send (int, const void *, size_t, int); ssize_t recv (int, void *, size_t, int); -#ifdef __wasilibc_unmodified_upstream /* WASI has no sendto/recvfrom */ +#if (defined __wasilibc_unmodified_upstream) || (defined __wasilibc_use_wasip2) ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t); ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict); #endif @@ -428,7 +434,7 @@ ssize_t recvmsg (int, struct msghdr *, int); #endif int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict); -#ifdef __wasilibc_unmodified_upstream /* WASI has no setsockopt */ +#if (defined __wasilibc_unmodified_upstream) || (defined __wasilibc_use_wasip2) int setsockopt (int, int, int, const void *, socklen_t); #endif diff --git a/lib/libc/include/wasm-wasi-musl/sys/stat.h b/lib/libc/include/wasm-wasi-musl/sys/stat.h index 72e1626158f3..c0090f7509fb 100644 --- a/lib/libc/include/wasm-wasi-musl/sys/stat.h +++ b/lib/libc/include/wasm-wasi-musl/sys/stat.h @@ -78,11 +78,9 @@ int stat(const char *__restrict, struct stat *__restrict); int fstat(int, struct stat *); int lstat(const char *__restrict, struct stat *__restrict); int fstatat(int, const char *__restrict, struct stat *__restrict, int); -#ifdef __wasilibc_unmodified_upstream /* WASI has no chmod */ int chmod(const char *, mode_t); int fchmod(int, mode_t); int fchmodat(int, const char *, mode_t, int); -#endif #ifdef __wasilibc_unmodified_upstream /* WASI has no umask */ mode_t umask(mode_t); #endif diff --git a/lib/libc/include/wasm-wasi-musl/sys/statvfs.h b/lib/libc/include/wasm-wasi-musl/sys/statvfs.h new file mode 100644 index 000000000000..793490b6dc8c --- /dev/null +++ b/lib/libc/include/wasm-wasi-musl/sys/statvfs.h @@ -0,0 +1,56 @@ +#ifndef _SYS_STATVFS_H +#define _SYS_STATVFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NEED_fsblkcnt_t +#define __NEED_fsfilcnt_t +#include + +struct statvfs { + unsigned long f_bsize, f_frsize; + fsblkcnt_t f_blocks, f_bfree, f_bavail; + fsfilcnt_t f_files, f_ffree, f_favail; +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned long f_fsid; + unsigned :8*(2*sizeof(int)-sizeof(long)); +#else + unsigned :8*(2*sizeof(int)-sizeof(long)); + unsigned long f_fsid; +#endif + unsigned long f_flag, f_namemax; + int __reserved[6]; +}; + +int statvfs (const char *__restrict, struct statvfs *__restrict); +int fstatvfs (int, struct statvfs *); + +#define ST_RDONLY 1 +#define ST_NOSUID 2 +#define ST_NODEV 4 +#define ST_NOEXEC 8 +#define ST_SYNCHRONOUS 16 +#define ST_MANDLOCK 64 +#define ST_WRITE 128 +#define ST_APPEND 256 +#define ST_IMMUTABLE 512 +#define ST_NOATIME 1024 +#define ST_NODIRATIME 2048 +#define ST_RELATIME 4096 + +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define statvfs64 statvfs +#define fstatvfs64 fstatvfs +#define fsblkcnt64_t fsblkcnt_t +#define fsfilcnt64_t fsfilcnt_t +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/libc/include/wasm-wasi-musl/unistd.h b/lib/libc/include/wasm-wasi-musl/unistd.h index b5cb5c663016..0be83e368c4c 100644 --- a/lib/libc/include/wasm-wasi-musl/unistd.h +++ b/lib/libc/include/wasm-wasi-musl/unistd.h @@ -336,7 +336,9 @@ pid_t gettid(void); #endif #define _POSIX_VDISABLE 0 +#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) #define _POSIX_THREADS _POSIX_VERSION +#endif #define _POSIX_THREAD_PROCESS_SHARED _POSIX_VERSION #define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION #define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION diff --git a/lib/libc/include/wasm-wasi-musl/wasi/libc.h b/lib/libc/include/wasm-wasi-musl/wasi/libc.h index b50518bfc132..18d8e9e3cba0 100644 --- a/lib/libc/include/wasm-wasi-musl/wasi/libc.h +++ b/lib/libc/include/wasm-wasi-musl/wasi/libc.h @@ -11,6 +11,12 @@ extern "C" { struct stat; struct timespec; +/// Populate libc's preopen tables. This is normally done automatically +/// just before it's needed, however if you call `__wasi_fd_renumber` or +/// `__wasi_fd_close` directly, and you need the preopens to be accurate +/// afterward, you should call this before doing so. +void __wasilibc_populate_preopens(void); + /// Register the given pre-opened file descriptor under the given path. /// /// This function does not take ownership of `prefix` (it makes its own copy). diff --git a/lib/libc/wasi/emmalloc/emmalloc.c b/lib/libc/wasi/emmalloc/emmalloc.c index 4eb78cbab626..e97ef44dc058 100644 --- a/lib/libc/wasi/emmalloc/emmalloc.c +++ b/lib/libc/wasi/emmalloc/emmalloc.c @@ -56,7 +56,7 @@ // Defind by the linker to have the address of the start of the heap. extern unsigned char __heap_base; -extern unsigned char __heap_end __attribute__((__weak__)); +extern unsigned char __heap_end; // Behavior of right shifting a signed integer is compiler implementation defined. static_assert((((int32_t)0x80000000U) >> 31) == -1, "This malloc implementation requires that right-shifting a signed integer produces a sign-extending (arithmetic) shift!"); @@ -66,7 +66,7 @@ static_assert((((int32_t)0x80000000U) >> 31) == -1, "This malloc implementation #define MALLOC_ALIGNMENT alignof(max_align_t) static_assert(alignof(max_align_t) == 16, "max_align_t must be correct"); -#define EMMALLOC_EXPORT __attribute__((__weak__)) +#define EMMALLOC_EXPORT __attribute__((weak)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MAX(x, y) ((x) > (y) ? (x) : (y)) @@ -546,12 +546,13 @@ static bool claim_more_memory(size_t numBytes) // If this is the first time we're called, see if we can use // the initial heap memory set up by wasm-ld. if (!listOfAllRegions) { + unsigned char *heap_base = &__heap_base; unsigned char *heap_end = &__heap_end; - if (heap_end == NULL) - heap_end = sbrk(0); - - if (numBytes <= (size_t)(heap_end - &__heap_base)) { - startPtr = &__heap_base; + if (heap_end < heap_base) { + __builtin_trap(); + } + if (numBytes <= (size_t)(heap_end - heap_base)) { + startPtr = heap_base; endPtr = heap_end; break; } diff --git a/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/poll/poll.c b/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/poll/poll.c index cde4e81c21b7..0ee14791d99e 100644 --- a/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/poll/poll.c +++ b/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/poll/poll.c @@ -7,7 +7,7 @@ #include #include -int poll(struct pollfd *fds, size_t nfds, int timeout) { +static int poll_wasip1(struct pollfd *fds, size_t nfds, int timeout) { // Construct events for poll(). size_t maxevents = 2 * nfds + 1; __wasi_subscription_t subscriptions[maxevents]; @@ -127,3 +127,48 @@ int poll(struct pollfd *fds, size_t nfds, int timeout) { } return retval; } + +#ifdef __wasilibc_use_wasip2 +#include + +int poll_wasip2(struct pollfd *fds, size_t nfds, int timeout); + +int poll(struct pollfd* fds, nfds_t nfds, int timeout) +{ + bool found_socket = false; + bool found_non_socket = false; + for (size_t i = 0; i < nfds; ++i) { + descriptor_table_entry_t* entry; + if (descriptor_table_get_ref(fds[i].fd, &entry)) { + found_socket = true; + } else { + found_non_socket = true; + } + } + + if (found_socket) { + if (found_non_socket) { + // We currently don't support polling a mix of non-sockets and + // sockets here (though you can do it by using the host APIs + // directly), and we probably won't until we've migrated entirely to + // WASI 0.2. + errno = ENOTSUP; + return -1; + } + + return poll_wasip2(fds, nfds, timeout); + } else if (found_non_socket) { + return poll_wasip1(fds, nfds, timeout); + } else if (timeout >= 0) { + return poll_wasip2(fds, nfds, timeout); + } else { + errno = ENOTSUP; + return -1; + } +} +#else // not __wasilibc_use_wasip2 +int poll(struct pollfd* fds, nfds_t nfds, int timeout) +{ + return poll_wasip1(fds, nfds, timeout); +} +#endif // not __wasilibc_use_wasip2 diff --git a/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c b/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c index 7d03cc61ad5b..2c968b2a05f1 100644 --- a/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c +++ b/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c @@ -4,11 +4,66 @@ #include -#include #include #include +#include +#ifdef __wasilibc_use_wasip2 +#include +#endif + int ioctl(int fildes, int request, ...) { +#ifdef __wasilibc_use_wasip2 + descriptor_table_entry_t *entry; + if (descriptor_table_get_ref(fildes, &entry)) { + switch (entry->tag) { + case DESCRIPTOR_TABLE_ENTRY_TCP_SOCKET: { + tcp_socket_t *socket = &entry->tcp_socket; + switch (request) { + case FIONBIO: { + va_list ap; + va_start(ap, request); + socket->blocking = *va_arg(ap, const int *) == + 0; + va_end(ap); + + return 0; + } + + default: + // TODO wasi-sockets: anything else we should support? + errno = EINVAL; + return -1; + } + } + + case DESCRIPTOR_TABLE_ENTRY_UDP_SOCKET: { + udp_socket_t *socket = &entry->udp_socket; + switch (request) { + case FIONBIO: { + va_list ap; + va_start(ap, request); + socket->blocking = *va_arg(ap, const int *) == + 0; + va_end(ap); + + return 0; + } + + default: + // TODO wasi-sockets: anything else we should support? + errno = EINVAL; + return -1; + } + } + + default: + errno = ENOPROTOOPT; + return -1; + } + } +#endif // __wasilibc_use_wasip2 + switch (request) { case FIONREAD: { // Poll the file descriptor to determine how many bytes can be read. diff --git a/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c b/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c index fdc470ea85ae..3b479edfbbef 100644 --- a/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c +++ b/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c @@ -8,6 +8,7 @@ #include #include +#include int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict errorfds, const struct timespec *restrict timeout, @@ -33,93 +34,66 @@ int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, if (writefds == NULL) writefds = ∅ - // Determine the maximum number of events. - size_t maxevents = readfds->__nfds + writefds->__nfds + 1; - __wasi_subscription_t subscriptions[maxevents]; - size_t nsubscriptions = 0; - - // Convert the readfds set. + struct pollfd poll_fds[readfds->__nfds + writefds->__nfds]; + size_t poll_nfds = 0; + for (size_t i = 0; i < readfds->__nfds; ++i) { int fd = readfds->__fds[i]; if (fd < nfds) { - __wasi_subscription_t *subscription = &subscriptions[nsubscriptions++]; - *subscription = (__wasi_subscription_t){ - .userdata = fd, - .u.tag = __WASI_EVENTTYPE_FD_READ, - .u.u.fd_read.file_descriptor = fd, - }; + poll_fds[poll_nfds++] = (struct pollfd){ + .fd = fd, + .events = POLLRDNORM, + .revents = 0 + }; } } - - // Convert the writefds set. + for (size_t i = 0; i < writefds->__nfds; ++i) { int fd = writefds->__fds[i]; if (fd < nfds) { - __wasi_subscription_t *subscription = &subscriptions[nsubscriptions++]; - *subscription = (__wasi_subscription_t){ - .userdata = fd, - .u.tag = __WASI_EVENTTYPE_FD_WRITE, - .u.u.fd_write.file_descriptor = fd, + poll_fds[poll_nfds++] = (struct pollfd){ + .fd = fd, + .events = POLLWRNORM, + .revents = 0 }; } } - // Create extra event for the timeout. - if (timeout != NULL) { - __wasi_subscription_t *subscription = &subscriptions[nsubscriptions++]; - *subscription = (__wasi_subscription_t){ - .u.tag = __WASI_EVENTTYPE_CLOCK, - .u.u.clock.id = __WASI_CLOCKID_REALTIME, - }; - if (!timespec_to_timestamp_clamp(timeout, &subscription->u.u.clock.timeout)) { + int poll_timeout; + if (timeout) { + uint64_t timeout_u64; + if (!timespec_to_timestamp_clamp(timeout, &timeout_u64) ) { errno = EINVAL; return -1; } - } - // Execute poll(). - size_t nevents; - __wasi_event_t events[nsubscriptions]; - __wasi_errno_t error = - __wasi_poll_oneoff(subscriptions, events, nsubscriptions, &nevents); - if (error != 0) { - // WASI's poll requires at least one subscription, or else it returns - // `EINVAL`. Since a `pselect` with nothing to wait for is valid in POSIX, - // return `ENOTSUP` to indicate that we don't support that case. - // - // Wasm has no signal handling, so if none of the user-provided `pollfd` - // elements, nor the timeout, led us to producing even one subscription - // to wait for, there would be no way for the poll to wake up. WASI - // returns `EINVAL` in this case, but for users of `poll`, `ENOTSUP` is - // more likely to be understood. - if (nsubscriptions == 0) - errno = ENOTSUP; - else - errno = error; - return -1; - } + // Convert nanoseconds to milliseconds: + timeout_u64 /= 1000000; - // Test for EBADF. - for (size_t i = 0; i < nevents; ++i) { - const __wasi_event_t *event = &events[i]; - if ((event->type == __WASI_EVENTTYPE_FD_READ || - event->type == __WASI_EVENTTYPE_FD_WRITE) && - event->error == __WASI_ERRNO_BADF) { - errno = EBADF; - return -1; + if (timeout_u64 > INT_MAX) { + timeout_u64 = INT_MAX; } + + poll_timeout = (int) timeout_u64; + } else { + poll_timeout = -1; + }; + + if (poll(poll_fds, poll_nfds, poll_timeout) < 0) { + return -1; } - // Clear and set entries in the result sets. FD_ZERO(readfds); FD_ZERO(writefds); - for (size_t i = 0; i < nevents; ++i) { - const __wasi_event_t *event = &events[i]; - if (event->type == __WASI_EVENTTYPE_FD_READ) { - readfds->__fds[readfds->__nfds++] = event->userdata; - } else if (event->type == __WASI_EVENTTYPE_FD_WRITE) { - writefds->__fds[writefds->__nfds++] = event->userdata; + for (size_t i = 0; i < poll_nfds; ++i) { + struct pollfd* pollfd = poll_fds + i; + if ((pollfd->revents & POLLRDNORM) != 0) { + readfds->__fds[readfds->__nfds++] = pollfd->fd; + } + if ((pollfd->revents & POLLWRNORM) != 0) { + writefds->__fds[writefds->__nfds++] = pollfd->fd; } } + return readfds->__nfds + writefds->__nfds; } diff --git a/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/unistd/close.c b/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/unistd/close.c index 2f5814bb655e..e69de29bb2d1 100644 --- a/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/unistd/close.c +++ b/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/unistd/close.c @@ -1,16 +0,0 @@ -// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ -// -// SPDX-License-Identifier: BSD-2-Clause - -#include -#include -#include - -int close(int fildes) { - __wasi_errno_t error = __wasi_fd_close(fildes); - if (error != 0) { - errno = error; - return -1; - } - return 0; -} diff --git a/lib/libc/wasi/libc-bottom-half/crt/crt1-command.c b/lib/libc/wasi/libc-bottom-half/crt/crt1-command.c index fb9ee71fb40e..d2030cb7805a 100644 --- a/lib/libc/wasi/libc-bottom-half/crt/crt1-command.c +++ b/lib/libc/wasi/libc-bottom-half/crt/crt1-command.c @@ -20,18 +20,18 @@ void _start(void) { static volatile _Atomic int started = 0; int expected = 0; if (!atomic_compare_exchange_strong(&started, &expected, 1)) { - __builtin_trap(); + __builtin_trap(); } #else static volatile int started = 0; if (started != 0) { - __builtin_trap(); + __builtin_trap(); } started = 1; #endif #ifdef _REENTRANT - __wasi_init_tp(); + __wasi_init_tp(); #endif // The linker synthesizes this to call constructors. diff --git a/lib/libc/wasi/libc-bottom-half/headers/private/wasi/descriptor_table.h b/lib/libc/wasi/libc-bottom-half/headers/private/wasi/descriptor_table.h new file mode 100644 index 000000000000..8e9a90d9d160 --- /dev/null +++ b/lib/libc/wasi/libc-bottom-half/headers/private/wasi/descriptor_table.h @@ -0,0 +1,127 @@ +#ifndef DESCRIPTOR_TABLE_H +#define DESCRIPTOR_TABLE_H + +#include + +typedef struct { + int dummy; +} tcp_socket_state_unbound_t; +typedef struct { + int dummy; +} tcp_socket_state_bound_t; +typedef struct { + int dummy; +} tcp_socket_state_connecting_t; +typedef struct { + int dummy; +} tcp_socket_state_listening_t; + +typedef struct { + streams_own_input_stream_t input; + poll_own_pollable_t input_pollable; + streams_own_output_stream_t output; + poll_own_pollable_t output_pollable; +} tcp_socket_state_connected_t; + +typedef struct { + network_error_code_t error_code; +} tcp_socket_state_connect_failed_t; + +// This is a tagged union. When adding/removing/renaming cases, be sure to keep the tag and union definitions in sync. +typedef struct { + enum { + TCP_SOCKET_STATE_UNBOUND, + TCP_SOCKET_STATE_BOUND, + TCP_SOCKET_STATE_CONNECTING, + TCP_SOCKET_STATE_CONNECTED, + TCP_SOCKET_STATE_CONNECT_FAILED, + TCP_SOCKET_STATE_LISTENING, + } tag; + union { + tcp_socket_state_unbound_t unbound; + tcp_socket_state_bound_t bound; + tcp_socket_state_connecting_t connecting; + tcp_socket_state_connected_t connected; + tcp_socket_state_connect_failed_t connect_failed; + tcp_socket_state_listening_t listening; + }; +} tcp_socket_state_t; + +typedef struct { + tcp_own_tcp_socket_t socket; + poll_own_pollable_t socket_pollable; + bool blocking; + bool fake_nodelay; + bool fake_reuseaddr; + network_ip_address_family_t family; + tcp_socket_state_t state; +} tcp_socket_t; + +typedef struct { + udp_own_incoming_datagram_stream_t incoming; + poll_own_pollable_t incoming_pollable; + udp_own_outgoing_datagram_stream_t outgoing; + poll_own_pollable_t outgoing_pollable; +} udp_socket_streams_t; + +typedef struct { + int dummy; +} udp_socket_state_unbound_t; +typedef struct { + int dummy; +} udp_socket_state_bound_nostreams_t; + +typedef struct { + udp_socket_streams_t streams; // Streams have no remote_address +} udp_socket_state_bound_streaming_t; + +typedef struct { + udp_socket_streams_t streams; // Streams have a remote_address +} udp_socket_state_connected_t; + +// This is a tagged union. When adding/removing/renaming cases, be sure to keep the tag and union definitions in sync. +// The "bound" state is split up into two distinct tags: +// - "bound_nostreams": Bound, but no datagram streams set up (yet). That will be done the first time send or recv is called. +// - "bound_streaming": Bound with active streams. +typedef struct { + enum { + UDP_SOCKET_STATE_UNBOUND, + UDP_SOCKET_STATE_BOUND_NOSTREAMS, + UDP_SOCKET_STATE_BOUND_STREAMING, + UDP_SOCKET_STATE_CONNECTED, + } tag; + union { + udp_socket_state_unbound_t unbound; + udp_socket_state_bound_nostreams_t bound_nostreams; + udp_socket_state_bound_streaming_t bound_streaming; + udp_socket_state_connected_t connected; + }; +} udp_socket_state_t; + +typedef struct { + udp_own_udp_socket_t socket; + poll_own_pollable_t socket_pollable; + bool blocking; + network_ip_address_family_t family; + udp_socket_state_t state; +} udp_socket_t; + +// This is a tagged union. When adding/removing/renaming cases, be sure to keep the tag and union definitions in sync. +typedef struct { + enum { + DESCRIPTOR_TABLE_ENTRY_TCP_SOCKET, + DESCRIPTOR_TABLE_ENTRY_UDP_SOCKET, + } tag; + union { + tcp_socket_t tcp_socket; + udp_socket_t udp_socket; + }; +} descriptor_table_entry_t; + +bool descriptor_table_insert(descriptor_table_entry_t entry, int *fd); + +bool descriptor_table_get_ref(int fd, descriptor_table_entry_t **entry); + +bool descriptor_table_remove(int fd, descriptor_table_entry_t *entry); + +#endif diff --git a/lib/libc/wasi/libc-bottom-half/headers/private/wasi/sockets_utils.h b/lib/libc/wasi/libc-bottom-half/headers/private/wasi/sockets_utils.h new file mode 100644 index 000000000000..93cf1f45d605 --- /dev/null +++ b/lib/libc/wasi/libc-bottom-half/headers/private/wasi/sockets_utils.h @@ -0,0 +1,53 @@ +#ifndef __wasi_sockets_utils_h +#define __wasi_sockets_utils_h + +#include + +#include + +typedef struct { + enum { + OUTPUT_SOCKADDR_NULL, + OUTPUT_SOCKADDR_V4, + OUTPUT_SOCKADDR_V6, + } tag; + union { + struct { + int dummy; + } null; + struct { + struct sockaddr_in *addr; + socklen_t *addrlen; + } v4; + struct { + struct sockaddr_in6 *addr; + socklen_t *addrlen; + } v6; + }; +} output_sockaddr_t; + +network_borrow_network_t __wasi_sockets_utils__borrow_network(); +int __wasi_sockets_utils__map_error(network_error_code_t wasi_error); +bool __wasi_sockets_utils__parse_address( + network_ip_address_family_t expected_family, + const struct sockaddr *address, socklen_t len, + network_ip_socket_address_t *result, int *error); +bool __wasi_sockets_utils__output_addr_validate( + network_ip_address_family_t expected_family, struct sockaddr *addr, + socklen_t *addrlen, output_sockaddr_t *result); +void __wasi_sockets_utils__output_addr_write( + const network_ip_socket_address_t input, output_sockaddr_t *output); +int __wasi_sockets_utils__posix_family(network_ip_address_family_t wasi_family); +network_ip_socket_address_t +__wasi_sockets_utils__any_addr(network_ip_address_family_t family); +int __wasi_sockets_utils__tcp_bind(tcp_socket_t *socket, + network_ip_socket_address_t *address); +int __wasi_sockets_utils__udp_bind(udp_socket_t *socket, + network_ip_socket_address_t *address); +bool __wasi_sockets_utils__stream(udp_socket_t *socket, + network_ip_socket_address_t *remote_address, + udp_socket_streams_t *result, + network_error_code_t *error); +void __wasi_sockets_utils__drop_streams(udp_socket_streams_t streams); + +#endif diff --git a/lib/libc/wasi/libc-bottom-half/signal/signal.c b/lib/libc/wasi/libc-bottom-half/signal/signal.c index 290d6b27431d..c9a435b39465 100644 --- a/lib/libc/wasi/libc-bottom-half/signal/signal.c +++ b/lib/libc/wasi/libc-bottom-half/signal/signal.c @@ -30,13 +30,13 @@ static void core_handler(int sig) { _Noreturn static void terminate_handler(int sig) { - fprintf(stderr, "Program recieved termination signal: %s\n", strsignal(sig)); + fprintf(stderr, "Program received termination signal: %s\n", strsignal(sig)); abort(); } _Noreturn static void stop_handler(int sig) { - fprintf(stderr, "Program recieved stop signal: %s\n", strsignal(sig)); + fprintf(stderr, "Program received stop signal: %s\n", strsignal(sig)); abort(); } diff --git a/lib/libc/wasi/libc-bottom-half/sources/__main_void.c b/lib/libc/wasi/libc-bottom-half/sources/__main_void.c index 997078f43bd0..cdb95c6bbacc 100644 --- a/lib/libc/wasi/libc-bottom-half/sources/__main_void.c +++ b/lib/libc/wasi/libc-bottom-half/sources/__main_void.c @@ -5,6 +5,11 @@ int __wasilibc_main(int argc, char *argv[]) asm("main"); // The user's `main` function, expecting arguments. +// +// Note that we make this a weak symbol so that it will have a +// `WASM_SYM_BINDING_WEAK` flag in libc.so, which tells the dynamic linker that +// it need not be defined (e.g. in reactor-style apps with no main function). +// See also the TODO comment on `__main_void` below. __attribute__((__weak__, nodebug)) int __main_argc_argv(int argc, char *argv[]) { return __wasilibc_main(argc, argv); @@ -13,6 +18,11 @@ int __main_argc_argv(int argc, char *argv[]) { // If the user's `main` function expects arguments, the compiler will rename // it to `__main_argc_argv`, and this version will get linked in, which // initializes the argument data and calls `__main_argc_argv`. +// +// TODO: Ideally this function would be defined in a crt*.o file and linked in +// as necessary by the Clang driver. However, moving it to crt1-command.c +// breaks `--no-gc-sections`, so we'll probably need to create a new file +// (e.g. crt0.o or crtend.o) and teach Clang to use it when needed. __attribute__((__weak__, nodebug)) int __main_void(void) { __wasi_errno_t err; diff --git a/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_fd_renumber.c b/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_fd_renumber.c index aa9d8dcb1c07..d5247518c693 100644 --- a/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_fd_renumber.c +++ b/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_fd_renumber.c @@ -11,3 +11,97 @@ int __wasilibc_fd_renumber(int fd, int newfd) { } return 0; } + +#ifdef __wasilibc_use_wasip2 +#include + +void drop_tcp_socket(tcp_socket_t socket) { + switch (socket.state.tag) { + case TCP_SOCKET_STATE_UNBOUND: + case TCP_SOCKET_STATE_BOUND: + case TCP_SOCKET_STATE_CONNECTING: + case TCP_SOCKET_STATE_LISTENING: + case TCP_SOCKET_STATE_CONNECT_FAILED: + // No additional resources to drop. + break; + case TCP_SOCKET_STATE_CONNECTED: { + tcp_socket_state_connected_t connection = socket.state.connected; + + poll_pollable_drop_own(connection.input_pollable); + poll_pollable_drop_own(connection.output_pollable); + streams_input_stream_drop_own(connection.input); + streams_output_stream_drop_own(connection.output); + break; + } + default: /* unreachable */ abort(); + } + + poll_pollable_drop_own(socket.socket_pollable); + tcp_tcp_socket_drop_own(socket.socket); +} + +void drop_udp_socket_streams(udp_socket_streams_t streams) { + poll_pollable_drop_own(streams.incoming_pollable); + poll_pollable_drop_own(streams.outgoing_pollable); + udp_incoming_datagram_stream_drop_own(streams.incoming); + udp_outgoing_datagram_stream_drop_own(streams.outgoing); +} + +void drop_udp_socket(udp_socket_t socket) { + switch (socket.state.tag) { + case UDP_SOCKET_STATE_UNBOUND: + case UDP_SOCKET_STATE_BOUND_NOSTREAMS: + // No additional resources to drop. + break; + case UDP_SOCKET_STATE_BOUND_STREAMING: + drop_udp_socket_streams(socket.state.bound_streaming.streams); + break; + case UDP_SOCKET_STATE_CONNECTED: { + drop_udp_socket_streams(socket.state.connected.streams); + break; + } + default: /* unreachable */ abort(); + } + + poll_pollable_drop_own(socket.socket_pollable); + udp_udp_socket_drop_own(socket.socket); +} +#endif // __wasilibc_use_wasip2 + +int close(int fd) { + // Scan the preopen fds before making any changes. + __wasilibc_populate_preopens(); + +#ifdef __wasilibc_use_wasip2 + descriptor_table_entry_t entry; + if (descriptor_table_remove(fd, &entry)) { + + switch (entry.tag) + { + case DESCRIPTOR_TABLE_ENTRY_TCP_SOCKET: + drop_tcp_socket(entry.tcp_socket); + break; + case DESCRIPTOR_TABLE_ENTRY_UDP_SOCKET: + drop_udp_socket(entry.udp_socket); + break; + default: /* unreachable */ abort(); + } + + return 0; + } +#endif // __wasilibc_use_wasip2 + + __wasi_errno_t error = __wasi_fd_close(fd); + if (error != 0) { + errno = error; + return -1; + } + + return 0; +} + +weak void __wasilibc_populate_preopens(void) { + // This version does nothing. It may be overridden by a version which does + // something if `__wasilibc_find_abspath` or `__wasilibc_find_relpath` are + // used. +} diff --git a/lib/libc/wasi/libc-bottom-half/sources/accept.c b/lib/libc/wasi/libc-bottom-half/sources/accept-wasip1.c similarity index 100% rename from lib/libc/wasi/libc-bottom-half/sources/accept.c rename to lib/libc/wasi/libc-bottom-half/sources/accept-wasip1.c diff --git a/lib/libc/wasi/libc-bottom-half/sources/posix.c b/lib/libc/wasi/libc-bottom-half/sources/posix.c index b3e59ec3948f..7da6a3df6813 100644 --- a/lib/libc/wasi/libc-bottom-half/sources/posix.c +++ b/lib/libc/wasi/libc-bottom-half/sources/posix.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -310,6 +311,46 @@ int rename(const char *old, const char *new) { return -1; } +int chmod(const char *path, mode_t mode) { + // TODO: We plan to support this eventually in WASI, but not yet. + // Meanwhile, we provide a stub so that libc++'s `` + // implementation will build unmodified. + errno = ENOSYS; + return -1; +} + +int fchmod(int fd, mode_t mode) { + // TODO: We plan to support this eventually in WASI, but not yet. + // Meanwhile, we provide a stub so that libc++'s `` + // implementation will build unmodified. + errno = ENOSYS; + return -1; +} + +int fchmodat(int fd, const char *path, mode_t mode, int flag) { + // TODO: We plan to support this eventually in WASI, but not yet. + // Meanwhile, we provide a stub so that libc++'s `` + // implementation will build unmodified. + errno = ENOSYS; + return -1; +} + +int statvfs(const char *__restrict path, struct statvfs *__restrict buf) { + // TODO: We plan to support this eventually in WASI, but not yet. + // Meanwhile, we provide a stub so that libc++'s `` + // implementation will build unmodified. + errno = ENOSYS; + return -1; +} + +int fstatvfs(int fd, struct statvfs *buf) { + // TODO: We plan to support this eventually in WASI, but not yet. + // Meanwhile, we provide a stub so that libc++'s `` + // implementation will build unmodified. + errno = ENOSYS; + return -1; +} + // Like `access`, but with `faccessat`'s flags argument. int __wasilibc_access(const char *path, int mode, int flags) diff --git a/lib/libc/wasi/libc-bottom-half/sources/preopens.c b/lib/libc/wasi/libc-bottom-half/sources/preopens.c index 7293c8c49e63..a49ca3e9ad05 100644 --- a/lib/libc/wasi/libc-bottom-half/sources/preopens.c +++ b/lib/libc/wasi/libc-bottom-half/sources/preopens.c @@ -218,51 +218,3 @@ int __wasilibc_find_abspath(const char *path, *relative_path = computed; return fd; } - -/// This is referenced by weak reference from crt1.c and lives in the same -/// source file as `__wasilibc_find_relpath` so that it's linked in when it's -/// needed. -// Concerning the 51 -- see the comment by the constructor priority in -// libc-bottom-half/sources/environ.c. -__attribute__((constructor(51))) -static void __wasilibc_populate_preopens(void) { - // Skip stdin, stdout, and stderr, and count up until we reach an invalid - // file descriptor. - for (__wasi_fd_t fd = 3; fd != 0; ++fd) { - __wasi_prestat_t prestat; - __wasi_errno_t ret = __wasi_fd_prestat_get(fd, &prestat); - if (ret == __WASI_ERRNO_BADF) - break; - if (ret != __WASI_ERRNO_SUCCESS) - goto oserr; - switch (prestat.tag) { - case __WASI_PREOPENTYPE_DIR: { - char *prefix = malloc(prestat.u.dir.pr_name_len + 1); - if (prefix == NULL) - goto software; - - // TODO: Remove the cast on `path` once the witx is updated with - // char8 support. - ret = __wasi_fd_prestat_dir_name(fd, (uint8_t *)prefix, - prestat.u.dir.pr_name_len); - if (ret != __WASI_ERRNO_SUCCESS) - goto oserr; - prefix[prestat.u.dir.pr_name_len] = '\0'; - - if (internal_register_preopened_fd(fd, prefix) != 0) - goto software; - free(prefix); - - break; - } - default: - break; - } - } - - return; -oserr: - _Exit(EX_OSERR); -software: - _Exit(EX_SOFTWARE); -} diff --git a/lib/libc/wasi/libc-top-half/musl/.mailmap b/lib/libc/wasi/libc-top-half/musl/.mailmap deleted file mode 100644 index aede9ec828c5..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/.mailmap +++ /dev/null @@ -1 +0,0 @@ -Ada Worcester diff --git a/lib/libc/wasi/libc-top-half/musl/arch/wasm32/bits/setjmp.h b/lib/libc/wasi/libc-top-half/musl/arch/wasm32/bits/setjmp.h new file mode 100644 index 000000000000..63973a800116 --- /dev/null +++ b/lib/libc/wasi/libc-top-half/musl/arch/wasm32/bits/setjmp.h @@ -0,0 +1 @@ +typedef unsigned long __jmp_buf[8]; diff --git a/lib/libc/wasi/libc-top-half/musl/include/aio.h b/lib/libc/wasi/libc-top-half/musl/include/aio.h deleted file mode 100644 index 453c41b7489f..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/aio.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef _AIO_H -#define _AIO_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -#define __NEED_ssize_t -#define __NEED_off_t - -#include - -struct aiocb { - int aio_fildes, aio_lio_opcode, aio_reqprio; - volatile void *aio_buf; - size_t aio_nbytes; - struct sigevent aio_sigevent; - void *__td; - int __lock[2]; - volatile int __err; - ssize_t __ret; - off_t aio_offset; - void *__next, *__prev; - char __dummy4[32-2*sizeof(void *)]; -}; - -#define AIO_CANCELED 0 -#define AIO_NOTCANCELED 1 -#define AIO_ALLDONE 2 - -#define LIO_READ 0 -#define LIO_WRITE 1 -#define LIO_NOP 2 - -#define LIO_WAIT 0 -#define LIO_NOWAIT 1 - -int aio_read(struct aiocb *); -int aio_write(struct aiocb *); -int aio_error(const struct aiocb *); -ssize_t aio_return(struct aiocb *); -int aio_cancel(int, struct aiocb *); -int aio_suspend(const struct aiocb *const [], int, const struct timespec *); -int aio_fsync(int, struct aiocb *); - -int lio_listio(int, struct aiocb *__restrict const *__restrict, int, struct sigevent *__restrict); - -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define aiocb64 aiocb -#define aio_read64 aio_read -#define aio_write64 aio_write -#define aio_error64 aio_error -#define aio_return64 aio_return -#define aio_cancel64 aio_cancel -#define aio_suspend64 aio_suspend -#define aio_fsync64 aio_fsync -#define lio_listio64 lio_listio -#define off64_t off_t -#endif - -#if _REDIR_TIME64 -__REDIR(aio_suspend, __aio_suspend_time64); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/alltypes.h.in b/lib/libc/wasi/libc-top-half/musl/include/alltypes.h.in deleted file mode 100644 index dcd474ff3acb..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/alltypes.h.in +++ /dev/null @@ -1,118 +0,0 @@ -#define __LITTLE_ENDIAN 1234 -#define __BIG_ENDIAN 4321 -#define __USE_TIME_BITS64 1 - -TYPEDEF unsigned _Addr size_t; -TYPEDEF unsigned _Addr uintptr_t; -TYPEDEF _Addr ptrdiff_t; -TYPEDEF _Addr ssize_t; -TYPEDEF _Addr intptr_t; -TYPEDEF _Addr regoff_t; -TYPEDEF _Reg register_t; -#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ -TYPEDEF _Int64 time_t; -TYPEDEF _Int64 suseconds_t; -#else -#if defined(__NEED_time_t) && !defined(__DEFINED_time_t) -#include <__typedef_time_t.h> -#define __DEFINED_time_t -#endif - -#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t) -#include <__typedef_suseconds_t.h> -#define __DEFINED_suseconds_t -#endif -#endif - -TYPEDEF signed char int8_t; -TYPEDEF signed short int16_t; -TYPEDEF signed int int32_t; -TYPEDEF signed _Int64 int64_t; -TYPEDEF signed _Int64 intmax_t; -TYPEDEF unsigned char uint8_t; -TYPEDEF unsigned short uint16_t; -TYPEDEF unsigned int uint32_t; -TYPEDEF unsigned _Int64 uint64_t; -TYPEDEF unsigned _Int64 u_int64_t; -TYPEDEF unsigned _Int64 uintmax_t; - -TYPEDEF unsigned mode_t; -TYPEDEF unsigned _Reg nlink_t; -TYPEDEF _Int64 off_t; -TYPEDEF unsigned _Int64 ino_t; -TYPEDEF unsigned _Int64 dev_t; -TYPEDEF long blksize_t; -TYPEDEF _Int64 blkcnt_t; -TYPEDEF unsigned _Int64 fsblkcnt_t; -TYPEDEF unsigned _Int64 fsfilcnt_t; - -TYPEDEF unsigned wint_t; -TYPEDEF unsigned long wctype_t; - -TYPEDEF void * timer_t; -TYPEDEF int clockid_t; -TYPEDEF long clock_t; -#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ -STRUCT timeval { time_t tv_sec; suseconds_t tv_usec; }; -STRUCT timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); }; -#else -#include <__struct_timeval.h> -#include <__struct_timespec.h> -#endif - -TYPEDEF int pid_t; -TYPEDEF unsigned id_t; -TYPEDEF unsigned uid_t; -TYPEDEF unsigned gid_t; -TYPEDEF int key_t; -TYPEDEF unsigned useconds_t; - -#ifdef __cplusplus -TYPEDEF unsigned long pthread_t; -#else -TYPEDEF struct __pthread * pthread_t; -#endif -TYPEDEF int pthread_once_t; -TYPEDEF unsigned pthread_key_t; -TYPEDEF int pthread_spinlock_t; -TYPEDEF struct { unsigned __attr; } pthread_mutexattr_t; -TYPEDEF struct { unsigned __attr; } pthread_condattr_t; -TYPEDEF struct { unsigned __attr; } pthread_barrierattr_t; -TYPEDEF struct { unsigned __attr[2]; } pthread_rwlockattr_t; - -#ifdef __wasilibc_unmodified_upstream /* WASI doesn't need to define FILE as a complete type */ -STRUCT _IO_FILE { char __x; }; -#endif -TYPEDEF struct _IO_FILE FILE; - -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; - -TYPEDEF struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t; - -TYPEDEF struct __locale_struct * locale_t; - -TYPEDEF struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t; - -#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ -STRUCT iovec { void *iov_base; size_t iov_len; }; -#else -#include <__struct_iovec.h> -#endif - -STRUCT winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; - -TYPEDEF unsigned socklen_t; -TYPEDEF unsigned short sa_family_t; - -TYPEDEF struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[sizeof(long)==8?8:5]; volatile int __vi[sizeof(long)==8?8:5]; void *__p[sizeof(long)==8?4:5]; } __u; } pthread_barrier_t; - -#undef _Addr -#undef _Int64 -#undef _Reg diff --git a/lib/libc/wasi/libc-top-half/musl/include/dlfcn.h b/lib/libc/wasi/libc-top-half/musl/include/dlfcn.h index 13ab71dd071e..e802de88f671 100644 --- a/lib/libc/wasi/libc-top-half/musl/include/dlfcn.h +++ b/lib/libc/wasi/libc-top-half/musl/include/dlfcn.h @@ -12,19 +12,29 @@ extern "C" { #define RTLD_NOLOAD 4 #define RTLD_NODELETE 4096 #define RTLD_GLOBAL 256 +#ifdef __wasilibc_unmodified_upstream #define RTLD_LOCAL 0 +#else +/* For WASI, we give `RTLD_LOCAL` a non-zero value, avoiding ambiguity and + * allowing us to defer the decision of whether `RTLD_LOCAL` or `RTLD_GLOBAL` + * should be the default when neither is specified. + */ +#define RTLD_LOCAL 8 +#endif #define RTLD_NEXT ((void *)-1) #define RTLD_DEFAULT ((void *)0) +#ifdef __wasilibc_unmodified_upstream #define RTLD_DI_LINKMAP 2 +#endif int dlclose(void *); char *dlerror(void); void *dlopen(const char *, int); void *dlsym(void *__restrict, const char *__restrict); -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#if defined(__wasilibc_unmodified_upstream) && (defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) typedef struct { const char *dli_fname; void *dli_fbase; diff --git a/lib/libc/wasi/libc-top-half/musl/include/elf.h b/lib/libc/wasi/libc-top-half/musl/include/elf.h deleted file mode 100644 index 86e2f0bb7d04..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/elf.h +++ /dev/null @@ -1,3296 +0,0 @@ -#ifndef _ELF_H -#define _ELF_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -typedef uint16_t Elf32_Half; -typedef uint16_t Elf64_Half; - -typedef uint32_t Elf32_Word; -typedef int32_t Elf32_Sword; -typedef uint32_t Elf64_Word; -typedef int32_t Elf64_Sword; - -typedef uint64_t Elf32_Xword; -typedef int64_t Elf32_Sxword; -typedef uint64_t Elf64_Xword; -typedef int64_t Elf64_Sxword; - -typedef uint32_t Elf32_Addr; -typedef uint64_t Elf64_Addr; - -typedef uint32_t Elf32_Off; -typedef uint64_t Elf64_Off; - -typedef uint16_t Elf32_Section; -typedef uint16_t Elf64_Section; - -typedef Elf32_Half Elf32_Versym; -typedef Elf64_Half Elf64_Versym; - -#define EI_NIDENT (16) - -typedef struct { - unsigned char e_ident[EI_NIDENT]; - Elf32_Half e_type; - Elf32_Half e_machine; - Elf32_Word e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf32_Word e_flags; - Elf32_Half e_ehsize; - Elf32_Half e_phentsize; - Elf32_Half e_phnum; - Elf32_Half e_shentsize; - Elf32_Half e_shnum; - Elf32_Half e_shstrndx; -} Elf32_Ehdr; - -typedef struct { - unsigned char e_ident[EI_NIDENT]; - Elf64_Half e_type; - Elf64_Half e_machine; - Elf64_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf64_Word e_flags; - Elf64_Half e_ehsize; - Elf64_Half e_phentsize; - Elf64_Half e_phnum; - Elf64_Half e_shentsize; - Elf64_Half e_shnum; - Elf64_Half e_shstrndx; -} Elf64_Ehdr; - -#define EI_MAG0 0 -#define ELFMAG0 0x7f - -#define EI_MAG1 1 -#define ELFMAG1 'E' - -#define EI_MAG2 2 -#define ELFMAG2 'L' - -#define EI_MAG3 3 -#define ELFMAG3 'F' - - -#define ELFMAG "\177ELF" -#define SELFMAG 4 - -#define EI_CLASS 4 -#define ELFCLASSNONE 0 -#define ELFCLASS32 1 -#define ELFCLASS64 2 -#define ELFCLASSNUM 3 - -#define EI_DATA 5 -#define ELFDATANONE 0 -#define ELFDATA2LSB 1 -#define ELFDATA2MSB 2 -#define ELFDATANUM 3 - -#define EI_VERSION 6 - - -#define EI_OSABI 7 -#define ELFOSABI_NONE 0 -#define ELFOSABI_SYSV 0 -#define ELFOSABI_HPUX 1 -#define ELFOSABI_NETBSD 2 -#define ELFOSABI_LINUX 3 -#define ELFOSABI_GNU 3 -#define ELFOSABI_SOLARIS 6 -#define ELFOSABI_AIX 7 -#define ELFOSABI_IRIX 8 -#define ELFOSABI_FREEBSD 9 -#define ELFOSABI_TRU64 10 -#define ELFOSABI_MODESTO 11 -#define ELFOSABI_OPENBSD 12 -#define ELFOSABI_ARM 97 -#define ELFOSABI_STANDALONE 255 - -#define EI_ABIVERSION 8 - -#define EI_PAD 9 - - - -#define ET_NONE 0 -#define ET_REL 1 -#define ET_EXEC 2 -#define ET_DYN 3 -#define ET_CORE 4 -#define ET_NUM 5 -#define ET_LOOS 0xfe00 -#define ET_HIOS 0xfeff -#define ET_LOPROC 0xff00 -#define ET_HIPROC 0xffff - - - -#define EM_NONE 0 -#define EM_M32 1 -#define EM_SPARC 2 -#define EM_386 3 -#define EM_68K 4 -#define EM_88K 5 -#define EM_860 7 -#define EM_MIPS 8 -#define EM_S370 9 -#define EM_MIPS_RS3_LE 10 - -#define EM_PARISC 15 -#define EM_VPP500 17 -#define EM_SPARC32PLUS 18 -#define EM_960 19 -#define EM_PPC 20 -#define EM_PPC64 21 -#define EM_S390 22 - -#define EM_V800 36 -#define EM_FR20 37 -#define EM_RH32 38 -#define EM_RCE 39 -#define EM_ARM 40 -#define EM_FAKE_ALPHA 41 -#define EM_SH 42 -#define EM_SPARCV9 43 -#define EM_TRICORE 44 -#define EM_ARC 45 -#define EM_H8_300 46 -#define EM_H8_300H 47 -#define EM_H8S 48 -#define EM_H8_500 49 -#define EM_IA_64 50 -#define EM_MIPS_X 51 -#define EM_COLDFIRE 52 -#define EM_68HC12 53 -#define EM_MMA 54 -#define EM_PCP 55 -#define EM_NCPU 56 -#define EM_NDR1 57 -#define EM_STARCORE 58 -#define EM_ME16 59 -#define EM_ST100 60 -#define EM_TINYJ 61 -#define EM_X86_64 62 -#define EM_PDSP 63 - -#define EM_FX66 66 -#define EM_ST9PLUS 67 -#define EM_ST7 68 -#define EM_68HC16 69 -#define EM_68HC11 70 -#define EM_68HC08 71 -#define EM_68HC05 72 -#define EM_SVX 73 -#define EM_ST19 74 -#define EM_VAX 75 -#define EM_CRIS 76 -#define EM_JAVELIN 77 -#define EM_FIREPATH 78 -#define EM_ZSP 79 -#define EM_MMIX 80 -#define EM_HUANY 81 -#define EM_PRISM 82 -#define EM_AVR 83 -#define EM_FR30 84 -#define EM_D10V 85 -#define EM_D30V 86 -#define EM_V850 87 -#define EM_M32R 88 -#define EM_MN10300 89 -#define EM_MN10200 90 -#define EM_PJ 91 -#define EM_OR1K 92 -#define EM_OPENRISC 92 -#define EM_ARC_A5 93 -#define EM_ARC_COMPACT 93 -#define EM_XTENSA 94 -#define EM_VIDEOCORE 95 -#define EM_TMM_GPP 96 -#define EM_NS32K 97 -#define EM_TPC 98 -#define EM_SNP1K 99 -#define EM_ST200 100 -#define EM_IP2K 101 -#define EM_MAX 102 -#define EM_CR 103 -#define EM_F2MC16 104 -#define EM_MSP430 105 -#define EM_BLACKFIN 106 -#define EM_SE_C33 107 -#define EM_SEP 108 -#define EM_ARCA 109 -#define EM_UNICORE 110 -#define EM_EXCESS 111 -#define EM_DXP 112 -#define EM_ALTERA_NIOS2 113 -#define EM_CRX 114 -#define EM_XGATE 115 -#define EM_C166 116 -#define EM_M16C 117 -#define EM_DSPIC30F 118 -#define EM_CE 119 -#define EM_M32C 120 -#define EM_TSK3000 131 -#define EM_RS08 132 -#define EM_SHARC 133 -#define EM_ECOG2 134 -#define EM_SCORE7 135 -#define EM_DSP24 136 -#define EM_VIDEOCORE3 137 -#define EM_LATTICEMICO32 138 -#define EM_SE_C17 139 -#define EM_TI_C6000 140 -#define EM_TI_C2000 141 -#define EM_TI_C5500 142 -#define EM_TI_ARP32 143 -#define EM_TI_PRU 144 -#define EM_MMDSP_PLUS 160 -#define EM_CYPRESS_M8C 161 -#define EM_R32C 162 -#define EM_TRIMEDIA 163 -#define EM_QDSP6 164 -#define EM_8051 165 -#define EM_STXP7X 166 -#define EM_NDS32 167 -#define EM_ECOG1X 168 -#define EM_MAXQ30 169 -#define EM_XIMO16 170 -#define EM_MANIK 171 -#define EM_CRAYNV2 172 -#define EM_RX 173 -#define EM_METAG 174 -#define EM_MCST_ELBRUS 175 -#define EM_ECOG16 176 -#define EM_CR16 177 -#define EM_ETPU 178 -#define EM_SLE9X 179 -#define EM_L10M 180 -#define EM_K10M 181 -#define EM_AARCH64 183 -#define EM_AVR32 185 -#define EM_STM8 186 -#define EM_TILE64 187 -#define EM_TILEPRO 188 -#define EM_MICROBLAZE 189 -#define EM_CUDA 190 -#define EM_TILEGX 191 -#define EM_CLOUDSHIELD 192 -#define EM_COREA_1ST 193 -#define EM_COREA_2ND 194 -#define EM_ARC_COMPACT2 195 -#define EM_OPEN8 196 -#define EM_RL78 197 -#define EM_VIDEOCORE5 198 -#define EM_78KOR 199 -#define EM_56800EX 200 -#define EM_BA1 201 -#define EM_BA2 202 -#define EM_XCORE 203 -#define EM_MCHP_PIC 204 -#define EM_KM32 210 -#define EM_KMX32 211 -#define EM_EMX16 212 -#define EM_EMX8 213 -#define EM_KVARC 214 -#define EM_CDP 215 -#define EM_COGE 216 -#define EM_COOL 217 -#define EM_NORC 218 -#define EM_CSR_KALIMBA 219 -#define EM_Z80 220 -#define EM_VISIUM 221 -#define EM_FT32 222 -#define EM_MOXIE 223 -#define EM_AMDGPU 224 -#define EM_RISCV 243 -#define EM_BPF 247 -#define EM_CSKY 252 -#define EM_NUM 253 - -#define EM_ALPHA 0x9026 - -#define EV_NONE 0 -#define EV_CURRENT 1 -#define EV_NUM 2 - -typedef struct { - Elf32_Word sh_name; - Elf32_Word sh_type; - Elf32_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf32_Word sh_size; - Elf32_Word sh_link; - Elf32_Word sh_info; - Elf32_Word sh_addralign; - Elf32_Word sh_entsize; -} Elf32_Shdr; - -typedef struct { - Elf64_Word sh_name; - Elf64_Word sh_type; - Elf64_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf64_Xword sh_size; - Elf64_Word sh_link; - Elf64_Word sh_info; - Elf64_Xword sh_addralign; - Elf64_Xword sh_entsize; -} Elf64_Shdr; - - - -#define SHN_UNDEF 0 -#define SHN_LORESERVE 0xff00 -#define SHN_LOPROC 0xff00 -#define SHN_BEFORE 0xff00 - -#define SHN_AFTER 0xff01 - -#define SHN_HIPROC 0xff1f -#define SHN_LOOS 0xff20 -#define SHN_HIOS 0xff3f -#define SHN_ABS 0xfff1 -#define SHN_COMMON 0xfff2 -#define SHN_XINDEX 0xffff -#define SHN_HIRESERVE 0xffff - - - -#define SHT_NULL 0 -#define SHT_PROGBITS 1 -#define SHT_SYMTAB 2 -#define SHT_STRTAB 3 -#define SHT_RELA 4 -#define SHT_HASH 5 -#define SHT_DYNAMIC 6 -#define SHT_NOTE 7 -#define SHT_NOBITS 8 -#define SHT_REL 9 -#define SHT_SHLIB 10 -#define SHT_DYNSYM 11 -#define SHT_INIT_ARRAY 14 -#define SHT_FINI_ARRAY 15 -#define SHT_PREINIT_ARRAY 16 -#define SHT_GROUP 17 -#define SHT_SYMTAB_SHNDX 18 -#define SHT_NUM 19 -#define SHT_LOOS 0x60000000 -#define SHT_GNU_ATTRIBUTES 0x6ffffff5 -#define SHT_GNU_HASH 0x6ffffff6 -#define SHT_GNU_LIBLIST 0x6ffffff7 -#define SHT_CHECKSUM 0x6ffffff8 -#define SHT_LOSUNW 0x6ffffffa -#define SHT_SUNW_move 0x6ffffffa -#define SHT_SUNW_COMDAT 0x6ffffffb -#define SHT_SUNW_syminfo 0x6ffffffc -#define SHT_GNU_verdef 0x6ffffffd -#define SHT_GNU_verneed 0x6ffffffe -#define SHT_GNU_versym 0x6fffffff -#define SHT_HISUNW 0x6fffffff -#define SHT_HIOS 0x6fffffff -#define SHT_LOPROC 0x70000000 -#define SHT_HIPROC 0x7fffffff -#define SHT_LOUSER 0x80000000 -#define SHT_HIUSER 0x8fffffff - -#define SHF_WRITE (1 << 0) -#define SHF_ALLOC (1 << 1) -#define SHF_EXECINSTR (1 << 2) -#define SHF_MERGE (1 << 4) -#define SHF_STRINGS (1 << 5) -#define SHF_INFO_LINK (1 << 6) -#define SHF_LINK_ORDER (1 << 7) -#define SHF_OS_NONCONFORMING (1 << 8) - -#define SHF_GROUP (1 << 9) -#define SHF_TLS (1 << 10) -#define SHF_COMPRESSED (1 << 11) -#define SHF_MASKOS 0x0ff00000 -#define SHF_MASKPROC 0xf0000000 -#define SHF_ORDERED (1 << 30) -#define SHF_EXCLUDE (1U << 31) - -typedef struct { - Elf32_Word ch_type; - Elf32_Word ch_size; - Elf32_Word ch_addralign; -} Elf32_Chdr; - -typedef struct { - Elf64_Word ch_type; - Elf64_Word ch_reserved; - Elf64_Xword ch_size; - Elf64_Xword ch_addralign; -} Elf64_Chdr; - -#define ELFCOMPRESS_ZLIB 1 -#define ELFCOMPRESS_LOOS 0x60000000 -#define ELFCOMPRESS_HIOS 0x6fffffff -#define ELFCOMPRESS_LOPROC 0x70000000 -#define ELFCOMPRESS_HIPROC 0x7fffffff - - -#define GRP_COMDAT 0x1 - -typedef struct { - Elf32_Word st_name; - Elf32_Addr st_value; - Elf32_Word st_size; - unsigned char st_info; - unsigned char st_other; - Elf32_Section st_shndx; -} Elf32_Sym; - -typedef struct { - Elf64_Word st_name; - unsigned char st_info; - unsigned char st_other; - Elf64_Section st_shndx; - Elf64_Addr st_value; - Elf64_Xword st_size; -} Elf64_Sym; - -typedef struct { - Elf32_Half si_boundto; - Elf32_Half si_flags; -} Elf32_Syminfo; - -typedef struct { - Elf64_Half si_boundto; - Elf64_Half si_flags; -} Elf64_Syminfo; - -#define SYMINFO_BT_SELF 0xffff -#define SYMINFO_BT_PARENT 0xfffe -#define SYMINFO_BT_LOWRESERVE 0xff00 - -#define SYMINFO_FLG_DIRECT 0x0001 -#define SYMINFO_FLG_PASSTHRU 0x0002 -#define SYMINFO_FLG_COPY 0x0004 -#define SYMINFO_FLG_LAZYLOAD 0x0008 - -#define SYMINFO_NONE 0 -#define SYMINFO_CURRENT 1 -#define SYMINFO_NUM 2 - -#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) -#define ELF32_ST_TYPE(val) ((val) & 0xf) -#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) - -#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) -#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) -#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) - -#define STB_LOCAL 0 -#define STB_GLOBAL 1 -#define STB_WEAK 2 -#define STB_NUM 3 -#define STB_LOOS 10 -#define STB_GNU_UNIQUE 10 -#define STB_HIOS 12 -#define STB_LOPROC 13 -#define STB_HIPROC 15 - -#define STT_NOTYPE 0 -#define STT_OBJECT 1 -#define STT_FUNC 2 -#define STT_SECTION 3 -#define STT_FILE 4 -#define STT_COMMON 5 -#define STT_TLS 6 -#define STT_NUM 7 -#define STT_LOOS 10 -#define STT_GNU_IFUNC 10 -#define STT_HIOS 12 -#define STT_LOPROC 13 -#define STT_HIPROC 15 - -#define STN_UNDEF 0 - -#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) -#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) - -#define STV_DEFAULT 0 -#define STV_INTERNAL 1 -#define STV_HIDDEN 2 -#define STV_PROTECTED 3 - - - - -typedef struct { - Elf32_Addr r_offset; - Elf32_Word r_info; -} Elf32_Rel; - -typedef struct { - Elf64_Addr r_offset; - Elf64_Xword r_info; -} Elf64_Rel; - - - -typedef struct { - Elf32_Addr r_offset; - Elf32_Word r_info; - Elf32_Sword r_addend; -} Elf32_Rela; - -typedef struct { - Elf64_Addr r_offset; - Elf64_Xword r_info; - Elf64_Sxword r_addend; -} Elf64_Rela; - - - -#define ELF32_R_SYM(val) ((val) >> 8) -#define ELF32_R_TYPE(val) ((val) & 0xff) -#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) - -#define ELF64_R_SYM(i) ((i) >> 32) -#define ELF64_R_TYPE(i) ((i) & 0xffffffff) -#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) - - - -typedef struct { - Elf32_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf32_Word p_filesz; - Elf32_Word p_memsz; - Elf32_Word p_flags; - Elf32_Word p_align; -} Elf32_Phdr; - -typedef struct { - Elf64_Word p_type; - Elf64_Word p_flags; - Elf64_Off p_offset; - Elf64_Addr p_vaddr; - Elf64_Addr p_paddr; - Elf64_Xword p_filesz; - Elf64_Xword p_memsz; - Elf64_Xword p_align; -} Elf64_Phdr; - - - -#define PT_NULL 0 -#define PT_LOAD 1 -#define PT_DYNAMIC 2 -#define PT_INTERP 3 -#define PT_NOTE 4 -#define PT_SHLIB 5 -#define PT_PHDR 6 -#define PT_TLS 7 -#define PT_NUM 8 -#define PT_LOOS 0x60000000 -#define PT_GNU_EH_FRAME 0x6474e550 -#define PT_GNU_STACK 0x6474e551 -#define PT_GNU_RELRO 0x6474e552 -#define PT_GNU_PROPERTY 0x6474e553 -#define PT_LOSUNW 0x6ffffffa -#define PT_SUNWBSS 0x6ffffffa -#define PT_SUNWSTACK 0x6ffffffb -#define PT_HISUNW 0x6fffffff -#define PT_HIOS 0x6fffffff -#define PT_LOPROC 0x70000000 -#define PT_HIPROC 0x7fffffff - - -#define PN_XNUM 0xffff - - -#define PF_X (1 << 0) -#define PF_W (1 << 1) -#define PF_R (1 << 2) -#define PF_MASKOS 0x0ff00000 -#define PF_MASKPROC 0xf0000000 - - - -#define NT_PRSTATUS 1 -#define NT_PRFPREG 2 -#define NT_FPREGSET 2 -#define NT_PRPSINFO 3 -#define NT_PRXREG 4 -#define NT_TASKSTRUCT 4 -#define NT_PLATFORM 5 -#define NT_AUXV 6 -#define NT_GWINDOWS 7 -#define NT_ASRS 8 -#define NT_PSTATUS 10 -#define NT_PSINFO 13 -#define NT_PRCRED 14 -#define NT_UTSNAME 15 -#define NT_LWPSTATUS 16 -#define NT_LWPSINFO 17 -#define NT_PRFPXREG 20 -#define NT_SIGINFO 0x53494749 -#define NT_FILE 0x46494c45 -#define NT_PRXFPREG 0x46e62b7f -#define NT_PPC_VMX 0x100 -#define NT_PPC_SPE 0x101 -#define NT_PPC_VSX 0x102 -#define NT_PPC_TAR 0x103 -#define NT_PPC_PPR 0x104 -#define NT_PPC_DSCR 0x105 -#define NT_PPC_EBB 0x106 -#define NT_PPC_PMU 0x107 -#define NT_PPC_TM_CGPR 0x108 -#define NT_PPC_TM_CFPR 0x109 -#define NT_PPC_TM_CVMX 0x10a -#define NT_PPC_TM_CVSX 0x10b -#define NT_PPC_TM_SPR 0x10c -#define NT_PPC_TM_CTAR 0x10d -#define NT_PPC_TM_CPPR 0x10e -#define NT_PPC_TM_CDSCR 0x10f -#define NT_386_TLS 0x200 -#define NT_386_IOPERM 0x201 -#define NT_X86_XSTATE 0x202 -#define NT_S390_HIGH_GPRS 0x300 -#define NT_S390_TIMER 0x301 -#define NT_S390_TODCMP 0x302 -#define NT_S390_TODPREG 0x303 -#define NT_S390_CTRS 0x304 -#define NT_S390_PREFIX 0x305 -#define NT_S390_LAST_BREAK 0x306 -#define NT_S390_SYSTEM_CALL 0x307 -#define NT_S390_TDB 0x308 -#define NT_S390_VXRS_LOW 0x309 -#define NT_S390_VXRS_HIGH 0x30a -#define NT_S390_GS_CB 0x30b -#define NT_S390_GS_BC 0x30c -#define NT_S390_RI_CB 0x30d -#define NT_ARM_VFP 0x400 -#define NT_ARM_TLS 0x401 -#define NT_ARM_HW_BREAK 0x402 -#define NT_ARM_HW_WATCH 0x403 -#define NT_ARM_SYSTEM_CALL 0x404 -#define NT_ARM_SVE 0x405 -#define NT_ARM_PAC_MASK 0x406 -#define NT_ARM_PACA_KEYS 0x407 -#define NT_ARM_PACG_KEYS 0x408 -#define NT_ARM_TAGGED_ADDR_CTRL 0x409 -#define NT_ARM_PAC_ENABLED_KEYS 0x40a -#define NT_METAG_CBUF 0x500 -#define NT_METAG_RPIPE 0x501 -#define NT_METAG_TLS 0x502 -#define NT_ARC_V2 0x600 -#define NT_VMCOREDD 0x700 -#define NT_MIPS_DSP 0x800 -#define NT_MIPS_FP_MODE 0x801 -#define NT_MIPS_MSA 0x802 -#define NT_VERSION 1 - - - - -typedef struct { - Elf32_Sword d_tag; - union { - Elf32_Word d_val; - Elf32_Addr d_ptr; - } d_un; -} Elf32_Dyn; - -typedef struct { - Elf64_Sxword d_tag; - union { - Elf64_Xword d_val; - Elf64_Addr d_ptr; - } d_un; -} Elf64_Dyn; - - - -#define DT_NULL 0 -#define DT_NEEDED 1 -#define DT_PLTRELSZ 2 -#define DT_PLTGOT 3 -#define DT_HASH 4 -#define DT_STRTAB 5 -#define DT_SYMTAB 6 -#define DT_RELA 7 -#define DT_RELASZ 8 -#define DT_RELAENT 9 -#define DT_STRSZ 10 -#define DT_SYMENT 11 -#define DT_INIT 12 -#define DT_FINI 13 -#define DT_SONAME 14 -#define DT_RPATH 15 -#define DT_SYMBOLIC 16 -#define DT_REL 17 -#define DT_RELSZ 18 -#define DT_RELENT 19 -#define DT_PLTREL 20 -#define DT_DEBUG 21 -#define DT_TEXTREL 22 -#define DT_JMPREL 23 -#define DT_BIND_NOW 24 -#define DT_INIT_ARRAY 25 -#define DT_FINI_ARRAY 26 -#define DT_INIT_ARRAYSZ 27 -#define DT_FINI_ARRAYSZ 28 -#define DT_RUNPATH 29 -#define DT_FLAGS 30 -#define DT_ENCODING 32 -#define DT_PREINIT_ARRAY 32 -#define DT_PREINIT_ARRAYSZ 33 -#define DT_SYMTAB_SHNDX 34 -#define DT_NUM 35 -#define DT_LOOS 0x6000000d -#define DT_HIOS 0x6ffff000 -#define DT_LOPROC 0x70000000 -#define DT_HIPROC 0x7fffffff -#define DT_PROCNUM DT_MIPS_NUM - -#define DT_VALRNGLO 0x6ffffd00 -#define DT_GNU_PRELINKED 0x6ffffdf5 -#define DT_GNU_CONFLICTSZ 0x6ffffdf6 -#define DT_GNU_LIBLISTSZ 0x6ffffdf7 -#define DT_CHECKSUM 0x6ffffdf8 -#define DT_PLTPADSZ 0x6ffffdf9 -#define DT_MOVEENT 0x6ffffdfa -#define DT_MOVESZ 0x6ffffdfb -#define DT_FEATURE_1 0x6ffffdfc -#define DT_POSFLAG_1 0x6ffffdfd - -#define DT_SYMINSZ 0x6ffffdfe -#define DT_SYMINENT 0x6ffffdff -#define DT_VALRNGHI 0x6ffffdff -#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) -#define DT_VALNUM 12 - -#define DT_ADDRRNGLO 0x6ffffe00 -#define DT_GNU_HASH 0x6ffffef5 -#define DT_TLSDESC_PLT 0x6ffffef6 -#define DT_TLSDESC_GOT 0x6ffffef7 -#define DT_GNU_CONFLICT 0x6ffffef8 -#define DT_GNU_LIBLIST 0x6ffffef9 -#define DT_CONFIG 0x6ffffefa -#define DT_DEPAUDIT 0x6ffffefb -#define DT_AUDIT 0x6ffffefc -#define DT_PLTPAD 0x6ffffefd -#define DT_MOVETAB 0x6ffffefe -#define DT_SYMINFO 0x6ffffeff -#define DT_ADDRRNGHI 0x6ffffeff -#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) -#define DT_ADDRNUM 11 - - - -#define DT_VERSYM 0x6ffffff0 - -#define DT_RELACOUNT 0x6ffffff9 -#define DT_RELCOUNT 0x6ffffffa - - -#define DT_FLAGS_1 0x6ffffffb -#define DT_VERDEF 0x6ffffffc - -#define DT_VERDEFNUM 0x6ffffffd -#define DT_VERNEED 0x6ffffffe - -#define DT_VERNEEDNUM 0x6fffffff -#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) -#define DT_VERSIONTAGNUM 16 - - - -#define DT_AUXILIARY 0x7ffffffd -#define DT_FILTER 0x7fffffff -#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) -#define DT_EXTRANUM 3 - - -#define DF_ORIGIN 0x00000001 -#define DF_SYMBOLIC 0x00000002 -#define DF_TEXTREL 0x00000004 -#define DF_BIND_NOW 0x00000008 -#define DF_STATIC_TLS 0x00000010 - - - -#define DF_1_NOW 0x00000001 -#define DF_1_GLOBAL 0x00000002 -#define DF_1_GROUP 0x00000004 -#define DF_1_NODELETE 0x00000008 -#define DF_1_LOADFLTR 0x00000010 -#define DF_1_INITFIRST 0x00000020 -#define DF_1_NOOPEN 0x00000040 -#define DF_1_ORIGIN 0x00000080 -#define DF_1_DIRECT 0x00000100 -#define DF_1_TRANS 0x00000200 -#define DF_1_INTERPOSE 0x00000400 -#define DF_1_NODEFLIB 0x00000800 -#define DF_1_NODUMP 0x00001000 -#define DF_1_CONFALT 0x00002000 -#define DF_1_ENDFILTEE 0x00004000 -#define DF_1_DISPRELDNE 0x00008000 -#define DF_1_DISPRELPND 0x00010000 -#define DF_1_NODIRECT 0x00020000 -#define DF_1_IGNMULDEF 0x00040000 -#define DF_1_NOKSYMS 0x00080000 -#define DF_1_NOHDR 0x00100000 -#define DF_1_EDITED 0x00200000 -#define DF_1_NORELOC 0x00400000 -#define DF_1_SYMINTPOSE 0x00800000 -#define DF_1_GLOBAUDIT 0x01000000 -#define DF_1_SINGLETON 0x02000000 -#define DF_1_STUB 0x04000000 -#define DF_1_PIE 0x08000000 - -#define DTF_1_PARINIT 0x00000001 -#define DTF_1_CONFEXP 0x00000002 - - -#define DF_P1_LAZYLOAD 0x00000001 -#define DF_P1_GROUPPERM 0x00000002 - - - - -typedef struct { - Elf32_Half vd_version; - Elf32_Half vd_flags; - Elf32_Half vd_ndx; - Elf32_Half vd_cnt; - Elf32_Word vd_hash; - Elf32_Word vd_aux; - Elf32_Word vd_next; -} Elf32_Verdef; - -typedef struct { - Elf64_Half vd_version; - Elf64_Half vd_flags; - Elf64_Half vd_ndx; - Elf64_Half vd_cnt; - Elf64_Word vd_hash; - Elf64_Word vd_aux; - Elf64_Word vd_next; -} Elf64_Verdef; - - - -#define VER_DEF_NONE 0 -#define VER_DEF_CURRENT 1 -#define VER_DEF_NUM 2 - - -#define VER_FLG_BASE 0x1 -#define VER_FLG_WEAK 0x2 - - -#define VER_NDX_LOCAL 0 -#define VER_NDX_GLOBAL 1 -#define VER_NDX_LORESERVE 0xff00 -#define VER_NDX_ELIMINATE 0xff01 - - - -typedef struct { - Elf32_Word vda_name; - Elf32_Word vda_next; -} Elf32_Verdaux; - -typedef struct { - Elf64_Word vda_name; - Elf64_Word vda_next; -} Elf64_Verdaux; - - - - -typedef struct { - Elf32_Half vn_version; - Elf32_Half vn_cnt; - Elf32_Word vn_file; - Elf32_Word vn_aux; - Elf32_Word vn_next; -} Elf32_Verneed; - -typedef struct { - Elf64_Half vn_version; - Elf64_Half vn_cnt; - Elf64_Word vn_file; - Elf64_Word vn_aux; - Elf64_Word vn_next; -} Elf64_Verneed; - - - -#define VER_NEED_NONE 0 -#define VER_NEED_CURRENT 1 -#define VER_NEED_NUM 2 - - - -typedef struct { - Elf32_Word vna_hash; - Elf32_Half vna_flags; - Elf32_Half vna_other; - Elf32_Word vna_name; - Elf32_Word vna_next; -} Elf32_Vernaux; - -typedef struct { - Elf64_Word vna_hash; - Elf64_Half vna_flags; - Elf64_Half vna_other; - Elf64_Word vna_name; - Elf64_Word vna_next; -} Elf64_Vernaux; - - - -#define VER_FLG_WEAK 0x2 - - - -typedef struct { - uint32_t a_type; - union { - uint32_t a_val; - } a_un; -} Elf32_auxv_t; - -typedef struct { - uint64_t a_type; - union { - uint64_t a_val; - } a_un; -} Elf64_auxv_t; - - - -#define AT_NULL 0 -#define AT_IGNORE 1 -#define AT_EXECFD 2 -#define AT_PHDR 3 -#define AT_PHENT 4 -#define AT_PHNUM 5 -#define AT_PAGESZ 6 -#define AT_BASE 7 -#define AT_FLAGS 8 -#define AT_ENTRY 9 -#define AT_NOTELF 10 -#define AT_UID 11 -#define AT_EUID 12 -#define AT_GID 13 -#define AT_EGID 14 -#define AT_CLKTCK 17 - - -#define AT_PLATFORM 15 -#define AT_HWCAP 16 - - - - -#define AT_FPUCW 18 - - -#define AT_DCACHEBSIZE 19 -#define AT_ICACHEBSIZE 20 -#define AT_UCACHEBSIZE 21 - - - -#define AT_IGNOREPPC 22 - -#define AT_SECURE 23 - -#define AT_BASE_PLATFORM 24 - -#define AT_RANDOM 25 - -#define AT_HWCAP2 26 - -#define AT_EXECFN 31 - - - -#define AT_SYSINFO 32 -#define AT_SYSINFO_EHDR 33 - - - -#define AT_L1I_CACHESHAPE 34 -#define AT_L1D_CACHESHAPE 35 -#define AT_L2_CACHESHAPE 36 -#define AT_L3_CACHESHAPE 37 - -#define AT_L1I_CACHESIZE 40 -#define AT_L1I_CACHEGEOMETRY 41 -#define AT_L1D_CACHESIZE 42 -#define AT_L1D_CACHEGEOMETRY 43 -#define AT_L2_CACHESIZE 44 -#define AT_L2_CACHEGEOMETRY 45 -#define AT_L3_CACHESIZE 46 -#define AT_L3_CACHEGEOMETRY 47 - -#define AT_MINSIGSTKSZ 51 - - -typedef struct { - Elf32_Word n_namesz; - Elf32_Word n_descsz; - Elf32_Word n_type; -} Elf32_Nhdr; - -typedef struct { - Elf64_Word n_namesz; - Elf64_Word n_descsz; - Elf64_Word n_type; -} Elf64_Nhdr; - - - - -#define ELF_NOTE_SOLARIS "SUNW Solaris" - - -#define ELF_NOTE_GNU "GNU" - - - - - -#define ELF_NOTE_PAGESIZE_HINT 1 - - -#define NT_GNU_ABI_TAG 1 -#define ELF_NOTE_ABI NT_GNU_ABI_TAG - - - -#define ELF_NOTE_OS_LINUX 0 -#define ELF_NOTE_OS_GNU 1 -#define ELF_NOTE_OS_SOLARIS2 2 -#define ELF_NOTE_OS_FREEBSD 3 - -#define NT_GNU_BUILD_ID 3 -#define NT_GNU_GOLD_VERSION 4 -#define NT_GNU_PROPERTY_TYPE_0 5 - - - -typedef struct { - Elf32_Xword m_value; - Elf32_Word m_info; - Elf32_Word m_poffset; - Elf32_Half m_repeat; - Elf32_Half m_stride; -} Elf32_Move; - -typedef struct { - Elf64_Xword m_value; - Elf64_Xword m_info; - Elf64_Xword m_poffset; - Elf64_Half m_repeat; - Elf64_Half m_stride; -} Elf64_Move; - - -#define ELF32_M_SYM(info) ((info) >> 8) -#define ELF32_M_SIZE(info) ((unsigned char) (info)) -#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) - -#define ELF64_M_SYM(info) ELF32_M_SYM (info) -#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) -#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) - -#define EF_CPU32 0x00810000 - -#define R_68K_NONE 0 -#define R_68K_32 1 -#define R_68K_16 2 -#define R_68K_8 3 -#define R_68K_PC32 4 -#define R_68K_PC16 5 -#define R_68K_PC8 6 -#define R_68K_GOT32 7 -#define R_68K_GOT16 8 -#define R_68K_GOT8 9 -#define R_68K_GOT32O 10 -#define R_68K_GOT16O 11 -#define R_68K_GOT8O 12 -#define R_68K_PLT32 13 -#define R_68K_PLT16 14 -#define R_68K_PLT8 15 -#define R_68K_PLT32O 16 -#define R_68K_PLT16O 17 -#define R_68K_PLT8O 18 -#define R_68K_COPY 19 -#define R_68K_GLOB_DAT 20 -#define R_68K_JMP_SLOT 21 -#define R_68K_RELATIVE 22 -#define R_68K_TLS_GD32 25 -#define R_68K_TLS_GD16 26 -#define R_68K_TLS_GD8 27 -#define R_68K_TLS_LDM32 28 -#define R_68K_TLS_LDM16 29 -#define R_68K_TLS_LDM8 30 -#define R_68K_TLS_LDO32 31 -#define R_68K_TLS_LDO16 32 -#define R_68K_TLS_LDO8 33 -#define R_68K_TLS_IE32 34 -#define R_68K_TLS_IE16 35 -#define R_68K_TLS_IE8 36 -#define R_68K_TLS_LE32 37 -#define R_68K_TLS_LE16 38 -#define R_68K_TLS_LE8 39 -#define R_68K_TLS_DTPMOD32 40 -#define R_68K_TLS_DTPREL32 41 -#define R_68K_TLS_TPREL32 42 -#define R_68K_NUM 43 - -#define R_386_NONE 0 -#define R_386_32 1 -#define R_386_PC32 2 -#define R_386_GOT32 3 -#define R_386_PLT32 4 -#define R_386_COPY 5 -#define R_386_GLOB_DAT 6 -#define R_386_JMP_SLOT 7 -#define R_386_RELATIVE 8 -#define R_386_GOTOFF 9 -#define R_386_GOTPC 10 -#define R_386_32PLT 11 -#define R_386_TLS_TPOFF 14 -#define R_386_TLS_IE 15 -#define R_386_TLS_GOTIE 16 -#define R_386_TLS_LE 17 -#define R_386_TLS_GD 18 -#define R_386_TLS_LDM 19 -#define R_386_16 20 -#define R_386_PC16 21 -#define R_386_8 22 -#define R_386_PC8 23 -#define R_386_TLS_GD_32 24 -#define R_386_TLS_GD_PUSH 25 -#define R_386_TLS_GD_CALL 26 -#define R_386_TLS_GD_POP 27 -#define R_386_TLS_LDM_32 28 -#define R_386_TLS_LDM_PUSH 29 -#define R_386_TLS_LDM_CALL 30 -#define R_386_TLS_LDM_POP 31 -#define R_386_TLS_LDO_32 32 -#define R_386_TLS_IE_32 33 -#define R_386_TLS_LE_32 34 -#define R_386_TLS_DTPMOD32 35 -#define R_386_TLS_DTPOFF32 36 -#define R_386_TLS_TPOFF32 37 -#define R_386_SIZE32 38 -#define R_386_TLS_GOTDESC 39 -#define R_386_TLS_DESC_CALL 40 -#define R_386_TLS_DESC 41 -#define R_386_IRELATIVE 42 -#define R_386_GOT32X 43 -#define R_386_NUM 44 - - - - - -#define STT_SPARC_REGISTER 13 - - - -#define EF_SPARCV9_MM 3 -#define EF_SPARCV9_TSO 0 -#define EF_SPARCV9_PSO 1 -#define EF_SPARCV9_RMO 2 -#define EF_SPARC_LEDATA 0x800000 -#define EF_SPARC_EXT_MASK 0xFFFF00 -#define EF_SPARC_32PLUS 0x000100 -#define EF_SPARC_SUN_US1 0x000200 -#define EF_SPARC_HAL_R1 0x000400 -#define EF_SPARC_SUN_US3 0x000800 - - - -#define R_SPARC_NONE 0 -#define R_SPARC_8 1 -#define R_SPARC_16 2 -#define R_SPARC_32 3 -#define R_SPARC_DISP8 4 -#define R_SPARC_DISP16 5 -#define R_SPARC_DISP32 6 -#define R_SPARC_WDISP30 7 -#define R_SPARC_WDISP22 8 -#define R_SPARC_HI22 9 -#define R_SPARC_22 10 -#define R_SPARC_13 11 -#define R_SPARC_LO10 12 -#define R_SPARC_GOT10 13 -#define R_SPARC_GOT13 14 -#define R_SPARC_GOT22 15 -#define R_SPARC_PC10 16 -#define R_SPARC_PC22 17 -#define R_SPARC_WPLT30 18 -#define R_SPARC_COPY 19 -#define R_SPARC_GLOB_DAT 20 -#define R_SPARC_JMP_SLOT 21 -#define R_SPARC_RELATIVE 22 -#define R_SPARC_UA32 23 - - - -#define R_SPARC_PLT32 24 -#define R_SPARC_HIPLT22 25 -#define R_SPARC_LOPLT10 26 -#define R_SPARC_PCPLT32 27 -#define R_SPARC_PCPLT22 28 -#define R_SPARC_PCPLT10 29 -#define R_SPARC_10 30 -#define R_SPARC_11 31 -#define R_SPARC_64 32 -#define R_SPARC_OLO10 33 -#define R_SPARC_HH22 34 -#define R_SPARC_HM10 35 -#define R_SPARC_LM22 36 -#define R_SPARC_PC_HH22 37 -#define R_SPARC_PC_HM10 38 -#define R_SPARC_PC_LM22 39 -#define R_SPARC_WDISP16 40 -#define R_SPARC_WDISP19 41 -#define R_SPARC_GLOB_JMP 42 -#define R_SPARC_7 43 -#define R_SPARC_5 44 -#define R_SPARC_6 45 -#define R_SPARC_DISP64 46 -#define R_SPARC_PLT64 47 -#define R_SPARC_HIX22 48 -#define R_SPARC_LOX10 49 -#define R_SPARC_H44 50 -#define R_SPARC_M44 51 -#define R_SPARC_L44 52 -#define R_SPARC_REGISTER 53 -#define R_SPARC_UA64 54 -#define R_SPARC_UA16 55 -#define R_SPARC_TLS_GD_HI22 56 -#define R_SPARC_TLS_GD_LO10 57 -#define R_SPARC_TLS_GD_ADD 58 -#define R_SPARC_TLS_GD_CALL 59 -#define R_SPARC_TLS_LDM_HI22 60 -#define R_SPARC_TLS_LDM_LO10 61 -#define R_SPARC_TLS_LDM_ADD 62 -#define R_SPARC_TLS_LDM_CALL 63 -#define R_SPARC_TLS_LDO_HIX22 64 -#define R_SPARC_TLS_LDO_LOX10 65 -#define R_SPARC_TLS_LDO_ADD 66 -#define R_SPARC_TLS_IE_HI22 67 -#define R_SPARC_TLS_IE_LO10 68 -#define R_SPARC_TLS_IE_LD 69 -#define R_SPARC_TLS_IE_LDX 70 -#define R_SPARC_TLS_IE_ADD 71 -#define R_SPARC_TLS_LE_HIX22 72 -#define R_SPARC_TLS_LE_LOX10 73 -#define R_SPARC_TLS_DTPMOD32 74 -#define R_SPARC_TLS_DTPMOD64 75 -#define R_SPARC_TLS_DTPOFF32 76 -#define R_SPARC_TLS_DTPOFF64 77 -#define R_SPARC_TLS_TPOFF32 78 -#define R_SPARC_TLS_TPOFF64 79 -#define R_SPARC_GOTDATA_HIX22 80 -#define R_SPARC_GOTDATA_LOX10 81 -#define R_SPARC_GOTDATA_OP_HIX22 82 -#define R_SPARC_GOTDATA_OP_LOX10 83 -#define R_SPARC_GOTDATA_OP 84 -#define R_SPARC_H34 85 -#define R_SPARC_SIZE32 86 -#define R_SPARC_SIZE64 87 -#define R_SPARC_GNU_VTINHERIT 250 -#define R_SPARC_GNU_VTENTRY 251 -#define R_SPARC_REV32 252 - -#define R_SPARC_NUM 253 - - - -#define DT_SPARC_REGISTER 0x70000001 -#define DT_SPARC_NUM 2 - - -#define EF_MIPS_NOREORDER 1 -#define EF_MIPS_PIC 2 -#define EF_MIPS_CPIC 4 -#define EF_MIPS_XGOT 8 -#define EF_MIPS_64BIT_WHIRL 16 -#define EF_MIPS_ABI2 32 -#define EF_MIPS_ABI_ON32 64 -#define EF_MIPS_FP64 512 -#define EF_MIPS_NAN2008 1024 -#define EF_MIPS_ARCH 0xf0000000 - - - -#define EF_MIPS_ARCH_1 0x00000000 -#define EF_MIPS_ARCH_2 0x10000000 -#define EF_MIPS_ARCH_3 0x20000000 -#define EF_MIPS_ARCH_4 0x30000000 -#define EF_MIPS_ARCH_5 0x40000000 -#define EF_MIPS_ARCH_32 0x50000000 -#define EF_MIPS_ARCH_64 0x60000000 -#define EF_MIPS_ARCH_32R2 0x70000000 -#define EF_MIPS_ARCH_64R2 0x80000000 - - -#define E_MIPS_ARCH_1 0x00000000 -#define E_MIPS_ARCH_2 0x10000000 -#define E_MIPS_ARCH_3 0x20000000 -#define E_MIPS_ARCH_4 0x30000000 -#define E_MIPS_ARCH_5 0x40000000 -#define E_MIPS_ARCH_32 0x50000000 -#define E_MIPS_ARCH_64 0x60000000 - - - -#define SHN_MIPS_ACOMMON 0xff00 -#define SHN_MIPS_TEXT 0xff01 -#define SHN_MIPS_DATA 0xff02 -#define SHN_MIPS_SCOMMON 0xff03 -#define SHN_MIPS_SUNDEFINED 0xff04 - - - -#define SHT_MIPS_LIBLIST 0x70000000 -#define SHT_MIPS_MSYM 0x70000001 -#define SHT_MIPS_CONFLICT 0x70000002 -#define SHT_MIPS_GPTAB 0x70000003 -#define SHT_MIPS_UCODE 0x70000004 -#define SHT_MIPS_DEBUG 0x70000005 -#define SHT_MIPS_REGINFO 0x70000006 -#define SHT_MIPS_PACKAGE 0x70000007 -#define SHT_MIPS_PACKSYM 0x70000008 -#define SHT_MIPS_RELD 0x70000009 -#define SHT_MIPS_IFACE 0x7000000b -#define SHT_MIPS_CONTENT 0x7000000c -#define SHT_MIPS_OPTIONS 0x7000000d -#define SHT_MIPS_SHDR 0x70000010 -#define SHT_MIPS_FDESC 0x70000011 -#define SHT_MIPS_EXTSYM 0x70000012 -#define SHT_MIPS_DENSE 0x70000013 -#define SHT_MIPS_PDESC 0x70000014 -#define SHT_MIPS_LOCSYM 0x70000015 -#define SHT_MIPS_AUXSYM 0x70000016 -#define SHT_MIPS_OPTSYM 0x70000017 -#define SHT_MIPS_LOCSTR 0x70000018 -#define SHT_MIPS_LINE 0x70000019 -#define SHT_MIPS_RFDESC 0x7000001a -#define SHT_MIPS_DELTASYM 0x7000001b -#define SHT_MIPS_DELTAINST 0x7000001c -#define SHT_MIPS_DELTACLASS 0x7000001d -#define SHT_MIPS_DWARF 0x7000001e -#define SHT_MIPS_DELTADECL 0x7000001f -#define SHT_MIPS_SYMBOL_LIB 0x70000020 -#define SHT_MIPS_EVENTS 0x70000021 -#define SHT_MIPS_TRANSLATE 0x70000022 -#define SHT_MIPS_PIXIE 0x70000023 -#define SHT_MIPS_XLATE 0x70000024 -#define SHT_MIPS_XLATE_DEBUG 0x70000025 -#define SHT_MIPS_WHIRL 0x70000026 -#define SHT_MIPS_EH_REGION 0x70000027 -#define SHT_MIPS_XLATE_OLD 0x70000028 -#define SHT_MIPS_PDR_EXCEPTION 0x70000029 - - - -#define SHF_MIPS_GPREL 0x10000000 -#define SHF_MIPS_MERGE 0x20000000 -#define SHF_MIPS_ADDR 0x40000000 -#define SHF_MIPS_STRINGS 0x80000000 -#define SHF_MIPS_NOSTRIP 0x08000000 -#define SHF_MIPS_LOCAL 0x04000000 -#define SHF_MIPS_NAMES 0x02000000 -#define SHF_MIPS_NODUPE 0x01000000 - - - - - -#define STO_MIPS_DEFAULT 0x0 -#define STO_MIPS_INTERNAL 0x1 -#define STO_MIPS_HIDDEN 0x2 -#define STO_MIPS_PROTECTED 0x3 -#define STO_MIPS_PLT 0x8 -#define STO_MIPS_SC_ALIGN_UNUSED 0xff - - -#define STB_MIPS_SPLIT_COMMON 13 - - - -typedef union { - struct { - Elf32_Word gt_current_g_value; - Elf32_Word gt_unused; - } gt_header; - struct { - Elf32_Word gt_g_value; - Elf32_Word gt_bytes; - } gt_entry; -} Elf32_gptab; - - - -typedef struct { - Elf32_Word ri_gprmask; - Elf32_Word ri_cprmask[4]; - Elf32_Sword ri_gp_value; -} Elf32_RegInfo; - - - -typedef struct { - unsigned char kind; - - unsigned char size; - Elf32_Section section; - - Elf32_Word info; -} Elf_Options; - - - -#define ODK_NULL 0 -#define ODK_REGINFO 1 -#define ODK_EXCEPTIONS 2 -#define ODK_PAD 3 -#define ODK_HWPATCH 4 -#define ODK_FILL 5 -#define ODK_TAGS 6 -#define ODK_HWAND 7 -#define ODK_HWOR 8 - - - -#define OEX_FPU_MIN 0x1f -#define OEX_FPU_MAX 0x1f00 -#define OEX_PAGE0 0x10000 -#define OEX_SMM 0x20000 -#define OEX_FPDBUG 0x40000 -#define OEX_PRECISEFP OEX_FPDBUG -#define OEX_DISMISS 0x80000 - -#define OEX_FPU_INVAL 0x10 -#define OEX_FPU_DIV0 0x08 -#define OEX_FPU_OFLO 0x04 -#define OEX_FPU_UFLO 0x02 -#define OEX_FPU_INEX 0x01 - - - -#define OHW_R4KEOP 0x1 -#define OHW_R8KPFETCH 0x2 -#define OHW_R5KEOP 0x4 -#define OHW_R5KCVTL 0x8 - -#define OPAD_PREFIX 0x1 -#define OPAD_POSTFIX 0x2 -#define OPAD_SYMBOL 0x4 - - - -typedef struct { - Elf32_Word hwp_flags1; - Elf32_Word hwp_flags2; -} Elf_Options_Hw; - - - -#define OHWA0_R4KEOP_CHECKED 0x00000001 -#define OHWA1_R4KEOP_CLEAN 0x00000002 - - - -#define R_MIPS_NONE 0 -#define R_MIPS_16 1 -#define R_MIPS_32 2 -#define R_MIPS_REL32 3 -#define R_MIPS_26 4 -#define R_MIPS_HI16 5 -#define R_MIPS_LO16 6 -#define R_MIPS_GPREL16 7 -#define R_MIPS_LITERAL 8 -#define R_MIPS_GOT16 9 -#define R_MIPS_PC16 10 -#define R_MIPS_CALL16 11 -#define R_MIPS_GPREL32 12 - -#define R_MIPS_SHIFT5 16 -#define R_MIPS_SHIFT6 17 -#define R_MIPS_64 18 -#define R_MIPS_GOT_DISP 19 -#define R_MIPS_GOT_PAGE 20 -#define R_MIPS_GOT_OFST 21 -#define R_MIPS_GOT_HI16 22 -#define R_MIPS_GOT_LO16 23 -#define R_MIPS_SUB 24 -#define R_MIPS_INSERT_A 25 -#define R_MIPS_INSERT_B 26 -#define R_MIPS_DELETE 27 -#define R_MIPS_HIGHER 28 -#define R_MIPS_HIGHEST 29 -#define R_MIPS_CALL_HI16 30 -#define R_MIPS_CALL_LO16 31 -#define R_MIPS_SCN_DISP 32 -#define R_MIPS_REL16 33 -#define R_MIPS_ADD_IMMEDIATE 34 -#define R_MIPS_PJUMP 35 -#define R_MIPS_RELGOT 36 -#define R_MIPS_JALR 37 -#define R_MIPS_TLS_DTPMOD32 38 -#define R_MIPS_TLS_DTPREL32 39 -#define R_MIPS_TLS_DTPMOD64 40 -#define R_MIPS_TLS_DTPREL64 41 -#define R_MIPS_TLS_GD 42 -#define R_MIPS_TLS_LDM 43 -#define R_MIPS_TLS_DTPREL_HI16 44 -#define R_MIPS_TLS_DTPREL_LO16 45 -#define R_MIPS_TLS_GOTTPREL 46 -#define R_MIPS_TLS_TPREL32 47 -#define R_MIPS_TLS_TPREL64 48 -#define R_MIPS_TLS_TPREL_HI16 49 -#define R_MIPS_TLS_TPREL_LO16 50 -#define R_MIPS_GLOB_DAT 51 -#define R_MIPS_COPY 126 -#define R_MIPS_JUMP_SLOT 127 - -#define R_MIPS_NUM 128 - - - -#define PT_MIPS_REGINFO 0x70000000 -#define PT_MIPS_RTPROC 0x70000001 -#define PT_MIPS_OPTIONS 0x70000002 -#define PT_MIPS_ABIFLAGS 0x70000003 - - - -#define PF_MIPS_LOCAL 0x10000000 - - - -#define DT_MIPS_RLD_VERSION 0x70000001 -#define DT_MIPS_TIME_STAMP 0x70000002 -#define DT_MIPS_ICHECKSUM 0x70000003 -#define DT_MIPS_IVERSION 0x70000004 -#define DT_MIPS_FLAGS 0x70000005 -#define DT_MIPS_BASE_ADDRESS 0x70000006 -#define DT_MIPS_MSYM 0x70000007 -#define DT_MIPS_CONFLICT 0x70000008 -#define DT_MIPS_LIBLIST 0x70000009 -#define DT_MIPS_LOCAL_GOTNO 0x7000000a -#define DT_MIPS_CONFLICTNO 0x7000000b -#define DT_MIPS_LIBLISTNO 0x70000010 -#define DT_MIPS_SYMTABNO 0x70000011 -#define DT_MIPS_UNREFEXTNO 0x70000012 -#define DT_MIPS_GOTSYM 0x70000013 -#define DT_MIPS_HIPAGENO 0x70000014 -#define DT_MIPS_RLD_MAP 0x70000016 -#define DT_MIPS_DELTA_CLASS 0x70000017 -#define DT_MIPS_DELTA_CLASS_NO 0x70000018 - -#define DT_MIPS_DELTA_INSTANCE 0x70000019 -#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a - -#define DT_MIPS_DELTA_RELOC 0x7000001b -#define DT_MIPS_DELTA_RELOC_NO 0x7000001c - -#define DT_MIPS_DELTA_SYM 0x7000001d - -#define DT_MIPS_DELTA_SYM_NO 0x7000001e - -#define DT_MIPS_DELTA_CLASSSYM 0x70000020 - -#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 - -#define DT_MIPS_CXX_FLAGS 0x70000022 -#define DT_MIPS_PIXIE_INIT 0x70000023 -#define DT_MIPS_SYMBOL_LIB 0x70000024 -#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 -#define DT_MIPS_LOCAL_GOTIDX 0x70000026 -#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 -#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 -#define DT_MIPS_OPTIONS 0x70000029 -#define DT_MIPS_INTERFACE 0x7000002a -#define DT_MIPS_DYNSTR_ALIGN 0x7000002b -#define DT_MIPS_INTERFACE_SIZE 0x7000002c -#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d - -#define DT_MIPS_PERF_SUFFIX 0x7000002e - -#define DT_MIPS_COMPACT_SIZE 0x7000002f -#define DT_MIPS_GP_VALUE 0x70000030 -#define DT_MIPS_AUX_DYNAMIC 0x70000031 - -#define DT_MIPS_PLTGOT 0x70000032 - -#define DT_MIPS_RWPLT 0x70000034 -#define DT_MIPS_RLD_MAP_REL 0x70000035 -#define DT_MIPS_NUM 0x36 - - - -#define RHF_NONE 0 -#define RHF_QUICKSTART (1 << 0) -#define RHF_NOTPOT (1 << 1) -#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) -#define RHF_NO_MOVE (1 << 3) -#define RHF_SGI_ONLY (1 << 4) -#define RHF_GUARANTEE_INIT (1 << 5) -#define RHF_DELTA_C_PLUS_PLUS (1 << 6) -#define RHF_GUARANTEE_START_INIT (1 << 7) -#define RHF_PIXIE (1 << 8) -#define RHF_DEFAULT_DELAY_LOAD (1 << 9) -#define RHF_REQUICKSTART (1 << 10) -#define RHF_REQUICKSTARTED (1 << 11) -#define RHF_CORD (1 << 12) -#define RHF_NO_UNRES_UNDEF (1 << 13) -#define RHF_RLD_ORDER_SAFE (1 << 14) - - - -typedef struct { - Elf32_Word l_name; - Elf32_Word l_time_stamp; - Elf32_Word l_checksum; - Elf32_Word l_version; - Elf32_Word l_flags; -} Elf32_Lib; - -typedef struct { - Elf64_Word l_name; - Elf64_Word l_time_stamp; - Elf64_Word l_checksum; - Elf64_Word l_version; - Elf64_Word l_flags; -} Elf64_Lib; - - - - -#define LL_NONE 0 -#define LL_EXACT_MATCH (1 << 0) -#define LL_IGNORE_INT_VER (1 << 1) -#define LL_REQUIRE_MINOR (1 << 2) -#define LL_EXPORTS (1 << 3) -#define LL_DELAY_LOAD (1 << 4) -#define LL_DELTA (1 << 5) - - - -typedef Elf32_Addr Elf32_Conflict; - -typedef struct { - Elf32_Half version; - unsigned char isa_level; - unsigned char isa_rev; - unsigned char gpr_size; - unsigned char cpr1_size; - unsigned char cpr2_size; - unsigned char fp_abi; - Elf32_Word isa_ext; - Elf32_Word ases; - Elf32_Word flags1; - Elf32_Word flags2; -} Elf_MIPS_ABIFlags_v0; - -#define MIPS_AFL_REG_NONE 0x00 -#define MIPS_AFL_REG_32 0x01 -#define MIPS_AFL_REG_64 0x02 -#define MIPS_AFL_REG_128 0x03 - -#define MIPS_AFL_ASE_DSP 0x00000001 -#define MIPS_AFL_ASE_DSPR2 0x00000002 -#define MIPS_AFL_ASE_EVA 0x00000004 -#define MIPS_AFL_ASE_MCU 0x00000008 -#define MIPS_AFL_ASE_MDMX 0x00000010 -#define MIPS_AFL_ASE_MIPS3D 0x00000020 -#define MIPS_AFL_ASE_MT 0x00000040 -#define MIPS_AFL_ASE_SMARTMIPS 0x00000080 -#define MIPS_AFL_ASE_VIRT 0x00000100 -#define MIPS_AFL_ASE_MSA 0x00000200 -#define MIPS_AFL_ASE_MIPS16 0x00000400 -#define MIPS_AFL_ASE_MICROMIPS 0x00000800 -#define MIPS_AFL_ASE_XPA 0x00001000 -#define MIPS_AFL_ASE_MASK 0x00001fff - -#define MIPS_AFL_EXT_XLR 1 -#define MIPS_AFL_EXT_OCTEON2 2 -#define MIPS_AFL_EXT_OCTEONP 3 -#define MIPS_AFL_EXT_LOONGSON_3A 4 -#define MIPS_AFL_EXT_OCTEON 5 -#define MIPS_AFL_EXT_5900 6 -#define MIPS_AFL_EXT_4650 7 -#define MIPS_AFL_EXT_4010 8 -#define MIPS_AFL_EXT_4100 9 -#define MIPS_AFL_EXT_3900 10 -#define MIPS_AFL_EXT_10000 11 -#define MIPS_AFL_EXT_SB1 12 -#define MIPS_AFL_EXT_4111 13 -#define MIPS_AFL_EXT_4120 14 -#define MIPS_AFL_EXT_5400 15 -#define MIPS_AFL_EXT_5500 16 -#define MIPS_AFL_EXT_LOONGSON_2E 17 -#define MIPS_AFL_EXT_LOONGSON_2F 18 - -#define MIPS_AFL_FLAGS1_ODDSPREG 1 - -enum -{ - Val_GNU_MIPS_ABI_FP_ANY = 0, - Val_GNU_MIPS_ABI_FP_DOUBLE = 1, - Val_GNU_MIPS_ABI_FP_SINGLE = 2, - Val_GNU_MIPS_ABI_FP_SOFT = 3, - Val_GNU_MIPS_ABI_FP_OLD_64 = 4, - Val_GNU_MIPS_ABI_FP_XX = 5, - Val_GNU_MIPS_ABI_FP_64 = 6, - Val_GNU_MIPS_ABI_FP_64A = 7, - Val_GNU_MIPS_ABI_FP_MAX = 7 -}; - - - - -#define EF_PARISC_TRAPNIL 0x00010000 -#define EF_PARISC_EXT 0x00020000 -#define EF_PARISC_LSB 0x00040000 -#define EF_PARISC_WIDE 0x00080000 -#define EF_PARISC_NO_KABP 0x00100000 - -#define EF_PARISC_LAZYSWAP 0x00400000 -#define EF_PARISC_ARCH 0x0000ffff - - - -#define EFA_PARISC_1_0 0x020b -#define EFA_PARISC_1_1 0x0210 -#define EFA_PARISC_2_0 0x0214 - - - -#define SHN_PARISC_ANSI_COMMON 0xff00 - -#define SHN_PARISC_HUGE_COMMON 0xff01 - - - -#define SHT_PARISC_EXT 0x70000000 -#define SHT_PARISC_UNWIND 0x70000001 -#define SHT_PARISC_DOC 0x70000002 - - - -#define SHF_PARISC_SHORT 0x20000000 -#define SHF_PARISC_HUGE 0x40000000 -#define SHF_PARISC_SBP 0x80000000 - - - -#define STT_PARISC_MILLICODE 13 - -#define STT_HP_OPAQUE (STT_LOOS + 0x1) -#define STT_HP_STUB (STT_LOOS + 0x2) - - - -#define R_PARISC_NONE 0 -#define R_PARISC_DIR32 1 -#define R_PARISC_DIR21L 2 -#define R_PARISC_DIR17R 3 -#define R_PARISC_DIR17F 4 -#define R_PARISC_DIR14R 6 -#define R_PARISC_PCREL32 9 -#define R_PARISC_PCREL21L 10 -#define R_PARISC_PCREL17R 11 -#define R_PARISC_PCREL17F 12 -#define R_PARISC_PCREL14R 14 -#define R_PARISC_DPREL21L 18 -#define R_PARISC_DPREL14R 22 -#define R_PARISC_GPREL21L 26 -#define R_PARISC_GPREL14R 30 -#define R_PARISC_LTOFF21L 34 -#define R_PARISC_LTOFF14R 38 -#define R_PARISC_SECREL32 41 -#define R_PARISC_SEGBASE 48 -#define R_PARISC_SEGREL32 49 -#define R_PARISC_PLTOFF21L 50 -#define R_PARISC_PLTOFF14R 54 -#define R_PARISC_LTOFF_FPTR32 57 -#define R_PARISC_LTOFF_FPTR21L 58 -#define R_PARISC_LTOFF_FPTR14R 62 -#define R_PARISC_FPTR64 64 -#define R_PARISC_PLABEL32 65 -#define R_PARISC_PLABEL21L 66 -#define R_PARISC_PLABEL14R 70 -#define R_PARISC_PCREL64 72 -#define R_PARISC_PCREL22F 74 -#define R_PARISC_PCREL14WR 75 -#define R_PARISC_PCREL14DR 76 -#define R_PARISC_PCREL16F 77 -#define R_PARISC_PCREL16WF 78 -#define R_PARISC_PCREL16DF 79 -#define R_PARISC_DIR64 80 -#define R_PARISC_DIR14WR 83 -#define R_PARISC_DIR14DR 84 -#define R_PARISC_DIR16F 85 -#define R_PARISC_DIR16WF 86 -#define R_PARISC_DIR16DF 87 -#define R_PARISC_GPREL64 88 -#define R_PARISC_GPREL14WR 91 -#define R_PARISC_GPREL14DR 92 -#define R_PARISC_GPREL16F 93 -#define R_PARISC_GPREL16WF 94 -#define R_PARISC_GPREL16DF 95 -#define R_PARISC_LTOFF64 96 -#define R_PARISC_LTOFF14WR 99 -#define R_PARISC_LTOFF14DR 100 -#define R_PARISC_LTOFF16F 101 -#define R_PARISC_LTOFF16WF 102 -#define R_PARISC_LTOFF16DF 103 -#define R_PARISC_SECREL64 104 -#define R_PARISC_SEGREL64 112 -#define R_PARISC_PLTOFF14WR 115 -#define R_PARISC_PLTOFF14DR 116 -#define R_PARISC_PLTOFF16F 117 -#define R_PARISC_PLTOFF16WF 118 -#define R_PARISC_PLTOFF16DF 119 -#define R_PARISC_LTOFF_FPTR64 120 -#define R_PARISC_LTOFF_FPTR14WR 123 -#define R_PARISC_LTOFF_FPTR14DR 124 -#define R_PARISC_LTOFF_FPTR16F 125 -#define R_PARISC_LTOFF_FPTR16WF 126 -#define R_PARISC_LTOFF_FPTR16DF 127 -#define R_PARISC_LORESERVE 128 -#define R_PARISC_COPY 128 -#define R_PARISC_IPLT 129 -#define R_PARISC_EPLT 130 -#define R_PARISC_TPREL32 153 -#define R_PARISC_TPREL21L 154 -#define R_PARISC_TPREL14R 158 -#define R_PARISC_LTOFF_TP21L 162 -#define R_PARISC_LTOFF_TP14R 166 -#define R_PARISC_LTOFF_TP14F 167 -#define R_PARISC_TPREL64 216 -#define R_PARISC_TPREL14WR 219 -#define R_PARISC_TPREL14DR 220 -#define R_PARISC_TPREL16F 221 -#define R_PARISC_TPREL16WF 222 -#define R_PARISC_TPREL16DF 223 -#define R_PARISC_LTOFF_TP64 224 -#define R_PARISC_LTOFF_TP14WR 227 -#define R_PARISC_LTOFF_TP14DR 228 -#define R_PARISC_LTOFF_TP16F 229 -#define R_PARISC_LTOFF_TP16WF 230 -#define R_PARISC_LTOFF_TP16DF 231 -#define R_PARISC_GNU_VTENTRY 232 -#define R_PARISC_GNU_VTINHERIT 233 -#define R_PARISC_TLS_GD21L 234 -#define R_PARISC_TLS_GD14R 235 -#define R_PARISC_TLS_GDCALL 236 -#define R_PARISC_TLS_LDM21L 237 -#define R_PARISC_TLS_LDM14R 238 -#define R_PARISC_TLS_LDMCALL 239 -#define R_PARISC_TLS_LDO21L 240 -#define R_PARISC_TLS_LDO14R 241 -#define R_PARISC_TLS_DTPMOD32 242 -#define R_PARISC_TLS_DTPMOD64 243 -#define R_PARISC_TLS_DTPOFF32 244 -#define R_PARISC_TLS_DTPOFF64 245 -#define R_PARISC_TLS_LE21L R_PARISC_TPREL21L -#define R_PARISC_TLS_LE14R R_PARISC_TPREL14R -#define R_PARISC_TLS_IE21L R_PARISC_LTOFF_TP21L -#define R_PARISC_TLS_IE14R R_PARISC_LTOFF_TP14R -#define R_PARISC_TLS_TPREL32 R_PARISC_TPREL32 -#define R_PARISC_TLS_TPREL64 R_PARISC_TPREL64 -#define R_PARISC_HIRESERVE 255 - - - -#define PT_HP_TLS (PT_LOOS + 0x0) -#define PT_HP_CORE_NONE (PT_LOOS + 0x1) -#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) -#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) -#define PT_HP_CORE_COMM (PT_LOOS + 0x4) -#define PT_HP_CORE_PROC (PT_LOOS + 0x5) -#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) -#define PT_HP_CORE_STACK (PT_LOOS + 0x7) -#define PT_HP_CORE_SHM (PT_LOOS + 0x8) -#define PT_HP_CORE_MMF (PT_LOOS + 0x9) -#define PT_HP_PARALLEL (PT_LOOS + 0x10) -#define PT_HP_FASTBIND (PT_LOOS + 0x11) -#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) -#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) -#define PT_HP_STACK (PT_LOOS + 0x14) - -#define PT_PARISC_ARCHEXT 0x70000000 -#define PT_PARISC_UNWIND 0x70000001 - - - -#define PF_PARISC_SBP 0x08000000 - -#define PF_HP_PAGE_SIZE 0x00100000 -#define PF_HP_FAR_SHARED 0x00200000 -#define PF_HP_NEAR_SHARED 0x00400000 -#define PF_HP_CODE 0x01000000 -#define PF_HP_MODIFY 0x02000000 -#define PF_HP_LAZYSWAP 0x04000000 -#define PF_HP_SBP 0x08000000 - - - - - - -#define EF_ALPHA_32BIT 1 -#define EF_ALPHA_CANRELAX 2 - - - - -#define SHT_ALPHA_DEBUG 0x70000001 -#define SHT_ALPHA_REGINFO 0x70000002 - - - -#define SHF_ALPHA_GPREL 0x10000000 - - -#define STO_ALPHA_NOPV 0x80 -#define STO_ALPHA_STD_GPLOAD 0x88 - - - -#define R_ALPHA_NONE 0 -#define R_ALPHA_REFLONG 1 -#define R_ALPHA_REFQUAD 2 -#define R_ALPHA_GPREL32 3 -#define R_ALPHA_LITERAL 4 -#define R_ALPHA_LITUSE 5 -#define R_ALPHA_GPDISP 6 -#define R_ALPHA_BRADDR 7 -#define R_ALPHA_HINT 8 -#define R_ALPHA_SREL16 9 -#define R_ALPHA_SREL32 10 -#define R_ALPHA_SREL64 11 -#define R_ALPHA_GPRELHIGH 17 -#define R_ALPHA_GPRELLOW 18 -#define R_ALPHA_GPREL16 19 -#define R_ALPHA_COPY 24 -#define R_ALPHA_GLOB_DAT 25 -#define R_ALPHA_JMP_SLOT 26 -#define R_ALPHA_RELATIVE 27 -#define R_ALPHA_TLS_GD_HI 28 -#define R_ALPHA_TLSGD 29 -#define R_ALPHA_TLS_LDM 30 -#define R_ALPHA_DTPMOD64 31 -#define R_ALPHA_GOTDTPREL 32 -#define R_ALPHA_DTPREL64 33 -#define R_ALPHA_DTPRELHI 34 -#define R_ALPHA_DTPRELLO 35 -#define R_ALPHA_DTPREL16 36 -#define R_ALPHA_GOTTPREL 37 -#define R_ALPHA_TPREL64 38 -#define R_ALPHA_TPRELHI 39 -#define R_ALPHA_TPRELLO 40 -#define R_ALPHA_TPREL16 41 - -#define R_ALPHA_NUM 46 - - -#define LITUSE_ALPHA_ADDR 0 -#define LITUSE_ALPHA_BASE 1 -#define LITUSE_ALPHA_BYTOFF 2 -#define LITUSE_ALPHA_JSR 3 -#define LITUSE_ALPHA_TLS_GD 4 -#define LITUSE_ALPHA_TLS_LDM 5 - - -#define DT_ALPHA_PLTRO (DT_LOPROC + 0) -#define DT_ALPHA_NUM 1 - - - - -#define EF_PPC_EMB 0x80000000 - - -#define EF_PPC_RELOCATABLE 0x00010000 -#define EF_PPC_RELOCATABLE_LIB 0x00008000 - - - -#define R_PPC_NONE 0 -#define R_PPC_ADDR32 1 -#define R_PPC_ADDR24 2 -#define R_PPC_ADDR16 3 -#define R_PPC_ADDR16_LO 4 -#define R_PPC_ADDR16_HI 5 -#define R_PPC_ADDR16_HA 6 -#define R_PPC_ADDR14 7 -#define R_PPC_ADDR14_BRTAKEN 8 -#define R_PPC_ADDR14_BRNTAKEN 9 -#define R_PPC_REL24 10 -#define R_PPC_REL14 11 -#define R_PPC_REL14_BRTAKEN 12 -#define R_PPC_REL14_BRNTAKEN 13 -#define R_PPC_GOT16 14 -#define R_PPC_GOT16_LO 15 -#define R_PPC_GOT16_HI 16 -#define R_PPC_GOT16_HA 17 -#define R_PPC_PLTREL24 18 -#define R_PPC_COPY 19 -#define R_PPC_GLOB_DAT 20 -#define R_PPC_JMP_SLOT 21 -#define R_PPC_RELATIVE 22 -#define R_PPC_LOCAL24PC 23 -#define R_PPC_UADDR32 24 -#define R_PPC_UADDR16 25 -#define R_PPC_REL32 26 -#define R_PPC_PLT32 27 -#define R_PPC_PLTREL32 28 -#define R_PPC_PLT16_LO 29 -#define R_PPC_PLT16_HI 30 -#define R_PPC_PLT16_HA 31 -#define R_PPC_SDAREL16 32 -#define R_PPC_SECTOFF 33 -#define R_PPC_SECTOFF_LO 34 -#define R_PPC_SECTOFF_HI 35 -#define R_PPC_SECTOFF_HA 36 - - -#define R_PPC_TLS 67 -#define R_PPC_DTPMOD32 68 -#define R_PPC_TPREL16 69 -#define R_PPC_TPREL16_LO 70 -#define R_PPC_TPREL16_HI 71 -#define R_PPC_TPREL16_HA 72 -#define R_PPC_TPREL32 73 -#define R_PPC_DTPREL16 74 -#define R_PPC_DTPREL16_LO 75 -#define R_PPC_DTPREL16_HI 76 -#define R_PPC_DTPREL16_HA 77 -#define R_PPC_DTPREL32 78 -#define R_PPC_GOT_TLSGD16 79 -#define R_PPC_GOT_TLSGD16_LO 80 -#define R_PPC_GOT_TLSGD16_HI 81 -#define R_PPC_GOT_TLSGD16_HA 82 -#define R_PPC_GOT_TLSLD16 83 -#define R_PPC_GOT_TLSLD16_LO 84 -#define R_PPC_GOT_TLSLD16_HI 85 -#define R_PPC_GOT_TLSLD16_HA 86 -#define R_PPC_GOT_TPREL16 87 -#define R_PPC_GOT_TPREL16_LO 88 -#define R_PPC_GOT_TPREL16_HI 89 -#define R_PPC_GOT_TPREL16_HA 90 -#define R_PPC_GOT_DTPREL16 91 -#define R_PPC_GOT_DTPREL16_LO 92 -#define R_PPC_GOT_DTPREL16_HI 93 -#define R_PPC_GOT_DTPREL16_HA 94 -#define R_PPC_TLSGD 95 -#define R_PPC_TLSLD 96 - - -#define R_PPC_EMB_NADDR32 101 -#define R_PPC_EMB_NADDR16 102 -#define R_PPC_EMB_NADDR16_LO 103 -#define R_PPC_EMB_NADDR16_HI 104 -#define R_PPC_EMB_NADDR16_HA 105 -#define R_PPC_EMB_SDAI16 106 -#define R_PPC_EMB_SDA2I16 107 -#define R_PPC_EMB_SDA2REL 108 -#define R_PPC_EMB_SDA21 109 -#define R_PPC_EMB_MRKREF 110 -#define R_PPC_EMB_RELSEC16 111 -#define R_PPC_EMB_RELST_LO 112 -#define R_PPC_EMB_RELST_HI 113 -#define R_PPC_EMB_RELST_HA 114 -#define R_PPC_EMB_BIT_FLD 115 -#define R_PPC_EMB_RELSDA 116 - - -#define R_PPC_DIAB_SDA21_LO 180 -#define R_PPC_DIAB_SDA21_HI 181 -#define R_PPC_DIAB_SDA21_HA 182 -#define R_PPC_DIAB_RELSDA_LO 183 -#define R_PPC_DIAB_RELSDA_HI 184 -#define R_PPC_DIAB_RELSDA_HA 185 - - -#define R_PPC_IRELATIVE 248 - - -#define R_PPC_REL16 249 -#define R_PPC_REL16_LO 250 -#define R_PPC_REL16_HI 251 -#define R_PPC_REL16_HA 252 - - - -#define R_PPC_TOC16 255 - - -#define DT_PPC_GOT (DT_LOPROC + 0) -#define DT_PPC_OPT (DT_LOPROC + 1) -#define DT_PPC_NUM 2 - -#define PPC_OPT_TLS 1 - - -#define R_PPC64_NONE R_PPC_NONE -#define R_PPC64_ADDR32 R_PPC_ADDR32 -#define R_PPC64_ADDR24 R_PPC_ADDR24 -#define R_PPC64_ADDR16 R_PPC_ADDR16 -#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO -#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI -#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA -#define R_PPC64_ADDR14 R_PPC_ADDR14 -#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN -#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN -#define R_PPC64_REL24 R_PPC_REL24 -#define R_PPC64_REL14 R_PPC_REL14 -#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN -#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN -#define R_PPC64_GOT16 R_PPC_GOT16 -#define R_PPC64_GOT16_LO R_PPC_GOT16_LO -#define R_PPC64_GOT16_HI R_PPC_GOT16_HI -#define R_PPC64_GOT16_HA R_PPC_GOT16_HA - -#define R_PPC64_COPY R_PPC_COPY -#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT -#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT -#define R_PPC64_RELATIVE R_PPC_RELATIVE - -#define R_PPC64_UADDR32 R_PPC_UADDR32 -#define R_PPC64_UADDR16 R_PPC_UADDR16 -#define R_PPC64_REL32 R_PPC_REL32 -#define R_PPC64_PLT32 R_PPC_PLT32 -#define R_PPC64_PLTREL32 R_PPC_PLTREL32 -#define R_PPC64_PLT16_LO R_PPC_PLT16_LO -#define R_PPC64_PLT16_HI R_PPC_PLT16_HI -#define R_PPC64_PLT16_HA R_PPC_PLT16_HA - -#define R_PPC64_SECTOFF R_PPC_SECTOFF -#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO -#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI -#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA -#define R_PPC64_ADDR30 37 -#define R_PPC64_ADDR64 38 -#define R_PPC64_ADDR16_HIGHER 39 -#define R_PPC64_ADDR16_HIGHERA 40 -#define R_PPC64_ADDR16_HIGHEST 41 -#define R_PPC64_ADDR16_HIGHESTA 42 -#define R_PPC64_UADDR64 43 -#define R_PPC64_REL64 44 -#define R_PPC64_PLT64 45 -#define R_PPC64_PLTREL64 46 -#define R_PPC64_TOC16 47 -#define R_PPC64_TOC16_LO 48 -#define R_PPC64_TOC16_HI 49 -#define R_PPC64_TOC16_HA 50 -#define R_PPC64_TOC 51 -#define R_PPC64_PLTGOT16 52 -#define R_PPC64_PLTGOT16_LO 53 -#define R_PPC64_PLTGOT16_HI 54 -#define R_PPC64_PLTGOT16_HA 55 - -#define R_PPC64_ADDR16_DS 56 -#define R_PPC64_ADDR16_LO_DS 57 -#define R_PPC64_GOT16_DS 58 -#define R_PPC64_GOT16_LO_DS 59 -#define R_PPC64_PLT16_LO_DS 60 -#define R_PPC64_SECTOFF_DS 61 -#define R_PPC64_SECTOFF_LO_DS 62 -#define R_PPC64_TOC16_DS 63 -#define R_PPC64_TOC16_LO_DS 64 -#define R_PPC64_PLTGOT16_DS 65 -#define R_PPC64_PLTGOT16_LO_DS 66 - - -#define R_PPC64_TLS 67 -#define R_PPC64_DTPMOD64 68 -#define R_PPC64_TPREL16 69 -#define R_PPC64_TPREL16_LO 70 -#define R_PPC64_TPREL16_HI 71 -#define R_PPC64_TPREL16_HA 72 -#define R_PPC64_TPREL64 73 -#define R_PPC64_DTPREL16 74 -#define R_PPC64_DTPREL16_LO 75 -#define R_PPC64_DTPREL16_HI 76 -#define R_PPC64_DTPREL16_HA 77 -#define R_PPC64_DTPREL64 78 -#define R_PPC64_GOT_TLSGD16 79 -#define R_PPC64_GOT_TLSGD16_LO 80 -#define R_PPC64_GOT_TLSGD16_HI 81 -#define R_PPC64_GOT_TLSGD16_HA 82 -#define R_PPC64_GOT_TLSLD16 83 -#define R_PPC64_GOT_TLSLD16_LO 84 -#define R_PPC64_GOT_TLSLD16_HI 85 -#define R_PPC64_GOT_TLSLD16_HA 86 -#define R_PPC64_GOT_TPREL16_DS 87 -#define R_PPC64_GOT_TPREL16_LO_DS 88 -#define R_PPC64_GOT_TPREL16_HI 89 -#define R_PPC64_GOT_TPREL16_HA 90 -#define R_PPC64_GOT_DTPREL16_DS 91 -#define R_PPC64_GOT_DTPREL16_LO_DS 92 -#define R_PPC64_GOT_DTPREL16_HI 93 -#define R_PPC64_GOT_DTPREL16_HA 94 -#define R_PPC64_TPREL16_DS 95 -#define R_PPC64_TPREL16_LO_DS 96 -#define R_PPC64_TPREL16_HIGHER 97 -#define R_PPC64_TPREL16_HIGHERA 98 -#define R_PPC64_TPREL16_HIGHEST 99 -#define R_PPC64_TPREL16_HIGHESTA 100 -#define R_PPC64_DTPREL16_DS 101 -#define R_PPC64_DTPREL16_LO_DS 102 -#define R_PPC64_DTPREL16_HIGHER 103 -#define R_PPC64_DTPREL16_HIGHERA 104 -#define R_PPC64_DTPREL16_HIGHEST 105 -#define R_PPC64_DTPREL16_HIGHESTA 106 -#define R_PPC64_TLSGD 107 -#define R_PPC64_TLSLD 108 -#define R_PPC64_TOCSAVE 109 -#define R_PPC64_ADDR16_HIGH 110 -#define R_PPC64_ADDR16_HIGHA 111 -#define R_PPC64_TPREL16_HIGH 112 -#define R_PPC64_TPREL16_HIGHA 113 -#define R_PPC64_DTPREL16_HIGH 114 -#define R_PPC64_DTPREL16_HIGHA 115 - - -#define R_PPC64_JMP_IREL 247 -#define R_PPC64_IRELATIVE 248 -#define R_PPC64_REL16 249 -#define R_PPC64_REL16_LO 250 -#define R_PPC64_REL16_HI 251 -#define R_PPC64_REL16_HA 252 - -#define EF_PPC64_ABI 3 - -#define DT_PPC64_GLINK (DT_LOPROC + 0) -#define DT_PPC64_OPD (DT_LOPROC + 1) -#define DT_PPC64_OPDSZ (DT_LOPROC + 2) -#define DT_PPC64_OPT (DT_LOPROC + 3) -#define DT_PPC64_NUM 4 - -#define PPC64_OPT_TLS 1 -#define PPC64_OPT_MULTI_TOC 2 -#define PPC64_OPT_LOCALENTRY 4 - -#define STO_PPC64_LOCAL_BIT 5 -#define STO_PPC64_LOCAL_MASK 0xe0 -#define PPC64_LOCAL_ENTRY_OFFSET(x) (1 << (((x)&0xe0)>>5) & 0xfc) - - -#define EF_ARM_RELEXEC 0x01 -#define EF_ARM_HASENTRY 0x02 -#define EF_ARM_INTERWORK 0x04 -#define EF_ARM_APCS_26 0x08 -#define EF_ARM_APCS_FLOAT 0x10 -#define EF_ARM_PIC 0x20 -#define EF_ARM_ALIGN8 0x40 -#define EF_ARM_NEW_ABI 0x80 -#define EF_ARM_OLD_ABI 0x100 -#define EF_ARM_SOFT_FLOAT 0x200 -#define EF_ARM_VFP_FLOAT 0x400 -#define EF_ARM_MAVERICK_FLOAT 0x800 - -#define EF_ARM_ABI_FLOAT_SOFT 0x200 -#define EF_ARM_ABI_FLOAT_HARD 0x400 - - -#define EF_ARM_SYMSARESORTED 0x04 -#define EF_ARM_DYNSYMSUSESEGIDX 0x08 -#define EF_ARM_MAPSYMSFIRST 0x10 -#define EF_ARM_EABIMASK 0XFF000000 - - -#define EF_ARM_BE8 0x00800000 -#define EF_ARM_LE8 0x00400000 - -#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) -#define EF_ARM_EABI_UNKNOWN 0x00000000 -#define EF_ARM_EABI_VER1 0x01000000 -#define EF_ARM_EABI_VER2 0x02000000 -#define EF_ARM_EABI_VER3 0x03000000 -#define EF_ARM_EABI_VER4 0x04000000 -#define EF_ARM_EABI_VER5 0x05000000 - - -#define STT_ARM_TFUNC STT_LOPROC -#define STT_ARM_16BIT STT_HIPROC - - -#define SHF_ARM_ENTRYSECT 0x10000000 -#define SHF_ARM_COMDEF 0x80000000 - - - -#define PF_ARM_SB 0x10000000 - -#define PF_ARM_PI 0x20000000 -#define PF_ARM_ABS 0x40000000 - - -#define PT_ARM_EXIDX (PT_LOPROC + 1) - - -#define SHT_ARM_EXIDX (SHT_LOPROC + 1) -#define SHT_ARM_PREEMPTMAP (SHT_LOPROC + 2) -#define SHT_ARM_ATTRIBUTES (SHT_LOPROC + 3) - -#define R_AARCH64_NONE 0 -#define R_AARCH64_P32_ABS32 1 -#define R_AARCH64_P32_COPY 180 -#define R_AARCH64_P32_GLOB_DAT 181 -#define R_AARCH64_P32_JUMP_SLOT 182 -#define R_AARCH64_P32_RELATIVE 183 -#define R_AARCH64_P32_TLS_DTPMOD 184 -#define R_AARCH64_P32_TLS_DTPREL 185 -#define R_AARCH64_P32_TLS_TPREL 186 -#define R_AARCH64_P32_TLSDESC 187 -#define R_AARCH64_P32_IRELATIVE 188 -#define R_AARCH64_ABS64 257 -#define R_AARCH64_ABS32 258 -#define R_AARCH64_ABS16 259 -#define R_AARCH64_PREL64 260 -#define R_AARCH64_PREL32 261 -#define R_AARCH64_PREL16 262 -#define R_AARCH64_MOVW_UABS_G0 263 -#define R_AARCH64_MOVW_UABS_G0_NC 264 -#define R_AARCH64_MOVW_UABS_G1 265 -#define R_AARCH64_MOVW_UABS_G1_NC 266 -#define R_AARCH64_MOVW_UABS_G2 267 -#define R_AARCH64_MOVW_UABS_G2_NC 268 -#define R_AARCH64_MOVW_UABS_G3 269 -#define R_AARCH64_MOVW_SABS_G0 270 -#define R_AARCH64_MOVW_SABS_G1 271 -#define R_AARCH64_MOVW_SABS_G2 272 -#define R_AARCH64_LD_PREL_LO19 273 -#define R_AARCH64_ADR_PREL_LO21 274 -#define R_AARCH64_ADR_PREL_PG_HI21 275 -#define R_AARCH64_ADR_PREL_PG_HI21_NC 276 -#define R_AARCH64_ADD_ABS_LO12_NC 277 -#define R_AARCH64_LDST8_ABS_LO12_NC 278 -#define R_AARCH64_TSTBR14 279 -#define R_AARCH64_CONDBR19 280 -#define R_AARCH64_JUMP26 282 -#define R_AARCH64_CALL26 283 -#define R_AARCH64_LDST16_ABS_LO12_NC 284 -#define R_AARCH64_LDST32_ABS_LO12_NC 285 -#define R_AARCH64_LDST64_ABS_LO12_NC 286 -#define R_AARCH64_MOVW_PREL_G0 287 -#define R_AARCH64_MOVW_PREL_G0_NC 288 -#define R_AARCH64_MOVW_PREL_G1 289 -#define R_AARCH64_MOVW_PREL_G1_NC 290 -#define R_AARCH64_MOVW_PREL_G2 291 -#define R_AARCH64_MOVW_PREL_G2_NC 292 -#define R_AARCH64_MOVW_PREL_G3 293 -#define R_AARCH64_LDST128_ABS_LO12_NC 299 -#define R_AARCH64_MOVW_GOTOFF_G0 300 -#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 -#define R_AARCH64_MOVW_GOTOFF_G1 302 -#define R_AARCH64_MOVW_GOTOFF_G1_NC 303 -#define R_AARCH64_MOVW_GOTOFF_G2 304 -#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 -#define R_AARCH64_MOVW_GOTOFF_G3 306 -#define R_AARCH64_GOTREL64 307 -#define R_AARCH64_GOTREL32 308 -#define R_AARCH64_GOT_LD_PREL19 309 -#define R_AARCH64_LD64_GOTOFF_LO15 310 -#define R_AARCH64_ADR_GOT_PAGE 311 -#define R_AARCH64_LD64_GOT_LO12_NC 312 -#define R_AARCH64_LD64_GOTPAGE_LO15 313 -#define R_AARCH64_TLSGD_ADR_PREL21 512 -#define R_AARCH64_TLSGD_ADR_PAGE21 513 -#define R_AARCH64_TLSGD_ADD_LO12_NC 514 -#define R_AARCH64_TLSGD_MOVW_G1 515 -#define R_AARCH64_TLSGD_MOVW_G0_NC 516 -#define R_AARCH64_TLSLD_ADR_PREL21 517 -#define R_AARCH64_TLSLD_ADR_PAGE21 518 -#define R_AARCH64_TLSLD_ADD_LO12_NC 519 -#define R_AARCH64_TLSLD_MOVW_G1 520 -#define R_AARCH64_TLSLD_MOVW_G0_NC 521 -#define R_AARCH64_TLSLD_LD_PREL19 522 -#define R_AARCH64_TLSLD_MOVW_DTPREL_G2 523 -#define R_AARCH64_TLSLD_MOVW_DTPREL_G1 524 -#define R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC 525 -#define R_AARCH64_TLSLD_MOVW_DTPREL_G0 526 -#define R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC 527 -#define R_AARCH64_TLSLD_ADD_DTPREL_HI12 528 -#define R_AARCH64_TLSLD_ADD_DTPREL_LO12 529 -#define R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC 530 -#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12 531 -#define R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC 532 -#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12 533 -#define R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC 534 -#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12 535 -#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 -#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 -#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 -#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 -#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 -#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 -#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 -#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 -#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 -#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545 -#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546 -#define R_AARCH64_TLSLE_MOVW_TPREL_G0 547 -#define R_AARCH64_TLSLE_MOVW_TPREL_G0_NC 548 -#define R_AARCH64_TLSLE_ADD_TPREL_HI12 549 -#define R_AARCH64_TLSLE_ADD_TPREL_LO12 550 -#define R_AARCH64_TLSLE_ADD_TPREL_LO12_NC 551 -#define R_AARCH64_TLSLE_LDST8_TPREL_LO12 552 -#define R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC 553 -#define R_AARCH64_TLSLE_LDST16_TPREL_LO12 554 -#define R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC 555 -#define R_AARCH64_TLSLE_LDST32_TPREL_LO12 556 -#define R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC 557 -#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558 -#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559 -#define R_AARCH64_TLSDESC_LD_PREL19 560 -#define R_AARCH64_TLSDESC_ADR_PREL21 561 -#define R_AARCH64_TLSDESC_ADR_PAGE21 562 -#define R_AARCH64_TLSDESC_LD64_LO12 563 -#define R_AARCH64_TLSDESC_ADD_LO12 564 -#define R_AARCH64_TLSDESC_OFF_G1 565 -#define R_AARCH64_TLSDESC_OFF_G0_NC 566 -#define R_AARCH64_TLSDESC_LDR 567 -#define R_AARCH64_TLSDESC_ADD 568 -#define R_AARCH64_TLSDESC_CALL 569 -#define R_AARCH64_TLSLE_LDST128_TPREL_LO12 570 -#define R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC 571 -#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12 572 -#define R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC 573 -#define R_AARCH64_COPY 1024 -#define R_AARCH64_GLOB_DAT 1025 -#define R_AARCH64_JUMP_SLOT 1026 -#define R_AARCH64_RELATIVE 1027 -#define R_AARCH64_TLS_DTPMOD 1028 -#define R_AARCH64_TLS_DTPMOD64 1028 -#define R_AARCH64_TLS_DTPREL 1029 -#define R_AARCH64_TLS_DTPREL64 1029 -#define R_AARCH64_TLS_TPREL 1030 -#define R_AARCH64_TLS_TPREL64 1030 -#define R_AARCH64_TLSDESC 1031 - - -#define R_ARM_NONE 0 -#define R_ARM_PC24 1 -#define R_ARM_ABS32 2 -#define R_ARM_REL32 3 -#define R_ARM_PC13 4 -#define R_ARM_ABS16 5 -#define R_ARM_ABS12 6 -#define R_ARM_THM_ABS5 7 -#define R_ARM_ABS8 8 -#define R_ARM_SBREL32 9 -#define R_ARM_THM_PC22 10 -#define R_ARM_THM_PC8 11 -#define R_ARM_AMP_VCALL9 12 -#define R_ARM_TLS_DESC 13 -#define R_ARM_THM_SWI8 14 -#define R_ARM_XPC25 15 -#define R_ARM_THM_XPC22 16 -#define R_ARM_TLS_DTPMOD32 17 -#define R_ARM_TLS_DTPOFF32 18 -#define R_ARM_TLS_TPOFF32 19 -#define R_ARM_COPY 20 -#define R_ARM_GLOB_DAT 21 -#define R_ARM_JUMP_SLOT 22 -#define R_ARM_RELATIVE 23 -#define R_ARM_GOTOFF 24 -#define R_ARM_GOTPC 25 -#define R_ARM_GOT32 26 -#define R_ARM_PLT32 27 -#define R_ARM_CALL 28 -#define R_ARM_JUMP24 29 -#define R_ARM_THM_JUMP24 30 -#define R_ARM_BASE_ABS 31 -#define R_ARM_ALU_PCREL_7_0 32 -#define R_ARM_ALU_PCREL_15_8 33 -#define R_ARM_ALU_PCREL_23_15 34 -#define R_ARM_LDR_SBREL_11_0 35 -#define R_ARM_ALU_SBREL_19_12 36 -#define R_ARM_ALU_SBREL_27_20 37 -#define R_ARM_TARGET1 38 -#define R_ARM_SBREL31 39 -#define R_ARM_V4BX 40 -#define R_ARM_TARGET2 41 -#define R_ARM_PREL31 42 -#define R_ARM_MOVW_ABS_NC 43 -#define R_ARM_MOVT_ABS 44 -#define R_ARM_MOVW_PREL_NC 45 -#define R_ARM_MOVT_PREL 46 -#define R_ARM_THM_MOVW_ABS_NC 47 -#define R_ARM_THM_MOVT_ABS 48 -#define R_ARM_THM_MOVW_PREL_NC 49 -#define R_ARM_THM_MOVT_PREL 50 -#define R_ARM_THM_JUMP19 51 -#define R_ARM_THM_JUMP6 52 -#define R_ARM_THM_ALU_PREL_11_0 53 -#define R_ARM_THM_PC12 54 -#define R_ARM_ABS32_NOI 55 -#define R_ARM_REL32_NOI 56 -#define R_ARM_ALU_PC_G0_NC 57 -#define R_ARM_ALU_PC_G0 58 -#define R_ARM_ALU_PC_G1_NC 59 -#define R_ARM_ALU_PC_G1 60 -#define R_ARM_ALU_PC_G2 61 -#define R_ARM_LDR_PC_G1 62 -#define R_ARM_LDR_PC_G2 63 -#define R_ARM_LDRS_PC_G0 64 -#define R_ARM_LDRS_PC_G1 65 -#define R_ARM_LDRS_PC_G2 66 -#define R_ARM_LDC_PC_G0 67 -#define R_ARM_LDC_PC_G1 68 -#define R_ARM_LDC_PC_G2 69 -#define R_ARM_ALU_SB_G0_NC 70 -#define R_ARM_ALU_SB_G0 71 -#define R_ARM_ALU_SB_G1_NC 72 -#define R_ARM_ALU_SB_G1 73 -#define R_ARM_ALU_SB_G2 74 -#define R_ARM_LDR_SB_G0 75 -#define R_ARM_LDR_SB_G1 76 -#define R_ARM_LDR_SB_G2 77 -#define R_ARM_LDRS_SB_G0 78 -#define R_ARM_LDRS_SB_G1 79 -#define R_ARM_LDRS_SB_G2 80 -#define R_ARM_LDC_SB_G0 81 -#define R_ARM_LDC_SB_G1 82 -#define R_ARM_LDC_SB_G2 83 -#define R_ARM_MOVW_BREL_NC 84 -#define R_ARM_MOVT_BREL 85 -#define R_ARM_MOVW_BREL 86 -#define R_ARM_THM_MOVW_BREL_NC 87 -#define R_ARM_THM_MOVT_BREL 88 -#define R_ARM_THM_MOVW_BREL 89 -#define R_ARM_TLS_GOTDESC 90 -#define R_ARM_TLS_CALL 91 -#define R_ARM_TLS_DESCSEQ 92 -#define R_ARM_THM_TLS_CALL 93 -#define R_ARM_PLT32_ABS 94 -#define R_ARM_GOT_ABS 95 -#define R_ARM_GOT_PREL 96 -#define R_ARM_GOT_BREL12 97 -#define R_ARM_GOTOFF12 98 -#define R_ARM_GOTRELAX 99 -#define R_ARM_GNU_VTENTRY 100 -#define R_ARM_GNU_VTINHERIT 101 -#define R_ARM_THM_PC11 102 -#define R_ARM_THM_PC9 103 -#define R_ARM_TLS_GD32 104 - -#define R_ARM_TLS_LDM32 105 - -#define R_ARM_TLS_LDO32 106 - -#define R_ARM_TLS_IE32 107 - -#define R_ARM_TLS_LE32 108 -#define R_ARM_TLS_LDO12 109 -#define R_ARM_TLS_LE12 110 -#define R_ARM_TLS_IE12GP 111 -#define R_ARM_ME_TOO 128 -#define R_ARM_THM_TLS_DESCSEQ 129 -#define R_ARM_THM_TLS_DESCSEQ16 129 -#define R_ARM_THM_TLS_DESCSEQ32 130 -#define R_ARM_THM_GOT_BREL12 131 -#define R_ARM_IRELATIVE 160 -#define R_ARM_RXPC25 249 -#define R_ARM_RSBREL32 250 -#define R_ARM_THM_RPC22 251 -#define R_ARM_RREL32 252 -#define R_ARM_RABS22 253 -#define R_ARM_RPC24 254 -#define R_ARM_RBASE 255 - -#define R_ARM_NUM 256 - - -#define R_CKCORE_NONE 0 -#define R_CKCORE_ADDR32 1 -#define R_CKCORE_PCRELIMM8BY4 2 -#define R_CKCORE_PCRELIMM11BY2 3 -#define R_CKCORE_PCREL32 5 -#define R_CKCORE_PCRELJSR_IMM11BY2 6 -#define R_CKCORE_RELATIVE 9 -#define R_CKCORE_COPY 10 -#define R_CKCORE_GLOB_DAT 11 -#define R_CKCORE_JUMP_SLOT 12 -#define R_CKCORE_GOTOFF 13 -#define R_CKCORE_GOTPC 14 -#define R_CKCORE_GOT32 15 -#define R_CKCORE_PLT32 16 -#define R_CKCORE_ADDRGOT 17 -#define R_CKCORE_ADDRPLT 18 -#define R_CKCORE_PCREL_IMM26BY2 19 -#define R_CKCORE_PCREL_IMM16BY2 20 -#define R_CKCORE_PCREL_IMM16BY4 21 -#define R_CKCORE_PCREL_IMM10BY2 22 -#define R_CKCORE_PCREL_IMM10BY4 23 -#define R_CKCORE_ADDR_HI16 24 -#define R_CKCORE_ADDR_LO16 25 -#define R_CKCORE_GOTPC_HI16 26 -#define R_CKCORE_GOTPC_LO16 27 -#define R_CKCORE_GOTOFF_HI16 28 -#define R_CKCORE_GOTOFF_LO16 29 -#define R_CKCORE_GOT12 30 -#define R_CKCORE_GOT_HI16 31 -#define R_CKCORE_GOT_LO16 32 -#define R_CKCORE_PLT12 33 -#define R_CKCORE_PLT_HI16 34 -#define R_CKCORE_PLT_LO16 35 -#define R_CKCORE_ADDRGOT_HI16 36 -#define R_CKCORE_ADDRGOT_LO16 37 -#define R_CKCORE_ADDRPLT_HI16 38 -#define R_CKCORE_ADDRPLT_LO16 39 -#define R_CKCORE_PCREL_JSR_IMM26BY2 40 -#define R_CKCORE_TOFFSET_LO16 41 -#define R_CKCORE_DOFFSET_LO16 42 -#define R_CKCORE_PCREL_IMM18BY2 43 -#define R_CKCORE_DOFFSET_IMM18 44 -#define R_CKCORE_DOFFSET_IMM18BY2 45 -#define R_CKCORE_DOFFSET_IMM18BY4 46 -#define R_CKCORE_GOT_IMM18BY4 48 -#define R_CKCORE_PLT_IMM18BY4 49 -#define R_CKCORE_PCREL_IMM7BY4 50 -#define R_CKCORE_TLS_LE32 51 -#define R_CKCORE_TLS_IE32 52 -#define R_CKCORE_TLS_GD32 53 -#define R_CKCORE_TLS_LDM32 54 -#define R_CKCORE_TLS_LDO32 55 -#define R_CKCORE_TLS_DTPMOD32 56 -#define R_CKCORE_TLS_DTPOFF32 57 -#define R_CKCORE_TLS_TPOFF32 58 - - -#define EF_IA_64_MASKOS 0x0000000f -#define EF_IA_64_ABI64 0x00000010 -#define EF_IA_64_ARCH 0xff000000 - - -#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) -#define PT_IA_64_UNWIND (PT_LOPROC + 1) -#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12) -#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13) -#define PT_IA_64_HP_STACK (PT_LOOS + 0x14) - - -#define PF_IA_64_NORECOV 0x80000000 - - -#define SHT_IA_64_EXT (SHT_LOPROC + 0) -#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) - - -#define SHF_IA_64_SHORT 0x10000000 -#define SHF_IA_64_NORECOV 0x20000000 - - -#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) -#define DT_IA_64_NUM 1 - - -#define R_IA64_NONE 0x00 -#define R_IA64_IMM14 0x21 -#define R_IA64_IMM22 0x22 -#define R_IA64_IMM64 0x23 -#define R_IA64_DIR32MSB 0x24 -#define R_IA64_DIR32LSB 0x25 -#define R_IA64_DIR64MSB 0x26 -#define R_IA64_DIR64LSB 0x27 -#define R_IA64_GPREL22 0x2a -#define R_IA64_GPREL64I 0x2b -#define R_IA64_GPREL32MSB 0x2c -#define R_IA64_GPREL32LSB 0x2d -#define R_IA64_GPREL64MSB 0x2e -#define R_IA64_GPREL64LSB 0x2f -#define R_IA64_LTOFF22 0x32 -#define R_IA64_LTOFF64I 0x33 -#define R_IA64_PLTOFF22 0x3a -#define R_IA64_PLTOFF64I 0x3b -#define R_IA64_PLTOFF64MSB 0x3e -#define R_IA64_PLTOFF64LSB 0x3f -#define R_IA64_FPTR64I 0x43 -#define R_IA64_FPTR32MSB 0x44 -#define R_IA64_FPTR32LSB 0x45 -#define R_IA64_FPTR64MSB 0x46 -#define R_IA64_FPTR64LSB 0x47 -#define R_IA64_PCREL60B 0x48 -#define R_IA64_PCREL21B 0x49 -#define R_IA64_PCREL21M 0x4a -#define R_IA64_PCREL21F 0x4b -#define R_IA64_PCREL32MSB 0x4c -#define R_IA64_PCREL32LSB 0x4d -#define R_IA64_PCREL64MSB 0x4e -#define R_IA64_PCREL64LSB 0x4f -#define R_IA64_LTOFF_FPTR22 0x52 -#define R_IA64_LTOFF_FPTR64I 0x53 -#define R_IA64_LTOFF_FPTR32MSB 0x54 -#define R_IA64_LTOFF_FPTR32LSB 0x55 -#define R_IA64_LTOFF_FPTR64MSB 0x56 -#define R_IA64_LTOFF_FPTR64LSB 0x57 -#define R_IA64_SEGREL32MSB 0x5c -#define R_IA64_SEGREL32LSB 0x5d -#define R_IA64_SEGREL64MSB 0x5e -#define R_IA64_SEGREL64LSB 0x5f -#define R_IA64_SECREL32MSB 0x64 -#define R_IA64_SECREL32LSB 0x65 -#define R_IA64_SECREL64MSB 0x66 -#define R_IA64_SECREL64LSB 0x67 -#define R_IA64_REL32MSB 0x6c -#define R_IA64_REL32LSB 0x6d -#define R_IA64_REL64MSB 0x6e -#define R_IA64_REL64LSB 0x6f -#define R_IA64_LTV32MSB 0x74 -#define R_IA64_LTV32LSB 0x75 -#define R_IA64_LTV64MSB 0x76 -#define R_IA64_LTV64LSB 0x77 -#define R_IA64_PCREL21BI 0x79 -#define R_IA64_PCREL22 0x7a -#define R_IA64_PCREL64I 0x7b -#define R_IA64_IPLTMSB 0x80 -#define R_IA64_IPLTLSB 0x81 -#define R_IA64_COPY 0x84 -#define R_IA64_SUB 0x85 -#define R_IA64_LTOFF22X 0x86 -#define R_IA64_LDXMOV 0x87 -#define R_IA64_TPREL14 0x91 -#define R_IA64_TPREL22 0x92 -#define R_IA64_TPREL64I 0x93 -#define R_IA64_TPREL64MSB 0x96 -#define R_IA64_TPREL64LSB 0x97 -#define R_IA64_LTOFF_TPREL22 0x9a -#define R_IA64_DTPMOD64MSB 0xa6 -#define R_IA64_DTPMOD64LSB 0xa7 -#define R_IA64_LTOFF_DTPMOD22 0xaa -#define R_IA64_DTPREL14 0xb1 -#define R_IA64_DTPREL22 0xb2 -#define R_IA64_DTPREL64I 0xb3 -#define R_IA64_DTPREL32MSB 0xb4 -#define R_IA64_DTPREL32LSB 0xb5 -#define R_IA64_DTPREL64MSB 0xb6 -#define R_IA64_DTPREL64LSB 0xb7 -#define R_IA64_LTOFF_DTPREL22 0xba - - -#define EF_SH_MACH_MASK 0x1f -#define EF_SH_UNKNOWN 0x0 -#define EF_SH1 0x1 -#define EF_SH2 0x2 -#define EF_SH3 0x3 -#define EF_SH_DSP 0x4 -#define EF_SH3_DSP 0x5 -#define EF_SH4AL_DSP 0x6 -#define EF_SH3E 0x8 -#define EF_SH4 0x9 -#define EF_SH2E 0xb -#define EF_SH4A 0xc -#define EF_SH2A 0xd -#define EF_SH4_NOFPU 0x10 -#define EF_SH4A_NOFPU 0x11 -#define EF_SH4_NOMMU_NOFPU 0x12 -#define EF_SH2A_NOFPU 0x13 -#define EF_SH3_NOMMU 0x14 -#define EF_SH2A_SH4_NOFPU 0x15 -#define EF_SH2A_SH3_NOFPU 0x16 -#define EF_SH2A_SH4 0x17 -#define EF_SH2A_SH3E 0x18 - -#define R_SH_NONE 0 -#define R_SH_DIR32 1 -#define R_SH_REL32 2 -#define R_SH_DIR8WPN 3 -#define R_SH_IND12W 4 -#define R_SH_DIR8WPL 5 -#define R_SH_DIR8WPZ 6 -#define R_SH_DIR8BP 7 -#define R_SH_DIR8W 8 -#define R_SH_DIR8L 9 -#define R_SH_SWITCH16 25 -#define R_SH_SWITCH32 26 -#define R_SH_USES 27 -#define R_SH_COUNT 28 -#define R_SH_ALIGN 29 -#define R_SH_CODE 30 -#define R_SH_DATA 31 -#define R_SH_LABEL 32 -#define R_SH_SWITCH8 33 -#define R_SH_GNU_VTINHERIT 34 -#define R_SH_GNU_VTENTRY 35 -#define R_SH_TLS_GD_32 144 -#define R_SH_TLS_LD_32 145 -#define R_SH_TLS_LDO_32 146 -#define R_SH_TLS_IE_32 147 -#define R_SH_TLS_LE_32 148 -#define R_SH_TLS_DTPMOD32 149 -#define R_SH_TLS_DTPOFF32 150 -#define R_SH_TLS_TPOFF32 151 -#define R_SH_GOT32 160 -#define R_SH_PLT32 161 -#define R_SH_COPY 162 -#define R_SH_GLOB_DAT 163 -#define R_SH_JMP_SLOT 164 -#define R_SH_RELATIVE 165 -#define R_SH_GOTOFF 166 -#define R_SH_GOTPC 167 -#define R_SH_GOT20 201 -#define R_SH_GOTOFF20 202 -#define R_SH_GOTFUNCDESC 203 -#define R_SH_GOTFUNCDEST20 204 -#define R_SH_GOTOFFFUNCDESC 205 -#define R_SH_GOTOFFFUNCDEST20 206 -#define R_SH_FUNCDESC 207 -#define R_SH_FUNCDESC_VALUE 208 - -#define R_SH_NUM 256 - - - -#define R_390_NONE 0 -#define R_390_8 1 -#define R_390_12 2 -#define R_390_16 3 -#define R_390_32 4 -#define R_390_PC32 5 -#define R_390_GOT12 6 -#define R_390_GOT32 7 -#define R_390_PLT32 8 -#define R_390_COPY 9 -#define R_390_GLOB_DAT 10 -#define R_390_JMP_SLOT 11 -#define R_390_RELATIVE 12 -#define R_390_GOTOFF32 13 -#define R_390_GOTPC 14 -#define R_390_GOT16 15 -#define R_390_PC16 16 -#define R_390_PC16DBL 17 -#define R_390_PLT16DBL 18 -#define R_390_PC32DBL 19 -#define R_390_PLT32DBL 20 -#define R_390_GOTPCDBL 21 -#define R_390_64 22 -#define R_390_PC64 23 -#define R_390_GOT64 24 -#define R_390_PLT64 25 -#define R_390_GOTENT 26 -#define R_390_GOTOFF16 27 -#define R_390_GOTOFF64 28 -#define R_390_GOTPLT12 29 -#define R_390_GOTPLT16 30 -#define R_390_GOTPLT32 31 -#define R_390_GOTPLT64 32 -#define R_390_GOTPLTENT 33 -#define R_390_PLTOFF16 34 -#define R_390_PLTOFF32 35 -#define R_390_PLTOFF64 36 -#define R_390_TLS_LOAD 37 -#define R_390_TLS_GDCALL 38 - -#define R_390_TLS_LDCALL 39 - -#define R_390_TLS_GD32 40 - -#define R_390_TLS_GD64 41 - -#define R_390_TLS_GOTIE12 42 - -#define R_390_TLS_GOTIE32 43 - -#define R_390_TLS_GOTIE64 44 - -#define R_390_TLS_LDM32 45 - -#define R_390_TLS_LDM64 46 - -#define R_390_TLS_IE32 47 - -#define R_390_TLS_IE64 48 - -#define R_390_TLS_IEENT 49 - -#define R_390_TLS_LE32 50 - -#define R_390_TLS_LE64 51 - -#define R_390_TLS_LDO32 52 - -#define R_390_TLS_LDO64 53 - -#define R_390_TLS_DTPMOD 54 -#define R_390_TLS_DTPOFF 55 -#define R_390_TLS_TPOFF 56 - -#define R_390_20 57 -#define R_390_GOT20 58 -#define R_390_GOTPLT20 59 -#define R_390_TLS_GOTIE20 60 - - -#define R_390_NUM 61 - - - -#define R_CRIS_NONE 0 -#define R_CRIS_8 1 -#define R_CRIS_16 2 -#define R_CRIS_32 3 -#define R_CRIS_8_PCREL 4 -#define R_CRIS_16_PCREL 5 -#define R_CRIS_32_PCREL 6 -#define R_CRIS_GNU_VTINHERIT 7 -#define R_CRIS_GNU_VTENTRY 8 -#define R_CRIS_COPY 9 -#define R_CRIS_GLOB_DAT 10 -#define R_CRIS_JUMP_SLOT 11 -#define R_CRIS_RELATIVE 12 -#define R_CRIS_16_GOT 13 -#define R_CRIS_32_GOT 14 -#define R_CRIS_16_GOTPLT 15 -#define R_CRIS_32_GOTPLT 16 -#define R_CRIS_32_GOTREL 17 -#define R_CRIS_32_PLT_GOTREL 18 -#define R_CRIS_32_PLT_PCREL 19 - -#define R_CRIS_NUM 20 - - - -#define R_X86_64_NONE 0 -#define R_X86_64_64 1 -#define R_X86_64_PC32 2 -#define R_X86_64_GOT32 3 -#define R_X86_64_PLT32 4 -#define R_X86_64_COPY 5 -#define R_X86_64_GLOB_DAT 6 -#define R_X86_64_JUMP_SLOT 7 -#define R_X86_64_RELATIVE 8 -#define R_X86_64_GOTPCREL 9 - -#define R_X86_64_32 10 -#define R_X86_64_32S 11 -#define R_X86_64_16 12 -#define R_X86_64_PC16 13 -#define R_X86_64_8 14 -#define R_X86_64_PC8 15 -#define R_X86_64_DTPMOD64 16 -#define R_X86_64_DTPOFF64 17 -#define R_X86_64_TPOFF64 18 -#define R_X86_64_TLSGD 19 - -#define R_X86_64_TLSLD 20 - -#define R_X86_64_DTPOFF32 21 -#define R_X86_64_GOTTPOFF 22 - -#define R_X86_64_TPOFF32 23 -#define R_X86_64_PC64 24 -#define R_X86_64_GOTOFF64 25 -#define R_X86_64_GOTPC32 26 -#define R_X86_64_GOT64 27 -#define R_X86_64_GOTPCREL64 28 -#define R_X86_64_GOTPC64 29 -#define R_X86_64_GOTPLT64 30 -#define R_X86_64_PLTOFF64 31 -#define R_X86_64_SIZE32 32 -#define R_X86_64_SIZE64 33 - -#define R_X86_64_GOTPC32_TLSDESC 34 -#define R_X86_64_TLSDESC_CALL 35 - -#define R_X86_64_TLSDESC 36 -#define R_X86_64_IRELATIVE 37 -#define R_X86_64_RELATIVE64 38 -#define R_X86_64_GOTPCRELX 41 -#define R_X86_64_REX_GOTPCRELX 42 -#define R_X86_64_NUM 43 - - - -#define R_MN10300_NONE 0 -#define R_MN10300_32 1 -#define R_MN10300_16 2 -#define R_MN10300_8 3 -#define R_MN10300_PCREL32 4 -#define R_MN10300_PCREL16 5 -#define R_MN10300_PCREL8 6 -#define R_MN10300_GNU_VTINHERIT 7 -#define R_MN10300_GNU_VTENTRY 8 -#define R_MN10300_24 9 -#define R_MN10300_GOTPC32 10 -#define R_MN10300_GOTPC16 11 -#define R_MN10300_GOTOFF32 12 -#define R_MN10300_GOTOFF24 13 -#define R_MN10300_GOTOFF16 14 -#define R_MN10300_PLT32 15 -#define R_MN10300_PLT16 16 -#define R_MN10300_GOT32 17 -#define R_MN10300_GOT24 18 -#define R_MN10300_GOT16 19 -#define R_MN10300_COPY 20 -#define R_MN10300_GLOB_DAT 21 -#define R_MN10300_JMP_SLOT 22 -#define R_MN10300_RELATIVE 23 - -#define R_MN10300_NUM 24 - - - -#define R_M32R_NONE 0 -#define R_M32R_16 1 -#define R_M32R_32 2 -#define R_M32R_24 3 -#define R_M32R_10_PCREL 4 -#define R_M32R_18_PCREL 5 -#define R_M32R_26_PCREL 6 -#define R_M32R_HI16_ULO 7 -#define R_M32R_HI16_SLO 8 -#define R_M32R_LO16 9 -#define R_M32R_SDA16 10 -#define R_M32R_GNU_VTINHERIT 11 -#define R_M32R_GNU_VTENTRY 12 - -#define R_M32R_16_RELA 33 -#define R_M32R_32_RELA 34 -#define R_M32R_24_RELA 35 -#define R_M32R_10_PCREL_RELA 36 -#define R_M32R_18_PCREL_RELA 37 -#define R_M32R_26_PCREL_RELA 38 -#define R_M32R_HI16_ULO_RELA 39 -#define R_M32R_HI16_SLO_RELA 40 -#define R_M32R_LO16_RELA 41 -#define R_M32R_SDA16_RELA 42 -#define R_M32R_RELA_GNU_VTINHERIT 43 -#define R_M32R_RELA_GNU_VTENTRY 44 -#define R_M32R_REL32 45 - -#define R_M32R_GOT24 48 -#define R_M32R_26_PLTREL 49 -#define R_M32R_COPY 50 -#define R_M32R_GLOB_DAT 51 -#define R_M32R_JMP_SLOT 52 -#define R_M32R_RELATIVE 53 -#define R_M32R_GOTOFF 54 -#define R_M32R_GOTPC24 55 -#define R_M32R_GOT16_HI_ULO 56 - -#define R_M32R_GOT16_HI_SLO 57 - -#define R_M32R_GOT16_LO 58 -#define R_M32R_GOTPC_HI_ULO 59 - -#define R_M32R_GOTPC_HI_SLO 60 - -#define R_M32R_GOTPC_LO 61 - -#define R_M32R_GOTOFF_HI_ULO 62 - -#define R_M32R_GOTOFF_HI_SLO 63 - -#define R_M32R_GOTOFF_LO 64 -#define R_M32R_NUM 256 - -#define R_MICROBLAZE_NONE 0 -#define R_MICROBLAZE_32 1 -#define R_MICROBLAZE_32_PCREL 2 -#define R_MICROBLAZE_64_PCREL 3 -#define R_MICROBLAZE_32_PCREL_LO 4 -#define R_MICROBLAZE_64 5 -#define R_MICROBLAZE_32_LO 6 -#define R_MICROBLAZE_SRO32 7 -#define R_MICROBLAZE_SRW32 8 -#define R_MICROBLAZE_64_NONE 9 -#define R_MICROBLAZE_32_SYM_OP_SYM 10 -#define R_MICROBLAZE_GNU_VTINHERIT 11 -#define R_MICROBLAZE_GNU_VTENTRY 12 -#define R_MICROBLAZE_GOTPC_64 13 -#define R_MICROBLAZE_GOT_64 14 -#define R_MICROBLAZE_PLT_64 15 -#define R_MICROBLAZE_REL 16 -#define R_MICROBLAZE_JUMP_SLOT 17 -#define R_MICROBLAZE_GLOB_DAT 18 -#define R_MICROBLAZE_GOTOFF_64 19 -#define R_MICROBLAZE_GOTOFF_32 20 -#define R_MICROBLAZE_COPY 21 -#define R_MICROBLAZE_TLS 22 -#define R_MICROBLAZE_TLSGD 23 -#define R_MICROBLAZE_TLSLD 24 -#define R_MICROBLAZE_TLSDTPMOD32 25 -#define R_MICROBLAZE_TLSDTPREL32 26 -#define R_MICROBLAZE_TLSDTPREL64 27 -#define R_MICROBLAZE_TLSGOTTPREL32 28 -#define R_MICROBLAZE_TLSTPREL32 29 - -#define DT_NIOS2_GP 0x70000002 - -#define R_NIOS2_NONE 0 -#define R_NIOS2_S16 1 -#define R_NIOS2_U16 2 -#define R_NIOS2_PCREL16 3 -#define R_NIOS2_CALL26 4 -#define R_NIOS2_IMM5 5 -#define R_NIOS2_CACHE_OPX 6 -#define R_NIOS2_IMM6 7 -#define R_NIOS2_IMM8 8 -#define R_NIOS2_HI16 9 -#define R_NIOS2_LO16 10 -#define R_NIOS2_HIADJ16 11 -#define R_NIOS2_BFD_RELOC_32 12 -#define R_NIOS2_BFD_RELOC_16 13 -#define R_NIOS2_BFD_RELOC_8 14 -#define R_NIOS2_GPREL 15 -#define R_NIOS2_GNU_VTINHERIT 16 -#define R_NIOS2_GNU_VTENTRY 17 -#define R_NIOS2_UJMP 18 -#define R_NIOS2_CJMP 19 -#define R_NIOS2_CALLR 20 -#define R_NIOS2_ALIGN 21 -#define R_NIOS2_GOT16 22 -#define R_NIOS2_CALL16 23 -#define R_NIOS2_GOTOFF_LO 24 -#define R_NIOS2_GOTOFF_HA 25 -#define R_NIOS2_PCREL_LO 26 -#define R_NIOS2_PCREL_HA 27 -#define R_NIOS2_TLS_GD16 28 -#define R_NIOS2_TLS_LDM16 29 -#define R_NIOS2_TLS_LDO16 30 -#define R_NIOS2_TLS_IE16 31 -#define R_NIOS2_TLS_LE16 32 -#define R_NIOS2_TLS_DTPMOD 33 -#define R_NIOS2_TLS_DTPREL 34 -#define R_NIOS2_TLS_TPREL 35 -#define R_NIOS2_COPY 36 -#define R_NIOS2_GLOB_DAT 37 -#define R_NIOS2_JUMP_SLOT 38 -#define R_NIOS2_RELATIVE 39 -#define R_NIOS2_GOTOFF 40 -#define R_NIOS2_CALL26_NOAT 41 -#define R_NIOS2_GOT_LO 42 -#define R_NIOS2_GOT_HA 43 -#define R_NIOS2_CALL_LO 44 -#define R_NIOS2_CALL_HA 45 - -#define R_OR1K_NONE 0 -#define R_OR1K_32 1 -#define R_OR1K_16 2 -#define R_OR1K_8 3 -#define R_OR1K_LO_16_IN_INSN 4 -#define R_OR1K_HI_16_IN_INSN 5 -#define R_OR1K_INSN_REL_26 6 -#define R_OR1K_GNU_VTENTRY 7 -#define R_OR1K_GNU_VTINHERIT 8 -#define R_OR1K_32_PCREL 9 -#define R_OR1K_16_PCREL 10 -#define R_OR1K_8_PCREL 11 -#define R_OR1K_GOTPC_HI16 12 -#define R_OR1K_GOTPC_LO16 13 -#define R_OR1K_GOT16 14 -#define R_OR1K_PLT26 15 -#define R_OR1K_GOTOFF_HI16 16 -#define R_OR1K_GOTOFF_LO16 17 -#define R_OR1K_COPY 18 -#define R_OR1K_GLOB_DAT 19 -#define R_OR1K_JMP_SLOT 20 -#define R_OR1K_RELATIVE 21 -#define R_OR1K_TLS_GD_HI16 22 -#define R_OR1K_TLS_GD_LO16 23 -#define R_OR1K_TLS_LDM_HI16 24 -#define R_OR1K_TLS_LDM_LO16 25 -#define R_OR1K_TLS_LDO_HI16 26 -#define R_OR1K_TLS_LDO_LO16 27 -#define R_OR1K_TLS_IE_HI16 28 -#define R_OR1K_TLS_IE_LO16 29 -#define R_OR1K_TLS_LE_HI16 30 -#define R_OR1K_TLS_LE_LO16 31 -#define R_OR1K_TLS_TPOFF 32 -#define R_OR1K_TLS_DTPOFF 33 -#define R_OR1K_TLS_DTPMOD 34 - -#define R_BPF_NONE 0 -#define R_BPF_MAP_FD 1 - -#define R_RISCV_NONE 0 -#define R_RISCV_32 1 -#define R_RISCV_64 2 -#define R_RISCV_RELATIVE 3 -#define R_RISCV_COPY 4 -#define R_RISCV_JUMP_SLOT 5 -#define R_RISCV_TLS_DTPMOD32 6 -#define R_RISCV_TLS_DTPMOD64 7 -#define R_RISCV_TLS_DTPREL32 8 -#define R_RISCV_TLS_DTPREL64 9 -#define R_RISCV_TLS_TPREL32 10 -#define R_RISCV_TLS_TPREL64 11 - -#define R_RISCV_BRANCH 16 -#define R_RISCV_JAL 17 -#define R_RISCV_CALL 18 -#define R_RISCV_CALL_PLT 19 -#define R_RISCV_GOT_HI20 20 -#define R_RISCV_TLS_GOT_HI20 21 -#define R_RISCV_TLS_GD_HI20 22 -#define R_RISCV_PCREL_HI20 23 -#define R_RISCV_PCREL_LO12_I 24 -#define R_RISCV_PCREL_LO12_S 25 -#define R_RISCV_HI20 26 -#define R_RISCV_LO12_I 27 -#define R_RISCV_LO12_S 28 -#define R_RISCV_TPREL_HI20 29 -#define R_RISCV_TPREL_LO12_I 30 -#define R_RISCV_TPREL_LO12_S 31 -#define R_RISCV_TPREL_ADD 32 -#define R_RISCV_ADD8 33 -#define R_RISCV_ADD16 34 -#define R_RISCV_ADD32 35 -#define R_RISCV_ADD64 36 -#define R_RISCV_SUB8 37 -#define R_RISCV_SUB16 38 -#define R_RISCV_SUB32 39 -#define R_RISCV_SUB64 40 -#define R_RISCV_GNU_VTINHERIT 41 -#define R_RISCV_GNU_VTENTRY 42 -#define R_RISCV_ALIGN 43 -#define R_RISCV_RVC_BRANCH 44 -#define R_RISCV_RVC_JUMP 45 -#define R_RISCV_RVC_LUI 46 -#define R_RISCV_GPREL_I 47 -#define R_RISCV_GPREL_S 48 -#define R_RISCV_TPREL_I 49 -#define R_RISCV_TPREL_S 50 -#define R_RISCV_RELAX 51 -#define R_RISCV_SUB6 52 -#define R_RISCV_SET6 53 -#define R_RISCV_SET8 54 -#define R_RISCV_SET16 55 -#define R_RISCV_SET32 56 -#define R_RISCV_32_PCREL 57 - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/grp.h b/lib/libc/wasi/libc-top-half/musl/include/grp.h deleted file mode 100644 index 27e8c5e6c672..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/grp.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _GRP_H -#define _GRP_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_size_t -#define __NEED_gid_t - -#ifdef _GNU_SOURCE -#define __NEED_FILE -#endif - -#include - -struct group { - char *gr_name; - char *gr_passwd; - gid_t gr_gid; - char **gr_mem; -}; - -struct group *getgrgid(gid_t); -struct group *getgrnam(const char *); - -int getgrgid_r(gid_t, struct group *, char *, size_t, struct group **); -int getgrnam_r(const char *, struct group *, char *, size_t, struct group **); - -#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -struct group *getgrent(void); -void endgrent(void); -void setgrent(void); -#endif - -#ifdef _GNU_SOURCE -struct group *fgetgrent(FILE *); -int putgrent(const struct group *, FILE *); -#endif - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -int getgrouplist(const char *, gid_t, gid_t *, int *); -int setgroups(size_t, const gid_t *); -int initgroups(const char *, gid_t); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/lastlog.h b/lib/libc/wasi/libc-top-half/musl/include/lastlog.h deleted file mode 100644 index 5fa45ee47780..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/lastlog.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/lib/libc/wasi/libc-top-half/musl/include/libintl.h b/lib/libc/wasi/libc-top-half/musl/include/libintl.h deleted file mode 100644 index 6a707bf0f001..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/libintl.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _LIBINTL_H -#define _LIBINTL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define __USE_GNU_GETTEXT 1 -#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 1 : -1) - -#if __GNUC__ >= 3 -#define __fa(n) __attribute__ ((__format_arg__ (n))) -#else -#define __fa(n) -#endif - -char *gettext(const char *) __fa(1); -char *dgettext(const char *, const char *) __fa(2); -char *dcgettext(const char *, const char *, int) __fa(2); -char *ngettext(const char *, const char *, unsigned long) __fa(1) __fa(2); -char *dngettext(const char *, const char *, const char *, unsigned long) __fa(2) __fa(3); -char *dcngettext(const char *, const char *, const char *, unsigned long, int) __fa(2) __fa(3); -char *textdomain(const char *); -char *bindtextdomain (const char *, const char *); -char *bind_textdomain_codeset(const char *, const char *); - -#undef __fa - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/link.h b/lib/libc/wasi/libc-top-half/musl/include/link.h deleted file mode 100644 index 815018594c77..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/link.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _LINK_H -#define _LINK_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#define __NEED_size_t -#define __NEED_uint32_t -#include - -#if UINTPTR_MAX > 0xffffffff -#define ElfW(type) Elf64_ ## type -#else -#define ElfW(type) Elf32_ ## type -#endif - -#include - -struct dl_phdr_info { - ElfW(Addr) dlpi_addr; - const char *dlpi_name; - const ElfW(Phdr) *dlpi_phdr; - ElfW(Half) dlpi_phnum; - unsigned long long int dlpi_adds; - unsigned long long int dlpi_subs; - size_t dlpi_tls_modid; - void *dlpi_tls_data; -}; - -struct link_map { - ElfW(Addr) l_addr; - char *l_name; - ElfW(Dyn) *l_ld; - struct link_map *l_next, *l_prev; -}; - -struct r_debug { - int r_version; - struct link_map *r_map; - ElfW(Addr) r_brk; - enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state; - ElfW(Addr) r_ldbase; -}; - -int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), void *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/mntent.h b/lib/libc/wasi/libc-top-half/musl/include/mntent.h deleted file mode 100644 index 3492a1d6daa2..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/mntent.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _MNTENT_H -#define _MNTENT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define __NEED_FILE -#include - -#define MOUNTED "/etc/mtab" - -#define MNTTYPE_IGNORE "ignore" -#define MNTTYPE_NFS "nfs" -#define MNTTYPE_SWAP "swap" -#define MNTOPT_DEFAULTS "defaults" -#define MNTOPT_RO "ro" -#define MNTOPT_RW "rw" -#define MNTOPT_SUID "suid" -#define MNTOPT_NOSUID "nosuid" -#define MNTOPT_NOAUTO "noauto" - -struct mntent { - char *mnt_fsname; - char *mnt_dir; - char *mnt_type; - char *mnt_opts; - int mnt_freq; - int mnt_passno; -}; - -FILE *setmntent(const char *, const char *); -int endmntent(FILE *); -struct mntent *getmntent(FILE *); -struct mntent *getmntent_r(FILE *, struct mntent *, char *, int); -int addmntent(FILE *, const struct mntent *); -char *hasmntopt(const struct mntent *, const char *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/net/ethernet.h b/lib/libc/wasi/libc-top-half/musl/include/net/ethernet.h deleted file mode 100644 index c8d4177fd278..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/net/ethernet.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _NET_ETHERNET_H -#define _NET_ETHERNET_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -struct ether_addr { - uint8_t ether_addr_octet[ETH_ALEN]; -}; - -struct ether_header { - uint8_t ether_dhost[ETH_ALEN]; - uint8_t ether_shost[ETH_ALEN]; - uint16_t ether_type; -}; - -#define ETHERTYPE_PUP 0x0200 -#define ETHERTYPE_SPRITE 0x0500 -#define ETHERTYPE_IP 0x0800 -#define ETHERTYPE_ARP 0x0806 -#define ETHERTYPE_REVARP 0x8035 -#define ETHERTYPE_AT 0x809B -#define ETHERTYPE_AARP 0x80F3 -#define ETHERTYPE_VLAN 0x8100 -#define ETHERTYPE_IPX 0x8137 -#define ETHERTYPE_IPV6 0x86dd -#define ETHERTYPE_LOOPBACK 0x9000 - - -#define ETHER_ADDR_LEN ETH_ALEN -#define ETHER_TYPE_LEN 2 -#define ETHER_CRC_LEN 4 -#define ETHER_HDR_LEN ETH_HLEN -#define ETHER_MIN_LEN (ETH_ZLEN + ETHER_CRC_LEN) -#define ETHER_MAX_LEN (ETH_FRAME_LEN + ETHER_CRC_LEN) - -#define ETHER_IS_VALID_LEN(foo) \ - ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) - -#define ETHERTYPE_TRAIL 0x1000 -#define ETHERTYPE_NTRAILER 16 - -#define ETHERMTU ETH_DATA_LEN -#define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/net/if.h b/lib/libc/wasi/libc-top-half/musl/include/net/if.h deleted file mode 100644 index 774cbff0b506..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/net/if.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef _NET_IF_H -#define _NET_IF_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define IF_NAMESIZE 16 - -struct if_nameindex { - unsigned int if_index; - char *if_name; -}; - -unsigned int if_nametoindex (const char *); -char *if_indextoname (unsigned int, char *); -struct if_nameindex *if_nameindex (void); -void if_freenameindex (struct if_nameindex *); - - - - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) - -#include - -#define IFF_UP 0x1 -#define IFF_BROADCAST 0x2 -#define IFF_DEBUG 0x4 -#define IFF_LOOPBACK 0x8 -#define IFF_POINTOPOINT 0x10 -#define IFF_NOTRAILERS 0x20 -#define IFF_RUNNING 0x40 -#define IFF_NOARP 0x80 -#define IFF_PROMISC 0x100 -#define IFF_ALLMULTI 0x200 -#define IFF_MASTER 0x400 -#define IFF_SLAVE 0x800 -#define IFF_MULTICAST 0x1000 -#define IFF_PORTSEL 0x2000 -#define IFF_AUTOMEDIA 0x4000 -#define IFF_DYNAMIC 0x8000 -#define IFF_LOWER_UP 0x10000 -#define IFF_DORMANT 0x20000 -#define IFF_ECHO 0x40000 -#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST| \ - IFF_ECHO|IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT) - -struct ifaddr { - struct sockaddr ifa_addr; - union { - struct sockaddr ifu_broadaddr; - struct sockaddr ifu_dstaddr; - } ifa_ifu; - struct iface *ifa_ifp; - struct ifaddr *ifa_next; -}; - -#define ifa_broadaddr ifa_ifu.ifu_broadaddr -#define ifa_dstaddr ifa_ifu.ifu_dstaddr - -struct ifmap { - unsigned long int mem_start; - unsigned long int mem_end; - unsigned short int base_addr; - unsigned char irq; - unsigned char dma; - unsigned char port; -}; - -#define IFHWADDRLEN 6 -#define IFNAMSIZ IF_NAMESIZE - -struct ifreq { - union { - char ifrn_name[IFNAMSIZ]; - } ifr_ifrn; - union { - struct sockaddr ifru_addr; - struct sockaddr ifru_dstaddr; - struct sockaddr ifru_broadaddr; - struct sockaddr ifru_netmask; - struct sockaddr ifru_hwaddr; - short int ifru_flags; - int ifru_ivalue; - int ifru_mtu; - struct ifmap ifru_map; - char ifru_slave[IFNAMSIZ]; - char ifru_newname[IFNAMSIZ]; - char *ifru_data; - } ifr_ifru; -}; - -#define ifr_name ifr_ifrn.ifrn_name -#define ifr_hwaddr ifr_ifru.ifru_hwaddr -#define ifr_addr ifr_ifru.ifru_addr -#define ifr_dstaddr ifr_ifru.ifru_dstaddr -#define ifr_broadaddr ifr_ifru.ifru_broadaddr -#define ifr_netmask ifr_ifru.ifru_netmask -#define ifr_flags ifr_ifru.ifru_flags -#define ifr_metric ifr_ifru.ifru_ivalue -#define ifr_mtu ifr_ifru.ifru_mtu -#define ifr_map ifr_ifru.ifru_map -#define ifr_slave ifr_ifru.ifru_slave -#define ifr_data ifr_ifru.ifru_data -#define ifr_ifindex ifr_ifru.ifru_ivalue -#define ifr_bandwidth ifr_ifru.ifru_ivalue -#define ifr_qlen ifr_ifru.ifru_ivalue -#define ifr_newname ifr_ifru.ifru_newname -#define _IOT_ifreq _IOT(_IOTS(char),IFNAMSIZ,_IOTS(char),16,0,0) -#define _IOT_ifreq_short _IOT(_IOTS(char),IFNAMSIZ,_IOTS(short),1,0,0) -#define _IOT_ifreq_int _IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0) - -struct ifconf { - int ifc_len; - union { - char *ifcu_buf; - struct ifreq *ifcu_req; - } ifc_ifcu; -}; - -#define ifc_buf ifc_ifcu.ifcu_buf -#define ifc_req ifc_ifcu.ifcu_req -#define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0) - -#define __UAPI_DEF_IF_IFCONF 0 -#define __UAPI_DEF_IF_IFMAP 0 -#define __UAPI_DEF_IF_IFNAMSIZ 0 -#define __UAPI_DEF_IF_IFREQ 0 -#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0 -#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0 - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/net/if_arp.h b/lib/libc/wasi/libc-top-half/musl/include/net/if_arp.h deleted file mode 100644 index 27becc835eeb..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/net/if_arp.h +++ /dev/null @@ -1,142 +0,0 @@ -/* Nonstandard header */ -#ifndef _NET_IF_ARP_H -#define _NET_IF_ARP_H -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -#define MAX_ADDR_LEN 7 - -#define ARPOP_REQUEST 1 -#define ARPOP_REPLY 2 -#define ARPOP_RREQUEST 3 -#define ARPOP_RREPLY 4 -#define ARPOP_InREQUEST 8 -#define ARPOP_InREPLY 9 -#define ARPOP_NAK 10 - -struct arphdr { - uint16_t ar_hrd; - uint16_t ar_pro; - uint8_t ar_hln; - uint8_t ar_pln; - uint16_t ar_op; -}; - - -#define ARPHRD_NETROM 0 -#define ARPHRD_ETHER 1 -#define ARPHRD_EETHER 2 -#define ARPHRD_AX25 3 -#define ARPHRD_PRONET 4 -#define ARPHRD_CHAOS 5 -#define ARPHRD_IEEE802 6 -#define ARPHRD_ARCNET 7 -#define ARPHRD_APPLETLK 8 -#define ARPHRD_DLCI 15 -#define ARPHRD_ATM 19 -#define ARPHRD_METRICOM 23 -#define ARPHRD_IEEE1394 24 -#define ARPHRD_EUI64 27 -#define ARPHRD_INFINIBAND 32 -#define ARPHRD_SLIP 256 -#define ARPHRD_CSLIP 257 -#define ARPHRD_SLIP6 258 -#define ARPHRD_CSLIP6 259 -#define ARPHRD_RSRVD 260 -#define ARPHRD_ADAPT 264 -#define ARPHRD_ROSE 270 -#define ARPHRD_X25 271 -#define ARPHRD_HWX25 272 -#define ARPHRD_CAN 280 -#define ARPHRD_PPP 512 -#define ARPHRD_CISCO 513 -#define ARPHRD_HDLC ARPHRD_CISCO -#define ARPHRD_LAPB 516 -#define ARPHRD_DDCMP 517 -#define ARPHRD_RAWHDLC 518 -#define ARPHRD_RAWIP 519 - -#define ARPHRD_TUNNEL 768 -#define ARPHRD_TUNNEL6 769 -#define ARPHRD_FRAD 770 -#define ARPHRD_SKIP 771 -#define ARPHRD_LOOPBACK 772 -#define ARPHRD_LOCALTLK 773 -#define ARPHRD_FDDI 774 -#define ARPHRD_BIF 775 -#define ARPHRD_SIT 776 -#define ARPHRD_IPDDP 777 -#define ARPHRD_IPGRE 778 -#define ARPHRD_PIMREG 779 -#define ARPHRD_HIPPI 780 -#define ARPHRD_ASH 781 -#define ARPHRD_ECONET 782 -#define ARPHRD_IRDA 783 -#define ARPHRD_FCPP 784 -#define ARPHRD_FCAL 785 -#define ARPHRD_FCPL 786 -#define ARPHRD_FCFABRIC 787 -#define ARPHRD_IEEE802_TR 800 -#define ARPHRD_IEEE80211 801 -#define ARPHRD_IEEE80211_PRISM 802 -#define ARPHRD_IEEE80211_RADIOTAP 803 -#define ARPHRD_IEEE802154 804 -#define ARPHRD_IEEE802154_MONITOR 805 -#define ARPHRD_PHONET 820 -#define ARPHRD_PHONET_PIPE 821 -#define ARPHRD_CAIF 822 -#define ARPHRD_IP6GRE 823 -#define ARPHRD_NETLINK 824 -#define ARPHRD_6LOWPAN 825 -#define ARPHRD_VSOCKMON 826 - -#define ARPHRD_VOID 0xFFFF -#define ARPHRD_NONE 0xFFFE - -struct arpreq { - struct sockaddr arp_pa; - struct sockaddr arp_ha; - int arp_flags; - struct sockaddr arp_netmask; - char arp_dev[16]; -}; - -struct arpreq_old { - struct sockaddr arp_pa; - struct sockaddr arp_ha; - int arp_flags; - struct sockaddr arp_netmask; -}; - -#define ATF_COM 0x02 -#define ATF_PERM 0x04 -#define ATF_PUBL 0x08 -#define ATF_USETRAILERS 0x10 -#define ATF_NETMASK 0x20 -#define ATF_DONTPUB 0x40 -#define ATF_MAGIC 0x80 - -#define ARPD_UPDATE 0x01 -#define ARPD_LOOKUP 0x02 -#define ARPD_FLUSH 0x03 - -struct arpd_request { - unsigned short req; - uint32_t ip; - unsigned long dev; - unsigned long stamp; - unsigned long updated; - unsigned char ha[MAX_ADDR_LEN]; -}; - - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/net/route.h b/lib/libc/wasi/libc-top-half/musl/include/net/route.h deleted file mode 100644 index 96ff48e014ce..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/net/route.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef _NET_ROUTE_H -#define _NET_ROUTE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include - - -struct rtentry { - unsigned long int rt_pad1; - struct sockaddr rt_dst; - struct sockaddr rt_gateway; - struct sockaddr rt_genmask; - unsigned short int rt_flags; - short int rt_pad2; - unsigned long int rt_pad3; - unsigned char rt_tos; - unsigned char rt_class; - short int rt_pad4[sizeof(long)/2-1]; - short int rt_metric; - char *rt_dev; - unsigned long int rt_mtu; - unsigned long int rt_window; - unsigned short int rt_irtt; -}; - -#define rt_mss rt_mtu - - -struct in6_rtmsg { - struct in6_addr rtmsg_dst; - struct in6_addr rtmsg_src; - struct in6_addr rtmsg_gateway; - uint32_t rtmsg_type; - uint16_t rtmsg_dst_len; - uint16_t rtmsg_src_len; - uint32_t rtmsg_metric; - unsigned long int rtmsg_info; - uint32_t rtmsg_flags; - int rtmsg_ifindex; -}; - - -#define RTF_UP 0x0001 -#define RTF_GATEWAY 0x0002 - -#define RTF_HOST 0x0004 -#define RTF_REINSTATE 0x0008 -#define RTF_DYNAMIC 0x0010 -#define RTF_MODIFIED 0x0020 -#define RTF_MTU 0x0040 -#define RTF_MSS RTF_MTU -#define RTF_WINDOW 0x0080 -#define RTF_IRTT 0x0100 -#define RTF_REJECT 0x0200 -#define RTF_STATIC 0x0400 -#define RTF_XRESOLVE 0x0800 -#define RTF_NOFORWARD 0x1000 -#define RTF_THROW 0x2000 -#define RTF_NOPMTUDISC 0x4000 - -#define RTF_DEFAULT 0x00010000 -#define RTF_ALLONLINK 0x00020000 -#define RTF_ADDRCONF 0x00040000 - -#define RTF_LINKRT 0x00100000 -#define RTF_NONEXTHOP 0x00200000 - -#define RTF_CACHE 0x01000000 -#define RTF_FLOW 0x02000000 -#define RTF_POLICY 0x04000000 - -#define RTCF_VALVE 0x00200000 -#define RTCF_MASQ 0x00400000 -#define RTCF_NAT 0x00800000 -#define RTCF_DOREDIRECT 0x01000000 -#define RTCF_LOG 0x02000000 -#define RTCF_DIRECTSRC 0x04000000 - -#define RTF_LOCAL 0x80000000 -#define RTF_INTERFACE 0x40000000 -#define RTF_MULTICAST 0x20000000 -#define RTF_BROADCAST 0x10000000 -#define RTF_NAT 0x08000000 - -#define RTF_ADDRCLASSMASK 0xF8000000 -#define RT_ADDRCLASS(flags) ((uint32_t) flags >> 23) - -#define RT_TOS(tos) ((tos) & IPTOS_TOS_MASK) - -#define RT_LOCALADDR(flags) ((flags & RTF_ADDRCLASSMASK) \ - == (RTF_LOCAL|RTF_INTERFACE)) - -#define RT_CLASS_UNSPEC 0 -#define RT_CLASS_DEFAULT 253 - -#define RT_CLASS_MAIN 254 -#define RT_CLASS_LOCAL 255 -#define RT_CLASS_MAX 255 - - -#define RTMSG_ACK NLMSG_ACK -#define RTMSG_OVERRUN NLMSG_OVERRUN - -#define RTMSG_NEWDEVICE 0x11 -#define RTMSG_DELDEVICE 0x12 -#define RTMSG_NEWROUTE 0x21 -#define RTMSG_DELROUTE 0x22 -#define RTMSG_NEWRULE 0x31 -#define RTMSG_DELRULE 0x32 -#define RTMSG_CONTROL 0x40 - -#define RTMSG_AR_FAILED 0x51 - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/netdb.h b/lib/libc/wasi/libc-top-half/musl/include/netdb.h deleted file mode 100644 index d096c78183b5..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/netdb.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef _NETDB_H -#define _NETDB_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define __NEED_size_t -#include -#endif - -struct addrinfo { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - socklen_t ai_addrlen; - struct sockaddr *ai_addr; - char *ai_canonname; - struct addrinfo *ai_next; -}; - -#define AI_PASSIVE 0x01 -#define AI_CANONNAME 0x02 -#define AI_NUMERICHOST 0x04 -#define AI_V4MAPPED 0x08 -#define AI_ALL 0x10 -#define AI_ADDRCONFIG 0x20 -#define AI_NUMERICSERV 0x400 - - -#define NI_NUMERICHOST 0x01 -#define NI_NUMERICSERV 0x02 -#define NI_NOFQDN 0x04 -#define NI_NAMEREQD 0x08 -#define NI_DGRAM 0x10 -#define NI_NUMERICSCOPE 0x100 - -#define EAI_BADFLAGS -1 -#define EAI_NONAME -2 -#define EAI_AGAIN -3 -#define EAI_FAIL -4 -#define EAI_FAMILY -6 -#define EAI_SOCKTYPE -7 -#define EAI_SERVICE -8 -#define EAI_MEMORY -10 -#define EAI_SYSTEM -11 -#define EAI_OVERFLOW -12 - -int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict); -void freeaddrinfo (struct addrinfo *); -int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int); -const char *gai_strerror(int); - - -/* Legacy functions follow (marked OBsolete in SUS) */ - -struct netent { - char *n_name; - char **n_aliases; - int n_addrtype; - uint32_t n_net; -}; - -struct hostent { - char *h_name; - char **h_aliases; - int h_addrtype; - int h_length; - char **h_addr_list; -}; -#define h_addr h_addr_list[0] - -struct servent { - char *s_name; - char **s_aliases; - int s_port; - char *s_proto; -}; - -struct protoent { - char *p_name; - char **p_aliases; - int p_proto; -}; - -void sethostent (int); -void endhostent (void); -struct hostent *gethostent (void); - -void setnetent (int); -void endnetent (void); -struct netent *getnetent (void); -struct netent *getnetbyaddr (uint32_t, int); -struct netent *getnetbyname (const char *); - -void setservent (int); -void endservent (void); -struct servent *getservent (void); -struct servent *getservbyname (const char *, const char *); -struct servent *getservbyport (int, const char *); - -void setprotoent (int); -void endprotoent (void); -struct protoent *getprotoent (void); -struct protoent *getprotobyname (const char *); -struct protoent *getprotobynumber (int); - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \ - || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \ - || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700) -struct hostent *gethostbyname (const char *); -struct hostent *gethostbyaddr (const void *, socklen_t, int); -#ifdef __GNUC__ -__attribute__((const)) -#endif -int *__h_errno_location(void); -#define h_errno (*__h_errno_location()) -#define HOST_NOT_FOUND 1 -#define TRY_AGAIN 2 -#define NO_RECOVERY 3 -#define NO_DATA 4 -#define NO_ADDRESS NO_DATA -#endif - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -void herror(const char *); -const char *hstrerror(int); -int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *); -int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *); -struct hostent *gethostbyname2(const char *, int); -int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *); -int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **); -int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **); -#define EAI_NODATA -5 -#define EAI_ADDRFAMILY -9 -#define EAI_INPROGRESS -100 -#define EAI_CANCELED -101 -#define EAI_NOTCANCELED -102 -#define EAI_ALLDONE -103 -#define EAI_INTR -104 -#define EAI_IDN_ENCODE -105 -#define NI_MAXHOST 255 -#define NI_MAXSERV 32 -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/netinet/ether.h b/lib/libc/wasi/libc-top-half/musl/include/netinet/ether.h deleted file mode 100644 index eec7e53ca497..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/netinet/ether.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _NETINET_ETHER_H -#define _NETINET_ETHER_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -char *ether_ntoa (const struct ether_addr *); -struct ether_addr *ether_aton (const char *); -char *ether_ntoa_r (const struct ether_addr *, char *); -struct ether_addr *ether_aton_r (const char *, struct ether_addr *); -int ether_line(const char *, struct ether_addr *, char *); -int ether_ntohost(char *, const struct ether_addr *); -int ether_hostton(const char *, struct ether_addr *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/netinet/if_ether.h b/lib/libc/wasi/libc-top-half/musl/include/netinet/if_ether.h deleted file mode 100644 index 3479f511bf21..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/netinet/if_ether.h +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef _NETINET_IF_ETHER_H -#define _NETINET_IF_ETHER_H - -#include -#include - -#define ETH_ALEN 6 -#define ETH_TLEN 2 -#define ETH_HLEN 14 -#define ETH_ZLEN 60 -#define ETH_DATA_LEN 1500 -#define ETH_FRAME_LEN 1514 -#define ETH_FCS_LEN 4 -#define ETH_MIN_MTU 68 -#define ETH_MAX_MTU 0xFFFFU - -#define ETH_P_LOOP 0x0060 -#define ETH_P_PUP 0x0200 -#define ETH_P_PUPAT 0x0201 -#define ETH_P_TSN 0x22F0 -#define ETH_P_ERSPAN2 0x22EB -#define ETH_P_IP 0x0800 -#define ETH_P_X25 0x0805 -#define ETH_P_ARP 0x0806 -#define ETH_P_BPQ 0x08FF -#define ETH_P_IEEEPUP 0x0a00 -#define ETH_P_IEEEPUPAT 0x0a01 -#define ETH_P_BATMAN 0x4305 -#define ETH_P_DEC 0x6000 -#define ETH_P_DNA_DL 0x6001 -#define ETH_P_DNA_RC 0x6002 -#define ETH_P_DNA_RT 0x6003 -#define ETH_P_LAT 0x6004 -#define ETH_P_DIAG 0x6005 -#define ETH_P_CUST 0x6006 -#define ETH_P_SCA 0x6007 -#define ETH_P_TEB 0x6558 -#define ETH_P_RARP 0x8035 -#define ETH_P_ATALK 0x809B -#define ETH_P_AARP 0x80F3 -#define ETH_P_8021Q 0x8100 -#define ETH_P_IPX 0x8137 -#define ETH_P_IPV6 0x86DD -#define ETH_P_PAUSE 0x8808 -#define ETH_P_SLOW 0x8809 -#define ETH_P_WCCP 0x883E -#define ETH_P_MPLS_UC 0x8847 -#define ETH_P_MPLS_MC 0x8848 -#define ETH_P_ATMMPOA 0x884c -#define ETH_P_PPP_DISC 0x8863 -#define ETH_P_PPP_SES 0x8864 -#define ETH_P_LINK_CTL 0x886c -#define ETH_P_ATMFATE 0x8884 -#define ETH_P_PAE 0x888E -#define ETH_P_AOE 0x88A2 -#define ETH_P_8021AD 0x88A8 -#define ETH_P_802_EX1 0x88B5 -#define ETH_P_ERSPAN 0x88BE -#define ETH_P_PREAUTH 0x88C7 -#define ETH_P_TIPC 0x88CA -#define ETH_P_LLDP 0x88CC -#define ETH_P_MRP 0x88E3 -#define ETH_P_MACSEC 0x88E5 -#define ETH_P_8021AH 0x88E7 -#define ETH_P_MVRP 0x88F5 -#define ETH_P_1588 0x88F7 -#define ETH_P_NCSI 0x88F8 -#define ETH_P_PRP 0x88FB -#define ETH_P_CFM 0x8902 -#define ETH_P_FCOE 0x8906 -#define ETH_P_TDLS 0x890D -#define ETH_P_FIP 0x8914 -#define ETH_P_IBOE 0x8915 -#define ETH_P_80221 0x8917 -#define ETH_P_HSR 0x892F -#define ETH_P_NSH 0x894F -#define ETH_P_LOOPBACK 0x9000 -#define ETH_P_QINQ1 0x9100 -#define ETH_P_QINQ2 0x9200 -#define ETH_P_QINQ3 0x9300 -#define ETH_P_EDSA 0xDADA -#define ETH_P_DSA_8021Q 0xDADB -#define ETH_P_IFE 0xED3E -#define ETH_P_AF_IUCV 0xFBFB - -#define ETH_P_802_3_MIN 0x0600 - -#define ETH_P_802_3 0x0001 -#define ETH_P_AX25 0x0002 -#define ETH_P_ALL 0x0003 -#define ETH_P_802_2 0x0004 -#define ETH_P_SNAP 0x0005 -#define ETH_P_DDCMP 0x0006 -#define ETH_P_WAN_PPP 0x0007 -#define ETH_P_PPP_MP 0x0008 -#define ETH_P_LOCALTALK 0x0009 -#define ETH_P_CAN 0x000C -#define ETH_P_CANFD 0x000D -#define ETH_P_PPPTALK 0x0010 -#define ETH_P_TR_802_2 0x0011 -#define ETH_P_MOBITEX 0x0015 -#define ETH_P_CONTROL 0x0016 -#define ETH_P_IRDA 0x0017 -#define ETH_P_ECONET 0x0018 -#define ETH_P_HDLC 0x0019 -#define ETH_P_ARCNET 0x001A -#define ETH_P_DSA 0x001B -#define ETH_P_TRAILER 0x001C -#define ETH_P_PHONET 0x00F5 -#define ETH_P_IEEE802154 0x00F6 -#define ETH_P_CAIF 0x00F7 -#define ETH_P_XDSA 0x00F8 -#define ETH_P_MAP 0x00F9 - -struct ethhdr { - uint8_t h_dest[ETH_ALEN]; - uint8_t h_source[ETH_ALEN]; - uint16_t h_proto; -}; - -#include -#include - -struct ether_arp { - struct arphdr ea_hdr; - uint8_t arp_sha[ETH_ALEN]; - uint8_t arp_spa[4]; - uint8_t arp_tha[ETH_ALEN]; - uint8_t arp_tpa[4]; -}; -#define arp_hrd ea_hdr.ar_hrd -#define arp_pro ea_hdr.ar_pro -#define arp_hln ea_hdr.ar_hln -#define arp_pln ea_hdr.ar_pln -#define arp_op ea_hdr.ar_op - -#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ -do { \ - (enaddr)[0] = 0x01; \ - (enaddr)[1] = 0x00; \ - (enaddr)[2] = 0x5e; \ - (enaddr)[3] = ((uint8_t *)ipaddr)[1] & 0x7f; \ - (enaddr)[4] = ((uint8_t *)ipaddr)[2]; \ - (enaddr)[5] = ((uint8_t *)ipaddr)[3]; \ -} while(0) - -#define __UAPI_DEF_ETHHDR 0 - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/paths.h b/lib/libc/wasi/libc-top-half/musl/include/paths.h deleted file mode 100644 index 67de6b3c3263..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/paths.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _PATHS_H -#define _PATHS_H - -#define _PATH_DEFPATH "/usr/local/bin:/bin:/usr/bin" -#define _PATH_STDPATH "/bin:/usr/bin:/sbin:/usr/sbin" - -#define _PATH_BSHELL "/bin/sh" -#define _PATH_CONSOLE "/dev/console" -#define _PATH_DEVNULL "/dev/null" -#define _PATH_KLOG "/proc/kmsg" -#define _PATH_LASTLOG "/var/log/lastlog" -#define _PATH_MAILDIR "/var/mail" -#define _PATH_MAN "/usr/share/man" -#define _PATH_MNTTAB "/etc/fstab" -#define _PATH_MOUNTED "/etc/mtab" -#define _PATH_NOLOGIN "/etc/nologin" -#define _PATH_SENDMAIL "/usr/sbin/sendmail" -#define _PATH_SHADOW "/etc/shadow" -#define _PATH_SHELLS "/etc/shells" -#define _PATH_TTY "/dev/tty" -#define _PATH_UTMP "/dev/null/utmp" -#define _PATH_VI "/usr/bin/vi" -#define _PATH_WTMP "/dev/null/wtmp" - -#define _PATH_DEV "/dev/" -#define _PATH_TMP "/tmp/" -#define _PATH_VARDB "/var/lib/misc/" -#define _PATH_VARRUN "/var/run/" -#define _PATH_VARTMP "/var/tmp/" - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/pthread.h b/lib/libc/wasi/libc-top-half/musl/include/pthread.h deleted file mode 100644 index 05101e8eb278..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/pthread.h +++ /dev/null @@ -1,250 +0,0 @@ -#ifndef _PTHREAD_H -#define _PTHREAD_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_time_t -#define __NEED_clockid_t -#define __NEED_struct_timespec -#define __NEED_sigset_t -#define __NEED_pthread_t -#define __NEED_pthread_attr_t -#define __NEED_pthread_mutexattr_t -#define __NEED_pthread_condattr_t -#define __NEED_pthread_rwlockattr_t -#define __NEED_pthread_barrierattr_t -#define __NEED_pthread_mutex_t -#define __NEED_pthread_cond_t -#define __NEED_pthread_rwlock_t -#define __NEED_pthread_barrier_t -#define __NEED_pthread_spinlock_t -#define __NEED_pthread_key_t -#define __NEED_pthread_once_t -#define __NEED_size_t - -#include - -#include -#include - -#define PTHREAD_CREATE_JOINABLE 0 -#define PTHREAD_CREATE_DETACHED 1 - -#define PTHREAD_MUTEX_NORMAL 0 -#define PTHREAD_MUTEX_DEFAULT 0 -#define PTHREAD_MUTEX_RECURSIVE 1 -#define PTHREAD_MUTEX_ERRORCHECK 2 - -#define PTHREAD_MUTEX_STALLED 0 -#define PTHREAD_MUTEX_ROBUST 1 - -#define PTHREAD_PRIO_NONE 0 -#define PTHREAD_PRIO_INHERIT 1 -#define PTHREAD_PRIO_PROTECT 2 - -#define PTHREAD_INHERIT_SCHED 0 -#define PTHREAD_EXPLICIT_SCHED 1 - -#define PTHREAD_SCOPE_SYSTEM 0 -#define PTHREAD_SCOPE_PROCESS 1 - -#define PTHREAD_PROCESS_PRIVATE 0 -#define PTHREAD_PROCESS_SHARED 1 - - -#define PTHREAD_MUTEX_INITIALIZER {{{0}}} -#define PTHREAD_RWLOCK_INITIALIZER {{{0}}} -#define PTHREAD_COND_INITIALIZER {{{0}}} -#define PTHREAD_ONCE_INIT 0 - - -#define PTHREAD_CANCEL_ENABLE 0 -#define PTHREAD_CANCEL_DISABLE 1 -#define PTHREAD_CANCEL_MASKED 2 - -#define PTHREAD_CANCEL_DEFERRED 0 -#define PTHREAD_CANCEL_ASYNCHRONOUS 1 - -#define PTHREAD_CANCELED ((void *)-1) - - -#define PTHREAD_BARRIER_SERIAL_THREAD (-1) - - -#define PTHREAD_NULL ((pthread_t)0) - - -int pthread_create(pthread_t *__restrict, const pthread_attr_t *__restrict, void *(*)(void *), void *__restrict); -int pthread_detach(pthread_t); -#ifdef __wasilibc_unmodified_upstream -_Noreturn void pthread_exit(void *); -#endif -int pthread_join(pthread_t, void **); - -#ifdef __GNUC__ -__attribute__((const)) -#endif -pthread_t pthread_self(void); - -int pthread_equal(pthread_t, pthread_t); -#ifndef __cplusplus -#define pthread_equal(x,y) ((x)==(y)) -#endif - -int pthread_setcancelstate(int, int *); -int pthread_setcanceltype(int, int *); -void pthread_testcancel(void); -int pthread_cancel(pthread_t); - -#ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */ -int pthread_getschedparam(pthread_t, int *__restrict, struct sched_param *__restrict); -int pthread_setschedparam(pthread_t, int, const struct sched_param *); -#endif -int pthread_setschedprio(pthread_t, int); - -int pthread_once(pthread_once_t *, void (*)(void)); - -int pthread_mutex_init(pthread_mutex_t *__restrict, const pthread_mutexattr_t *__restrict); -int pthread_mutex_lock(pthread_mutex_t *); -int pthread_mutex_unlock(pthread_mutex_t *); -int pthread_mutex_trylock(pthread_mutex_t *); -int pthread_mutex_timedlock(pthread_mutex_t *__restrict, const struct timespec *__restrict); -int pthread_mutex_destroy(pthread_mutex_t *); -int pthread_mutex_consistent(pthread_mutex_t *); - -int pthread_mutex_getprioceiling(const pthread_mutex_t *__restrict, int *__restrict); -int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict, int, int *__restrict); - -int pthread_cond_init(pthread_cond_t *__restrict, const pthread_condattr_t *__restrict); -int pthread_cond_destroy(pthread_cond_t *); -int pthread_cond_wait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict); -int pthread_cond_timedwait(pthread_cond_t *__restrict, pthread_mutex_t *__restrict, const struct timespec *__restrict); -int pthread_cond_broadcast(pthread_cond_t *); -int pthread_cond_signal(pthread_cond_t *); - -int pthread_rwlock_init(pthread_rwlock_t *__restrict, const pthread_rwlockattr_t *__restrict); -int pthread_rwlock_destroy(pthread_rwlock_t *); -int pthread_rwlock_rdlock(pthread_rwlock_t *); -int pthread_rwlock_tryrdlock(pthread_rwlock_t *); -int pthread_rwlock_timedrdlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict); -int pthread_rwlock_wrlock(pthread_rwlock_t *); -int pthread_rwlock_trywrlock(pthread_rwlock_t *); -int pthread_rwlock_timedwrlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict); -int pthread_rwlock_unlock(pthread_rwlock_t *); - -int pthread_spin_init(pthread_spinlock_t *, int); -int pthread_spin_destroy(pthread_spinlock_t *); -int pthread_spin_lock(pthread_spinlock_t *); -int pthread_spin_trylock(pthread_spinlock_t *); -int pthread_spin_unlock(pthread_spinlock_t *); - -int pthread_barrier_init(pthread_barrier_t *__restrict, const pthread_barrierattr_t *__restrict, unsigned); -int pthread_barrier_destroy(pthread_barrier_t *); -int pthread_barrier_wait(pthread_barrier_t *); - -int pthread_key_create(pthread_key_t *, void (*)(void *)); -int pthread_key_delete(pthread_key_t); -void *pthread_getspecific(pthread_key_t); -int pthread_setspecific(pthread_key_t, const void *); - -int pthread_attr_init(pthread_attr_t *); -int pthread_attr_destroy(pthread_attr_t *); - -int pthread_attr_getguardsize(const pthread_attr_t *__restrict, size_t *__restrict); -int pthread_attr_setguardsize(pthread_attr_t *, size_t); -int pthread_attr_getstacksize(const pthread_attr_t *__restrict, size_t *__restrict); -int pthread_attr_setstacksize(pthread_attr_t *, size_t); -int pthread_attr_getdetachstate(const pthread_attr_t *, int *); -int pthread_attr_setdetachstate(pthread_attr_t *, int); -int pthread_attr_getstack(const pthread_attr_t *__restrict, void **__restrict, size_t *__restrict); -int pthread_attr_setstack(pthread_attr_t *, void *, size_t); -int pthread_attr_getscope(const pthread_attr_t *__restrict, int *__restrict); -int pthread_attr_setscope(pthread_attr_t *, int); -int pthread_attr_getschedpolicy(const pthread_attr_t *__restrict, int *__restrict); -int pthread_attr_setschedpolicy(pthread_attr_t *, int); -#ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */ -int pthread_attr_getschedparam(const pthread_attr_t *__restrict, struct sched_param *__restrict); -int pthread_attr_setschedparam(pthread_attr_t *__restrict, const struct sched_param *__restrict); -#endif -int pthread_attr_getinheritsched(const pthread_attr_t *__restrict, int *__restrict); -int pthread_attr_setinheritsched(pthread_attr_t *, int); - -int pthread_mutexattr_destroy(pthread_mutexattr_t *); -int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *__restrict, int *__restrict); -int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__restrict, int *__restrict); -int pthread_mutexattr_getpshared(const pthread_mutexattr_t *__restrict, int *__restrict); -int pthread_mutexattr_getrobust(const pthread_mutexattr_t *__restrict, int *__restrict); -int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict, int *__restrict); -int pthread_mutexattr_init(pthread_mutexattr_t *); -int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int); -int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int); -int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); -int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int); -int pthread_mutexattr_settype(pthread_mutexattr_t *, int); - -int pthread_condattr_init(pthread_condattr_t *); -int pthread_condattr_destroy(pthread_condattr_t *); -int pthread_condattr_setclock(pthread_condattr_t *, clockid_t); -int pthread_condattr_setpshared(pthread_condattr_t *, int); -int pthread_condattr_getclock(const pthread_condattr_t *__restrict, clockid_t *__restrict); -int pthread_condattr_getpshared(const pthread_condattr_t *__restrict, int *__restrict); - -int pthread_rwlockattr_init(pthread_rwlockattr_t *); -int pthread_rwlockattr_destroy(pthread_rwlockattr_t *); -int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int); -int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *__restrict, int *__restrict); - -int pthread_barrierattr_destroy(pthread_barrierattr_t *); -int pthread_barrierattr_getpshared(const pthread_barrierattr_t *__restrict, int *__restrict); -int pthread_barrierattr_init(pthread_barrierattr_t *); -int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int); - -int pthread_atfork(void (*)(void), void (*)(void), void (*)(void)); - -int pthread_getconcurrency(void); -int pthread_setconcurrency(int); - -int pthread_getcpuclockid(pthread_t, clockid_t *); - -struct __ptcb { - void (*__f)(void *); - void *__x; - struct __ptcb *__next; -}; - -void _pthread_cleanup_push(struct __ptcb *, void (*)(void *), void *); -void _pthread_cleanup_pop(struct __ptcb *, int); - -#define pthread_cleanup_push(f, x) do { struct __ptcb __cb; _pthread_cleanup_push(&__cb, f, x); -#define pthread_cleanup_pop(r) _pthread_cleanup_pop(&__cb, (r)); } while(0) - -#ifdef _GNU_SOURCE -struct cpu_set_t; -int pthread_getaffinity_np(pthread_t, size_t, struct cpu_set_t *); -int pthread_setaffinity_np(pthread_t, size_t, const struct cpu_set_t *); -int pthread_getattr_np(pthread_t, pthread_attr_t *); -int pthread_setname_np(pthread_t, const char *); -int pthread_getname_np(pthread_t, char *, size_t); -int pthread_getattr_default_np(pthread_attr_t *); -int pthread_setattr_default_np(const pthread_attr_t *); -int pthread_tryjoin_np(pthread_t, void **); -int pthread_timedjoin_np(pthread_t, void **, const struct timespec *); -#endif - -#if _REDIR_TIME64 -__REDIR(pthread_mutex_timedlock, __pthread_mutex_timedlock_time64); -__REDIR(pthread_cond_timedwait, __pthread_cond_timedwait_time64); -__REDIR(pthread_rwlock_timedrdlock, __pthread_rwlock_timedrdlock_time64); -__REDIR(pthread_rwlock_timedwrlock, __pthread_rwlock_timedwrlock_time64); -#ifdef _GNU_SOURCE -__REDIR(pthread_timedjoin_np, __pthread_timedjoin_np_time64); -#endif -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/pty.h b/lib/libc/wasi/libc-top-half/musl/include/pty.h deleted file mode 100644 index db6385341187..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/pty.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _PTY_H -#define _PTY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -int openpty(int *, int *, char *, const struct termios *, const struct winsize *); -int forkpty(int *, char *, const struct termios *, const struct winsize *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/pwd.h b/lib/libc/wasi/libc-top-half/musl/include/pwd.h deleted file mode 100644 index 4f470b558b15..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/pwd.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _PWD_H -#define _PWD_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_size_t -#define __NEED_uid_t -#define __NEED_gid_t - -#ifdef _GNU_SOURCE -#define __NEED_FILE -#endif - -#include - -struct passwd { - char *pw_name; - char *pw_passwd; - uid_t pw_uid; - gid_t pw_gid; - char *pw_gecos; - char *pw_dir; - char *pw_shell; -}; - -#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -void setpwent (void); -void endpwent (void); -struct passwd *getpwent (void); -#endif - -struct passwd *getpwuid (uid_t); -struct passwd *getpwnam (const char *); -int getpwuid_r (uid_t, struct passwd *, char *, size_t, struct passwd **); -int getpwnam_r (const char *, struct passwd *, char *, size_t, struct passwd **); - -#ifdef _GNU_SOURCE -struct passwd *fgetpwent(FILE *); -int putpwent(const struct passwd *, FILE *); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/resolv.h b/lib/libc/wasi/libc-top-half/musl/include/resolv.h deleted file mode 100644 index 8b23ad66cc76..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/resolv.h +++ /dev/null @@ -1,142 +0,0 @@ -#ifndef _RESOLV_H -#define _RESOLV_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAXNS 3 -#define MAXDFLSRCH 3 -#define MAXDNSRCH 6 -#define LOCALDOMAINPARTS 2 - -#define RES_TIMEOUT 5 -#define MAXRESOLVSORT 10 -#define RES_MAXNDOTS 15 -#define RES_MAXRETRANS 30 -#define RES_MAXRETRY 5 -#define RES_DFLRETRY 2 -#define RES_MAXTIME 65535 - -/* unused; purely for broken apps */ -typedef struct __res_state { - int retrans; - int retry; - unsigned long options; - int nscount; - struct sockaddr_in nsaddr_list[MAXNS]; -# define nsaddr nsaddr_list[0] - unsigned short id; - char *dnsrch[MAXDNSRCH+1]; - char defdname[256]; - unsigned long pfcode; - unsigned ndots:4; - unsigned nsort:4; - unsigned ipv6_unavail:1; - unsigned unused:23; - struct { - struct in_addr addr; - uint32_t mask; - } sort_list[MAXRESOLVSORT]; - void *qhook; - void *rhook; - int res_h_errno; - int _vcsock; - unsigned _flags; - union { - char pad[52]; - struct { - uint16_t nscount; - uint16_t nsmap[MAXNS]; - int nssocks[MAXNS]; - uint16_t nscount6; - uint16_t nsinit; - struct sockaddr_in6 *nsaddrs[MAXNS]; - unsigned int _initstamp[2]; - } _ext; - } _u; -} *res_state; - -#define __RES 19960801 - -#ifndef _PATH_RESCONF -#define _PATH_RESCONF "/etc/resolv.conf" -#endif - -struct res_sym { - int number; - char *name; - char *humanname; -}; - -#define RES_F_VC 0x00000001 -#define RES_F_CONN 0x00000002 -#define RES_F_EDNS0ERR 0x00000004 - -#define RES_EXHAUSTIVE 0x00000001 - -#define RES_INIT 0x00000001 -#define RES_DEBUG 0x00000002 -#define RES_AAONLY 0x00000004 -#define RES_USEVC 0x00000008 -#define RES_PRIMARY 0x00000010 -#define RES_IGNTC 0x00000020 -#define RES_RECURSE 0x00000040 -#define RES_DEFNAMES 0x00000080 -#define RES_STAYOPEN 0x00000100 -#define RES_DNSRCH 0x00000200 -#define RES_INSECURE1 0x00000400 -#define RES_INSECURE2 0x00000800 -#define RES_NOALIASES 0x00001000 -#define RES_USE_INET6 0x00002000 -#define RES_ROTATE 0x00004000 -#define RES_NOCHECKNAME 0x00008000 -#define RES_KEEPTSIG 0x00010000 -#define RES_BLAST 0x00020000 -#define RES_USEBSTRING 0x00040000 -#define RES_NOIP6DOTINT 0x00080000 -#define RES_USE_EDNS0 0x00100000 -#define RES_SNGLKUP 0x00200000 -#define RES_SNGLKUPREOP 0x00400000 -#define RES_USE_DNSSEC 0x00800000 - -#define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT) - -#define RES_PRF_STATS 0x00000001 -#define RES_PRF_UPDATE 0x00000002 -#define RES_PRF_CLASS 0x00000004 -#define RES_PRF_CMD 0x00000008 -#define RES_PRF_QUES 0x00000010 -#define RES_PRF_ANS 0x00000020 -#define RES_PRF_AUTH 0x00000040 -#define RES_PRF_ADD 0x00000080 -#define RES_PRF_HEAD1 0x00000100 -#define RES_PRF_HEAD2 0x00000200 -#define RES_PRF_TTLID 0x00000400 -#define RES_PRF_HEADX 0x00000800 -#define RES_PRF_QUERY 0x00001000 -#define RES_PRF_REPLY 0x00002000 -#define RES_PRF_INIT 0x00004000 - -struct __res_state *__res_state(void); -#define _res (*__res_state()) - -int res_init(void); -int res_query(const char *, int, int, unsigned char *, int); -int res_querydomain(const char *, const char *, int, int, unsigned char *, int); -int res_search(const char *, int, int, unsigned char *, int); -int res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int); -int res_send(const unsigned char *, int, unsigned char *, int); -int dn_comp(const char *, unsigned char *, int, unsigned char **, unsigned char **); -int dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int); -int dn_skipname(const unsigned char *, const unsigned char *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/scsi/scsi.h b/lib/libc/wasi/libc-top-half/musl/include/scsi/scsi.h deleted file mode 100644 index 8837f5875656..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/scsi/scsi.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef _SCSI_SCSI_H -#define _SCSI_SCSI_H - -#define TEST_UNIT_READY 0x00 -#define REZERO_UNIT 0x01 -#define REQUEST_SENSE 0x03 -#define FORMAT_UNIT 0x04 -#define READ_BLOCK_LIMITS 0x05 -#define REASSIGN_BLOCKS 0x07 -#define READ_6 0x08 -#define WRITE_6 0x0a -#define SEEK_6 0x0b -#define READ_REVERSE 0x0f -#define WRITE_FILEMARKS 0x10 -#define SPACE 0x11 -#define INQUIRY 0x12 -#define RECOVER_BUFFERED_DATA 0x14 -#define MODE_SELECT 0x15 -#define RESERVE 0x16 -#define RELEASE 0x17 -#define COPY 0x18 -#define ERASE 0x19 -#define MODE_SENSE 0x1a -#define START_STOP 0x1b -#define RECEIVE_DIAGNOSTIC 0x1c -#define SEND_DIAGNOSTIC 0x1d -#define ALLOW_MEDIUM_REMOVAL 0x1e -#define SET_WINDOW 0x24 -#define READ_CAPACITY 0x25 -#define READ_10 0x28 -#define WRITE_10 0x2a -#define SEEK_10 0x2b -#define WRITE_VERIFY 0x2e -#define VERIFY 0x2f -#define SEARCH_HIGH 0x30 -#define SEARCH_EQUAL 0x31 -#define SEARCH_LOW 0x32 -#define SET_LIMITS 0x33 -#define PRE_FETCH 0x34 -#define READ_POSITION 0x34 -#define SYNCHRONIZE_CACHE 0x35 -#define LOCK_UNLOCK_CACHE 0x36 -#define READ_DEFECT_DATA 0x37 -#define MEDIUM_SCAN 0x38 -#define COMPARE 0x39 -#define COPY_VERIFY 0x3a -#define WRITE_BUFFER 0x3b -#define READ_BUFFER 0x3c -#define UPDATE_BLOCK 0x3d -#define READ_LONG 0x3e -#define WRITE_LONG 0x3f -#define CHANGE_DEFINITION 0x40 -#define WRITE_SAME 0x41 -#define READ_TOC 0x43 -#define LOG_SELECT 0x4c -#define LOG_SENSE 0x4d -#define MODE_SELECT_10 0x55 -#define RESERVE_10 0x56 -#define RELEASE_10 0x57 -#define MODE_SENSE_10 0x5a -#define PERSISTENT_RESERVE_IN 0x5e -#define PERSISTENT_RESERVE_OUT 0x5f -#define MOVE_MEDIUM 0xa5 -#define READ_12 0xa8 -#define WRITE_12 0xaa -#define WRITE_VERIFY_12 0xae -#define SEARCH_HIGH_12 0xb0 -#define SEARCH_EQUAL_12 0xb1 -#define SEARCH_LOW_12 0xb2 -#define READ_ELEMENT_STATUS 0xb8 -#define SEND_VOLUME_TAG 0xb6 -#define WRITE_LONG_2 0xea -#define GOOD 0x00 -#define CHECK_CONDITION 0x01 -#define CONDITION_GOOD 0x02 -#define BUSY 0x04 -#define INTERMEDIATE_GOOD 0x08 -#define INTERMEDIATE_C_GOOD 0x0a -#define RESERVATION_CONFLICT 0x0c -#define COMMAND_TERMINATED 0x11 -#define QUEUE_FULL 0x14 -#define STATUS_MASK 0x3e -#define NO_SENSE 0x00 -#define RECOVERED_ERROR 0x01 -#define NOT_READY 0x02 -#define MEDIUM_ERROR 0x03 -#define HARDWARE_ERROR 0x04 -#define ILLEGAL_REQUEST 0x05 -#define UNIT_ATTENTION 0x06 -#define DATA_PROTECT 0x07 -#define BLANK_CHECK 0x08 -#define COPY_ABORTED 0x0a -#define ABORTED_COMMAND 0x0b -#define VOLUME_OVERFLOW 0x0d -#define MISCOMPARE 0x0e -#define TYPE_DISK 0x00 -#define TYPE_TAPE 0x01 -#define TYPE_PROCESSOR 0x03 -#define TYPE_WORM 0x04 -#define TYPE_ROM 0x05 -#define TYPE_SCANNER 0x06 -#define TYPE_MOD 0x07 -#define TYPE_MEDIUM_CHANGER 0x08 -#define TYPE_ENCLOSURE 0x0d -#define TYPE_NO_LUN 0x7f -#define COMMAND_COMPLETE 0x00 -#define EXTENDED_MESSAGE 0x01 -#define EXTENDED_MODIFY_DATA_POINTER 0x00 -#define EXTENDED_SDTR 0x01 -#define EXTENDED_EXTENDED_IDENTIFY 0x02 -#define EXTENDED_WDTR 0x03 -#define SAVE_POINTERS 0x02 -#define RESTORE_POINTERS 0x03 -#define DISCONNECT 0x04 -#define INITIATOR_ERROR 0x05 -#define ABORT 0x06 -#define MESSAGE_REJECT 0x07 -#define NOP 0x08 -#define MSG_PARITY_ERROR 0x09 -#define LINKED_CMD_COMPLETE 0x0a -#define LINKED_FLG_CMD_COMPLETE 0x0b -#define BUS_DEVICE_RESET 0x0c -#define INITIATE_RECOVERY 0x0f -#define RELEASE_RECOVERY 0x10 -#define SIMPLE_QUEUE_TAG 0x20 -#define HEAD_OF_QUEUE_TAG 0x21 -#define ORDERED_QUEUE_TAG 0x22 -#define SCSI_IOCTL_GET_IDLUN 0x5382 -#define SCSI_IOCTL_TAGGED_ENABLE 0x5383 -#define SCSI_IOCTL_TAGGED_DISABLE 0x5384 -#define SCSI_IOCTL_PROBE_HOST 0x5385 -#define SCSI_IOCTL_GET_BUS_NUMBER 0x5386 - -struct ccs_modesel_head { - unsigned char _r1; - unsigned char medium; - unsigned char _r2; - unsigned char block_desc_length; - unsigned char density; - unsigned char number_blocks_hi; - unsigned char number_blocks_med; - unsigned char number_blocks_lo; - unsigned char _r3; - unsigned char block_length_hi; - unsigned char block_length_med; - unsigned char block_length_lo; -}; - -#endif - diff --git a/lib/libc/wasi/libc-top-half/musl/include/scsi/scsi_ioctl.h b/lib/libc/wasi/libc-top-half/musl/include/scsi/scsi_ioctl.h deleted file mode 100644 index 22df7feffaed..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/scsi/scsi_ioctl.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _SCSI_IOCTL_H -#define _SCSI_IOCTL_H -#define SCSI_IOCTL_SEND_COMMAND 1 -#define SCSI_IOCTL_TEST_UNIT_READY 2 -#define SCSI_IOCTL_BENCHMARK_COMMAND 3 -#define SCSI_IOCTL_SYNC 4 -#define SCSI_IOCTL_START_UNIT 5 -#define SCSI_IOCTL_STOP_UNIT 6 -#define SCSI_IOCTL_DOORLOCK 0x5380 -#define SCSI_IOCTL_DOORUNLOCK 0x5381 -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/scsi/sg.h b/lib/libc/wasi/libc-top-half/musl/include/scsi/sg.h deleted file mode 100644 index a7ac247e3ffa..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/scsi/sg.h +++ /dev/null @@ -1,129 +0,0 @@ -#ifndef _SCSI_SG_H -#define _SCSI_SG_H - -#define SG_DXFER_NONE -1 -#define SG_DXFER_TO_DEV -2 -#define SG_DXFER_FROM_DEV -3 -#define SG_DXFER_TO_FROM_DEV -4 -#define SG_FLAG_DIRECT_IO 1 -#define SG_FLAG_LUN_INHIBIT 2 -#define SG_FLAG_NO_DXFER 0x10000 -#define SG_INFO_OK_MASK 0x1 -#define SG_INFO_OK 0x0 -#define SG_INFO_CHECK 0x1 -#define SG_INFO_DIRECT_IO_MASK 0x6 -#define SG_INFO_INDIRECT_IO 0x0 -#define SG_INFO_DIRECT_IO 0x2 -#define SG_INFO_MIXED_IO 0x4 -#define SG_EMULATED_HOST 0x2203 -#define SG_SET_TRANSFORM 0x2204 -#define SG_GET_TRANSFORM 0x2205 -#define SG_SET_RESERVED_SIZE 0x2275 -#define SG_GET_RESERVED_SIZE 0x2272 -#define SG_GET_SCSI_ID 0x2276 -#define SG_SET_FORCE_LOW_DMA 0x2279 -#define SG_GET_LOW_DMA 0x227a -#define SG_SET_FORCE_PACK_ID 0x227b -#define SG_GET_PACK_ID 0x227c -#define SG_GET_NUM_WAITING 0x227d -#define SG_GET_SG_TABLESIZE 0x227F -#define SG_GET_VERSION_NUM 0x2282 -#define SG_SCSI_RESET 0x2284 -#define SG_SCSI_RESET_NOTHING 0 -#define SG_SCSI_RESET_DEVICE 1 -#define SG_SCSI_RESET_BUS 2 -#define SG_SCSI_RESET_HOST 3 -#define SG_IO 0x2285 -#define SG_GET_REQUEST_TABLE 0x2286 -#define SG_SET_KEEP_ORPHAN 0x2287 -#define SG_GET_KEEP_ORPHAN 0x2288 -#define SG_SCATTER_SZ (8 * 4096) -#define SG_DEFAULT_RETRIES 1 -#define SG_DEF_FORCE_LOW_DMA 0 -#define SG_DEF_FORCE_PACK_ID 0 -#define SG_DEF_KEEP_ORPHAN 0 -#define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ -#define SG_MAX_QUEUE 16 -#define SG_BIG_BUFF SG_DEF_RESERVED_SIZE -#define SG_MAX_SENSE 16 -#define SG_SET_TIMEOUT 0x2201 -#define SG_GET_TIMEOUT 0x2202 -#define SG_GET_COMMAND_Q 0x2270 -#define SG_SET_COMMAND_Q 0x2271 -#define SG_SET_DEBUG 0x227e -#define SG_NEXT_CMD_LEN 0x2283 -#define SG_DEFAULT_TIMEOUT (60*100) /* 60*HZ */ -#define SG_DEF_COMMAND_Q 0 -#define SG_DEF_UNDERRUN_FLAG 0 - -typedef struct sg_iovec { - void *iov_base; - unsigned long iov_len; -} sg_iovec_t; - -typedef struct sg_io_hdr { - int interface_id; - int dxfer_direction; - unsigned char cmd_len; - unsigned char mx_sb_len; - unsigned short iovec_count; - unsigned dxfer_len; - void *dxferp; - unsigned char *cmdp; - unsigned char *sbp; - unsigned timeout; - unsigned flags; - int pack_id; - void *usr_ptr; - unsigned char status; - unsigned char masked_status; - unsigned char msg_status; - unsigned char sb_len_wr; - unsigned short host_status; - unsigned short driver_status; - int resid; - unsigned int duration; - unsigned int info; -} sg_io_hdr_t; - -struct sg_scsi_id { - int host_no; - int channel; - int scsi_id; - int lun; - int scsi_type; - short h_cmd_per_lun; - short d_queue_depth; - int unused[2]; -}; - -typedef struct sg_req_info { - char req_state; - char orphan; - char sg_io_owned; - char problem; - int pack_id; - void *usr_ptr; - unsigned duration; - int unused; -} sg_req_info_t; - -typedef struct sg_io_hdr Sg_io_hdr; -typedef struct sg_io_vec Sg_io_vec; -typedef struct sg_scsi_id Sg_scsi_id; -typedef struct sg_req_info Sg_req_info; - -struct sg_header { - int pack_len; - int reply_len; - int pack_id; - int result; - unsigned twelve_byte:1; - unsigned target_status:5; - unsigned host_status:8; - unsigned driver_status:8; - unsigned other_flags:10; - unsigned char sense_buffer[SG_MAX_SENSE]; -}; - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/setjmp.h b/lib/libc/wasi/libc-top-half/musl/include/setjmp.h index f505f8e4fa3b..b57999ed61e8 100644 --- a/lib/libc/wasi/libc-top-half/musl/include/setjmp.h +++ b/lib/libc/wasi/libc-top-half/musl/include/setjmp.h @@ -7,7 +7,12 @@ extern "C" { #include -#ifdef __wasilibc_unmodified_upstream /* WASI has no setjmp */ +#ifndef __wasilibc_unmodified_upstream +/* WASI has no setjmp */ +#if !defined(__wasm_exception_handling__) +#error Setjmp/longjmp support requires Exception handling support, which is [not yet standardized](https://github.com/WebAssembly/proposals?tab=readme-ov-file#phase-3---implementation-phase-cg--wg). To enable it, compile with `-mllvm -wasm-enable-sjlj` and use an engine that implements the Exception handling proposal. +#endif +#endif #include typedef struct __jmp_buf_tag { @@ -40,9 +45,6 @@ int setjmp (jmp_buf) __setjmp_attr; _Noreturn void longjmp (jmp_buf, int); #define setjmp setjmp -#else -#warning setjmp is not yet implemented for WASI -#endif #undef __setjmp_attr diff --git a/lib/libc/wasi/libc-top-half/musl/include/shadow.h b/lib/libc/wasi/libc-top-half/musl/include/shadow.h deleted file mode 100644 index 2b1be413f364..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/shadow.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _SHADOW_H -#define _SHADOW_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define __NEED_FILE -#define __NEED_size_t - -#include - -#define SHADOW "/etc/shadow" - -struct spwd { - char *sp_namp; - char *sp_pwdp; - long sp_lstchg; - long sp_min; - long sp_max; - long sp_warn; - long sp_inact; - long sp_expire; - unsigned long sp_flag; -}; - -void setspent(void); -void endspent(void); -struct spwd *getspent(void); -struct spwd *fgetspent(FILE *); -struct spwd *sgetspent(const char *); -int putspent(const struct spwd *, FILE *); - -struct spwd *getspnam(const char *); -int getspnam_r(const char *, struct spwd *, char *, size_t, struct spwd **); - -int lckpwdf(void); -int ulckpwdf(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/spawn.h b/lib/libc/wasi/libc-top-half/musl/include/spawn.h deleted file mode 100644 index 8eb73e003a65..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/spawn.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef _SPAWN_H -#define _SPAWN_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_mode_t -#define __NEED_pid_t -#define __NEED_sigset_t - -#include - -struct sched_param; - -#define POSIX_SPAWN_RESETIDS 1 -#define POSIX_SPAWN_SETPGROUP 2 -#define POSIX_SPAWN_SETSIGDEF 4 -#define POSIX_SPAWN_SETSIGMASK 8 -#define POSIX_SPAWN_SETSCHEDPARAM 16 -#define POSIX_SPAWN_SETSCHEDULER 32 -#define POSIX_SPAWN_USEVFORK 64 -#define POSIX_SPAWN_SETSID 128 - -typedef struct { - int __flags; - pid_t __pgrp; - sigset_t __def, __mask; - int __prio, __pol; - void *__fn; - char __pad[64-sizeof(void *)]; -} posix_spawnattr_t; - -typedef struct { - int __pad0[2]; - void *__actions; - int __pad[16]; -} posix_spawn_file_actions_t; - -int posix_spawn(pid_t *__restrict, const char *__restrict, const posix_spawn_file_actions_t *, - const posix_spawnattr_t *__restrict, char *const *__restrict, char *const *__restrict); -int posix_spawnp(pid_t *__restrict, const char *__restrict, const posix_spawn_file_actions_t *, - const posix_spawnattr_t *__restrict, char *const *__restrict, char *const *__restrict); - -int posix_spawnattr_init(posix_spawnattr_t *); -int posix_spawnattr_destroy(posix_spawnattr_t *); - -int posix_spawnattr_setflags(posix_spawnattr_t *, short); -int posix_spawnattr_getflags(const posix_spawnattr_t *__restrict, short *__restrict); - -int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t); -int posix_spawnattr_getpgroup(const posix_spawnattr_t *__restrict, pid_t *__restrict); - -int posix_spawnattr_setsigmask(posix_spawnattr_t *__restrict, const sigset_t *__restrict); -int posix_spawnattr_getsigmask(const posix_spawnattr_t *__restrict, sigset_t *__restrict); - -int posix_spawnattr_setsigdefault(posix_spawnattr_t *__restrict, const sigset_t *__restrict); -int posix_spawnattr_getsigdefault(const posix_spawnattr_t *__restrict, sigset_t *__restrict); - -int posix_spawnattr_setschedparam(posix_spawnattr_t *__restrict, const struct sched_param *__restrict); -int posix_spawnattr_getschedparam(const posix_spawnattr_t *__restrict, struct sched_param *__restrict); -int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int); -int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *__restrict, int *__restrict); - -int posix_spawn_file_actions_init(posix_spawn_file_actions_t *); -int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *); - -int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *__restrict, int, const char *__restrict, int, mode_t); -int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int); -int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int); - -#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) -int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *__restrict, const char *__restrict); -int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *, int); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/stdarg.h b/lib/libc/wasi/libc-top-half/musl/include/stdarg.h deleted file mode 100644 index 3256f8050019..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/stdarg.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _STDARG_H -#define _STDARG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define __NEED_va_list - -#include - -#define va_start(v,l) __builtin_va_start(v,l) -#define va_end(v) __builtin_va_end(v) -#define va_arg(v,l) __builtin_va_arg(v,l) -#define va_copy(d,s) __builtin_va_copy(d,s) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/stddef.h b/lib/libc/wasi/libc-top-half/musl/include/stddef.h deleted file mode 100644 index f25b86396e80..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/stddef.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _STDDEF_H -#define _STDDEF_H - -#if __cplusplus >= 201103L -#define NULL nullptr -#elif defined(__cplusplus) -#define NULL 0L -#else -#define NULL ((void*)0) -#endif - -#define __NEED_ptrdiff_t -#define __NEED_size_t -#define __NEED_wchar_t -#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L -#define __NEED_max_align_t -#endif - -#include - -#if __GNUC__ > 3 -#define offsetof(type, member) __builtin_offsetof(type, member) -#else -#define offsetof(type, member) ((size_t)( (char *)&(((type *)0)->member) - (char *)0 )) -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/stdlib.h b/lib/libc/wasi/libc-top-half/musl/include/stdlib.h index 1bcb9ab0aa24..553e9aeabff7 100644 --- a/lib/libc/wasi/libc-top-half/musl/include/stdlib.h +++ b/lib/libc/wasi/libc-top-half/musl/include/stdlib.h @@ -128,9 +128,7 @@ int rand_r (unsigned *); #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ || defined(_BSD_SOURCE) -#ifdef __wasilibc_unmodified_upstream /* WASI has no absolute paths */ char *realpath (const char *__restrict, char *__restrict); -#endif long int random (void); void srandom (unsigned int); char *initstate (unsigned int, char *, size_t); diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/acct.h b/lib/libc/wasi/libc-top-half/musl/include/sys/acct.h deleted file mode 100644 index fae9d0508f9c..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/acct.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _SYS_ACCT_H -#define _SYS_ACCT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -#define ACCT_COMM 16 - -typedef uint16_t comp_t; - -struct acct { - char ac_flag; - uint16_t ac_uid; - uint16_t ac_gid; - uint16_t ac_tty; - uint32_t ac_btime; - comp_t ac_utime; - comp_t ac_stime; - comp_t ac_etime; - comp_t ac_mem; - comp_t ac_io; - comp_t ac_rw; - comp_t ac_minflt; - comp_t ac_majflt; - comp_t ac_swaps; - uint32_t ac_exitcode; - char ac_comm[ACCT_COMM+1]; - char ac_pad[10]; -}; - - -struct acct_v3 { - char ac_flag; - char ac_version; - uint16_t ac_tty; - uint32_t ac_exitcode; - uint32_t ac_uid; - uint32_t ac_gid; - uint32_t ac_pid; - uint32_t ac_ppid; - uint32_t ac_btime; - float ac_etime; - comp_t ac_utime; - comp_t ac_stime; - comp_t ac_mem; - comp_t ac_io; - comp_t ac_rw; - comp_t ac_minflt; - comp_t ac_majflt; - comp_t ac_swaps; - char ac_comm[ACCT_COMM]; -}; - -#define AFORK 1 -#define ASU 2 -#define ACORE 8 -#define AXSIG 16 -#define ACCT_BYTEORDER (128*(__BYTE_ORDER==__BIG_ENDIAN)) -#define AHZ 100 - -int acct(const char *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/auxv.h b/lib/libc/wasi/libc-top-half/musl/include/sys/auxv.h deleted file mode 100644 index ddccf57ff6f3..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/auxv.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _SYS_AUXV_H -#define _SYS_AUXV_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -unsigned long getauxval(unsigned long); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/cachectl.h b/lib/libc/wasi/libc-top-half/musl/include/sys/cachectl.h deleted file mode 100644 index f3b896a8e059..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/cachectl.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _SYS_CACHECTL_H -#define _SYS_CACHECTL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define ICACHE (1<<0) -#define DCACHE (1<<1) -#define BCACHE (ICACHE|DCACHE) -#define CACHEABLE 0 -#define UNCACHEABLE 1 - -int cachectl(void *, int, int); -int cacheflush(void *, int, int); -int _flush_cache(void *, int, int); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/epoll.h b/lib/libc/wasi/libc-top-half/musl/include/sys/epoll.h deleted file mode 100644 index ac81a8418a0c..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/epoll.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _SYS_EPOLL_H -#define _SYS_EPOLL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -#define __NEED_sigset_t - -#include - -#define EPOLL_CLOEXEC O_CLOEXEC -#define EPOLL_NONBLOCK O_NONBLOCK - -enum EPOLL_EVENTS { __EPOLL_DUMMY }; -#define EPOLLIN 0x001 -#define EPOLLPRI 0x002 -#define EPOLLOUT 0x004 -#define EPOLLRDNORM 0x040 -#define EPOLLNVAL 0x020 -#define EPOLLRDBAND 0x080 -#define EPOLLWRNORM 0x100 -#define EPOLLWRBAND 0x200 -#define EPOLLMSG 0x400 -#define EPOLLERR 0x008 -#define EPOLLHUP 0x010 -#define EPOLLRDHUP 0x2000 -#define EPOLLEXCLUSIVE (1U<<28) -#define EPOLLWAKEUP (1U<<29) -#define EPOLLONESHOT (1U<<30) -#define EPOLLET (1U<<31) - -#define EPOLL_CTL_ADD 1 -#define EPOLL_CTL_DEL 2 -#define EPOLL_CTL_MOD 3 - -typedef union epoll_data { - void *ptr; - int fd; - uint32_t u32; - uint64_t u64; -} epoll_data_t; - -struct epoll_event { - uint32_t events; - epoll_data_t data; -} -#ifdef __x86_64__ -__attribute__ ((__packed__)) -#endif -; - - -int epoll_create(int); -int epoll_create1(int); -int epoll_ctl(int, int, int, struct epoll_event *); -int epoll_wait(int, struct epoll_event *, int, int); -int epoll_pwait(int, struct epoll_event *, int, int, const sigset_t *); - - -#ifdef __cplusplus -} -#endif - -#endif /* sys/epoll.h */ diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/fanotify.h b/lib/libc/wasi/libc-top-half/musl/include/sys/fanotify.h deleted file mode 100644 index 10e5f15e24b1..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/fanotify.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef _FANOTIFY_H -#define _FANOTIFY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -struct fanotify_event_metadata { - unsigned event_len; - unsigned char vers; - unsigned char reserved; - unsigned short metadata_len; - unsigned long long mask -#ifdef __GNUC__ - __attribute__((__aligned__(8))) -#endif - ; - int fd; - int pid; -}; - -struct fanotify_event_info_header { - unsigned char info_type; - unsigned char pad; - unsigned short len; -}; - -struct fanotify_event_info_fid { - struct fanotify_event_info_header hdr; - fsid_t fsid; - unsigned char handle[]; -}; - -struct fanotify_response { - int fd; - unsigned response; -}; - -#define FAN_ACCESS 0x01 -#define FAN_MODIFY 0x02 -#define FAN_ATTRIB 0x04 -#define FAN_CLOSE_WRITE 0x08 -#define FAN_CLOSE_NOWRITE 0x10 -#define FAN_OPEN 0x20 -#define FAN_MOVED_FROM 0x40 -#define FAN_MOVED_TO 0x80 -#define FAN_CREATE 0x100 -#define FAN_DELETE 0x200 -#define FAN_DELETE_SELF 0x400 -#define FAN_MOVE_SELF 0x800 -#define FAN_OPEN_EXEC 0x1000 -#define FAN_Q_OVERFLOW 0x4000 -#define FAN_OPEN_PERM 0x10000 -#define FAN_ACCESS_PERM 0x20000 -#define FAN_OPEN_EXEC_PERM 0x40000 -#define FAN_DIR_MODIFY 0x00080000 -#define FAN_EVENT_ON_CHILD 0x08000000 -#define FAN_ONDIR 0x40000000 -#define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) -#define FAN_MOVE (FAN_MOVED_FROM | FAN_MOVED_TO) -#define FAN_CLOEXEC 0x01 -#define FAN_NONBLOCK 0x02 -#define FAN_CLASS_NOTIF 0 -#define FAN_CLASS_CONTENT 0x04 -#define FAN_CLASS_PRE_CONTENT 0x08 -#define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT) -#define FAN_UNLIMITED_QUEUE 0x10 -#define FAN_UNLIMITED_MARKS 0x20 -#define FAN_ENABLE_AUDIT 0x40 -#define FAN_REPORT_TID 0x100 -#define FAN_REPORT_FID 0x200 -#define FAN_REPORT_DIR_FID 0x00000400 -#define FAN_REPORT_NAME 0x00000800 -#define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME) -#define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS) -#define FAN_MARK_ADD 0x01 -#define FAN_MARK_REMOVE 0x02 -#define FAN_MARK_DONT_FOLLOW 0x04 -#define FAN_MARK_ONLYDIR 0x08 -#define FAN_MARK_IGNORED_MASK 0x20 -#define FAN_MARK_IGNORED_SURV_MODIFY 0x40 -#define FAN_MARK_FLUSH 0x80 -#define FAN_MARK_INODE 0x00 -#define FAN_MARK_MOUNT 0x10 -#define FAN_MARK_FILESYSTEM 0x100 -#define FAN_MARK_TYPE_MASK (FAN_MARK_INODE | FAN_MARK_MOUNT | FAN_MARK_FILESYSTEM) -#define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_DONT_FOLLOW | FAN_MARK_ONLYDIR | FAN_MARK_MOUNT | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY | FAN_MARK_FLUSH) -#define FAN_ALL_EVENTS (FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN) -#define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM) -#define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW) -#define FANOTIFY_METADATA_VERSION 3 -#define FAN_EVENT_INFO_TYPE_FID 1 -#define FAN_EVENT_INFO_TYPE_DFID_NAME 2 -#define FAN_EVENT_INFO_TYPE_DFID 3 -#define FAN_ALLOW 0x01 -#define FAN_DENY 0x02 -#define FAN_AUDIT 0x10 -#define FAN_NOFD -1 -#define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata)) -#define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, (struct fanotify_event_metadata*)(((char *)(meta)) + (meta)->event_len)) -#define FAN_EVENT_OK(meta, len) ((long)(len) >= (long)FAN_EVENT_METADATA_LEN && (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && (long)(meta)->event_len <= (long)(len)) - -int fanotify_init(unsigned, unsigned); -int fanotify_mark(int, unsigned, unsigned long long, int, const char *); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/fsuid.h b/lib/libc/wasi/libc-top-half/musl/include/sys/fsuid.h deleted file mode 100644 index c7a9b8faa795..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/fsuid.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _SYS_FSUID_H -#define _SYS_FSUID_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define __NEED_uid_t -#define __NEED_gid_t - -#include - -int setfsuid(uid_t); -int setfsgid(gid_t); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/inotify.h b/lib/libc/wasi/libc-top-half/musl/include/sys/inotify.h deleted file mode 100644 index 69b586319922..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/inotify.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef _SYS_INOTIFY_H -#define _SYS_INOTIFY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -struct inotify_event { - int wd; - uint32_t mask, cookie, len; - char name[]; -}; - -#define IN_CLOEXEC O_CLOEXEC -#define IN_NONBLOCK O_NONBLOCK - -#define IN_ACCESS 0x00000001 -#define IN_MODIFY 0x00000002 -#define IN_ATTRIB 0x00000004 -#define IN_CLOSE_WRITE 0x00000008 -#define IN_CLOSE_NOWRITE 0x00000010 -#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) -#define IN_OPEN 0x00000020 -#define IN_MOVED_FROM 0x00000040 -#define IN_MOVED_TO 0x00000080 -#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) -#define IN_CREATE 0x00000100 -#define IN_DELETE 0x00000200 -#define IN_DELETE_SELF 0x00000400 -#define IN_MOVE_SELF 0x00000800 -#define IN_ALL_EVENTS 0x00000fff - -#define IN_UNMOUNT 0x00002000 -#define IN_Q_OVERFLOW 0x00004000 -#define IN_IGNORED 0x00008000 - -#define IN_ONLYDIR 0x01000000 -#define IN_DONT_FOLLOW 0x02000000 -#define IN_EXCL_UNLINK 0x04000000 -#define IN_MASK_CREATE 0x10000000 -#define IN_MASK_ADD 0x20000000 - -#define IN_ISDIR 0x40000000 -#define IN_ONESHOT 0x80000000 - -int inotify_init(void); -int inotify_init1(int); -int inotify_add_watch(int, const char *, uint32_t); -int inotify_rm_watch(int, int); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/io.h b/lib/libc/wasi/libc-top-half/musl/include/sys/io.h deleted file mode 100644 index 16658cecae9b..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/io.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _SYS_IO_H -#define _SYS_IO_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include - -int iopl(int); -int ioperm(unsigned long, unsigned long, int); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/ipc.h b/lib/libc/wasi/libc-top-half/musl/include/sys/ipc.h deleted file mode 100644 index 9e366b7bed04..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/ipc.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _SYS_IPC_H -#define _SYS_IPC_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_uid_t -#define __NEED_gid_t -#define __NEED_mode_t -#define __NEED_key_t - -#include - -#define __ipc_perm_key __key -#define __ipc_perm_seq __seq - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define __key key -#define __seq seq -#endif - -#include -#include - -#define IPC_CREAT 01000 -#define IPC_EXCL 02000 -#define IPC_NOWAIT 04000 - -#define IPC_RMID 0 -#define IPC_SET 1 -#define IPC_INFO 3 - -#define IPC_PRIVATE ((key_t) 0) - -key_t ftok (const char *, int); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/kd.h b/lib/libc/wasi/libc-top-half/musl/include/sys/kd.h deleted file mode 100644 index 42122b9c3a4c..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/kd.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/klog.h b/lib/libc/wasi/libc-top-half/musl/include/sys/klog.h deleted file mode 100644 index aa66684e3fd8..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/klog.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _SYS_KLOG_H -#define _SYS_KLOG_H - -#ifdef __cplusplus -extern "C" { -#endif - -int klogctl (int, char *, int); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/membarrier.h b/lib/libc/wasi/libc-top-half/musl/include/sys/membarrier.h deleted file mode 100644 index 11193eda15a6..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/membarrier.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _SYS_MEMBARRIER_H -#define _SYS_MEMBARRIER_H - -#define MEMBARRIER_CMD_QUERY 0 -#define MEMBARRIER_CMD_GLOBAL 1 -#define MEMBARRIER_CMD_GLOBAL_EXPEDITED 2 -#define MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED 4 -#define MEMBARRIER_CMD_PRIVATE_EXPEDITED 8 -#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED 16 -#define MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE 32 -#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE 64 -#define MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ 128 -#define MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ 256 - -#define MEMBARRIER_CMD_SHARED MEMBARRIER_CMD_GLOBAL - -#define MEMBARRIER_CMD_FLAG_CPU 1 - -int membarrier(int, int); - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/mount.h b/lib/libc/wasi/libc-top-half/musl/include/sys/mount.h deleted file mode 100644 index 09bd6e9dfeff..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/mount.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef _SYS_MOUNT_H -#define _SYS_MOUNT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define BLKROSET _IO(0x12, 93) -#define BLKROGET _IO(0x12, 94) -#define BLKRRPART _IO(0x12, 95) -#define BLKGETSIZE _IO(0x12, 96) -#define BLKFLSBUF _IO(0x12, 97) -#define BLKRASET _IO(0x12, 98) -#define BLKRAGET _IO(0x12, 99) -#define BLKFRASET _IO(0x12,100) -#define BLKFRAGET _IO(0x12,101) -#define BLKSECTSET _IO(0x12,102) -#define BLKSECTGET _IO(0x12,103) -#define BLKSSZGET _IO(0x12,104) -#define BLKBSZGET _IOR(0x12,112,size_t) -#define BLKBSZSET _IOW(0x12,113,size_t) -#define BLKGETSIZE64 _IOR(0x12,114,size_t) - -#define MS_RDONLY 1 -#define MS_NOSUID 2 -#define MS_NODEV 4 -#define MS_NOEXEC 8 -#define MS_SYNCHRONOUS 16 -#define MS_REMOUNT 32 -#define MS_MANDLOCK 64 -#define MS_DIRSYNC 128 -#define MS_NOSYMFOLLOW 256 -#define MS_NOATIME 1024 -#define MS_NODIRATIME 2048 -#define MS_BIND 4096 -#define MS_MOVE 8192 -#define MS_REC 16384 -#define MS_SILENT 32768 -#define MS_POSIXACL (1<<16) -#define MS_UNBINDABLE (1<<17) -#define MS_PRIVATE (1<<18) -#define MS_SLAVE (1<<19) -#define MS_SHARED (1<<20) -#define MS_RELATIME (1<<21) -#define MS_KERNMOUNT (1<<22) -#define MS_I_VERSION (1<<23) -#define MS_STRICTATIME (1<<24) -#define MS_LAZYTIME (1<<25) -#define MS_NOREMOTELOCK (1<<27) -#define MS_NOSEC (1<<28) -#define MS_BORN (1<<29) -#define MS_ACTIVE (1<<30) -#define MS_NOUSER (1U<<31) - -#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION|MS_LAZYTIME) - -#define MS_MGC_VAL 0xc0ed0000 -#define MS_MGC_MSK 0xffff0000 - -#define MNT_FORCE 1 -#define MNT_DETACH 2 -#define MNT_EXPIRE 4 -#define UMOUNT_NOFOLLOW 8 - -int mount(const char *, const char *, const char *, unsigned long, const void *); -int umount(const char *); -int umount2(const char *, int); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/msg.h b/lib/libc/wasi/libc-top-half/musl/include/sys/msg.h deleted file mode 100644 index db5c62a42f59..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/msg.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _SYS_MSG_H -#define _SYS_MSG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_pid_t -#define __NEED_key_t -#define __NEED_time_t -#define __NEED_size_t -#define __NEED_ssize_t - -#include - -typedef unsigned long msgqnum_t; -typedef unsigned long msglen_t; - -#include - -#define __msg_cbytes msg_cbytes - -#define MSG_NOERROR 010000 -#define MSG_EXCEPT 020000 - -#define MSG_STAT (11 | (IPC_STAT & 0x100)) -#define MSG_INFO 12 -#define MSG_STAT_ANY (13 | (IPC_STAT & 0x100)) - -struct msginfo { - int msgpool, msgmap, msgmax, msgmnb, msgmni, msgssz, msgtql; - unsigned short msgseg; -}; - -int msgctl (int, int, struct msqid_ds *); -int msgget (key_t, int); -ssize_t msgrcv (int, void *, size_t, long, int); -int msgsnd (int, const void *, size_t, int); - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -struct msgbuf { - long mtype; - char mtext[1]; -}; -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/mtio.h b/lib/libc/wasi/libc-top-half/musl/include/sys/mtio.h deleted file mode 100644 index f16a529bb409..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/mtio.h +++ /dev/null @@ -1,188 +0,0 @@ -#ifndef _SYS_MTIO_H -#define _SYS_MTIO_H - -#include -#include - -struct mtop { - short mt_op; - int mt_count; -}; - -#define _IOT_mtop _IOT (_IOTS (short), 1, _IOTS (int), 1, 0, 0) -#define _IOT_mtget _IOT (_IOTS (long), 7, 0, 0, 0, 0) -#define _IOT_mtpos _IOT_SIMPLE (long) -#define _IOT_mtconfiginfo _IOT (_IOTS (long), 2, _IOTS (short), 3, _IOTS (long), 1) - - -#define MTRESET 0 -#define MTFSF 1 -#define MTBSF 2 -#define MTFSR 3 -#define MTBSR 4 -#define MTWEOF 5 -#define MTREW 6 -#define MTOFFL 7 -#define MTNOP 8 -#define MTRETEN 9 -#define MTBSFM 10 -#define MTFSFM 11 -#define MTEOM 12 -#define MTERASE 13 -#define MTRAS1 14 -#define MTRAS2 15 -#define MTRAS3 16 -#define MTSETBLK 20 -#define MTSETDENSITY 21 -#define MTSEEK 22 -#define MTTELL 23 -#define MTSETDRVBUFFER 24 -#define MTFSS 25 -#define MTBSS 26 -#define MTWSM 27 -#define MTLOCK 28 -#define MTUNLOCK 29 -#define MTLOAD 30 -#define MTUNLOAD 31 -#define MTCOMPRESSION 32 -#define MTSETPART 33 -#define MTMKPART 34 - -struct mtget { - long mt_type; - long mt_resid; - long mt_dsreg; - long mt_gstat; - long mt_erreg; - int mt_fileno; - int mt_blkno; -}; - -#define MT_ISUNKNOWN 0x01 -#define MT_ISQIC02 0x02 -#define MT_ISWT5150 0x03 -#define MT_ISARCHIVE_5945L2 0x04 -#define MT_ISCMSJ500 0x05 -#define MT_ISTDC3610 0x06 -#define MT_ISARCHIVE_VP60I 0x07 -#define MT_ISARCHIVE_2150L 0x08 -#define MT_ISARCHIVE_2060L 0x09 -#define MT_ISARCHIVESC499 0x0A -#define MT_ISQIC02_ALL_FEATURES 0x0F -#define MT_ISWT5099EEN24 0x11 -#define MT_ISTEAC_MT2ST 0x12 -#define MT_ISEVEREX_FT40A 0x32 -#define MT_ISDDS1 0x51 -#define MT_ISDDS2 0x52 -#define MT_ISSCSI1 0x71 -#define MT_ISSCSI2 0x72 -#define MT_ISFTAPE_UNKNOWN 0x800000 -#define MT_ISFTAPE_FLAG 0x800000 - -struct mt_tape_info { - long t_type; - char *t_name; -}; - -#define MT_TAPE_INFO \ -{ \ - {MT_ISUNKNOWN, "Unknown type of tape device"}, \ - {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \ - {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \ - {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \ - {MT_ISCMSJ500, "CMS Jumbo 500"}, \ - {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \ - {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \ - {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \ - {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \ - {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \ - {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \ - {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \ - {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \ - {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, \ - {MT_ISSCSI1, "Generic SCSI-1 tape"}, \ - {MT_ISSCSI2, "Generic SCSI-2 tape"}, \ - {0, 0} \ -} - -struct mtpos { - long mt_blkno; -}; - -struct mtconfiginfo { - long mt_type; - long ifc_type; - unsigned short irqnr; - unsigned short dmanr; - unsigned short port; - unsigned long debug; - unsigned have_dens:1; - unsigned have_bsf:1; - unsigned have_fsr:1; - unsigned have_bsr:1; - unsigned have_eod:1; - unsigned have_seek:1; - unsigned have_tell:1; - unsigned have_ras1:1; - unsigned have_ras2:1; - unsigned have_ras3:1; - unsigned have_qfa:1; - unsigned pad1:5; - char reserved[10]; -}; - -#define MTIOCTOP _IOW('m', 1, struct mtop) -#define MTIOCGET _IOR('m', 2, struct mtget) -#define MTIOCPOS _IOR('m', 3, struct mtpos) - -#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo) -#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo) - -#define GMT_EOF(x) ((x) & 0x80000000) -#define GMT_BOT(x) ((x) & 0x40000000) -#define GMT_EOT(x) ((x) & 0x20000000) -#define GMT_SM(x) ((x) & 0x10000000) -#define GMT_EOD(x) ((x) & 0x08000000) -#define GMT_WR_PROT(x) ((x) & 0x04000000) -#define GMT_ONLINE(x) ((x) & 0x01000000) -#define GMT_D_6250(x) ((x) & 0x00800000) -#define GMT_D_1600(x) ((x) & 0x00400000) -#define GMT_D_800(x) ((x) & 0x00200000) -#define GMT_DR_OPEN(x) ((x) & 0x00040000) -#define GMT_IM_REP_EN(x) ((x) & 0x00010000) - -#define MT_ST_BLKSIZE_SHIFT 0 -#define MT_ST_BLKSIZE_MASK 0xffffff -#define MT_ST_DENSITY_SHIFT 24 -#define MT_ST_DENSITY_MASK 0xff000000 -#define MT_ST_SOFTERR_SHIFT 0 -#define MT_ST_SOFTERR_MASK 0xffff -#define MT_ST_OPTIONS 0xf0000000 -#define MT_ST_BOOLEANS 0x10000000 -#define MT_ST_SETBOOLEANS 0x30000000 -#define MT_ST_CLEARBOOLEANS 0x40000000 -#define MT_ST_WRITE_THRESHOLD 0x20000000 -#define MT_ST_DEF_BLKSIZE 0x50000000 -#define MT_ST_DEF_OPTIONS 0x60000000 -#define MT_ST_BUFFER_WRITES 0x1 -#define MT_ST_ASYNC_WRITES 0x2 -#define MT_ST_READ_AHEAD 0x4 -#define MT_ST_DEBUGGING 0x8 -#define MT_ST_TWO_FM 0x10 -#define MT_ST_FAST_MTEOM 0x20 -#define MT_ST_AUTO_LOCK 0x40 -#define MT_ST_DEF_WRITES 0x80 -#define MT_ST_CAN_BSR 0x100 -#define MT_ST_NO_BLKLIMS 0x200 -#define MT_ST_CAN_PARTITIONS 0x400 -#define MT_ST_SCSI2LOGICAL 0x800 -#define MT_ST_CLEAR_DEFAULT 0xfffff -#define MT_ST_DEF_DENSITY (MT_ST_DEF_OPTIONS | 0x100000) -#define MT_ST_DEF_COMPRESSION (MT_ST_DEF_OPTIONS | 0x200000) -#define MT_ST_DEF_DRVBUFFER (MT_ST_DEF_OPTIONS | 0x300000) -#define MT_ST_HPLOADER_OFFSET 10000 -#ifndef DEFTAPE -# define DEFTAPE "/dev/tape" -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/personality.h b/lib/libc/wasi/libc-top-half/musl/include/sys/personality.h deleted file mode 100644 index 411dc4756392..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/personality.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _PERSONALITY_H -#define _PERSONALITY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define UNAME26 0x0020000 -#define ADDR_NO_RANDOMIZE 0x0040000 -#define FDPIC_FUNCPTRS 0x0080000 -#define MMAP_PAGE_ZERO 0x0100000 -#define ADDR_COMPAT_LAYOUT 0x0200000 -#define READ_IMPLIES_EXEC 0x0400000 -#define ADDR_LIMIT_32BIT 0x0800000 -#define SHORT_INODE 0x1000000 -#define WHOLE_SECONDS 0x2000000 -#define STICKY_TIMEOUTS 0x4000000 -#define ADDR_LIMIT_3GB 0x8000000 - -#define PER_LINUX 0 -#define PER_LINUX_32BIT ADDR_LIMIT_32BIT -#define PER_LINUX_FDPIC FDPIC_FUNCPTRS -#define PER_SVR4 (1 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO) -#define PER_SVR3 (2 | STICKY_TIMEOUTS | SHORT_INODE) -#define PER_SCOSVR3 (3 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE) -#define PER_OSR5 (3 | STICKY_TIMEOUTS | WHOLE_SECONDS) -#define PER_WYSEV386 (4 | STICKY_TIMEOUTS | SHORT_INODE) -#define PER_ISCR4 (5 | STICKY_TIMEOUTS) -#define PER_BSD 6 -#define PER_SUNOS (6 | STICKY_TIMEOUTS) -#define PER_XENIX (7 | STICKY_TIMEOUTS | SHORT_INODE) -#define PER_LINUX32 8 -#define PER_LINUX32_3GB (8 | ADDR_LIMIT_3GB) -#define PER_IRIX32 (9 | STICKY_TIMEOUTS) -#define PER_IRIXN32 (0xa | STICKY_TIMEOUTS) -#define PER_IRIX64 (0x0b | STICKY_TIMEOUTS) -#define PER_RISCOS 0xc -#define PER_SOLARIS (0xd | STICKY_TIMEOUTS) -#define PER_UW7 (0xe | STICKY_TIMEOUTS | MMAP_PAGE_ZERO) -#define PER_OSF4 0xf -#define PER_HPUX 0x10 -#define PER_MASK 0xff - -int personality(unsigned long); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/prctl.h b/lib/libc/wasi/libc-top-half/musl/include/sys/prctl.h deleted file mode 100644 index 087a75c9da0c..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/prctl.h +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef _SYS_PRCTL_H -#define _SYS_PRCTL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define PR_SET_PDEATHSIG 1 -#define PR_GET_PDEATHSIG 2 -#define PR_GET_DUMPABLE 3 -#define PR_SET_DUMPABLE 4 -#define PR_GET_UNALIGN 5 -#define PR_SET_UNALIGN 6 -#define PR_UNALIGN_NOPRINT 1 -#define PR_UNALIGN_SIGBUS 2 -#define PR_GET_KEEPCAPS 7 -#define PR_SET_KEEPCAPS 8 -#define PR_GET_FPEMU 9 -#define PR_SET_FPEMU 10 -#define PR_FPEMU_NOPRINT 1 -#define PR_FPEMU_SIGFPE 2 -#define PR_GET_FPEXC 11 -#define PR_SET_FPEXC 12 -#define PR_FP_EXC_SW_ENABLE 0x80 -#define PR_FP_EXC_DIV 0x010000 -#define PR_FP_EXC_OVF 0x020000 -#define PR_FP_EXC_UND 0x040000 -#define PR_FP_EXC_RES 0x080000 -#define PR_FP_EXC_INV 0x100000 -#define PR_FP_EXC_DISABLED 0 -#define PR_FP_EXC_NONRECOV 1 -#define PR_FP_EXC_ASYNC 2 -#define PR_FP_EXC_PRECISE 3 -#define PR_GET_TIMING 13 -#define PR_SET_TIMING 14 -#define PR_TIMING_STATISTICAL 0 -#define PR_TIMING_TIMESTAMP 1 -#define PR_SET_NAME 15 -#define PR_GET_NAME 16 -#define PR_GET_ENDIAN 19 -#define PR_SET_ENDIAN 20 -#define PR_ENDIAN_BIG 0 -#define PR_ENDIAN_LITTLE 1 -#define PR_ENDIAN_PPC_LITTLE 2 -#define PR_GET_SECCOMP 21 -#define PR_SET_SECCOMP 22 -#define PR_CAPBSET_READ 23 -#define PR_CAPBSET_DROP 24 -#define PR_GET_TSC 25 -#define PR_SET_TSC 26 -#define PR_TSC_ENABLE 1 -#define PR_TSC_SIGSEGV 2 -#define PR_GET_SECUREBITS 27 -#define PR_SET_SECUREBITS 28 -#define PR_SET_TIMERSLACK 29 -#define PR_GET_TIMERSLACK 30 - -#define PR_TASK_PERF_EVENTS_DISABLE 31 -#define PR_TASK_PERF_EVENTS_ENABLE 32 - -#define PR_MCE_KILL 33 -#define PR_MCE_KILL_CLEAR 0 -#define PR_MCE_KILL_SET 1 -#define PR_MCE_KILL_LATE 0 -#define PR_MCE_KILL_EARLY 1 -#define PR_MCE_KILL_DEFAULT 2 -#define PR_MCE_KILL_GET 34 - -#define PR_SET_MM 35 -#define PR_SET_MM_START_CODE 1 -#define PR_SET_MM_END_CODE 2 -#define PR_SET_MM_START_DATA 3 -#define PR_SET_MM_END_DATA 4 -#define PR_SET_MM_START_STACK 5 -#define PR_SET_MM_START_BRK 6 -#define PR_SET_MM_BRK 7 -#define PR_SET_MM_ARG_START 8 -#define PR_SET_MM_ARG_END 9 -#define PR_SET_MM_ENV_START 10 -#define PR_SET_MM_ENV_END 11 -#define PR_SET_MM_AUXV 12 -#define PR_SET_MM_EXE_FILE 13 -#define PR_SET_MM_MAP 14 -#define PR_SET_MM_MAP_SIZE 15 - -struct prctl_mm_map { - uint64_t start_code; - uint64_t end_code; - uint64_t start_data; - uint64_t end_data; - uint64_t start_brk; - uint64_t brk; - uint64_t start_stack; - uint64_t arg_start; - uint64_t arg_end; - uint64_t env_start; - uint64_t env_end; - uint64_t *auxv; - uint32_t auxv_size; - uint32_t exe_fd; -}; - -#define PR_SET_PTRACER 0x59616d61 -#define PR_SET_PTRACER_ANY (-1UL) - -#define PR_SET_CHILD_SUBREAPER 36 -#define PR_GET_CHILD_SUBREAPER 37 - -#define PR_SET_NO_NEW_PRIVS 38 -#define PR_GET_NO_NEW_PRIVS 39 - -#define PR_GET_TID_ADDRESS 40 - -#define PR_SET_THP_DISABLE 41 -#define PR_GET_THP_DISABLE 42 - -#define PR_MPX_ENABLE_MANAGEMENT 43 -#define PR_MPX_DISABLE_MANAGEMENT 44 - -#define PR_SET_FP_MODE 45 -#define PR_GET_FP_MODE 46 -#define PR_FP_MODE_FR (1 << 0) -#define PR_FP_MODE_FRE (1 << 1) - -#define PR_CAP_AMBIENT 47 -#define PR_CAP_AMBIENT_IS_SET 1 -#define PR_CAP_AMBIENT_RAISE 2 -#define PR_CAP_AMBIENT_LOWER 3 -#define PR_CAP_AMBIENT_CLEAR_ALL 4 - -#define PR_SVE_SET_VL 50 -#define PR_SVE_SET_VL_ONEXEC (1 << 18) -#define PR_SVE_GET_VL 51 -#define PR_SVE_VL_LEN_MASK 0xffff -#define PR_SVE_VL_INHERIT (1 << 17) - -#define PR_GET_SPECULATION_CTRL 52 -#define PR_SET_SPECULATION_CTRL 53 -#define PR_SPEC_STORE_BYPASS 0 -#define PR_SPEC_INDIRECT_BRANCH 1 -#define PR_SPEC_NOT_AFFECTED 0 -#define PR_SPEC_PRCTL (1UL << 0) -#define PR_SPEC_ENABLE (1UL << 1) -#define PR_SPEC_DISABLE (1UL << 2) -#define PR_SPEC_FORCE_DISABLE (1UL << 3) -#define PR_SPEC_DISABLE_NOEXEC (1UL << 4) - -#define PR_PAC_RESET_KEYS 54 -#define PR_PAC_APIAKEY (1UL << 0) -#define PR_PAC_APIBKEY (1UL << 1) -#define PR_PAC_APDAKEY (1UL << 2) -#define PR_PAC_APDBKEY (1UL << 3) -#define PR_PAC_APGAKEY (1UL << 4) - -#define PR_SET_TAGGED_ADDR_CTRL 55 -#define PR_GET_TAGGED_ADDR_CTRL 56 -#define PR_TAGGED_ADDR_ENABLE (1UL << 0) -#define PR_MTE_TCF_SHIFT 1 -#define PR_MTE_TCF_NONE (0UL << 1) -#define PR_MTE_TCF_SYNC (1UL << 1) -#define PR_MTE_TCF_ASYNC (2UL << 1) -#define PR_MTE_TCF_MASK (3UL << 1) -#define PR_MTE_TAG_SHIFT 3 -#define PR_MTE_TAG_MASK (0xffffUL << 3) - -#define PR_SET_IO_FLUSHER 57 -#define PR_GET_IO_FLUSHER 58 - -#define PR_SET_SYSCALL_USER_DISPATCH 59 -#define PR_SYS_DISPATCH_OFF 0 -#define PR_SYS_DISPATCH_ON 1 -#define SYSCALL_DISPATCH_FILTER_ALLOW 0 -#define SYSCALL_DISPATCH_FILTER_BLOCK 1 - -#define PR_PAC_SET_ENABLED_KEYS 60 -#define PR_PAC_GET_ENABLED_KEYS 61 - -int prctl (int, ...); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/procfs.h b/lib/libc/wasi/libc-top-half/musl/include/sys/procfs.h deleted file mode 100644 index 38e58c168b41..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/procfs.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _SYS_PROCFS_H -#define _SYS_PROCFS_H -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -struct elf_siginfo { - int si_signo; - int si_code; - int si_errno; -}; - -struct elf_prstatus { - struct elf_siginfo pr_info; - short int pr_cursig; - unsigned long int pr_sigpend; - unsigned long int pr_sighold; - pid_t pr_pid; - pid_t pr_ppid; - pid_t pr_pgrp; - pid_t pr_sid; - struct { - long tv_sec, tv_usec; - } pr_utime, pr_stime, pr_cutime, pr_cstime; - elf_gregset_t pr_reg; - int pr_fpvalid; -}; - -#define ELF_PRARGSZ 80 - -struct elf_prpsinfo { - char pr_state; - char pr_sname; - char pr_zomb; - char pr_nice; - unsigned long int pr_flag; -#if UINTPTR_MAX == 0xffffffff - unsigned short int pr_uid; - unsigned short int pr_gid; -#else - unsigned int pr_uid; - unsigned int pr_gid; -#endif - int pr_pid, pr_ppid, pr_pgrp, pr_sid; - char pr_fname[16]; - char pr_psargs[ELF_PRARGSZ]; -}; - -typedef void *psaddr_t; -typedef elf_gregset_t prgregset_t; -typedef elf_fpregset_t prfpregset_t; -typedef pid_t lwpid_t; -typedef struct elf_prstatus prstatus_t; -typedef struct elf_prpsinfo prpsinfo_t; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/ptrace.h b/lib/libc/wasi/libc-top-half/musl/include/sys/ptrace.h deleted file mode 100644 index c72e3c061c3b..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/ptrace.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef _SYS_PTRACE_H -#define _SYS_PTRACE_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define PTRACE_TRACEME 0 -#define PT_TRACE_ME PTRACE_TRACEME - -#define PTRACE_PEEKTEXT 1 -#define PTRACE_PEEKDATA 2 -#define PTRACE_PEEKUSER 3 -#define PTRACE_POKETEXT 4 -#define PTRACE_POKEDATA 5 -#define PTRACE_POKEUSER 6 -#define PTRACE_CONT 7 -#define PTRACE_KILL 8 -#define PTRACE_SINGLESTEP 9 -#define PTRACE_GETREGS 12 -#define PTRACE_SETREGS 13 -#define PTRACE_GETFPREGS 14 -#define PTRACE_SETFPREGS 15 -#define PTRACE_ATTACH 16 -#define PTRACE_DETACH 17 -#define PTRACE_GETFPXREGS 18 -#define PTRACE_SETFPXREGS 19 -#define PTRACE_SYSCALL 24 -#define PTRACE_SETOPTIONS 0x4200 -#define PTRACE_GETEVENTMSG 0x4201 -#define PTRACE_GETSIGINFO 0x4202 -#define PTRACE_SETSIGINFO 0x4203 -#define PTRACE_GETREGSET 0x4204 -#define PTRACE_SETREGSET 0x4205 -#define PTRACE_SEIZE 0x4206 -#define PTRACE_INTERRUPT 0x4207 -#define PTRACE_LISTEN 0x4208 -#define PTRACE_PEEKSIGINFO 0x4209 -#define PTRACE_GETSIGMASK 0x420a -#define PTRACE_SETSIGMASK 0x420b -#define PTRACE_SECCOMP_GET_FILTER 0x420c -#define PTRACE_SECCOMP_GET_METADATA 0x420d -#define PTRACE_GET_SYSCALL_INFO 0x420e -#define PTRACE_GET_RSEQ_CONFIGURATION 0x420f - -#define PT_READ_I PTRACE_PEEKTEXT -#define PT_READ_D PTRACE_PEEKDATA -#define PT_READ_U PTRACE_PEEKUSER -#define PT_WRITE_I PTRACE_POKETEXT -#define PT_WRITE_D PTRACE_POKEDATA -#define PT_WRITE_U PTRACE_POKEUSER -#define PT_CONTINUE PTRACE_CONT -#define PT_KILL PTRACE_KILL -#define PT_STEP PTRACE_SINGLESTEP -#define PT_GETREGS PTRACE_GETREGS -#define PT_SETREGS PTRACE_SETREGS -#define PT_GETFPREGS PTRACE_GETFPREGS -#define PT_SETFPREGS PTRACE_SETFPREGS -#define PT_ATTACH PTRACE_ATTACH -#define PT_DETACH PTRACE_DETACH -#define PT_GETFPXREGS PTRACE_GETFPXREGS -#define PT_SETFPXREGS PTRACE_SETFPXREGS -#define PT_SYSCALL PTRACE_SYSCALL -#define PT_SETOPTIONS PTRACE_SETOPTIONS -#define PT_GETEVENTMSG PTRACE_GETEVENTMSG -#define PT_GETSIGINFO PTRACE_GETSIGINFO -#define PT_SETSIGINFO PTRACE_SETSIGINFO - -#define PTRACE_O_TRACESYSGOOD 0x00000001 -#define PTRACE_O_TRACEFORK 0x00000002 -#define PTRACE_O_TRACEVFORK 0x00000004 -#define PTRACE_O_TRACECLONE 0x00000008 -#define PTRACE_O_TRACEEXEC 0x00000010 -#define PTRACE_O_TRACEVFORKDONE 0x00000020 -#define PTRACE_O_TRACEEXIT 0x00000040 -#define PTRACE_O_TRACESECCOMP 0x00000080 -#define PTRACE_O_EXITKILL 0x00100000 -#define PTRACE_O_SUSPEND_SECCOMP 0x00200000 -#define PTRACE_O_MASK 0x003000ff - -#define PTRACE_EVENT_FORK 1 -#define PTRACE_EVENT_VFORK 2 -#define PTRACE_EVENT_CLONE 3 -#define PTRACE_EVENT_EXEC 4 -#define PTRACE_EVENT_VFORK_DONE 5 -#define PTRACE_EVENT_EXIT 6 -#define PTRACE_EVENT_SECCOMP 7 -#define PTRACE_EVENT_STOP 128 - -#define PTRACE_PEEKSIGINFO_SHARED 1 - -#define PTRACE_SYSCALL_INFO_NONE 0 -#define PTRACE_SYSCALL_INFO_ENTRY 1 -#define PTRACE_SYSCALL_INFO_EXIT 2 -#define PTRACE_SYSCALL_INFO_SECCOMP 3 - -#include - -struct __ptrace_peeksiginfo_args { - uint64_t off; - uint32_t flags; - int32_t nr; -}; - -struct __ptrace_seccomp_metadata { - uint64_t filter_off; - uint64_t flags; -}; - -struct __ptrace_syscall_info { - uint8_t op; - uint8_t __pad[3]; - uint32_t arch; - uint64_t instruction_pointer; - uint64_t stack_pointer; - union { - struct { - uint64_t nr; - uint64_t args[6]; - } entry; - struct { - int64_t rval; - uint8_t is_error; - } exit; - struct { - uint64_t nr; - uint64_t args[6]; - uint32_t ret_data; - } seccomp; - }; -}; - -struct __ptrace_rseq_configuration { - uint64_t rseq_abi_pointer; - uint32_t rseq_abi_size; - uint32_t signature; - uint32_t flags; - uint32_t pad; -}; - -long ptrace(int, ...); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/quota.h b/lib/libc/wasi/libc-top-half/musl/include/sys/quota.h deleted file mode 100644 index 3ed73785df4c..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/quota.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef _SYS_QUOTA_H -#define _SYS_QUOTA_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define _LINUX_QUOTA_VERSION 2 - -#define dbtob(num) ((num) << 10) -#define btodb(num) ((num) >> 10) -#define fs_to_dq_blocks(num, blksize) (((num) * (blksize)) / 1024) - -#define MAX_IQ_TIME 604800 -#define MAX_DQ_TIME 604800 - -#define MAXQUOTAS 2 -#define USRQUOTA 0 -#define GRPQUOTA 1 - -#define INITQFNAMES { "user", "group", "undefined" }; - -#define QUOTAFILENAME "quota" -#define QUOTAGROUP "staff" - -#define NR_DQHASH 43 -#define NR_DQUOTS 256 - -#define SUBCMDMASK 0x00ff -#define SUBCMDSHIFT 8 -#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK)) - -#define Q_SYNC 0x800001 -#define Q_QUOTAON 0x800002 -#define Q_QUOTAOFF 0x800003 -#define Q_GETFMT 0x800004 -#define Q_GETINFO 0x800005 -#define Q_SETINFO 0x800006 -#define Q_GETQUOTA 0x800007 -#define Q_SETQUOTA 0x800008 - -#define QFMT_VFS_OLD 1 -#define QFMT_VFS_V0 2 -#define QFMT_OCFS2 3 -#define QFMT_VFS_V1 4 - -#define QIF_BLIMITS 1 -#define QIF_SPACE 2 -#define QIF_ILIMITS 4 -#define QIF_INODES 8 -#define QIF_BTIME 16 -#define QIF_ITIME 32 -#define QIF_LIMITS (QIF_BLIMITS | QIF_ILIMITS) -#define QIF_USAGE (QIF_SPACE | QIF_INODES) -#define QIF_TIMES (QIF_BTIME | QIF_ITIME) -#define QIF_ALL (QIF_LIMITS | QIF_USAGE | QIF_TIMES) - -struct dqblk { - uint64_t dqb_bhardlimit; - uint64_t dqb_bsoftlimit; - uint64_t dqb_curspace; - uint64_t dqb_ihardlimit; - uint64_t dqb_isoftlimit; - uint64_t dqb_curinodes; - uint64_t dqb_btime; - uint64_t dqb_itime; - uint32_t dqb_valid; -}; - -#define dq_bhardlimit dq_dqb.dqb_bhardlimit -#define dq_bsoftlimit dq_dqb.dqb_bsoftlimit -#define dq_curspace dq_dqb.dqb_curspace -#define dq_valid dq_dqb.dqb_valid -#define dq_ihardlimit dq_dqb.dqb_ihardlimit -#define dq_isoftlimit dq_dqb.dqb_isoftlimit -#define dq_curinodes dq_dqb.dqb_curinodes -#define dq_btime dq_dqb.dqb_btime -#define dq_itime dq_dqb.dqb_itime - -#define dqoff(UID) ((long long)(UID) * sizeof (struct dqblk)) - -#define IIF_BGRACE 1 -#define IIF_IGRACE 2 -#define IIF_FLAGS 4 -#define IIF_ALL (IIF_BGRACE | IIF_IGRACE | IIF_FLAGS) - -struct dqinfo { - uint64_t dqi_bgrace; - uint64_t dqi_igrace; - uint32_t dqi_flags; - uint32_t dqi_valid; -}; - -int quotactl(int, const char *, int, char *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/reboot.h b/lib/libc/wasi/libc-top-half/musl/include/sys/reboot.h deleted file mode 100644 index 9702eddba4ba..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/reboot.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef _SYS_REBOOT_H -#define _SYS_REBOOT_H -#ifdef __cplusplus -extern "C" { -#endif - -#define RB_AUTOBOOT 0x01234567 -#define RB_HALT_SYSTEM 0xcdef0123 -#define RB_ENABLE_CAD 0x89abcdef -#define RB_DISABLE_CAD 0 -#define RB_POWER_OFF 0x4321fedc -#define RB_SW_SUSPEND 0xd000fce2 -#define RB_KEXEC 0x45584543 - -int reboot(int); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/sem.h b/lib/libc/wasi/libc-top-half/musl/include/sys/sem.h deleted file mode 100644 index a747784ede9e..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/sem.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _SYS_SEM_H -#define _SYS_SEM_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_size_t -#define __NEED_pid_t -#define __NEED_time_t -#ifdef _GNU_SOURCE -#define __NEED_struct_timespec -#endif -#include - -#include - -#define SEM_UNDO 0x1000 -#define GETPID 11 -#define GETVAL 12 -#define GETALL 13 -#define GETNCNT 14 -#define GETZCNT 15 -#define SETVAL 16 -#define SETALL 17 - -#include - -#define _SEM_SEMUN_UNDEFINED 1 - -#define SEM_STAT (18 | (IPC_STAT & 0x100)) -#define SEM_INFO 19 -#define SEM_STAT_ANY (20 | (IPC_STAT & 0x100)) - -struct seminfo { - int semmap; - int semmni; - int semmns; - int semmnu; - int semmsl; - int semopm; - int semume; - int semusz; - int semvmx; - int semaem; -}; - -struct sembuf { - unsigned short sem_num; - short sem_op; - short sem_flg; -}; - -int semctl(int, int, int, ...); -int semget(key_t, int, int); -int semop(int, struct sembuf *, size_t); - -#ifdef _GNU_SOURCE -int semtimedop(int, struct sembuf *, size_t, const struct timespec *); -#endif - -#if _REDIR_TIME64 -#ifdef _GNU_SOURCE -__REDIR(semtimedop, __semtimedop_time64); -#endif -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/sendfile.h b/lib/libc/wasi/libc-top-half/musl/include/sys/sendfile.h deleted file mode 100644 index e7570d8e5c4f..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/sendfile.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _SYS_SENDFILE_H -#define _SYS_SENDFILE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -ssize_t sendfile(int, int, off_t *, size_t); - -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define sendfile64 sendfile -#define off64_t off_t -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/shm.h b/lib/libc/wasi/libc-top-half/musl/include/sys/shm.h deleted file mode 100644 index fd708cab1eb8..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/shm.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _SYS_SHM_H -#define _SYS_SHM_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_time_t -#define __NEED_size_t -#define __NEED_pid_t - -#include - -#include - -#ifdef _GNU_SOURCE -#define __used_ids used_ids -#define __swap_attempts swap_attempts -#define __swap_successes swap_successes -#endif - -#include - -#define SHM_R 0400 -#define SHM_W 0200 - -#define SHM_RDONLY 010000 -#define SHM_RND 020000 -#define SHM_REMAP 040000 -#define SHM_EXEC 0100000 - -#define SHM_LOCK 11 -#define SHM_UNLOCK 12 -#define SHM_STAT (13 | (IPC_STAT & 0x100)) -#define SHM_INFO 14 -#define SHM_STAT_ANY (15 | (IPC_STAT & 0x100)) -#define SHM_DEST 01000 -#define SHM_LOCKED 02000 -#define SHM_HUGETLB 04000 -#define SHM_NORESERVE 010000 - -#define SHM_HUGE_SHIFT 26 -#define SHM_HUGE_MASK 0x3f -#define SHM_HUGE_64KB (16 << 26) -#define SHM_HUGE_512KB (19 << 26) -#define SHM_HUGE_1MB (20 << 26) -#define SHM_HUGE_2MB (21 << 26) -#define SHM_HUGE_8MB (23 << 26) -#define SHM_HUGE_16MB (24 << 26) -#define SHM_HUGE_32MB (25 << 26) -#define SHM_HUGE_256MB (28 << 26) -#define SHM_HUGE_512MB (29 << 26) -#define SHM_HUGE_1GB (30 << 26) -#define SHM_HUGE_2GB (31 << 26) -#define SHM_HUGE_16GB (34U << 26) - -typedef unsigned long shmatt_t; - -void *shmat(int, const void *, int); -int shmctl(int, int, struct shmid_ds *); -int shmdt(const void *); -int shmget(key_t, size_t, int); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/signalfd.h b/lib/libc/wasi/libc-top-half/musl/include/sys/signalfd.h deleted file mode 100644 index e881e2cfddcc..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/signalfd.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _SYS_SIGNALFD_H -#define _SYS_SIGNALFD_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -#define __NEED_sigset_t - -#include - -#define SFD_CLOEXEC O_CLOEXEC -#define SFD_NONBLOCK O_NONBLOCK - -int signalfd(int, const sigset_t *, int); - -struct signalfd_siginfo { - uint32_t ssi_signo; - int32_t ssi_errno; - int32_t ssi_code; - uint32_t ssi_pid; - uint32_t ssi_uid; - int32_t ssi_fd; - uint32_t ssi_tid; - uint32_t ssi_band; - uint32_t ssi_overrun; - uint32_t ssi_trapno; - int32_t ssi_status; - int32_t ssi_int; - uint64_t ssi_ptr; - uint64_t ssi_utime; - uint64_t ssi_stime; - uint64_t ssi_addr; - uint16_t ssi_addr_lsb; - uint16_t __pad2; - int32_t ssi_syscall; - uint64_t ssi_call_addr; - uint32_t ssi_arch; - uint8_t __pad[128-14*4-5*8-2*2]; -}; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/socket.h b/lib/libc/wasi/libc-top-half/musl/include/sys/socket.h index 4d574c6627e0..29189e39eb84 100644 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/socket.h +++ b/lib/libc/wasi/libc-top-half/musl/include/sys/socket.h @@ -1,5 +1,8 @@ #ifndef _SYS_SOCKET_H #define _SYS_SOCKET_H + +#include <__wasi_snapshot.h> + #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ #else #include <__header_sys_socket.h> @@ -395,30 +398,33 @@ struct sockaddr_storage { #include <__struct_sockaddr_storage.h> #endif -#ifdef __wasilibc_unmodified_upstream /* WASI has no socket/socketpair */ +#if (defined __wasilibc_unmodified_upstream) || (defined __wasilibc_use_wasip2) int socket (int, int, int); +#endif + +#ifdef __wasilibc_unmodified_upstream /* WASI has no socketpair */ int socketpair (int, int, int, int [2]); #endif int shutdown (int, int); -#ifdef __wasilibc_unmodified_upstream /* WASI has no bind/connect/listen/accept */ -int bind (int, const struct sockaddr *, socklen_t); +#if (defined __wasilibc_unmodified_upstream) || (defined __wasilibc_use_wasip2) int connect (int, const struct sockaddr *, socklen_t); +int bind (int, const struct sockaddr *, socklen_t); int listen (int, int); #endif int accept (int, struct sockaddr *__restrict, socklen_t *__restrict); int accept4(int, struct sockaddr *__restrict, socklen_t *__restrict, int); -#ifdef __wasilibc_unmodified_upstream /* WASI has no getsockname/getpeername */ +#if (defined __wasilibc_unmodified_upstream) || (defined __wasilibc_use_wasip2) int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict); int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict); #endif ssize_t send (int, const void *, size_t, int); ssize_t recv (int, void *, size_t, int); -#ifdef __wasilibc_unmodified_upstream /* WASI has no sendto/recvfrom */ +#if (defined __wasilibc_unmodified_upstream) || (defined __wasilibc_use_wasip2) ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t); ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict); #endif @@ -428,7 +434,7 @@ ssize_t recvmsg (int, struct msghdr *, int); #endif int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict); -#ifdef __wasilibc_unmodified_upstream /* WASI has no setsockopt */ +#if (defined __wasilibc_unmodified_upstream) || (defined __wasilibc_use_wasip2) int setsockopt (int, int, int, const void *, socklen_t); #endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/soundcard.h b/lib/libc/wasi/libc-top-half/musl/include/sys/soundcard.h deleted file mode 100644 index 5ca776461e08..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/soundcard.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/stat.h b/lib/libc/wasi/libc-top-half/musl/include/sys/stat.h index 72e1626158f3..c0090f7509fb 100644 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/stat.h +++ b/lib/libc/wasi/libc-top-half/musl/include/sys/stat.h @@ -78,11 +78,9 @@ int stat(const char *__restrict, struct stat *__restrict); int fstat(int, struct stat *); int lstat(const char *__restrict, struct stat *__restrict); int fstatat(int, const char *__restrict, struct stat *__restrict, int); -#ifdef __wasilibc_unmodified_upstream /* WASI has no chmod */ int chmod(const char *, mode_t); int fchmod(int, mode_t); int fchmodat(int, const char *, mode_t, int); -#endif #ifdef __wasilibc_unmodified_upstream /* WASI has no umask */ mode_t umask(mode_t); #endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/statfs.h b/lib/libc/wasi/libc-top-half/musl/include/sys/statfs.h deleted file mode 100644 index 6f4c6230f7a0..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/statfs.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _SYS_STATFS_H -#define _SYS_STATFS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include - -typedef struct __fsid_t { - int __val[2]; -} fsid_t; - -#include - -int statfs (const char *, struct statfs *); -int fstatfs (int, struct statfs *); - -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define statfs64 statfs -#define fstatfs64 fstatfs -#define fsblkcnt64_t fsblkcnt_t -#define fsfilcnt64_t fsfilcnt_t -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/swap.h b/lib/libc/wasi/libc-top-half/musl/include/sys/swap.h deleted file mode 100644 index 11c0f9296179..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/swap.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _SYS_SWAP_H -#define _SYS_SWAP_H - -#ifdef __cplusplus -extern "C" { -#endif - - -#define SWAP_FLAG_PREFER 0x8000 -#define SWAP_FLAG_PRIO_MASK 0x7fff -#define SWAP_FLAG_PRIO_SHIFT 0 -#define SWAP_FLAG_DISCARD 0x10000 - -int swapon (const char *, int); -int swapoff (const char *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/syslog.h b/lib/libc/wasi/libc-top-half/musl/include/sys/syslog.h deleted file mode 100644 index 7761eceebbeb..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/syslog.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/sysmacros.h b/lib/libc/wasi/libc-top-half/musl/include/sys/sysmacros.h deleted file mode 100644 index 07a3ef183cb6..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/sysmacros.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _SYS_SYSMACROS_H -#define _SYS_SYSMACROS_H - -#define major(x) \ - ((unsigned)( (((x)>>31>>1) & 0xfffff000) | (((x)>>8) & 0x00000fff) )) -#define minor(x) \ - ((unsigned)( (((x)>>12) & 0xffffff00) | ((x) & 0x000000ff) )) - -#define makedev(x,y) ( \ - (((x)&0xfffff000ULL) << 32) | \ - (((x)&0x00000fffULL) << 8) | \ - (((y)&0xffffff00ULL) << 12) | \ - (((y)&0x000000ffULL)) ) - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/termios.h b/lib/libc/wasi/libc-top-half/musl/include/sys/termios.h deleted file mode 100644 index f5f751f04336..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/termios.h +++ /dev/null @@ -1,2 +0,0 @@ -#warning redirecting incorrect #include to -#include diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/timerfd.h b/lib/libc/wasi/libc-top-half/musl/include/sys/timerfd.h deleted file mode 100644 index 1b832cdd8f8f..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/timerfd.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _SYS_TIMERFD_H -#define _SYS_TIMERFD_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -#define TFD_NONBLOCK O_NONBLOCK -#define TFD_CLOEXEC O_CLOEXEC - -#define TFD_TIMER_ABSTIME 1 -#define TFD_TIMER_CANCEL_ON_SET (1 << 1) - -struct itimerspec; - -int timerfd_create(int, int); -int timerfd_settime(int, int, const struct itimerspec *, struct itimerspec *); -int timerfd_gettime(int, struct itimerspec *); - -#if _REDIR_TIME64 -__REDIR(timerfd_settime, __timerfd_settime64); -__REDIR(timerfd_gettime, __timerfd_gettime64); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/ucontext.h b/lib/libc/wasi/libc-top-half/musl/include/sys/ucontext.h deleted file mode 100644 index 5fdbd63dbb26..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/ucontext.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/user.h b/lib/libc/wasi/libc-top-half/musl/include/sys/user.h deleted file mode 100644 index 96a03400900b..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/user.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _SYS_USER_H -#define _SYS_USER_H -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -#include - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/vfs.h b/lib/libc/wasi/libc-top-half/musl/include/sys/vfs.h deleted file mode 100644 index a899db276342..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/vfs.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/vt.h b/lib/libc/wasi/libc-top-half/musl/include/sys/vt.h deleted file mode 100644 index 5000de499fa2..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/vt.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/wait.h b/lib/libc/wasi/libc-top-half/musl/include/sys/wait.h deleted file mode 100644 index d4b1f2e185c6..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/wait.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _SYS_WAIT_H -#define _SYS_WAIT_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_pid_t -#define __NEED_id_t -#include - -typedef enum { - P_ALL = 0, - P_PID = 1, - P_PGID = 2, - P_PIDFD = 3 -} idtype_t; - -pid_t wait (int *); -pid_t waitpid (pid_t, int *, int ); - -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ - || defined(_BSD_SOURCE) -#include -int waitid (idtype_t, id_t, siginfo_t *, int); -#endif - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#include -pid_t wait3 (int *, int, struct rusage *); -pid_t wait4 (pid_t, int *, int, struct rusage *); -#endif - -#define WNOHANG 1 -#define WUNTRACED 2 - -#define WSTOPPED 2 -#define WEXITED 4 -#define WCONTINUED 8 -#define WNOWAIT 0x1000000 - -#define __WNOTHREAD 0x20000000 -#define __WALL 0x40000000 -#define __WCLONE 0x80000000 - -#define WEXITSTATUS(s) (((s) & 0xff00) >> 8) -#define WTERMSIG(s) ((s) & 0x7f) -#define WSTOPSIG(s) WEXITSTATUS(s) -#define WCOREDUMP(s) ((s) & 0x80) -#define WIFEXITED(s) (!WTERMSIG(s)) -#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00) -#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) -#define WIFCONTINUED(s) ((s) == 0xffff) - -#if _REDIR_TIME64 -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -__REDIR(wait3, __wait3_time64); -__REDIR(wait4, __wait4_time64); -#endif -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/sys/xattr.h b/lib/libc/wasi/libc-top-half/musl/include/sys/xattr.h deleted file mode 100644 index eeeaafc44f09..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/sys/xattr.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _SYS_XATTR_H -#define _SYS_XATTR_H -#ifdef __cplusplus -extern "C" { -#endif - -#define __NEED_ssize_t -#define __NEED_size_t -#include - -#define XATTR_CREATE 1 -#define XATTR_REPLACE 2 - -ssize_t getxattr(const char *, const char *, void *, size_t); -ssize_t lgetxattr(const char *, const char *, void *, size_t); -ssize_t fgetxattr(int, const char *, void *, size_t); -ssize_t listxattr(const char *, char *, size_t); -ssize_t llistxattr(const char *, char *, size_t); -ssize_t flistxattr(int, char *, size_t); -int setxattr(const char *, const char *, const void *, size_t, int); -int lsetxattr(const char *, const char *, const void *, size_t, int); -int fsetxattr(int, const char *, const void *, size_t, int); -int removexattr(const char *, const char *); -int lremovexattr(const char *, const char *); -int fremovexattr(int, const char *); - -#define __UAPI_DEF_XATTR 0 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/syslog.h b/lib/libc/wasi/libc-top-half/musl/include/syslog.h deleted file mode 100644 index 5b4d2964e780..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/syslog.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef _SYSLOG_H -#define _SYSLOG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define LOG_EMERG 0 -#define LOG_ALERT 1 -#define LOG_CRIT 2 -#define LOG_ERR 3 -#define LOG_WARNING 4 -#define LOG_NOTICE 5 -#define LOG_INFO 6 -#define LOG_DEBUG 7 - -#define LOG_PRIMASK 7 -#define LOG_PRI(p) ((p)&LOG_PRIMASK) -#define LOG_MAKEPRI(f, p) (((f)<<3)|(p)) - -#define LOG_MASK(p) (1<<(p)) -#define LOG_UPTO(p) ((1<<((p)+1))-1) - -#define LOG_KERN (0<<3) -#define LOG_USER (1<<3) -#define LOG_MAIL (2<<3) -#define LOG_DAEMON (3<<3) -#define LOG_AUTH (4<<3) -#define LOG_SYSLOG (5<<3) -#define LOG_LPR (6<<3) -#define LOG_NEWS (7<<3) -#define LOG_UUCP (8<<3) -#define LOG_CRON (9<<3) -#define LOG_AUTHPRIV (10<<3) -#define LOG_FTP (11<<3) - -#define LOG_LOCAL0 (16<<3) -#define LOG_LOCAL1 (17<<3) -#define LOG_LOCAL2 (18<<3) -#define LOG_LOCAL3 (19<<3) -#define LOG_LOCAL4 (20<<3) -#define LOG_LOCAL5 (21<<3) -#define LOG_LOCAL6 (22<<3) -#define LOG_LOCAL7 (23<<3) - -#define LOG_NFACILITIES 24 -#define LOG_FACMASK 0x3f8 -#define LOG_FAC(p) (((p)&LOG_FACMASK)>>3) - -#define LOG_PID 0x01 -#define LOG_CONS 0x02 -#define LOG_ODELAY 0x04 -#define LOG_NDELAY 0x08 -#define LOG_NOWAIT 0x10 -#define LOG_PERROR 0x20 - -void closelog (void); -void openlog (const char *, int, int); -int setlogmask (int); -void syslog (int, const char *, ...); - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define _PATH_LOG "/dev/log" -#define __NEED_va_list -#include -void vsyslog (int, const char *, va_list); -#if defined(SYSLOG_NAMES) -#define INTERNAL_NOPRI 0x10 -#define INTERNAL_MARK (LOG_NFACILITIES<<3) -typedef struct { - char *c_name; - int c_val; -} CODE; -#define prioritynames ((CODE *)(const CODE []){ \ - { "alert", LOG_ALERT }, { "crit", LOG_CRIT }, { "debug", LOG_DEBUG }, \ - { "emerg", LOG_EMERG }, { "err", LOG_ERR }, { "error", LOG_ERR }, \ - { "info", LOG_INFO }, { "none", INTERNAL_NOPRI }, \ - { "notice", LOG_NOTICE }, { "panic", LOG_EMERG }, \ - { "warn", LOG_WARNING }, { "warning", LOG_WARNING }, { 0, -1 } }) -#define facilitynames ((CODE *)(const CODE []){ \ - { "auth", LOG_AUTH }, { "authpriv", LOG_AUTHPRIV }, \ - { "cron", LOG_CRON }, { "daemon", LOG_DAEMON }, { "ftp", LOG_FTP }, \ - { "kern", LOG_KERN }, { "lpr", LOG_LPR }, { "mail", LOG_MAIL }, \ - { "mark", INTERNAL_MARK }, { "news", LOG_NEWS }, \ - { "security", LOG_AUTH }, { "syslog", LOG_SYSLOG }, \ - { "user", LOG_USER }, { "uucp", LOG_UUCP }, \ - { "local0", LOG_LOCAL0 }, { "local1", LOG_LOCAL1 }, \ - { "local2", LOG_LOCAL2 }, { "local3", LOG_LOCAL3 }, \ - { "local4", LOG_LOCAL4 }, { "local5", LOG_LOCAL5 }, \ - { "local6", LOG_LOCAL6 }, { "local7", LOG_LOCAL7 }, { 0, -1 } }) -#endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/termios.h b/lib/libc/wasi/libc-top-half/musl/include/termios.h deleted file mode 100644 index cbb533010e8b..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/termios.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _TERMIOS_H -#define _TERMIOS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_pid_t -#define __NEED_struct_winsize - -#include - -typedef unsigned char cc_t; -typedef unsigned int speed_t; -typedef unsigned int tcflag_t; - -#define NCCS 32 - -#include - -speed_t cfgetospeed (const struct termios *); -speed_t cfgetispeed (const struct termios *); -int cfsetospeed (struct termios *, speed_t); -int cfsetispeed (struct termios *, speed_t); - -int tcgetattr (int, struct termios *); -int tcsetattr (int, int, const struct termios *); - -int tcgetwinsize (int, struct winsize *); -int tcsetwinsize (int, const struct winsize *); - -int tcsendbreak (int, int); -int tcdrain (int); -int tcflush (int, int); -int tcflow (int, int); - -pid_t tcgetsid (int); - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -void cfmakeraw(struct termios *); -int cfsetspeed(struct termios *, speed_t); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/ucontext.h b/lib/libc/wasi/libc-top-half/musl/include/ucontext.h deleted file mode 100644 index 0f75712548c3..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/ucontext.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _UCONTEXT_H -#define _UCONTEXT_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define NGREG (sizeof(gregset_t)/sizeof(greg_t)) -#endif - -struct __ucontext; - -int getcontext(struct __ucontext *); -void makecontext(struct __ucontext *, void (*)(), int, ...); -int setcontext(const struct __ucontext *); -int swapcontext(struct __ucontext *, const struct __ucontext *); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/ulimit.h b/lib/libc/wasi/libc-top-half/musl/include/ulimit.h deleted file mode 100644 index efdcd311e5c7..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/ulimit.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _ULIMIT_H -#define _ULIMIT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define UL_GETFSIZE 1 -#define UL_SETFSIZE 2 - -long ulimit (int, ...); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/utmp.h b/lib/libc/wasi/libc-top-half/musl/include/utmp.h deleted file mode 100644 index 48a400d84dec..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/utmp.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _UTMP_H -#define _UTMP_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define ACCOUNTING 9 -#define UT_NAMESIZE 32 -#define UT_HOSTSIZE 256 -#define UT_LINESIZE 32 - -struct lastlog { - time_t ll_time; - char ll_line[UT_LINESIZE]; - char ll_host[UT_HOSTSIZE]; -}; - -#define ut_time ut_tv.tv_sec -#define ut_name ut_user -#define ut_addr ut_addr_v6[0] -#define utmp utmpx -#define e_exit __e_exit -#define e_termination __e_termination - -void endutent(void); -struct utmp *getutent(void); -struct utmp *getutid(const struct utmp *); -struct utmp *getutline(const struct utmp *); -struct utmp *pututline(const struct utmp *); -void setutent(void); - -void updwtmp(const char *, const struct utmp *); -int utmpname(const char *); - -int login_tty(int); - -#define _PATH_UTMP "/dev/null/utmp" -#define _PATH_WTMP "/dev/null/wtmp" - -#define UTMP_FILE _PATH_UTMP -#define WTMP_FILE _PATH_WTMP -#define UTMP_FILENAME _PATH_UTMP -#define WTMP_FILENAME _PATH_WTMP - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/utmpx.h b/lib/libc/wasi/libc-top-half/musl/include/utmpx.h deleted file mode 100644 index b293f427e6b0..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/utmpx.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _UTMPX_H -#define _UTMPX_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_pid_t -#define __NEED_time_t -#define __NEED_suseconds_t -#define __NEED_struct_timeval - -#include - -struct utmpx { - short ut_type; - short __ut_pad1; - pid_t ut_pid; - char ut_line[32]; - char ut_id[4]; - char ut_user[32]; - char ut_host[256]; - struct { - short __e_termination; - short __e_exit; - } ut_exit; -#if __BYTE_ORDER == 1234 - int ut_session, __ut_pad2; -#else - int __ut_pad2, ut_session; -#endif - struct timeval ut_tv; - unsigned ut_addr_v6[4]; - char __unused[20]; -}; - -void endutxent(void); -struct utmpx *getutxent(void); -struct utmpx *getutxid(const struct utmpx *); -struct utmpx *getutxline(const struct utmpx *); -struct utmpx *pututxline(const struct utmpx *); -void setutxent(void); - -#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) -#define e_exit __e_exit -#define e_termination __e_termination -void updwtmpx(const char *, const struct utmpx *); -int utmpxname(const char *); -#endif - -#define EMPTY 0 -#define RUN_LVL 1 -#define BOOT_TIME 2 -#define NEW_TIME 3 -#define OLD_TIME 4 -#define INIT_PROCESS 5 -#define LOGIN_PROCESS 6 -#define USER_PROCESS 7 -#define DEAD_PROCESS 8 - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/include/wait.h b/lib/libc/wasi/libc-top-half/musl/include/wait.h deleted file mode 100644 index 98396e2d20ba..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/wait.h +++ /dev/null @@ -1,2 +0,0 @@ -#warning redirecting incorrect #include to -#include diff --git a/lib/libc/wasi/libc-top-half/musl/include/wordexp.h b/lib/libc/wasi/libc-top-half/musl/include/wordexp.h deleted file mode 100644 index 5460002deec7..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/include/wordexp.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _WORDEXP_H -#define _WORDEXP_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define __NEED_size_t - -#include - -#define WRDE_DOOFFS 1 -#define WRDE_APPEND 2 -#define WRDE_NOCMD 4 -#define WRDE_REUSE 8 -#define WRDE_SHOWERR 16 -#define WRDE_UNDEF 32 - -typedef struct { - size_t we_wordc; - char **we_wordv; - size_t we_offs; -} wordexp_t; - -#define WRDE_NOSYS -1 -#define WRDE_NOSPACE 1 -#define WRDE_BADCHAR 2 -#define WRDE_BADVAL 3 -#define WRDE_CMDSUB 4 -#define WRDE_SYNTAX 5 - -int wordexp (const char *__restrict, wordexp_t *__restrict, int); -void wordfree (wordexp_t *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/src/include/pthread.h b/lib/libc/wasi/libc-top-half/musl/src/include/pthread.h deleted file mode 100644 index 0aba813e9a47..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/include/pthread.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef PTHREAD_H -#define PTHREAD_H - -#include "../../include/pthread.h" - -hidden int __pthread_once(pthread_once_t *, void (*)(void)); -hidden void __pthread_testcancel(void); -hidden int __pthread_setcancelstate(int, int *); -hidden int __pthread_create(pthread_t *restrict, const pthread_attr_t *restrict, void *(*)(void *), void *restrict); -#ifdef __wasilibc_unmodified_upstream -hidden _Noreturn void __pthread_exit(void *); -#endif -hidden int __pthread_join(pthread_t, void **); -hidden int __pthread_mutex_lock(pthread_mutex_t *); -hidden int __pthread_mutex_trylock(pthread_mutex_t *); -hidden int __pthread_mutex_trylock_owner(pthread_mutex_t *); -hidden int __pthread_mutex_timedlock(pthread_mutex_t *restrict, const struct timespec *restrict); -hidden int __pthread_mutex_unlock(pthread_mutex_t *); -hidden int __private_cond_signal(pthread_cond_t *, int); -hidden int __pthread_cond_timedwait(pthread_cond_t *restrict, pthread_mutex_t *restrict, const struct timespec *restrict); -hidden int __pthread_key_create(pthread_key_t *, void (*)(void *)); -hidden int __pthread_key_delete(pthread_key_t); -hidden int __pthread_rwlock_rdlock(pthread_rwlock_t *); -hidden int __pthread_rwlock_tryrdlock(pthread_rwlock_t *); -hidden int __pthread_rwlock_timedrdlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict); -hidden int __pthread_rwlock_wrlock(pthread_rwlock_t *); -hidden int __pthread_rwlock_trywrlock(pthread_rwlock_t *); -hidden int __pthread_rwlock_timedwrlock(pthread_rwlock_t *__restrict, const struct timespec *__restrict); -hidden int __pthread_rwlock_unlock(pthread_rwlock_t *); - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/src/include/resolv.h b/lib/libc/wasi/libc-top-half/musl/src/include/resolv.h deleted file mode 100644 index 945e89e6354e..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/include/resolv.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef RESOLV_H -#define RESOLV_H - -#include "../../include/resolv.h" - -hidden int __dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int); - -hidden int __res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int); -hidden int __res_send(const unsigned char *, int, unsigned char *, int); -hidden int __res_msend(int, const unsigned char *const *, const int *, unsigned char *const *, int *, int); - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/src/include/sys/auxv.h b/lib/libc/wasi/libc-top-half/musl/src/include/sys/auxv.h deleted file mode 100644 index 9358a4a5d8c5..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/include/sys/auxv.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef SYS_AUXV_H -#define SYS_AUXV_H - -#include "../../../include/sys/auxv.h" - -#include - -hidden unsigned long __getauxval(unsigned long); - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/src/include/sys/membarrier.h b/lib/libc/wasi/libc-top-half/musl/src/include/sys/membarrier.h deleted file mode 100644 index 3654491c2d46..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/include/sys/membarrier.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef SYS_MEMBARRIER_H -#define SYS_MEMBARRIER_H - -#include "../../../include/sys/membarrier.h" -#include - -hidden int __membarrier(int, int); - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/src/internal/locale_impl.h b/lib/libc/wasi/libc-top-half/musl/src/internal/locale_impl.h index 7f79b7f51937..4649a43e090a 100644 --- a/lib/libc/wasi/libc-top-half/musl/src/internal/locale_impl.h +++ b/lib/libc/wasi/libc-top-half/musl/src/internal/locale_impl.h @@ -28,7 +28,15 @@ extern hidden const struct __locale_struct __c_dot_utf8_locale; hidden const struct __locale_map *__get_locale(int, const char *); hidden const char *__mo_lookup(const void *, size_t, const char *); hidden const char *__lctrans(const char *, const struct __locale_map *); +#ifdef __wasilibc_unmodified_upstream hidden const char *__lctrans_cur(const char *); +#else +// We make this visible in the wasi-libc build because +// libwasi-emulated-signal.so needs to import it from libc.so. If we ever +// decide to merge libwasi-emulated-signal.so into libc.so, this will no longer +// be necessary. +const char *__lctrans_cur(const char *); +#endif hidden const char *__lctrans_impl(const char *, const struct __locale_map *); hidden int __loc_is_allocated(locale_t); hidden char *__gettextdomain(void); diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/ipc.h b/lib/libc/wasi/libc-top-half/musl/src/ipc/ipc.h deleted file mode 100644 index 746a905c986a..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/ipc/ipc.h +++ /dev/null @@ -1,24 +0,0 @@ -#include "syscall.h" - -#define IPCOP_semop 1 -#define IPCOP_semget 2 -#define IPCOP_semctl 3 -#define IPCOP_semtimedop 4 -#define IPCOP_msgsnd 11 -#define IPCOP_msgrcv 12 -#define IPCOP_msgget 13 -#define IPCOP_msgctl 14 -#define IPCOP_shmat 21 -#define IPCOP_shmdt 22 -#define IPCOP_shmget 23 -#define IPCOP_shmctl 24 - -#ifndef IPC_64 -#define IPC_64 0x100 -#endif - -#define IPC_TIME64 (IPC_STAT & 0x100) - -#define IPC_CMD(cmd) (((cmd) & ~IPC_TIME64) | IPC_64) - -#define IPC_HILO(b,t) ((b)->t = (b)->__##t##_lo | 0LL+(b)->__##t##_hi<<32) diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/glue.h b/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/glue.h deleted file mode 100644 index 151c48b804b2..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/glue.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef MALLOC_GLUE_H -#define MALLOC_GLUE_H - -#include -#include -#include -#include -#include -#include -#include "atomic.h" -#include "syscall.h" -#include "libc.h" -#include "lock.h" -#include "dynlink.h" - -// use macros to appropriately namespace these. -#define size_classes __malloc_size_classes -#define ctx __malloc_context -#define alloc_meta __malloc_alloc_meta -#define is_allzero __malloc_allzerop -#define dump_heap __dump_heap - -#define malloc __libc_malloc_impl -#define realloc __libc_realloc -#define free __libc_free - -#if USE_REAL_ASSERT -#include -#else -#undef assert -#define assert(x) do { if (!(x)) a_crash(); } while(0) -#endif - -#define brk(p) ((uintptr_t)__syscall(SYS_brk, p)) - -#define mmap __mmap -#define madvise __madvise -#define mremap __mremap - -#define DISABLE_ALIGNED_ALLOC (__malloc_replaced && !__aligned_alloc_replaced) - -static inline uint64_t get_random_secret() -{ - uint64_t secret = (uintptr_t)&secret * 1103515245; - for (size_t i=0; libc.auxv[i]; i+=2) - if (libc.auxv[i]==AT_RANDOM) - memcpy(&secret, (char *)libc.auxv[i+1]+8, sizeof secret); - return secret; -} - -#ifndef PAGESIZE -#define PAGESIZE PAGE_SIZE -#endif - -#define MT (libc.need_locks) - -#define RDLOCK_IS_EXCLUSIVE 1 - -__attribute__((__visibility__("hidden"))) -extern int __malloc_lock[1]; - -#define LOCK_OBJ_DEF \ -int __malloc_lock[1]; \ -void __malloc_atfork(int who) { malloc_atfork(who); } - -static inline void rdlock() -{ - if (MT) LOCK(__malloc_lock); -} -static inline void wrlock() -{ - if (MT) LOCK(__malloc_lock); -} -static inline void unlock() -{ - UNLOCK(__malloc_lock); -} -static inline void upgradelock() -{ -} -static inline void resetlock() -{ - __malloc_lock[0] = 0; -} - -static inline void malloc_atfork(int who) -{ - if (who<0) rdlock(); - else if (who>0) resetlock(); - else unlock(); -} - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/meta.h b/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/meta.h deleted file mode 100644 index 61ec53f9a589..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/meta.h +++ /dev/null @@ -1,288 +0,0 @@ -#ifndef MALLOC_META_H -#define MALLOC_META_H - -#include -#include -#include -#include "glue.h" - -__attribute__((__visibility__("hidden"))) -extern const uint16_t size_classes[]; - -#define MMAP_THRESHOLD 131052 - -#define UNIT 16 -#define IB 4 - -struct group { - struct meta *meta; - unsigned char active_idx:5; - char pad[UNIT - sizeof(struct meta *) - 1]; - unsigned char storage[]; -}; - -struct meta { - struct meta *prev, *next; - struct group *mem; - volatile int avail_mask, freed_mask; - uintptr_t last_idx:5; - uintptr_t freeable:1; - uintptr_t sizeclass:6; - uintptr_t maplen:8*sizeof(uintptr_t)-12; -}; - -struct meta_area { - uint64_t check; - struct meta_area *next; - int nslots; - struct meta slots[]; -}; - -struct malloc_context { - uint64_t secret; -#ifndef PAGESIZE - size_t pagesize; -#endif - int init_done; - unsigned mmap_counter; - struct meta *free_meta_head; - struct meta *avail_meta; - size_t avail_meta_count, avail_meta_area_count, meta_alloc_shift; - struct meta_area *meta_area_head, *meta_area_tail; - unsigned char *avail_meta_areas; - struct meta *active[48]; - size_t usage_by_class[48]; - uint8_t unmap_seq[32], bounces[32]; - uint8_t seq; - uintptr_t brk; -}; - -__attribute__((__visibility__("hidden"))) -extern struct malloc_context ctx; - -#ifdef PAGESIZE -#define PGSZ PAGESIZE -#else -#define PGSZ ctx.pagesize -#endif - -__attribute__((__visibility__("hidden"))) -struct meta *alloc_meta(void); - -__attribute__((__visibility__("hidden"))) -int is_allzero(void *); - -static inline void queue(struct meta **phead, struct meta *m) -{ - assert(!m->next); - assert(!m->prev); - if (*phead) { - struct meta *head = *phead; - m->next = head; - m->prev = head->prev; - m->next->prev = m->prev->next = m; - } else { - m->prev = m->next = m; - *phead = m; - } -} - -static inline void dequeue(struct meta **phead, struct meta *m) -{ - if (m->next != m) { - m->prev->next = m->next; - m->next->prev = m->prev; - if (*phead == m) *phead = m->next; - } else { - *phead = 0; - } - m->prev = m->next = 0; -} - -static inline struct meta *dequeue_head(struct meta **phead) -{ - struct meta *m = *phead; - if (m) dequeue(phead, m); - return m; -} - -static inline void free_meta(struct meta *m) -{ - *m = (struct meta){0}; - queue(&ctx.free_meta_head, m); -} - -static inline uint32_t activate_group(struct meta *m) -{ - assert(!m->avail_mask); - uint32_t mask, act = (2u<mem->active_idx)-1; - do mask = m->freed_mask; - while (a_cas(&m->freed_mask, mask, mask&~act)!=mask); - return m->avail_mask = mask & act; -} - -static inline int get_slot_index(const unsigned char *p) -{ - return p[-3] & 31; -} - -static inline struct meta *get_meta(const unsigned char *p) -{ - assert(!((uintptr_t)p & 15)); - int offset = *(const uint16_t *)(p - 2); - int index = get_slot_index(p); - if (p[-4]) { - assert(!offset); - offset = *(uint32_t *)(p - 8); - assert(offset > 0xffff); - } - const struct group *base = (const void *)(p - UNIT*offset - UNIT); - const struct meta *meta = base->meta; - assert(meta->mem == base); - assert(index <= meta->last_idx); - assert(!(meta->avail_mask & (1u<freed_mask & (1u<check == ctx.secret); - if (meta->sizeclass < 48) { - assert(offset >= size_classes[meta->sizeclass]*index); - assert(offset < size_classes[meta->sizeclass]*(index+1)); - } else { - assert(meta->sizeclass == 63); - } - if (meta->maplen) { - assert(offset <= meta->maplen*4096UL/UNIT - 1); - } - return (struct meta *)meta; -} - -static inline size_t get_nominal_size(const unsigned char *p, const unsigned char *end) -{ - size_t reserved = p[-3] >> 5; - if (reserved >= 5) { - assert(reserved == 5); - reserved = *(const uint32_t *)(end-4); - assert(reserved >= 5); - assert(!end[-5]); - } - assert(reserved <= end-p); - assert(!*(end-reserved)); - // also check the slot's overflow byte - assert(!*end); - return end-reserved-p; -} - -static inline size_t get_stride(const struct meta *g) -{ - if (!g->last_idx && g->maplen) { - return g->maplen*4096UL - UNIT; - } else { - return UNIT*size_classes[g->sizeclass]; - } -} - -static inline void set_size(unsigned char *p, unsigned char *end, size_t n) -{ - int reserved = end-p-n; - if (reserved) end[-reserved] = 0; - if (reserved >= 5) { - *(uint32_t *)(end-4) = reserved; - end[-5] = 0; - reserved = 5; - } - p[-3] = (p[-3]&31) + (reserved<<5); -} - -static inline void *enframe(struct meta *g, int idx, size_t n, int ctr) -{ - size_t stride = get_stride(g); - size_t slack = (stride-IB-n)/UNIT; - unsigned char *p = g->mem->storage + stride*idx; - unsigned char *end = p+stride-IB; - // cycle offset within slot to increase interval to address - // reuse, facilitate trapping double-free. - int off = (p[-3] ? *(uint16_t *)(p-2) + 1 : ctr) & 255; - assert(!p[-4]); - if (off > slack) { - size_t m = slack; - m |= m>>1; m |= m>>2; m |= m>>4; - off &= m; - if (off > slack) off -= slack+1; - assert(off <= slack); - } - if (off) { - // store offset in unused header at offset zero - // if enframing at non-zero offset. - *(uint16_t *)(p-2) = off; - p[-3] = 7<<5; - p += UNIT*off; - // for nonzero offset there is no permanent check - // byte, so make one. - p[-4] = 0; - } - *(uint16_t *)(p-2) = (size_t)(p-g->mem->storage)/UNIT; - p[-3] = idx; - set_size(p, end, n); - return p; -} - -static inline int size_to_class(size_t n) -{ - n = (n+IB-1)>>4; - if (n<10) return n; - n++; - int i = (28-a_clz_32(n))*4 + 8; - if (n>size_classes[i+1]) i+=2; - if (n>size_classes[i]) i++; - return i; -} - -static inline int size_overflows(size_t n) -{ - if (n >= SIZE_MAX/2 - 4096) { - errno = ENOMEM; - return 1; - } - return 0; -} - -static inline void step_seq(void) -{ - if (ctx.seq==255) { - for (int i=0; i<32; i++) ctx.unmap_seq[i] = 0; - ctx.seq = 1; - } else { - ctx.seq++; - } -} - -static inline void record_seq(int sc) -{ - if (sc-7U < 32) ctx.unmap_seq[sc-7] = ctx.seq; -} - -static inline void account_bounce(int sc) -{ - if (sc-7U < 32) { - int seq = ctx.unmap_seq[sc-7]; - if (seq && ctx.seq-seq < 10) { - if (ctx.bounces[sc-7]+1 < 100) - ctx.bounces[sc-7]++; - else - ctx.bounces[sc-7] = 150; - } - } -} - -static inline void decay_bounces(int sc) -{ - if (sc-7U < 32 && ctx.bounces[sc-7]) - ctx.bounces[sc-7]--; -} - -static inline int is_bouncing(int sc) -{ - return (sc-7U < 32 && ctx.bounces[sc-7] >= 100); -} - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc_impl.h b/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc_impl.h deleted file mode 100644 index e1cf4774c1e4..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc_impl.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef MALLOC_IMPL_H -#define MALLOC_IMPL_H - -#include -#include "dynlink.h" - -struct chunk { - size_t psize, csize; - struct chunk *next, *prev; -}; - -struct bin { - volatile int lock[2]; - struct chunk *head; - struct chunk *tail; -}; - -#define SIZE_ALIGN (4*sizeof(size_t)) -#define SIZE_MASK (-SIZE_ALIGN) -#define OVERHEAD (2*sizeof(size_t)) -#define MMAP_THRESHOLD (0x1c00*SIZE_ALIGN) -#define DONTCARE 16 -#define RECLAIM 163840 - -#define CHUNK_SIZE(c) ((c)->csize & -2) -#define CHUNK_PSIZE(c) ((c)->psize & -2) -#define PREV_CHUNK(c) ((struct chunk *)((char *)(c) - CHUNK_PSIZE(c))) -#define NEXT_CHUNK(c) ((struct chunk *)((char *)(c) + CHUNK_SIZE(c))) -#define MEM_TO_CHUNK(p) (struct chunk *)((char *)(p) - OVERHEAD) -#define CHUNK_TO_MEM(c) (void *)((char *)(c) + OVERHEAD) -#define BIN_TO_CHUNK(i) (MEM_TO_CHUNK(&mal.bins[i].head)) - -#define C_INUSE ((size_t)1) - -#define IS_MMAPPED(c) !((c)->csize & (C_INUSE)) - -hidden void __bin_chunk(struct chunk *); - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/realpath.c b/lib/libc/wasi/libc-top-half/musl/src/misc/realpath.c new file mode 100644 index 000000000000..db8b74dc8dbb --- /dev/null +++ b/lib/libc/wasi/libc-top-half/musl/src/misc/realpath.c @@ -0,0 +1,156 @@ +#include +#include +#include +#include +#include + +static size_t slash_len(const char *s) +{ + const char *s0 = s; + while (*s == '/') s++; + return s-s0; +} + +char *realpath(const char *restrict filename, char *restrict resolved) +{ + char stack[PATH_MAX+1]; + char output[PATH_MAX]; + size_t p, q, l, l0, cnt=0, nup=0; + int check_dir=0; + + if (!filename) { + errno = EINVAL; + return 0; + } + l = strnlen(filename, sizeof stack); + if (!l) { + errno = ENOENT; + return 0; + } + if (l >= PATH_MAX) goto toolong; + p = sizeof stack - l - 1; + q = 0; + memcpy(stack+p, filename, l+1); + + /* Main loop. Each iteration pops the next part from stack of + * remaining path components and consumes any slashes that follow. + * If not a link, it's moved to output; if a link, contents are + * pushed to the stack. */ +restart: + for (; ; p+=slash_len(stack+p)) { + /* If stack starts with /, the whole component is / or // + * and the output state must be reset. */ + if (stack[p] == '/') { + check_dir=0; + nup=0; + q=0; + output[q++] = '/'; + p++; + /* Initial // is special. */ + if (stack[p] == '/' && stack[p+1] != '/') + output[q++] = '/'; + continue; + } + + char *z = __strchrnul(stack+p, '/'); + l0 = l = z-(stack+p); + + if (!l && !check_dir) break; + + /* Skip any . component but preserve check_dir status. */ + if (l==1 && stack[p]=='.') { + p += l; + continue; + } + + /* Copy next component onto output at least temporarily, to + * call readlink, but wait to advance output position until + * determining it's not a link. */ + if (q && output[q-1] != '/') { + if (!p) goto toolong; + stack[--p] = '/'; + l++; + } + if (q+l >= PATH_MAX) goto toolong; + memcpy(output+q, stack+p, l); + output[q+l] = 0; + p += l; + + int up = 0; + if (l0==2 && stack[p-2]=='.' && stack[p-1]=='.') { + up = 1; + /* Any non-.. path components we could cancel start + * after nup repetitions of the 3-byte string "../"; + * if there are none, accumulate .. components to + * later apply to cwd, if needed. */ + if (q <= 3*nup) { + nup++; + q += l; + continue; + } + /* When previous components are already known to be + * directories, processing .. can skip readlink. */ + if (!check_dir) goto skip_readlink; + } + ssize_t k = readlink(output, stack, p); + if (k==p) goto toolong; + if (!k) { + errno = ENOENT; + return 0; + } + if (k<0) { + if (errno != EINVAL) return 0; +skip_readlink: + check_dir = 0; + if (up) { + while(q && output[q-1]!='/') q--; + if (q>1 && (q>2 || output[0]!='/')) q--; + continue; + } + if (l0) q += l; + check_dir = stack[p]; + continue; + } + if (++cnt == SYMLOOP_MAX) { + errno = ELOOP; + return 0; + } + + /* If link contents end in /, strip any slashes already on + * stack to avoid /->// or //->/// or spurious toolong. */ + if (stack[k-1]=='/') while (stack[p]=='/') p++; + p -= k; + memmove(stack+p, stack, k); + + /* Skip the stack advancement in case we have a new + * absolute base path. */ + goto restart; + } + + output[q] = 0; + + if (output[0] != '/') { + if (!getcwd(stack, sizeof stack)) return 0; + l = strlen(stack); + /* Cancel any initial .. components. */ + p = 0; + while (nup--) { + while(l>1 && stack[l-1]!='/') l--; + if (l>1) l--; + p += 2; + if (p= PATH_MAX) goto toolong; + memmove(output + l, output + p, q - p + 1); + memcpy(output, stack, l); + q = l + q-p; + } + + if (resolved) return memcpy(resolved, output, q+1); + else return strdup(output); + +toolong: + errno = ENAMETOOLONG; + return 0; +} diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/nscd.h b/lib/libc/wasi/libc-top-half/musl/src/passwd/nscd.h deleted file mode 100644 index ae5aa8d5dbfa..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/passwd/nscd.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef NSCD_H -#define NSCD_H - -#include - -#define NSCDVERSION 2 -#define GETPWBYNAME 0 -#define GETPWBYUID 1 -#define GETGRBYNAME 2 -#define GETGRBYGID 3 -#define GETINITGR 15 - -#define REQVERSION 0 -#define REQTYPE 1 -#define REQKEYLEN 2 -#define REQ_LEN 3 - -#define PWVERSION 0 -#define PWFOUND 1 -#define PWNAMELEN 2 -#define PWPASSWDLEN 3 -#define PWUID 4 -#define PWGID 5 -#define PWGECOSLEN 6 -#define PWDIRLEN 7 -#define PWSHELLLEN 8 -#define PW_LEN 9 - -#define GRVERSION 0 -#define GRFOUND 1 -#define GRNAMELEN 2 -#define GRPASSWDLEN 3 -#define GRGID 4 -#define GRMEMCNT 5 -#define GR_LEN 6 - -#define INITGRVERSION 0 -#define INITGRFOUND 1 -#define INITGRNGRPS 2 -#define INITGR_LEN 3 - -hidden FILE *__nscd_query(int32_t req, const char *key, int32_t *buf, size_t len, int *swap); - -#endif diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/pwf.h b/lib/libc/wasi/libc-top-half/musl/src/passwd/pwf.h deleted file mode 100644 index 95bb6e0534c1..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/passwd/pwf.h +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -hidden int __getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *size, struct passwd **res); -hidden int __getpw_a(const char *name, uid_t uid, struct passwd *pw, char **buf, size_t *size, struct passwd **res); -hidden int __getgrent_a(FILE *f, struct group *gr, char **line, size_t *size, char ***mem, size_t *nmem, struct group **res); -hidden int __getgr_a(const char *name, gid_t gid, struct group *gr, char **buf, size_t *size, char ***mem, size_t *nmem, struct group **res); -hidden int __parsespent(char *s, struct spwd *sp); diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/fdop.h b/lib/libc/wasi/libc-top-half/musl/src/process/fdop.h deleted file mode 100644 index 7cf733b21dc1..000000000000 --- a/lib/libc/wasi/libc-top-half/musl/src/process/fdop.h +++ /dev/null @@ -1,17 +0,0 @@ -#define FDOP_CLOSE 1 -#define FDOP_DUP2 2 -#define FDOP_OPEN 3 -#define FDOP_CHDIR 4 -#define FDOP_FCHDIR 5 - -struct fdop { - struct fdop *next, *prev; - int cmd, fd, srcfd, oflag; - mode_t mode; - char path[]; -}; - -#define malloc __libc_malloc -#define calloc __libc_calloc -#define realloc undef -#define free __libc_free diff --git a/src/wasi_libc.zig b/src/wasi_libc.zig index a44a187e8f6f..bd63b1bd93b3 100644 --- a/src/wasi_libc.zig +++ b/src/wasi_libc.zig @@ -490,7 +490,7 @@ const libc_bottom_half_src_files = [_][]const u8{ "wasi/libc-bottom-half/sources/__wasilibc_tell.c", "wasi/libc-bottom-half/sources/__wasilibc_unlinkat.c", "wasi/libc-bottom-half/sources/abort.c", - "wasi/libc-bottom-half/sources/accept.c", + "wasi/libc-bottom-half/sources/accept-wasip1.c", "wasi/libc-bottom-half/sources/at_fdcwd.c", "wasi/libc-bottom-half/sources/complex-builtins.c", "wasi/libc-bottom-half/sources/environ.c", @@ -521,6 +521,7 @@ const libc_top_half_src_files = [_][]const u8{ "wasi/libc-top-half/musl/src/misc/getopt.c", "wasi/libc-top-half/musl/src/misc/getopt_long.c", "wasi/libc-top-half/musl/src/misc/getsubopt.c", + "wasi/libc-top-half/musl/src/misc/realpath.c", "wasi/libc-top-half/musl/src/misc/uname.c", "wasi/libc-top-half/musl/src/misc/nftw.c", "wasi/libc-top-half/musl/src/errno/strerror.c", From 8a8da49b5212030d603000d699a8ca9ed92e24cd Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 12 Apr 2024 22:51:52 +0200 Subject: [PATCH 2/3] Re-add lazy preopen changes --- lib/libc/include/wasm-wasi-musl/wasi/libc.h | 4 + .../cloudlibc/src/libc/unistd/close.c | 0 .../sources/__wasilibc_fd_renumber.c | 3 + .../wasi/libc-bottom-half/sources/preopens.c | 111 ++++++++++++++++-- src/wasi_libc.zig | 1 - 5 files changed, 109 insertions(+), 10 deletions(-) delete mode 100644 lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/unistd/close.c diff --git a/lib/libc/include/wasm-wasi-musl/wasi/libc.h b/lib/libc/include/wasm-wasi-musl/wasi/libc.h index 18d8e9e3cba0..6acb672ad0b2 100644 --- a/lib/libc/include/wasm-wasi-musl/wasi/libc.h +++ b/lib/libc/include/wasm-wasi-musl/wasi/libc.h @@ -17,6 +17,10 @@ struct timespec; /// afterward, you should call this before doing so. void __wasilibc_populate_preopens(void); +/// Reset the preopens table to an uninitialized state, forcing it to be +/// reinitialized next time it is needed. +void __wasilibc_reset_preopens(void); + /// Register the given pre-opened file descriptor under the given path. /// /// This function does not take ownership of `prefix` (it makes its own copy). diff --git a/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/unistd/close.c b/lib/libc/wasi/libc-bottom-half/cloudlibc/src/libc/unistd/close.c deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_fd_renumber.c b/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_fd_renumber.c index d5247518c693..7690d1359eac 100644 --- a/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_fd_renumber.c +++ b/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_fd_renumber.c @@ -4,6 +4,9 @@ #include int __wasilibc_fd_renumber(int fd, int newfd) { + // Scan the preopen fds before making any changes. + __wasilibc_populate_preopens(); + __wasi_errno_t error = __wasi_fd_renumber(fd, newfd); if (error != 0) { errno = error; diff --git a/lib/libc/wasi/libc-bottom-half/sources/preopens.c b/lib/libc/wasi/libc-bottom-half/sources/preopens.c index a49ca3e9ad05..a7ebe646b902 100644 --- a/lib/libc/wasi/libc-bottom-half/sources/preopens.c +++ b/lib/libc/wasi/libc-bottom-half/sources/preopens.c @@ -25,6 +25,7 @@ typedef struct preopen { } preopen; /// A simple growable array of `preopen`. +static _Atomic _Bool preopens_populated = false; static preopen *preopens; static size_t num_preopens; static size_t preopen_capacity; @@ -100,12 +101,9 @@ static const char *strip_prefixes(const char *path) { return path; } -/// Register the given preopened file descriptor under the given path. -/// -/// This function takes ownership of `prefix`. -static int internal_register_preopened_fd(__wasi_fd_t fd, const char *relprefix) { - LOCK(lock); - +/// Similar to `internal_register_preopened_fd_unlocked` but does not +/// take a lock. +static int internal_register_preopened_fd_unlocked(__wasi_fd_t fd, const char *relprefix) { // Check preconditions. assert_invariants(); assert(fd != AT_FDCWD); @@ -113,22 +111,32 @@ static int internal_register_preopened_fd(__wasi_fd_t fd, const char *relprefix) assert(relprefix != NULL); if (num_preopens == preopen_capacity && resize() != 0) { - UNLOCK(lock); return -1; } char *prefix = strdup(strip_prefixes(relprefix)); if (prefix == NULL) { - UNLOCK(lock); return -1; } preopens[num_preopens++] = (preopen) { prefix, fd, }; assert_invariants(); - UNLOCK(lock); return 0; } +/// Register the given preopened file descriptor under the given path. +/// +/// This function takes ownership of `prefix`. +static int internal_register_preopened_fd(__wasi_fd_t fd, const char *relprefix) { + LOCK(lock); + + int r = internal_register_preopened_fd_unlocked(fd, relprefix); + + UNLOCK(lock); + + return r; +} + /// Are the `prefix_len` bytes pointed to by `prefix` a prefix of `path`? static bool prefix_matches(const char *prefix, size_t prefix_len, const char *path) { // Allow an empty string as a prefix of any relative path. @@ -152,6 +160,8 @@ static bool prefix_matches(const char *prefix, size_t prefix_len, const char *pa // See the documentation in libc.h int __wasilibc_register_preopened_fd(int fd, const char *prefix) { + __wasilibc_populate_preopens(); + return internal_register_preopened_fd((__wasi_fd_t)fd, prefix); } @@ -172,6 +182,8 @@ int __wasilibc_find_relpath(const char *path, int __wasilibc_find_abspath(const char *path, const char **abs_prefix, const char **relative_path) { + __wasilibc_populate_preopens(); + // Strip leading `/` characters, the prefixes we're mataching won't have // them. while (*path == '/') @@ -218,3 +230,84 @@ int __wasilibc_find_abspath(const char *path, *relative_path = computed; return fd; } + +__attribute__((constructor(51))) +void __wasilibc_populate_preopens(void) { + // Fast path: If the preopens are already initialized, do nothing. + if (preopens_populated) { + return; + } + + LOCK(lock); + + // Check whether another thread initialized the preopens already. + if (preopens_populated) { + UNLOCK(lock); + return; + } + + // Skip stdin, stdout, and stderr, and count up until we reach an invalid + // file descriptor. + for (__wasi_fd_t fd = 3; fd != 0; ++fd) { + __wasi_prestat_t prestat; + __wasi_errno_t ret = __wasi_fd_prestat_get(fd, &prestat); + if (ret == __WASI_ERRNO_BADF) + break; + if (ret != __WASI_ERRNO_SUCCESS) + goto oserr; + switch (prestat.tag) { + case __WASI_PREOPENTYPE_DIR: { + char *prefix = malloc(prestat.u.dir.pr_name_len + 1); + if (prefix == NULL) + goto software; + + // TODO: Remove the cast on `prefix` once the witx is updated with + // char8 support. + ret = __wasi_fd_prestat_dir_name(fd, (uint8_t *)prefix, + prestat.u.dir.pr_name_len); + if (ret != __WASI_ERRNO_SUCCESS) + goto oserr; + prefix[prestat.u.dir.pr_name_len] = '\0'; + + if (internal_register_preopened_fd_unlocked(fd, prefix) != 0) + goto software; + free(prefix); + + break; + } + default: + break; + } + } + + // Preopens are now initialized. + preopens_populated = true; + + UNLOCK(lock); + + return; +oserr: + _Exit(EX_OSERR); +software: + _Exit(EX_SOFTWARE); +} + +void __wasilibc_reset_preopens(void) { + LOCK(lock); + + if (num_preopens) { + for (int i = 0; i < num_preopens; ++i) { + free((void*) preopens[i].prefix); + } + free(preopens); + } + + preopens_populated = false; + preopens = NULL; + num_preopens = 0; + preopen_capacity = 0; + + assert_invariants(); + + UNLOCK(lock); +} diff --git a/src/wasi_libc.zig b/src/wasi_libc.zig index bd63b1bd93b3..97a435c26ca9 100644 --- a/src/wasi_libc.zig +++ b/src/wasi_libc.zig @@ -463,7 +463,6 @@ const libc_bottom_half_src_files = [_][]const u8{ "wasi/libc-bottom-half/cloudlibc/src/libc/time/clock_nanosleep.c", "wasi/libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c", "wasi/libc-bottom-half/cloudlibc/src/libc/time/time.c", - "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/close.c", "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/faccessat.c", "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/fdatasync.c", "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/fsync.c", From e60072635eca3f3c983d92819aa67c0decc7d4a6 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 18 Apr 2024 21:47:47 +0200 Subject: [PATCH 3/3] Add libdl shims from wasi-libc --- lib/libc/include/wasm-wasi-musl/dlfcn.h | 56 +++++++++++++++++++ .../wasi/libc-top-half/musl/src/misc/dl.c | 45 +++++++++++++++ src/Compilation.zig | 1 + src/wasi_libc.zig | 28 ++++++++++ 4 files changed, 130 insertions(+) create mode 100644 lib/libc/include/wasm-wasi-musl/dlfcn.h create mode 100644 lib/libc/wasi/libc-top-half/musl/src/misc/dl.c diff --git a/lib/libc/include/wasm-wasi-musl/dlfcn.h b/lib/libc/include/wasm-wasi-musl/dlfcn.h new file mode 100644 index 000000000000..e802de88f671 --- /dev/null +++ b/lib/libc/include/wasm-wasi-musl/dlfcn.h @@ -0,0 +1,56 @@ +#ifndef _DLFCN_H +#define _DLFCN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define RTLD_LAZY 1 +#define RTLD_NOW 2 +#define RTLD_NOLOAD 4 +#define RTLD_NODELETE 4096 +#define RTLD_GLOBAL 256 +#ifdef __wasilibc_unmodified_upstream +#define RTLD_LOCAL 0 +#else +/* For WASI, we give `RTLD_LOCAL` a non-zero value, avoiding ambiguity and + * allowing us to defer the decision of whether `RTLD_LOCAL` or `RTLD_GLOBAL` + * should be the default when neither is specified. + */ +#define RTLD_LOCAL 8 +#endif + +#define RTLD_NEXT ((void *)-1) +#define RTLD_DEFAULT ((void *)0) + +#ifdef __wasilibc_unmodified_upstream +#define RTLD_DI_LINKMAP 2 +#endif + +int dlclose(void *); +char *dlerror(void); +void *dlopen(const char *, int); +void *dlsym(void *__restrict, const char *__restrict); + +#if defined(__wasilibc_unmodified_upstream) && (defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) +typedef struct { + const char *dli_fname; + void *dli_fbase; + const char *dli_sname; + void *dli_saddr; +} Dl_info; +int dladdr(const void *, Dl_info *); +int dlinfo(void *, int, void *); +#endif + +#if _REDIR_TIME64 +__REDIR(dlsym, __dlsym_time64); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/dl.c b/lib/libc/wasi/libc-top-half/musl/src/misc/dl.c new file mode 100644 index 000000000000..266594fd1fd6 --- /dev/null +++ b/lib/libc/wasi/libc-top-half/musl/src/misc/dl.c @@ -0,0 +1,45 @@ +/* This file is used to build libdl.so with stub versions of `dlopen`, `dlsym`, + * etc. The intention is that this stubbed libdl.so can be used to build + * libraries and applications which use `dlopen` without committing to a + * specific runtime implementation. Later, it can be replaced with a real, + * working libdl.so (e.g. at runtime or component composition time). + * + * For example, the `wasm-tools component link` subcommand can be used to create + * a component that bundles any `dlopen`-able libraries in such a way that their + * function exports can be resolved symbolically at runtime using an + * implementation of libdl.so designed for that purpose. In other cases, a + * runtime might provide Emscripten-style dynamic linking via URLs or else a + * more traditional, filesystem-based implementation. Finally, even this + * stubbed version of libdl.so can be used at runtime in cases where dynamic + * library resolution cannot or should not be supported (and the application can + * handle this situation gracefully). */ + +#include +#include + +static const char *error = NULL; + +weak int dlclose(void *library) +{ + error = "dlclose not implemented"; + return -1; +} + +weak char *dlerror(void) +{ + const char *var = error; + error = NULL; + return (char*) var; +} + +weak void *dlopen(const char *name, int flags) +{ + error = "dlopen not implemented"; + return NULL; +} + +weak void *dlsym(void *library, const char *name) +{ + error = "dlsym not implemented"; + return NULL; +} diff --git a/src/Compilation.zig b/src/Compilation.zig index 1362b16cc992..8b1247442289 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -806,6 +806,7 @@ pub const MiscTask = enum { @"wasi crt1-reactor.o", @"wasi crt1-command.o", @"wasi libc.a", + @"wasi libdl.a", @"libwasi-emulated-process-clocks.a", @"libwasi-emulated-getpid.a", @"libwasi-emulated-mman.a", diff --git a/src/wasi_libc.zig b/src/wasi_libc.zig index 97a435c26ca9..05ae41954acd 100644 --- a/src/wasi_libc.zig +++ b/src/wasi_libc.zig @@ -10,6 +10,7 @@ pub const CrtFile = enum { crt1_reactor_o, crt1_command_o, libc_a, + libdl_a, libwasi_emulated_process_clocks_a, libwasi_emulated_getpid_a, libwasi_emulated_mman_a, @@ -17,6 +18,9 @@ pub const CrtFile = enum { }; pub fn getEmulatedLibCrtFile(lib_name: []const u8) ?CrtFile { + if (mem.eql(u8, lib_name, "dl")) { + return .libdl_a; + } if (mem.eql(u8, lib_name, "wasi-emulated-process-clocks")) { return .libwasi_emulated_process_clocks_a; } @@ -34,6 +38,7 @@ pub fn getEmulatedLibCrtFile(lib_name: []const u8) ?CrtFile { pub fn emulatedLibCRFileLibName(crt_file: CrtFile) []const u8 { return switch (crt_file) { + .libdl_a => "libdl.a", .libwasi_emulated_process_clocks_a => "libwasi-emulated-process-clocks.a", .libwasi_emulated_getpid_a => "libwasi-emulated-getpid.a", .libwasi_emulated_mman_a => "libwasi-emulated-mman.a", @@ -154,6 +159,25 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre try comp.build_crt_file("c", .Lib, .@"wasi libc.a", prog_node, libc_sources.items, .{}); }, + + .libdl_a => { + var args = std.ArrayList([]const u8).init(arena); + try addCCArgs(comp, arena, &args, .{ .want_O3 = true }); + try addLibcBottomHalfIncludes(comp, arena, &args); + + var emu_dl_sources = std.ArrayList(Compilation.CSourceFile).init(arena); + for (emulated_dl_src_files) |file_path| { + try emu_dl_sources.append(.{ + .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ + "libc", try sanitize(arena, file_path), + }), + .extra_flags = args.items, + .owner = undefined, + }); + } + try comp.build_crt_file("dl", .Lib, .@"wasi libdl.a", prog_node, emu_dl_sources.items, .{}); + }, + .libwasi_emulated_process_clocks_a => { var args = std.ArrayList([]const u8).init(arena); try addCCArgs(comp, arena, &args, .{ .want_O3 = true }); @@ -1173,6 +1197,10 @@ const libc_top_half_src_files = [_][]const u8{ const crt1_command_src_file = "wasi/libc-bottom-half/crt/crt1-command.c"; const crt1_reactor_src_file = "wasi/libc-bottom-half/crt/crt1-reactor.c"; +const emulated_dl_src_files = &[_][]const u8{ + "wasi/libc-top-half/musl/src/misc/dl.c", +}; + const emulated_process_clocks_src_files = &[_][]const u8{ "wasi/libc-bottom-half/clocks/clock.c", "wasi/libc-bottom-half/clocks/getrusage.c",