summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/include
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 16:08:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 16:08:03 +0000
commitf1db79e6e5c383cf76f3bf0dd42115d19591a72b (patch)
tree3f9509008e8a130c45b7e31b1520d66d720493ec /libc-top-half/musl/include
parentAdding upstream version 0.0~git20230821.ec4566b. (diff)
downloadwasi-libc-f1db79e6e5c383cf76f3bf0dd42115d19591a72b.tar.xz
wasi-libc-f1db79e6e5c383cf76f3bf0dd42115d19591a72b.zip
Adding upstream version 0.0~git20240411.9e8c542.upstream/0.0_git20240411.9e8c542upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libc-top-half/musl/include')
-rw-r--r--libc-top-half/musl/include/dlfcn.h12
-rw-r--r--libc-top-half/musl/include/netdb.h5
-rw-r--r--libc-top-half/musl/include/pthread.h2
-rw-r--r--libc-top-half/musl/include/setjmp.h10
-rw-r--r--libc-top-half/musl/include/stdlib.h2
-rw-r--r--libc-top-half/musl/include/sys/socket.h18
-rw-r--r--libc-top-half/musl/include/sys/stat.h2
7 files changed, 36 insertions, 15 deletions
diff --git a/libc-top-half/musl/include/dlfcn.h b/libc-top-half/musl/include/dlfcn.h
index 13ab71d..e802de8 100644
--- a/libc-top-half/musl/include/dlfcn.h
+++ b/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/libc-top-half/musl/include/netdb.h b/libc-top-half/musl/include/netdb.h
index d096c78..f9797bc 100644
--- a/libc-top-half/musl/include/netdb.h
+++ b/libc-top-half/musl/include/netdb.h
@@ -118,8 +118,13 @@ struct hostent *gethostbyaddr (const void *, socklen_t, int);
#ifdef __GNUC__
__attribute__((const))
#endif
+#ifdef __wasilibc_unmodified_upstream
int *__h_errno_location(void);
#define h_errno (*__h_errno_location())
+#elif (defined __wasilibc_use_wasip2)
+extern _Thread_local int h_errno;
+#define h_errno h_errno
+#endif
#define HOST_NOT_FOUND 1
#define TRY_AGAIN 2
#define NO_RECOVERY 3
diff --git a/libc-top-half/musl/include/pthread.h b/libc-top-half/musl/include/pthread.h
index 05101e8..2c35d0b 100644
--- a/libc-top-half/musl/include/pthread.h
+++ b/libc-top-half/musl/include/pthread.h
@@ -97,7 +97,9 @@ int pthread_equal(pthread_t, pthread_t);
int pthread_setcancelstate(int, int *);
int pthread_setcanceltype(int, int *);
void pthread_testcancel(void);
+#ifdef __wasilibc_unmodified_upstream /* WASI has no cancellation support. */
int pthread_cancel(pthread_t);
+#endif
#ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */
int pthread_getschedparam(pthread_t, int *__restrict, struct sched_param *__restrict);
diff --git a/libc-top-half/musl/include/setjmp.h b/libc-top-half/musl/include/setjmp.h
index f505f8e..b57999e 100644
--- a/libc-top-half/musl/include/setjmp.h
+++ b/libc-top-half/musl/include/setjmp.h
@@ -7,7 +7,12 @@ extern "C" {
#include <features.h>
-#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 <bits/setjmp.h>
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/libc-top-half/musl/include/stdlib.h b/libc-top-half/musl/include/stdlib.h
index 1bcb9ab..553e9ae 100644
--- a/libc-top-half/musl/include/stdlib.h
+++ b/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/libc-top-half/musl/include/sys/socket.h b/libc-top-half/musl/include/sys/socket.h
index 4d574c6..29189e3 100644
--- a/libc-top-half/musl/include/sys/socket.h
+++ b/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/libc-top-half/musl/include/sys/stat.h b/libc-top-half/musl/include/sys/stat.h
index 72e1626..c0090f7 100644
--- a/libc-top-half/musl/include/sys/stat.h
+++ b/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