From f1db79e6e5c383cf76f3bf0dd42115d19591a72b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 26 Jun 2024 18:08:03 +0200 Subject: Adding upstream version 0.0~git20240411.9e8c542. Signed-off-by: Daniel Baumann --- libc-top-half/musl/src/thread/pthread_create.c | 17 +++++++++++------ libc-top-half/musl/src/thread/pthread_getattr_np.c | 6 ++++++ 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'libc-top-half/musl/src/thread') diff --git a/libc-top-half/musl/src/thread/pthread_create.c b/libc-top-half/musl/src/thread/pthread_create.c index 5de9f5a..450fe15 100644 --- a/libc-top-half/musl/src/thread/pthread_create.c +++ b/libc-top-half/musl/src/thread/pthread_create.c @@ -13,6 +13,7 @@ #endif #include +#include static void dummy_0() { @@ -558,13 +559,17 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att __wait(&args->control, 0, 3, 0); } #else +#define WASI_THREADS_MAX_TID 0x1FFFFFFF /* `wasi_thread_spawn` will either return a host-provided thread ID (TID) - * (`>= 0`) or an error code (`< 0`). As in the unmodified version, all - * spawn failures translate to EAGAIN; unlike the modified version, there is - * no need to "start up" the child thread--the host does this. If the spawn - * did succeed, then we store the TID atomically, since this parent thread - * is racing with the child thread to set this field; this way, whichever - * thread reaches this point first can continue without waiting. */ + * (`<1, 0x1FFFFFFF>`) or an error code (`< 0`). Please note that `0` is + * reserved for compatibility reasons and must not be returned by the runtime. + * As in the unmodified version, all spawn failures translate to EAGAIN; + * unlike the modified version, there is no need to "start up" the child + * thread--the host does this. If the spawn did succeed, then we store the + * TID atomically, since this parent thread is racing with the child thread + * to set this field; this way, whichever thread reaches this point first + * can continue without waiting. */ + assert(ret != 0 && ret <= WASI_THREADS_MAX_TID); if (ret < 0) { ret = -EAGAIN; } else { diff --git a/libc-top-half/musl/src/thread/pthread_getattr_np.c b/libc-top-half/musl/src/thread/pthread_getattr_np.c index 2881831..c23e5d7 100644 --- a/libc-top-half/musl/src/thread/pthread_getattr_np.c +++ b/libc-top-half/musl/src/thread/pthread_getattr_np.c @@ -1,7 +1,9 @@ #define _GNU_SOURCE #include "pthread_impl.h" #include "libc.h" +#ifdef __wasilibc_unmodified_upstream #include +#endif int pthread_getattr_np(pthread_t t, pthread_attr_t *a) { @@ -12,6 +14,7 @@ int pthread_getattr_np(pthread_t t, pthread_attr_t *a) a->_a_stackaddr = (uintptr_t)t->stack; a->_a_stacksize = t->stack_size; } else { +#ifdef __wasilibc_unmodified_upstream char *p = (void *)libc.auxv; size_t l = PAGE_SIZE; p += -(uintptr_t)p & PAGE_SIZE-1; @@ -19,6 +22,9 @@ int pthread_getattr_np(pthread_t t, pthread_attr_t *a) while (mremap(p-l-PAGE_SIZE, PAGE_SIZE, 2*PAGE_SIZE, 0)==MAP_FAILED && errno==ENOMEM) l += PAGE_SIZE; a->_a_stacksize = l; +#else + return ENOSYS; +#endif } return 0; } -- cgit v1.2.3