From 421005cd633c809d2f7ab888b79c2eba8844c1b1 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Wed, 11 Feb 2026 13:03:12 +0000 Subject: [PATCH 01/43] Restructure thread impls --- libc-top-half/CMakeLists.txt | 140 +++++++++--------- libc-top-half/musl/src/thread/README.md | 6 + .../src/thread/aarch64/__set_thread_area.s | 7 - .../musl/src/thread/aarch64/__unmapself.s | 7 - libc-top-half/musl/src/thread/aarch64/clone.s | 30 ---- .../musl/src/thread/aarch64/syscall_cp.s | 32 ---- .../musl/src/thread/arm/__aeabi_read_tp.s | 10 -- .../musl/src/thread/arm/__set_thread_area.c | 52 ------- .../musl/src/thread/arm/__unmapself.s | 9 -- libc-top-half/musl/src/thread/arm/atomics.s | 106 ------------- libc-top-half/musl/src/thread/arm/clone.s | 28 ---- .../musl/src/thread/arm/syscall_cp.s | 29 ---- .../musl/src/thread/i386/__set_thread_area.s | 47 ------ .../musl/src/thread/i386/__unmapself.s | 11 -- libc-top-half/musl/src/thread/i386/clone.s | 49 ------ .../musl/src/thread/i386/syscall_cp.s | 41 ----- libc-top-half/musl/src/thread/i386/tls.s | 9 -- .../thread/loongarch64/__set_thread_area.s | 7 - .../musl/src/thread/loongarch64/__unmapself.s | 7 - .../musl/src/thread/loongarch64/clone.s | 29 ---- .../musl/src/thread/loongarch64/syscall_cp.s | 29 ---- .../musl/src/thread/m68k/__m68k_read_tp.s | 8 - libc-top-half/musl/src/thread/m68k/clone.s | 25 ---- .../musl/src/thread/m68k/syscall_cp.s | 26 ---- .../src/thread/microblaze/__set_thread_area.s | 7 - .../musl/src/thread/microblaze/__unmapself.s | 8 - .../musl/src/thread/microblaze/clone.s | 30 ---- .../musl/src/thread/microblaze/syscall_cp.s | 27 ---- .../musl/src/thread/mips/__unmapself.s | 10 -- libc-top-half/musl/src/thread/mips/clone.s | 36 ----- .../musl/src/thread/mips/syscall_cp.s | 53 ------- .../musl/src/thread/mips64/__unmapself.s | 9 -- libc-top-half/musl/src/thread/mips64/clone.s | 34 ----- .../musl/src/thread/mips64/syscall_cp.s | 52 ------- .../musl/src/thread/mipsn32/__unmapself.s | 9 -- libc-top-half/musl/src/thread/mipsn32/clone.s | 34 ----- .../musl/src/thread/mipsn32/syscall_cp.s | 51 ------- .../musl/src/thread/or1k/__set_thread_area.s | 7 - .../musl/src/thread/or1k/__unmapself.s | 8 - libc-top-half/musl/src/thread/or1k/clone.s | 31 ---- .../musl/src/thread/or1k/syscall_cp.s | 29 ---- .../src/thread/powerpc/__set_thread_area.s | 12 -- .../musl/src/thread/powerpc/__unmapself.s | 9 -- libc-top-half/musl/src/thread/powerpc/clone.s | 73 --------- .../musl/src/thread/powerpc/syscall_cp.s | 59 -------- .../src/thread/powerpc64/__set_thread_area.s | 9 -- .../musl/src/thread/powerpc64/__unmapself.s | 9 -- .../musl/src/thread/powerpc64/clone.s | 48 ------ .../musl/src/thread/powerpc64/syscall_cp.s | 44 ------ .../src/thread/riscv32/__set_thread_area.s | 6 - .../musl/src/thread/riscv32/__unmapself.s | 7 - libc-top-half/musl/src/thread/riscv32/clone.s | 34 ----- .../musl/src/thread/riscv32/syscall_cp.s | 29 ---- .../src/thread/riscv64/__set_thread_area.s | 6 - .../musl/src/thread/riscv64/__unmapself.s | 7 - libc-top-half/musl/src/thread/riscv64/clone.s | 34 ----- .../musl/src/thread/riscv64/syscall_cp.s | 29 ---- .../musl/src/thread/s390x/__set_thread_area.s | 10 -- .../musl/src/thread/s390x/__tls_get_offset.s | 17 --- .../musl/src/thread/s390x/__unmapself.s | 6 - libc-top-half/musl/src/thread/s390x/clone.s | 54 ------- .../musl/src/thread/s390x/syscall_cp.s | 34 ----- .../musl/src/thread/sh/__set_thread_area.c | 37 ----- .../musl/src/thread/sh/__unmapself.c | 24 --- .../musl/src/thread/sh/__unmapself_mmu.s | 23 --- libc-top-half/musl/src/thread/sh/atomics.s | 65 -------- libc-top-half/musl/src/thread/sh/clone.s | 54 ------- libc-top-half/musl/src/thread/sh/syscall_cp.s | 45 ------ .../thread/stubs}/pthread_barrier_destroy.c | 0 .../src/thread/stubs}/pthread_barrier_init.c | 0 .../src/thread/stubs}/pthread_barrier_wait.c | 0 .../thread/stubs}/pthread_cond_broadcast.c | 0 .../src/thread/stubs}/pthread_cond_destroy.c | 0 .../src/thread/stubs}/pthread_cond_init.c | 0 .../src/thread/stubs}/pthread_cond_signal.c | 0 .../thread/stubs}/pthread_cond_timedwait.c | 0 .../src/thread/stubs}/pthread_cond_wait.c | 0 .../musl/src/thread/stubs}/pthread_create.c | 0 .../musl/src/thread/stubs}/pthread_detach.c | 0 .../musl/src/thread/stubs}/pthread_join.c | 0 .../thread/stubs}/pthread_mutex_consistent.c | 0 .../pthread_mutex_getprioceiling.c | 0 .../src/thread/stubs}/pthread_mutex_lock.c | 0 .../thread/stubs}/pthread_mutex_timedlock.c | 0 .../src/thread/stubs}/pthread_mutex_trylock.c | 0 .../src/thread/stubs}/pthread_mutex_unlock.c | 0 .../musl/src/thread/stubs}/pthread_once.c | 0 .../src/thread/stubs}/pthread_rwlock_rdlock.c | 0 .../stubs}/pthread_rwlock_timedrdlock.c | 0 .../stubs}/pthread_rwlock_timedwrlock.c | 0 .../thread/stubs}/pthread_rwlock_tryrdlock.c | 0 .../thread/stubs}/pthread_rwlock_trywrlock.c | 0 .../src/thread/stubs}/pthread_rwlock_unlock.c | 0 .../src/thread/stubs}/pthread_rwlock_wrlock.c | 0 .../src/thread/stubs}/pthread_spin_lock.c | 0 .../src/thread/stubs}/pthread_spin_trylock.c | 0 .../src/thread/stubs}/pthread_spin_unlock.c | 0 .../src/thread/{ => wasi-threads}/__lock.c | 0 .../{ => wasi-threads}/__set_thread_area.c | 0 .../thread/{ => wasi-threads}/__syscall_cp.c | 0 .../thread/{ => wasi-threads}/__timedwait.c | 0 .../{ => wasi-threads}/__tls_get_addr.c | 0 .../thread/{ => wasi-threads}/__unmapself.c | 0 .../src/thread/{ => wasi-threads}/__wait.c | 0 .../__wasilibc_busywait.c | 0 .../src/thread/{ => wasi-threads}/call_once.c | 0 .../src/thread/{ => wasi-threads}/clone.c | 0 .../thread/{ => wasi-threads}/cnd_broadcast.c | 0 .../thread/{ => wasi-threads}/cnd_destroy.c | 0 .../src/thread/{ => wasi-threads}/cnd_init.c | 0 .../thread/{ => wasi-threads}/cnd_signal.c | 0 .../thread/{ => wasi-threads}/cnd_timedwait.c | 0 .../src/thread/{ => wasi-threads}/cnd_wait.c | 0 .../thread/{ => wasi-threads}/default_attr.c | 0 .../src/thread/{ => wasi-threads}/lock_ptc.c | 0 .../thread/{ => wasi-threads}/mtx_destroy.c | 0 .../src/thread/{ => wasi-threads}/mtx_init.c | 0 .../src/thread/{ => wasi-threads}/mtx_lock.c | 0 .../thread/{ => wasi-threads}/mtx_timedlock.c | 0 .../thread/{ => wasi-threads}/mtx_trylock.c | 0 .../thread/{ => wasi-threads}/mtx_unlock.c | 0 .../{ => wasi-threads}/pthread_atfork.c | 0 .../{ => wasi-threads}/pthread_attr_destroy.c | 0 .../{ => wasi-threads}/pthread_attr_get.c | 0 .../{ => wasi-threads}/pthread_attr_init.c | 0 .../pthread_attr_setdetachstate.c | 0 .../pthread_attr_setguardsize.c | 0 .../pthread_attr_setinheritsched.c | 0 .../pthread_attr_setschedparam.c | 0 .../pthread_attr_setschedpolicy.c | 0 .../pthread_attr_setscope.c | 0 .../pthread_attr_setstack.c | 0 .../pthread_attr_setstacksize.c | 0 .../pthread_barrier_destroy.c | 0 .../{ => wasi-threads}/pthread_barrier_init.c | 0 .../{ => wasi-threads}/pthread_barrier_wait.c | 0 .../pthread_barrierattr_destroy.c | 0 .../pthread_barrierattr_init.c | 0 .../pthread_barrierattr_setpshared.c | 0 .../{ => wasi-threads}/pthread_cancel.c | 0 .../{ => wasi-threads}/pthread_cleanup_push.c | 0 .../pthread_cond_broadcast.c | 0 .../{ => wasi-threads}/pthread_cond_destroy.c | 0 .../{ => wasi-threads}/pthread_cond_init.c | 0 .../{ => wasi-threads}/pthread_cond_signal.c | 0 .../pthread_cond_timedwait.c | 0 .../{ => wasi-threads}/pthread_cond_wait.c | 0 .../pthread_condattr_destroy.c | 0 .../pthread_condattr_init.c | 0 .../pthread_condattr_setclock.c | 0 .../pthread_condattr_setpshared.c | 0 .../{ => wasi-threads}/pthread_create.c | 0 .../{ => wasi-threads}/pthread_detach.c | 0 .../thread/{ => wasi-threads}/pthread_equal.c | 0 .../{ => wasi-threads}/pthread_getattr_np.c | 0 .../pthread_getconcurrency.c | 0 .../pthread_getcpuclockid.c | 0 .../{ => wasi-threads}/pthread_getname_np.c | 0 .../pthread_getschedparam.c | 0 .../{ => wasi-threads}/pthread_getspecific.c | 0 .../thread/{ => wasi-threads}/pthread_join.c | 0 .../{ => wasi-threads}/pthread_key_create.c | 0 .../thread/{ => wasi-threads}/pthread_kill.c | 0 .../pthread_mutex_consistent.c | 0 .../pthread_mutex_destroy.c | 0 .../pthread_mutex_getprioceiling.c | 0 .../{ => wasi-threads}/pthread_mutex_init.c | 0 .../{ => wasi-threads}/pthread_mutex_lock.c | 0 .../pthread_mutex_setprioceiling.c | 0 .../pthread_mutex_timedlock.c | 0 .../pthread_mutex_trylock.c | 0 .../{ => wasi-threads}/pthread_mutex_unlock.c | 0 .../pthread_mutexattr_destroy.c | 0 .../pthread_mutexattr_init.c | 0 .../pthread_mutexattr_setprotocol.c | 0 .../pthread_mutexattr_setpshared.c | 0 .../pthread_mutexattr_setrobust.c | 0 .../pthread_mutexattr_settype.c | 0 .../thread/{ => wasi-threads}/pthread_once.c | 0 .../pthread_rwlock_destroy.c | 0 .../{ => wasi-threads}/pthread_rwlock_init.c | 0 .../pthread_rwlock_rdlock.c | 0 .../pthread_rwlock_timedrdlock.c | 0 .../pthread_rwlock_timedwrlock.c | 0 .../pthread_rwlock_tryrdlock.c | 0 .../pthread_rwlock_trywrlock.c | 0 .../pthread_rwlock_unlock.c | 0 .../pthread_rwlock_wrlock.c | 0 .../pthread_rwlockattr_destroy.c | 0 .../pthread_rwlockattr_init.c | 0 .../pthread_rwlockattr_setpshared.c | 0 .../thread/{ => wasi-threads}/pthread_self.c | 0 .../pthread_setattr_default_np.c | 0 .../pthread_setcancelstate.c | 0 .../pthread_setcanceltype.c | 0 .../pthread_setconcurrency.c | 0 .../{ => wasi-threads}/pthread_setname_np.c | 0 .../pthread_setschedparam.c | 0 .../{ => wasi-threads}/pthread_setschedprio.c | 0 .../{ => wasi-threads}/pthread_setspecific.c | 0 .../{ => wasi-threads}/pthread_sigmask.c | 0 .../{ => wasi-threads}/pthread_spin_destroy.c | 0 .../{ => wasi-threads}/pthread_spin_init.c | 0 .../{ => wasi-threads}/pthread_spin_lock.c | 0 .../{ => wasi-threads}/pthread_spin_trylock.c | 0 .../{ => wasi-threads}/pthread_spin_unlock.c | 0 .../{ => wasi-threads}/pthread_testcancel.c | 0 .../thread/{ => wasi-threads}/sem_destroy.c | 0 .../thread/{ => wasi-threads}/sem_getvalue.c | 0 .../src/thread/{ => wasi-threads}/sem_init.c | 0 .../src/thread/{ => wasi-threads}/sem_open.c | 0 .../src/thread/{ => wasi-threads}/sem_post.c | 0 .../thread/{ => wasi-threads}/sem_timedwait.c | 0 .../thread/{ => wasi-threads}/sem_trywait.c | 0 .../thread/{ => wasi-threads}/sem_unlink.c | 0 .../src/thread/{ => wasi-threads}/sem_wait.c | 0 .../src/thread/{ => wasi-threads}/synccall.c | 0 .../thread/{ => wasi-threads}/syscall_cp.c | 0 .../thread/{ => wasi-threads}/thrd_create.c | 0 .../src/thread/{ => wasi-threads}/thrd_exit.c | 0 .../src/thread/{ => wasi-threads}/thrd_join.c | 0 .../thread/{ => wasi-threads}/thrd_sleep.c | 0 .../thread/{ => wasi-threads}/thrd_yield.c | 0 .../musl/src/thread/{ => wasi-threads}/tls.c | 0 .../thread/{ => wasi-threads}/tss_create.c | 0 .../thread/{ => wasi-threads}/tss_delete.c | 0 .../src/thread/{ => wasi-threads}/tss_set.c | 0 .../src/thread/{ => wasi-threads}/vmlock.c | 0 .../wasi_thread_start.s | 0 .../musl/src/thread/x32/__set_thread_area.s | 11 -- .../musl/src/thread/x32/__unmapself.s | 10 -- libc-top-half/musl/src/thread/x32/clone.s | 26 ---- .../musl/src/thread/x32/syscall_cp.s | 31 ---- .../src/thread/x86_64/__set_thread_area.s | 11 -- .../musl/src/thread/x86_64/__unmapself.s | 10 -- libc-top-half/musl/src/thread/x86_64/clone.s | 28 ---- .../musl/src/thread/x86_64/syscall_cp.s | 31 ---- thread-stub/README.md | 7 - 238 files changed, 76 insertions(+), 2052 deletions(-) create mode 100644 libc-top-half/musl/src/thread/README.md delete mode 100644 libc-top-half/musl/src/thread/aarch64/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/aarch64/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/aarch64/clone.s delete mode 100644 libc-top-half/musl/src/thread/aarch64/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/arm/__aeabi_read_tp.s delete mode 100644 libc-top-half/musl/src/thread/arm/__set_thread_area.c delete mode 100644 libc-top-half/musl/src/thread/arm/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/arm/atomics.s delete mode 100644 libc-top-half/musl/src/thread/arm/clone.s delete mode 100644 libc-top-half/musl/src/thread/arm/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/i386/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/i386/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/i386/clone.s delete mode 100644 libc-top-half/musl/src/thread/i386/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/i386/tls.s delete mode 100644 libc-top-half/musl/src/thread/loongarch64/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/loongarch64/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/loongarch64/clone.s delete mode 100644 libc-top-half/musl/src/thread/loongarch64/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/m68k/__m68k_read_tp.s delete mode 100644 libc-top-half/musl/src/thread/m68k/clone.s delete mode 100644 libc-top-half/musl/src/thread/m68k/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/microblaze/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/microblaze/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/microblaze/clone.s delete mode 100644 libc-top-half/musl/src/thread/microblaze/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/mips/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/mips/clone.s delete mode 100644 libc-top-half/musl/src/thread/mips/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/mips64/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/mips64/clone.s delete mode 100644 libc-top-half/musl/src/thread/mips64/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/mipsn32/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/mipsn32/clone.s delete mode 100644 libc-top-half/musl/src/thread/mipsn32/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/or1k/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/or1k/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/or1k/clone.s delete mode 100644 libc-top-half/musl/src/thread/or1k/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/powerpc/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/powerpc/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/powerpc/clone.s delete mode 100644 libc-top-half/musl/src/thread/powerpc/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/powerpc64/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/powerpc64/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/powerpc64/clone.s delete mode 100644 libc-top-half/musl/src/thread/powerpc64/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/riscv32/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/riscv32/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/riscv32/clone.s delete mode 100644 libc-top-half/musl/src/thread/riscv32/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/riscv64/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/riscv64/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/riscv64/clone.s delete mode 100644 libc-top-half/musl/src/thread/riscv64/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/s390x/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/s390x/__tls_get_offset.s delete mode 100644 libc-top-half/musl/src/thread/s390x/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/s390x/clone.s delete mode 100644 libc-top-half/musl/src/thread/s390x/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/sh/__set_thread_area.c delete mode 100644 libc-top-half/musl/src/thread/sh/__unmapself.c delete mode 100644 libc-top-half/musl/src/thread/sh/__unmapself_mmu.s delete mode 100644 libc-top-half/musl/src/thread/sh/atomics.s delete mode 100644 libc-top-half/musl/src/thread/sh/clone.s delete mode 100644 libc-top-half/musl/src/thread/sh/syscall_cp.s rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_barrier_destroy.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_barrier_init.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_barrier_wait.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_cond_broadcast.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_cond_destroy.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_cond_init.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_cond_signal.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_cond_timedwait.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_cond_wait.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_create.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_detach.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_join.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_mutex_consistent.c (100%) rename libc-top-half/musl/src/thread/{ => stubs}/pthread_mutex_getprioceiling.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_mutex_lock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_mutex_timedlock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_mutex_trylock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_mutex_unlock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_once.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_rwlock_rdlock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_rwlock_timedrdlock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_rwlock_timedwrlock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_rwlock_tryrdlock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_rwlock_trywrlock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_rwlock_unlock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_rwlock_wrlock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_spin_lock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_spin_trylock.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/stubs}/pthread_spin_unlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/__lock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/__set_thread_area.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/__syscall_cp.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/__timedwait.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/__tls_get_addr.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/__unmapself.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/__wait.c (100%) rename libc-top-half/musl/src/thread/{wasm32 => wasi-threads}/__wasilibc_busywait.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/call_once.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/clone.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/cnd_broadcast.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/cnd_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/cnd_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/cnd_signal.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/cnd_timedwait.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/cnd_wait.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/default_attr.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/lock_ptc.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/mtx_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/mtx_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/mtx_lock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/mtx_timedlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/mtx_trylock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/mtx_unlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_atfork.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_attr_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_attr_get.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_attr_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_attr_setdetachstate.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_attr_setguardsize.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_attr_setinheritsched.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_attr_setschedparam.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_attr_setschedpolicy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_attr_setscope.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_attr_setstack.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_attr_setstacksize.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_barrier_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_barrier_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_barrier_wait.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_barrierattr_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_barrierattr_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_barrierattr_setpshared.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_cancel.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_cleanup_push.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_cond_broadcast.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_cond_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_cond_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_cond_signal.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_cond_timedwait.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_cond_wait.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_condattr_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_condattr_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_condattr_setclock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_condattr_setpshared.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_create.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_detach.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_equal.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_getattr_np.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_getconcurrency.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_getcpuclockid.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_getname_np.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_getschedparam.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_getspecific.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_join.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_key_create.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_kill.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutex_consistent.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutex_destroy.c (100%) rename {thread-stub => libc-top-half/musl/src/thread/wasi-threads}/pthread_mutex_getprioceiling.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutex_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutex_lock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutex_setprioceiling.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutex_timedlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutex_trylock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutex_unlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutexattr_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutexattr_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutexattr_setprotocol.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutexattr_setpshared.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutexattr_setrobust.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_mutexattr_settype.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_once.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlock_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlock_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlock_rdlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlock_timedrdlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlock_timedwrlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlock_tryrdlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlock_trywrlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlock_unlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlock_wrlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlockattr_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlockattr_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_rwlockattr_setpshared.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_self.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_setattr_default_np.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_setcancelstate.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_setcanceltype.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_setconcurrency.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_setname_np.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_setschedparam.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_setschedprio.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_setspecific.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_sigmask.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_spin_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_spin_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_spin_lock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_spin_trylock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_spin_unlock.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/pthread_testcancel.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/sem_destroy.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/sem_getvalue.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/sem_init.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/sem_open.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/sem_post.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/sem_timedwait.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/sem_trywait.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/sem_unlink.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/sem_wait.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/synccall.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/syscall_cp.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/thrd_create.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/thrd_exit.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/thrd_join.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/thrd_sleep.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/thrd_yield.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/tls.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/tss_create.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/tss_delete.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/tss_set.c (100%) rename libc-top-half/musl/src/thread/{ => wasi-threads}/vmlock.c (100%) rename libc-top-half/musl/src/thread/{wasm32 => wasi-threads}/wasi_thread_start.s (100%) delete mode 100644 libc-top-half/musl/src/thread/x32/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/x32/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/x32/clone.s delete mode 100644 libc-top-half/musl/src/thread/x32/syscall_cp.s delete mode 100644 libc-top-half/musl/src/thread/x86_64/__set_thread_area.s delete mode 100644 libc-top-half/musl/src/thread/x86_64/__unmapself.s delete mode 100644 libc-top-half/musl/src/thread/x86_64/clone.s delete mode 100644 libc-top-half/musl/src/thread/x86_64/syscall_cp.s delete mode 100644 thread-stub/README.md diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index 8dcf63abc..7a476b10f 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -396,80 +396,80 @@ if (THREADS) musl/src/stdio/flockfile.c musl/src/stdio/ftrylockfile.c musl/src/stdio/funlockfile.c - musl/src/thread/__lock.c - musl/src/thread/__wait.c - musl/src/thread/__timedwait.c - musl/src/thread/pthread_barrier_destroy.c - musl/src/thread/pthread_barrier_init.c - musl/src/thread/pthread_barrier_wait.c - musl/src/thread/pthread_cond_broadcast.c - musl/src/thread/pthread_cond_destroy.c - musl/src/thread/pthread_cond_init.c - musl/src/thread/pthread_cond_signal.c - musl/src/thread/pthread_cond_timedwait.c - musl/src/thread/pthread_cond_wait.c - musl/src/thread/pthread_create.c - musl/src/thread/pthread_detach.c - musl/src/thread/pthread_join.c - musl/src/thread/pthread_mutex_consistent.c - musl/src/thread/pthread_mutex_getprioceiling.c - musl/src/thread/pthread_mutex_lock.c - musl/src/thread/pthread_mutex_timedlock.c - musl/src/thread/pthread_mutex_trylock.c - musl/src/thread/pthread_mutex_unlock.c - musl/src/thread/pthread_once.c - musl/src/thread/pthread_rwlock_rdlock.c - musl/src/thread/pthread_rwlock_timedrdlock.c - musl/src/thread/pthread_rwlock_timedwrlock.c - musl/src/thread/pthread_rwlock_tryrdlock.c - musl/src/thread/pthread_rwlock_trywrlock.c - musl/src/thread/pthread_rwlock_unlock.c - musl/src/thread/pthread_rwlock_wrlock.c - musl/src/thread/pthread_spin_lock.c - musl/src/thread/pthread_spin_trylock.c - musl/src/thread/pthread_spin_unlock.c - musl/src/thread/sem_destroy.c - musl/src/thread/sem_getvalue.c - musl/src/thread/sem_init.c - musl/src/thread/sem_post.c - musl/src/thread/sem_timedwait.c - musl/src/thread/sem_trywait.c - musl/src/thread/sem_wait.c - musl/src/thread/wasm32/wasi_thread_start.s - musl/src/thread/wasm32/__wasilibc_busywait.c + musl/src/thread/wasi-threads/__lock.c + musl/src/thread/wasi-threads/__wait.c + musl/src/thread/wasi-threads/__timedwait.c + musl/src/thread/wasi-threads/pthread_barrier_destroy.c + musl/src/thread/wasi-threads/pthread_barrier_init.c + musl/src/thread/wasi-threads/pthread_barrier_wait.c + musl/src/thread/wasi-threads/pthread_cond_broadcast.c + musl/src/thread/wasi-threads/pthread_cond_destroy.c + musl/src/thread/wasi-threads/pthread_cond_init.c + musl/src/thread/wasi-threads/pthread_cond_signal.c + musl/src/thread/wasi-threads/pthread_cond_timedwait.c + musl/src/thread/wasi-threads/pthread_cond_wait.c + musl/src/thread/wasi-threads/pthread_create.c + musl/src/thread/wasi-threads/pthread_detach.c + musl/src/thread/wasi-threads/pthread_join.c + musl/src/thread/wasi-threads/pthread_mutex_consistent.c + musl/src/thread/wasi-threads/pthread_mutex_getprioceiling.c + musl/src/thread/wasi-threads/pthread_mutex_lock.c + musl/src/thread/wasi-threads/pthread_mutex_timedlock.c + musl/src/thread/wasi-threads/pthread_mutex_trylock.c + musl/src/thread/wasi-threads/pthread_mutex_unlock.c + musl/src/thread/wasi-threads/pthread_once.c + musl/src/thread/wasi-threads/pthread_rwlock_rdlock.c + musl/src/thread/wasi-threads/pthread_rwlock_timedrdlock.c + musl/src/thread/wasi-threads/pthread_rwlock_timedwrlock.c + musl/src/thread/wasi-threads/pthread_rwlock_tryrdlock.c + musl/src/thread/wasi-threads/pthread_rwlock_trywrlock.c + musl/src/thread/wasi-threads/pthread_rwlock_unlock.c + musl/src/thread/wasi-threads/pthread_rwlock_wrlock.c + musl/src/thread/wasi-threads/pthread_spin_lock.c + musl/src/thread/wasi-threads/pthread_spin_trylock.c + musl/src/thread/wasi-threads/pthread_spin_unlock.c + musl/src/thread/wasi-threads/sem_destroy.c + musl/src/thread/wasi-threads/sem_getvalue.c + musl/src/thread/wasi-threads/sem_init.c + musl/src/thread/wasi-threads/sem_post.c + musl/src/thread/wasi-threads/sem_timedwait.c + musl/src/thread/wasi-threads/sem_trywait.c + musl/src/thread/wasi-threads/sem_wait.c + musl/src/thread/wasi-threads/wasi_thread_start.s + musl/src/thread/wasi-threads/__wasilibc_busywait.c ) else() # pthreads stubs for single-threaded environment list(APPEND top_half_sources - ../thread-stub/pthread_barrier_destroy.c - ../thread-stub/pthread_barrier_init.c - ../thread-stub/pthread_barrier_wait.c - ../thread-stub/pthread_cond_broadcast.c - ../thread-stub/pthread_cond_destroy.c - ../thread-stub/pthread_cond_init.c - ../thread-stub/pthread_cond_signal.c - ../thread-stub/pthread_cond_timedwait.c - ../thread-stub/pthread_cond_wait.c - ../thread-stub/pthread_create.c - ../thread-stub/pthread_detach.c - ../thread-stub/pthread_join.c - ../thread-stub/pthread_mutex_consistent.c - ../thread-stub/pthread_mutex_getprioceiling.c - ../thread-stub/pthread_mutex_lock.c - ../thread-stub/pthread_mutex_timedlock.c - ../thread-stub/pthread_mutex_trylock.c - ../thread-stub/pthread_mutex_unlock.c - ../thread-stub/pthread_once.c - ../thread-stub/pthread_rwlock_rdlock.c - ../thread-stub/pthread_rwlock_timedrdlock.c - ../thread-stub/pthread_rwlock_timedwrlock.c - ../thread-stub/pthread_rwlock_tryrdlock.c - ../thread-stub/pthread_rwlock_trywrlock.c - ../thread-stub/pthread_rwlock_unlock.c - ../thread-stub/pthread_rwlock_wrlock.c - ../thread-stub/pthread_spin_lock.c - ../thread-stub/pthread_spin_trylock.c - ../thread-stub/pthread_spin_unlock.c + musl/src/thread/wasi-threads/pthread_barrier_destroy.c + musl/src/thread/wasi-threads/pthread_barrier_init.c + musl/src/thread/wasi-threads/pthread_barrier_wait.c + musl/src/thread/wasi-threads/pthread_cond_broadcast.c + musl/src/thread/wasi-threads/pthread_cond_destroy.c + musl/src/thread/wasi-threads/pthread_cond_init.c + musl/src/thread/wasi-threads/pthread_cond_signal.c + musl/src/thread/wasi-threads/pthread_cond_timedwait.c + musl/src/thread/wasi-threads/pthread_cond_wait.c + musl/src/thread/wasi-threads/pthread_create.c + musl/src/thread/wasi-threads/pthread_detach.c + musl/src/thread/wasi-threads/pthread_join.c + musl/src/thread/wasi-threads/pthread_mutex_consistent.c + musl/src/thread/wasi-threads/pthread_mutex_getprioceiling.c + musl/src/thread/wasi-threads/pthread_mutex_lock.c + musl/src/thread/wasi-threads/pthread_mutex_timedlock.c + musl/src/thread/wasi-threads/pthread_mutex_trylock.c + musl/src/thread/wasi-threads/pthread_mutex_unlock.c + musl/src/thread/wasi-threads/pthread_once.c + musl/src/thread/wasi-threads/pthread_rwlock_rdlock.c + musl/src/thread/wasi-threads/pthread_rwlock_timedrdlock.c + musl/src/thread/wasi-threads/pthread_rwlock_timedwrlock.c + musl/src/thread/wasi-threads/pthread_rwlock_tryrdlock.c + musl/src/thread/wasi-threads/pthread_rwlock_trywrlock.c + musl/src/thread/wasi-threads/pthread_rwlock_unlock.c + musl/src/thread/wasi-threads/pthread_rwlock_wrlock.c + musl/src/thread/wasi-threads/pthread_spin_lock.c + musl/src/thread/wasi-threads/pthread_spin_trylock.c + musl/src/thread/wasi-threads/pthread_spin_unlock.c ) endif() diff --git a/libc-top-half/musl/src/thread/README.md b/libc-top-half/musl/src/thread/README.md new file mode 100644 index 000000000..b5ec85726 --- /dev/null +++ b/libc-top-half/musl/src/thread/README.md @@ -0,0 +1,6 @@ +# pthreads + +This directory contains two implementations of the `pthreads` library: + +- `wasi-threads` - based on the original musl implementation, used for the `wasm32-wasip1-threads` target; see [`wasi-threads`](https://github.com/WebAssembly/wasi-threads) for details +- `stubs` - used for single-threaded WASIP1 and WASIP2 targets; is never able to spawn new threads, but otherwise follows the letter of the specification diff --git a/libc-top-half/musl/src/thread/aarch64/__set_thread_area.s b/libc-top-half/musl/src/thread/aarch64/__set_thread_area.s deleted file mode 100644 index fd0df34b0..000000000 --- a/libc-top-half/musl/src/thread/aarch64/__set_thread_area.s +++ /dev/null @@ -1,7 +0,0 @@ -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - msr tpidr_el0,x0 - mov w0,#0 - ret diff --git a/libc-top-half/musl/src/thread/aarch64/__unmapself.s b/libc-top-half/musl/src/thread/aarch64/__unmapself.s deleted file mode 100644 index 2c5d254f7..000000000 --- a/libc-top-half/musl/src/thread/aarch64/__unmapself.s +++ /dev/null @@ -1,7 +0,0 @@ -.global __unmapself -.type __unmapself,%function -__unmapself: - mov x8,#215 // SYS_munmap - svc 0 - mov x8,#93 // SYS_exit - svc 0 diff --git a/libc-top-half/musl/src/thread/aarch64/clone.s b/libc-top-half/musl/src/thread/aarch64/clone.s deleted file mode 100644 index e3c83395c..000000000 --- a/libc-top-half/musl/src/thread/aarch64/clone.s +++ /dev/null @@ -1,30 +0,0 @@ -// __clone(func, stack, flags, arg, ptid, tls, ctid) -// x0, x1, w2, x3, x4, x5, x6 - -// syscall(SYS_clone, flags, stack, ptid, tls, ctid) -// x8, x0, x1, x2, x3, x4 - -.global __clone -.hidden __clone -.type __clone,%function -__clone: - // align stack and save func,arg - and x1,x1,#-16 - stp x0,x3,[x1,#-16]! - - // syscall - uxtw x0,w2 - mov x2,x4 - mov x3,x5 - mov x4,x6 - mov x8,#220 // SYS_clone - svc #0 - - cbz x0,1f - // parent - ret - // child -1: ldp x1,x0,[sp],#16 - blr x1 - mov x8,#93 // SYS_exit - svc #0 diff --git a/libc-top-half/musl/src/thread/aarch64/syscall_cp.s b/libc-top-half/musl/src/thread/aarch64/syscall_cp.s deleted file mode 100644 index 41db68af9..000000000 --- a/libc-top-half/musl/src/thread/aarch64/syscall_cp.s +++ /dev/null @@ -1,32 +0,0 @@ -// __syscall_cp_asm(&self->cancel, nr, u, v, w, x, y, z) -// x0 x1 x2 x3 x4 x5 x6 x7 - -// syscall(nr, u, v, w, x, y, z) -// x8 x0 x1 x2 x3 x4 x5 - -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,%function -__syscall_cp_asm: -__cp_begin: - ldr w0,[x0] - cbnz w0,__cp_cancel - mov x8,x1 - mov x0,x2 - mov x1,x3 - mov x2,x4 - mov x3,x5 - mov x4,x6 - mov x5,x7 - svc 0 -__cp_end: - ret -__cp_cancel: - b __cancel diff --git a/libc-top-half/musl/src/thread/arm/__aeabi_read_tp.s b/libc-top-half/musl/src/thread/arm/__aeabi_read_tp.s deleted file mode 100644 index 2585620c4..000000000 --- a/libc-top-half/musl/src/thread/arm/__aeabi_read_tp.s +++ /dev/null @@ -1,10 +0,0 @@ -.syntax unified -.global __aeabi_read_tp -.type __aeabi_read_tp,%function -__aeabi_read_tp: - ldr r0,1f - add r0,r0,pc - ldr r0,[r0] -2: bx r0 - .align 2 -1: .word __a_gettp_ptr - 2b diff --git a/libc-top-half/musl/src/thread/arm/__set_thread_area.c b/libc-top-half/musl/src/thread/arm/__set_thread_area.c deleted file mode 100644 index 09de65aab..000000000 --- a/libc-top-half/musl/src/thread/arm/__set_thread_area.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include "pthread_impl.h" -#include "libc.h" - -#define HWCAP_TLS (1 << 15) - -extern hidden const unsigned char - __a_barrier_oldkuser[], __a_barrier_v6[], __a_barrier_v7[], - __a_cas_v6[], __a_cas_v7[], - __a_gettp_cp15[]; - -#define __a_barrier_kuser 0xffff0fa0 -#define __a_barrier_oldkuser (uintptr_t)__a_barrier_oldkuser -#define __a_barrier_v6 (uintptr_t)__a_barrier_v6 -#define __a_barrier_v7 (uintptr_t)__a_barrier_v7 - -#define __a_cas_kuser 0xffff0fc0 -#define __a_cas_v6 (uintptr_t)__a_cas_v6 -#define __a_cas_v7 (uintptr_t)__a_cas_v7 - -#define __a_gettp_kuser 0xffff0fe0 -#define __a_gettp_cp15 (uintptr_t)__a_gettp_cp15 - -extern hidden uintptr_t __a_barrier_ptr, __a_cas_ptr, __a_gettp_ptr; - -int __set_thread_area(void *p) -{ -#if !__ARM_ARCH_7A__ && !__ARM_ARCH_7R__ && __ARM_ARCH < 7 - if (__hwcap & HWCAP_TLS) { - size_t *aux; - __a_cas_ptr = __a_cas_v7; - __a_barrier_ptr = __a_barrier_v7; - for (aux=libc.auxv; *aux; aux+=2) { - if (*aux != AT_PLATFORM) continue; - const char *s = (void *)aux[1]; - if (s[0]!='v' || s[1]!='6' || s[2]-'0'<10u) break; - __a_cas_ptr = __a_cas_v6; - __a_barrier_ptr = __a_barrier_v6; - break; - } - } else { - int ver = *(int *)0xffff0ffc; - __a_gettp_ptr = __a_gettp_kuser; - __a_cas_ptr = __a_cas_kuser; - __a_barrier_ptr = __a_barrier_kuser; - if (ver < 2) a_crash(); - if (ver < 3) __a_barrier_ptr = __a_barrier_oldkuser; - } -#endif - return __syscall(0xf0005, p); -} diff --git a/libc-top-half/musl/src/thread/arm/__unmapself.s b/libc-top-half/musl/src/thread/arm/__unmapself.s deleted file mode 100644 index 29c2d07b1..000000000 --- a/libc-top-half/musl/src/thread/arm/__unmapself.s +++ /dev/null @@ -1,9 +0,0 @@ -.syntax unified -.text -.global __unmapself -.type __unmapself,%function -__unmapself: - mov r7,#91 - svc 0 - mov r7,#1 - svc 0 diff --git a/libc-top-half/musl/src/thread/arm/atomics.s b/libc-top-half/musl/src/thread/arm/atomics.s deleted file mode 100644 index da50508d8..000000000 --- a/libc-top-half/musl/src/thread/arm/atomics.s +++ /dev/null @@ -1,106 +0,0 @@ -.syntax unified -.text - -.global __a_barrier_dummy -.hidden __a_barrier_dummy -.type __a_barrier_dummy,%function -__a_barrier_dummy: - bx lr - -.global __a_barrier_oldkuser -.hidden __a_barrier_oldkuser -.type __a_barrier_oldkuser,%function -__a_barrier_oldkuser: - push {r0,r1,r2,r3,ip,lr} - mov r1,r0 - mov r2,sp - ldr ip,=0xffff0fc0 - bl 1f - pop {r0,r1,r2,r3,ip,lr} - bx lr -1: bx ip - -.global __a_barrier_v6 -.hidden __a_barrier_v6 -.type __a_barrier_v6,%function -__a_barrier_v6: - .arch armv6t2 - mcr p15,0,r0,c7,c10,5 - bx lr - -.global __a_barrier_v7 -.hidden __a_barrier_v7 -.type __a_barrier_v7,%function -__a_barrier_v7: - .arch armv7-a - dmb ish - bx lr - -.global __a_cas_dummy -.hidden __a_cas_dummy -.type __a_cas_dummy,%function -__a_cas_dummy: - mov r3,r0 - ldr r0,[r2] - subs r0,r3,r0 - streq r1,[r2] - bx lr - -.global __a_cas_v6 -.hidden __a_cas_v6 -.type __a_cas_v6,%function -__a_cas_v6: - .arch armv6t2 - mov r3,r0 - mcr p15,0,r0,c7,c10,5 -1: ldrex r0,[r2] - subs r0,r3,r0 - strexeq r0,r1,[r2] - teqeq r0,#1 - beq 1b - mcr p15,0,r0,c7,c10,5 - bx lr - -.global __a_cas_v7 -.hidden __a_cas_v7 -.type __a_cas_v7,%function -__a_cas_v7: - .arch armv7-a - mov r3,r0 - dmb ish -1: ldrex r0,[r2] - subs r0,r3,r0 - strexeq r0,r1,[r2] - teqeq r0,#1 - beq 1b - dmb ish - bx lr - -.global __a_gettp_cp15 -.hidden __a_gettp_cp15 -.type __a_gettp_cp15,%function -__a_gettp_cp15: - mrc p15,0,r0,c13,c0,3 - bx lr - -/* Tag this file with minimum ISA level so as not to affect linking. */ -.object_arch armv4t -.eabi_attribute 6,2 - -.data -.align 2 - -.global __a_barrier_ptr -.hidden __a_barrier_ptr -__a_barrier_ptr: - .word __a_barrier_dummy - -.global __a_cas_ptr -.hidden __a_cas_ptr -__a_cas_ptr: - .word __a_cas_dummy - -.global __a_gettp_ptr -.hidden __a_gettp_ptr -__a_gettp_ptr: - .word __a_gettp_cp15 diff --git a/libc-top-half/musl/src/thread/arm/clone.s b/libc-top-half/musl/src/thread/arm/clone.s deleted file mode 100644 index bb0965daf..000000000 --- a/libc-top-half/musl/src/thread/arm/clone.s +++ /dev/null @@ -1,28 +0,0 @@ -.syntax unified -.text -.global __clone -.hidden __clone -.type __clone,%function -__clone: - stmfd sp!,{r4,r5,r6,r7} - mov r7,#120 - mov r6,r3 - mov r5,r0 - mov r0,r2 - and r1,r1,#-16 - ldr r2,[sp,#16] - ldr r3,[sp,#20] - ldr r4,[sp,#24] - svc 0 - tst r0,r0 - beq 1f - ldmfd sp!,{r4,r5,r6,r7} - bx lr - -1: mov r0,r6 - bl 3f -2: mov r7,#1 - svc 0 - b 2b - -3: bx r5 diff --git a/libc-top-half/musl/src/thread/arm/syscall_cp.s b/libc-top-half/musl/src/thread/arm/syscall_cp.s deleted file mode 100644 index e607dd426..000000000 --- a/libc-top-half/musl/src/thread/arm/syscall_cp.s +++ /dev/null @@ -1,29 +0,0 @@ -.syntax unified -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,%function -__syscall_cp_asm: - mov ip,sp - stmfd sp!,{r4,r5,r6,r7} -__cp_begin: - ldr r0,[r0] - cmp r0,#0 - bne __cp_cancel - mov r7,r1 - mov r0,r2 - mov r1,r3 - ldmfd ip,{r2,r3,r4,r5,r6} - svc 0 -__cp_end: - ldmfd sp!,{r4,r5,r6,r7} - bx lr -__cp_cancel: - ldmfd sp!,{r4,r5,r6,r7} - b __cancel diff --git a/libc-top-half/musl/src/thread/i386/__set_thread_area.s b/libc-top-half/musl/src/thread/i386/__set_thread_area.s deleted file mode 100644 index aa6852beb..000000000 --- a/libc-top-half/musl/src/thread/i386/__set_thread_area.s +++ /dev/null @@ -1,47 +0,0 @@ -.text -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - push %ebx - push $0x51 - push $0xfffff - push 16(%esp) - call 1f -1: addl $4f-1b,(%esp) - pop %ecx - mov (%ecx),%edx - push %edx - mov %esp,%ebx - xor %eax,%eax - mov $243,%al - int $128 - testl %eax,%eax - jnz 2f - movl (%esp),%edx - movl %edx,(%ecx) - leal 3(,%edx,8),%edx -3: movw %dx,%gs -1: - addl $16,%esp - popl %ebx - ret -2: - mov %ebx,%ecx - xor %eax,%eax - xor %ebx,%ebx - xor %edx,%edx - mov %ebx,(%esp) - mov $1,%bl - mov $16,%dl - mov $123,%al - int $128 - testl %eax,%eax - jnz 1b - mov $7,%dl - inc %al - jmp 3b - -.data - .align 4 -4: .long -1 diff --git a/libc-top-half/musl/src/thread/i386/__unmapself.s b/libc-top-half/musl/src/thread/i386/__unmapself.s deleted file mode 100644 index d6569594a..000000000 --- a/libc-top-half/musl/src/thread/i386/__unmapself.s +++ /dev/null @@ -1,11 +0,0 @@ -.text -.global __unmapself -.type __unmapself,@function -__unmapself: - movl $91,%eax - movl 4(%esp),%ebx - movl 8(%esp),%ecx - int $128 - xorl %ebx,%ebx - movl $1,%eax - int $128 diff --git a/libc-top-half/musl/src/thread/i386/clone.s b/libc-top-half/musl/src/thread/i386/clone.s deleted file mode 100644 index e237d3c63..000000000 --- a/libc-top-half/musl/src/thread/i386/clone.s +++ /dev/null @@ -1,49 +0,0 @@ -.text -.global __clone -.hidden __clone -.type __clone,@function -__clone: - push %ebp - mov %esp,%ebp - push %ebx - push %esi - push %edi - - xor %eax,%eax - push $0x51 - mov %gs,%ax - push $0xfffff - shr $3,%eax - push 28(%ebp) - push %eax - mov $120,%al - - mov 12(%ebp),%ecx - mov 16(%ebp),%ebx - and $-16,%ecx - sub $16,%ecx - mov 20(%ebp),%edi - mov %edi,(%ecx) - mov 24(%ebp),%edx - mov %esp,%esi - mov 32(%ebp),%edi - mov 8(%ebp),%ebp - int $128 - test %eax,%eax - jnz 1f - - mov %ebp,%eax - xor %ebp,%ebp - call *%eax - mov %eax,%ebx - xor %eax,%eax - inc %eax - int $128 - hlt - -1: add $16,%esp - pop %edi - pop %esi - pop %ebx - pop %ebp - ret diff --git a/libc-top-half/musl/src/thread/i386/syscall_cp.s b/libc-top-half/musl/src/thread/i386/syscall_cp.s deleted file mode 100644 index 7dce1eb3a..000000000 --- a/libc-top-half/musl/src/thread/i386/syscall_cp.s +++ /dev/null @@ -1,41 +0,0 @@ -.text -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,@function -__syscall_cp_asm: - mov 4(%esp),%ecx - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp -__cp_begin: - movl (%ecx),%eax - testl %eax,%eax - jnz __cp_cancel - movl 24(%esp),%eax - movl 28(%esp),%ebx - movl 32(%esp),%ecx - movl 36(%esp),%edx - movl 40(%esp),%esi - movl 44(%esp),%edi - movl 48(%esp),%ebp - int $128 -__cp_end: - popl %ebp - popl %edi - popl %esi - popl %ebx - ret -__cp_cancel: - popl %ebp - popl %edi - popl %esi - popl %ebx - jmp __cancel diff --git a/libc-top-half/musl/src/thread/i386/tls.s b/libc-top-half/musl/src/thread/i386/tls.s deleted file mode 100644 index 6e4c4cb92..000000000 --- a/libc-top-half/musl/src/thread/i386/tls.s +++ /dev/null @@ -1,9 +0,0 @@ -.text -.global ___tls_get_addr -.type ___tls_get_addr,@function -___tls_get_addr: - mov %gs:4,%edx - mov (%eax),%ecx - mov 4(%eax),%eax - add (%edx,%ecx,4),%eax - ret diff --git a/libc-top-half/musl/src/thread/loongarch64/__set_thread_area.s b/libc-top-half/musl/src/thread/loongarch64/__set_thread_area.s deleted file mode 100644 index 021307fc4..000000000 --- a/libc-top-half/musl/src/thread/loongarch64/__set_thread_area.s +++ /dev/null @@ -1,7 +0,0 @@ -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - move $tp, $a0 - move $a0, $zero - jr $ra diff --git a/libc-top-half/musl/src/thread/loongarch64/__unmapself.s b/libc-top-half/musl/src/thread/loongarch64/__unmapself.s deleted file mode 100644 index 719ad0563..000000000 --- a/libc-top-half/musl/src/thread/loongarch64/__unmapself.s +++ /dev/null @@ -1,7 +0,0 @@ -.global __unmapself -.type __unmapself, @function -__unmapself: - li.d $a7, 215 # call munmap - syscall 0 - li.d $a7, 93 # call exit - syscall 0 diff --git a/libc-top-half/musl/src/thread/loongarch64/clone.s b/libc-top-half/musl/src/thread/loongarch64/clone.s deleted file mode 100644 index a165b365a..000000000 --- a/libc-top-half/musl/src/thread/loongarch64/clone.s +++ /dev/null @@ -1,29 +0,0 @@ -#__clone(func, stack, flags, arg, ptid, tls, ctid) -# a0, a1, a2, a3, a4, a5, a6 -# sys_clone(flags, stack, ptid, ctid, tls) -# a0, a1, a2, a3, a4 - -.global __clone -.hidden __clone -.type __clone,@function -__clone: - bstrins.d $a1, $zero, 3, 0 #stack to 16 align - # Save function pointer and argument pointer on new thread stack - addi.d $a1, $a1, -16 - st.d $a0, $a1, 0 # save function pointer - st.d $a3, $a1, 8 # save argument pointer - or $a0, $a2, $zero - or $a2, $a4, $zero - or $a3, $a6, $zero - or $a4, $a5, $zero - ori $a7, $zero, 220 - syscall 0 # call clone - - beqz $a0, 1f # whether child process - jirl $zero, $ra, 0 # parent process return -1: - ld.d $t8, $sp, 0 # function pointer - ld.d $a0, $sp, 8 # argument pointer - jirl $ra, $t8, 0 # call the user's function - ori $a7, $zero, 93 - syscall 0 # child process exit diff --git a/libc-top-half/musl/src/thread/loongarch64/syscall_cp.s b/libc-top-half/musl/src/thread/loongarch64/syscall_cp.s deleted file mode 100644 index c057a97b9..000000000 --- a/libc-top-half/musl/src/thread/loongarch64/syscall_cp.s +++ /dev/null @@ -1,29 +0,0 @@ -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,@function - -__syscall_cp_asm: -__cp_begin: - ld.w $a0, $a0, 0 - bnez $a0, __cp_cancel - move $t8, $a1 # reserve system call number - move $a0, $a2 - move $a1, $a3 - move $a2, $a4 - move $a3, $a5 - move $a4, $a6 - move $a5, $a7 - move $a7, $t8 - syscall 0 -__cp_end: - jr $ra -__cp_cancel: - la.local $t8, __cancel - jr $t8 diff --git a/libc-top-half/musl/src/thread/m68k/__m68k_read_tp.s b/libc-top-half/musl/src/thread/m68k/__m68k_read_tp.s deleted file mode 100644 index 86886da8a..000000000 --- a/libc-top-half/musl/src/thread/m68k/__m68k_read_tp.s +++ /dev/null @@ -1,8 +0,0 @@ -.text -.global __m68k_read_tp -.type __m68k_read_tp,@function -__m68k_read_tp: - move.l #333,%d0 - trap #0 - move.l %d0,%a0 - rts diff --git a/libc-top-half/musl/src/thread/m68k/clone.s b/libc-top-half/musl/src/thread/m68k/clone.s deleted file mode 100644 index f6dfa06f4..000000000 --- a/libc-top-half/musl/src/thread/m68k/clone.s +++ /dev/null @@ -1,25 +0,0 @@ -.text -.global __clone -.hidden __clone -.type __clone,@function -__clone: - movem.l %d2-%d5,-(%sp) - move.l #120,%d0 - move.l 28(%sp),%d1 - move.l 24(%sp),%d2 - and.l #-16,%d2 - move.l 36(%sp),%d3 - move.l 44(%sp),%d4 - move.l 40(%sp),%d5 - move.l 20(%sp),%a0 - move.l 32(%sp),%a1 - trap #0 - tst.l %d0 - beq 1f - movem.l (%sp)+,%d2-%d5 - rts -1: move.l %a1,-(%sp) - jsr (%a0) - move.l #1,%d0 - trap #0 - clr.b 0 diff --git a/libc-top-half/musl/src/thread/m68k/syscall_cp.s b/libc-top-half/musl/src/thread/m68k/syscall_cp.s deleted file mode 100644 index 5628a896e..000000000 --- a/libc-top-half/musl/src/thread/m68k/syscall_cp.s +++ /dev/null @@ -1,26 +0,0 @@ -.text -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,@function -__syscall_cp_asm: - movem.l %d2-%d5,-(%sp) - movea.l 20(%sp),%a0 -__cp_begin: - move.l (%a0),%d0 - bne __cp_cancel - movem.l 24(%sp),%d0-%d5/%a0 - trap #0 -__cp_end: - movem.l (%sp)+,%d2-%d5 - rts -__cp_cancel: - movem.l (%sp)+,%d2-%d5 - move.l __cancel-.-8,%a1 - jmp (%pc,%a1) diff --git a/libc-top-half/musl/src/thread/microblaze/__set_thread_area.s b/libc-top-half/musl/src/thread/microblaze/__set_thread_area.s deleted file mode 100644 index 9a226a915..000000000 --- a/libc-top-half/musl/src/thread/microblaze/__set_thread_area.s +++ /dev/null @@ -1,7 +0,0 @@ -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - ori r21, r5, 0 - rtsd r15, 8 - ori r3, r0, 0 diff --git a/libc-top-half/musl/src/thread/microblaze/__unmapself.s b/libc-top-half/musl/src/thread/microblaze/__unmapself.s deleted file mode 100644 index b180de60a..000000000 --- a/libc-top-half/musl/src/thread/microblaze/__unmapself.s +++ /dev/null @@ -1,8 +0,0 @@ -.global __unmapself -.type __unmapself,@function -__unmapself: - ori r12, r0, 91 - brki r14, 0x8 - ori r12, r0, 1 - brki r14, 0x8 - nop diff --git a/libc-top-half/musl/src/thread/microblaze/clone.s b/libc-top-half/musl/src/thread/microblaze/clone.s deleted file mode 100644 index b68cc5fc2..000000000 --- a/libc-top-half/musl/src/thread/microblaze/clone.s +++ /dev/null @@ -1,30 +0,0 @@ -.global __clone -.hidden __clone -.type __clone,@function - -# r5, r6, r7, r8, r9, r10, stack -# fn, st, fl, ar, pt, tl, ct -# fl, st, __, pt, ct, tl - -__clone: - andi r6, r6, -16 - addi r6, r6, -16 - swi r5, r6, 0 - swi r8, r6, 4 - - ori r5, r7, 0 - ori r8, r9, 0 - lwi r9, r1, 28 - ori r12, r0, 120 - - brki r14, 8 - beqi r3, 1f - rtsd r15, 8 - nop - -1: lwi r3, r1, 0 - lwi r5, r1, 4 - brald r15, r3 - nop - ori r12, r0, 1 - brki r14, 8 diff --git a/libc-top-half/musl/src/thread/microblaze/syscall_cp.s b/libc-top-half/musl/src/thread/microblaze/syscall_cp.s deleted file mode 100644 index b0df61c57..000000000 --- a/libc-top-half/musl/src/thread/microblaze/syscall_cp.s +++ /dev/null @@ -1,27 +0,0 @@ -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,@function -__syscall_cp_asm: -__cp_begin: - lwi r5, r5, 0 - bnei r5, __cp_cancel - addi r12, r6, 0 - add r5, r7, r0 - add r6, r8, r0 - add r7, r9, r0 - add r8, r10, r0 - lwi r9, r1, 28 - lwi r10, r1, 32 - brki r14, 0x8 -__cp_end: - rtsd r15, 8 - nop -__cp_cancel: - bri __cancel diff --git a/libc-top-half/musl/src/thread/mips/__unmapself.s b/libc-top-half/musl/src/thread/mips/__unmapself.s deleted file mode 100644 index ba139dc8e..000000000 --- a/libc-top-half/musl/src/thread/mips/__unmapself.s +++ /dev/null @@ -1,10 +0,0 @@ -.set noreorder -.global __unmapself -.type __unmapself,@function -__unmapself: - move $sp, $25 - li $2, 4091 - syscall - li $4, 0 - li $2, 4001 - syscall diff --git a/libc-top-half/musl/src/thread/mips/clone.s b/libc-top-half/musl/src/thread/mips/clone.s deleted file mode 100644 index 044633856..000000000 --- a/libc-top-half/musl/src/thread/mips/clone.s +++ /dev/null @@ -1,36 +0,0 @@ -.set noreorder -.global __clone -.hidden __clone -.type __clone,@function -__clone: - # Save function pointer and argument pointer on new thread stack - and $5, $5, -8 - subu $5, $5, 16 - sw $4, 0($5) - sw $7, 4($5) - # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid) - move $4, $6 - lw $6, 16($sp) - lw $7, 20($sp) - lw $9, 24($sp) - subu $sp, $sp, 16 - sw $9, 16($sp) - li $2, 4120 - syscall - beq $7, $0, 1f - nop - addu $sp, $sp, 16 - jr $ra - subu $2, $0, $2 -1: beq $2, $0, 1f - nop - addu $sp, $sp, 16 - jr $ra - nop -1: lw $25, 0($sp) - lw $4, 4($sp) - jalr $25 - nop - move $4, $2 - li $2, 4001 - syscall diff --git a/libc-top-half/musl/src/thread/mips/syscall_cp.s b/libc-top-half/musl/src/thread/mips/syscall_cp.s deleted file mode 100644 index d28462645..000000000 --- a/libc-top-half/musl/src/thread/mips/syscall_cp.s +++ /dev/null @@ -1,53 +0,0 @@ -.set noreorder - -.global __cp_begin -.hidden __cp_begin -.type __cp_begin,@function -.global __cp_end -.hidden __cp_end -.type __cp_end,@function -.global __cp_cancel -.hidden __cp_cancel -.type __cp_cancel,@function -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,@function -__syscall_cp_asm: - subu $sp, $sp, 32 -__cp_begin: - lw $4, 0($4) - bne $4, $0, __cp_cancel - move $2, $5 - move $4, $6 - move $5, $7 - lw $6, 48($sp) - lw $7, 52($sp) - lw $8, 56($sp) - lw $9, 60($sp) - lw $10,64($sp) - sw $8, 16($sp) - sw $9, 20($sp) - sw $10,24($sp) - sw $2, 28($sp) - lw $2, 28($sp) - syscall -__cp_end: - beq $7, $0, 1f - addu $sp, $sp, 32 - subu $2, $0, $2 -1: jr $ra - nop - -__cp_cancel: - move $2, $ra - bal 1f - addu $sp, $sp, 32 - .gpword . - .gpword __cancel -1: lw $3, ($ra) - subu $3, $ra, $3 - lw $25, 4($ra) - addu $25, $25, $3 - jr $25 - move $ra, $2 diff --git a/libc-top-half/musl/src/thread/mips64/__unmapself.s b/libc-top-half/musl/src/thread/mips64/__unmapself.s deleted file mode 100644 index f6795cda2..000000000 --- a/libc-top-half/musl/src/thread/mips64/__unmapself.s +++ /dev/null @@ -1,9 +0,0 @@ -.set noreorder -.global __unmapself -.type __unmapself, @function -__unmapself: - li $2, 5011 - syscall - li $4, 0 - li $2, 5058 - syscall diff --git a/libc-top-half/musl/src/thread/mips64/clone.s b/libc-top-half/musl/src/thread/mips64/clone.s deleted file mode 100644 index 2d86899a1..000000000 --- a/libc-top-half/musl/src/thread/mips64/clone.s +++ /dev/null @@ -1,34 +0,0 @@ -.set noreorder -.global __clone -.hidden __clone -.type __clone,@function -__clone: - # Save function pointer and argument pointer on new thread stack - and $5, $5, -16 # aligning stack to double word - dsubu $5, $5, 16 - sd $4, 0($5) # save function pointer - sd $7, 8($5) # save argument pointer - - # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid) - # sys_clone(u64 flags, u64 ustack_base, u64 parent_tidptr, u64 child_tidptr, u64 tls) - move $4, $6 - move $6, $8 - move $7, $9 - move $8, $10 - li $2, 5055 - syscall - beq $7, $0, 1f - nop - jr $ra - dsubu $2, $0, $2 -1: beq $2, $0, 1f - nop - jr $ra - nop -1: ld $25, 0($sp) # function pointer - ld $4, 8($sp) # argument pointer - jalr $25 # call the user's function - nop - move $4, $2 - li $2, 5058 - syscall diff --git a/libc-top-half/musl/src/thread/mips64/syscall_cp.s b/libc-top-half/musl/src/thread/mips64/syscall_cp.s deleted file mode 100644 index 0d4ede763..000000000 --- a/libc-top-half/musl/src/thread/mips64/syscall_cp.s +++ /dev/null @@ -1,52 +0,0 @@ -.set noreorder -.global __cp_begin -.hidden __cp_begin -.type __cp_begin,@function -.global __cp_end -.hidden __cp_end -.type __cp_end,@function -.global __cp_cancel -.hidden __cp_cancel -.type __cp_cancel,@function -.global __cp_cancel_data -.hidden __cp_cancel_data -.type __cp_cancel_data,@function -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,@function -__syscall_cp_asm: -__cp_begin: - lw $4, 0($4) - bne $4, $0, __cp_cancel - move $2, $5 - move $4, $6 - move $5, $7 - move $6, $8 - move $7, $9 - move $8, $10 - move $9, $11 - ld $10, 0($sp) - syscall -__cp_end: - beq $7, $0, 1f - nop - dsubu $2, $0, $2 -1: jr $ra - nop - - # if cancellation flag is 1 then call __cancel -__cp_cancel: - move $2, $ra -.align 8 - bal 1f - nop -__cp_cancel_data: - .gpdword __cp_cancel_data - .gpdword __cancel -1: ld $3, ($ra) - dsubu $3, $ra, $3 - ld $25, 8($ra) - daddu $25, $25, $3 - jr $25 - move $ra, $2 diff --git a/libc-top-half/musl/src/thread/mipsn32/__unmapself.s b/libc-top-half/musl/src/thread/mipsn32/__unmapself.s deleted file mode 100644 index 4b032e5e5..000000000 --- a/libc-top-half/musl/src/thread/mipsn32/__unmapself.s +++ /dev/null @@ -1,9 +0,0 @@ -.set noreorder -.global __unmapself -.type __unmapself,@function -__unmapself: - li $2, 6011 - syscall - li $4, 0 - li $2, 6058 - syscall diff --git a/libc-top-half/musl/src/thread/mipsn32/clone.s b/libc-top-half/musl/src/thread/mipsn32/clone.s deleted file mode 100644 index 4d3c8c7a2..000000000 --- a/libc-top-half/musl/src/thread/mipsn32/clone.s +++ /dev/null @@ -1,34 +0,0 @@ -.set noreorder -.global __clone -.hidden __clone -.type __clone,@function -__clone: - # Save function pointer and argument pointer on new thread stack - and $5, $5, -16 # aligning stack to double word - subu $5, $5, 16 - sw $4, 0($5) # save function pointer - sw $7, 4($5) # save argument pointer - - # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid) - # sys_clone(u64 flags, u64 ustack_base, u64 parent_tidptr, u64 child_tidptr, u64 tls) - move $4, $6 - move $6, $8 - move $7, $9 - move $8, $10 - li $2, 6055 - syscall - beq $7, $0, 1f - nop - jr $ra - subu $2, $0, $2 -1: beq $2, $0, 1f - nop - jr $ra - nop -1: lw $25, 0($sp) # function pointer - lw $4, 4($sp) # argument pointer - jalr $25 # call the user's function - nop - move $4, $2 - li $2, 6058 - syscall diff --git a/libc-top-half/musl/src/thread/mipsn32/syscall_cp.s b/libc-top-half/musl/src/thread/mipsn32/syscall_cp.s deleted file mode 100644 index e85615bcb..000000000 --- a/libc-top-half/musl/src/thread/mipsn32/syscall_cp.s +++ /dev/null @@ -1,51 +0,0 @@ -.set noreorder -.global __cp_begin -.hidden __cp_begin -.type __cp_begin,@function -.global __cp_end -.hidden __cp_end -.type __cp_end,@function -.global __cp_cancel -.hidden __cp_cancel -.type __cp_cancel,@function -.global __cp_cancel_data -.hidden __cp_cancel_data -.type __cp_cancel_data,@function -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,@function -__syscall_cp_asm: -__cp_begin: - lw $4, 0($4) - bne $4, $0, __cp_cancel - move $2, $5 - move $4, $6 - move $5, $7 - move $6, $8 - move $7, $9 - move $8, $10 - move $9, $11 - lw $10, 0($sp) - syscall -__cp_end: - beq $7, $0, 1f - nop - subu $2, $0, $2 -1: jr $ra - nop - - # if cancellation flag is 1 then call __cancel -__cp_cancel: - move $2, $ra - bal 1f - nop -__cp_cancel_data: - .gpword __cp_cancel_data - .gpword __cancel -1: lw $3, 0($ra) - subu $3, $ra, $3 - lw $25, 4($ra) - addu $25, $25, $3 - jr $25 - move $ra, $2 diff --git a/libc-top-half/musl/src/thread/or1k/__set_thread_area.s b/libc-top-half/musl/src/thread/or1k/__set_thread_area.s deleted file mode 100644 index b9ffb9303..000000000 --- a/libc-top-half/musl/src/thread/or1k/__set_thread_area.s +++ /dev/null @@ -1,7 +0,0 @@ -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - l.ori r10, r3, 0 - l.jr r9 - l.ori r11, r0, 0 diff --git a/libc-top-half/musl/src/thread/or1k/__unmapself.s b/libc-top-half/musl/src/thread/or1k/__unmapself.s deleted file mode 100644 index 6c0fa2acf..000000000 --- a/libc-top-half/musl/src/thread/or1k/__unmapself.s +++ /dev/null @@ -1,8 +0,0 @@ -.global __unmapself -.type __unmapself,@function -__unmapself: - l.ori r11, r0, 215 /* __NR_munmap */ - l.sys 1 - l.ori r3, r0, 0 - l.ori r11, r0, 93 /* __NR_exit */ - l.sys 1 diff --git a/libc-top-half/musl/src/thread/or1k/clone.s b/libc-top-half/musl/src/thread/or1k/clone.s deleted file mode 100644 index 2473ac204..000000000 --- a/libc-top-half/musl/src/thread/or1k/clone.s +++ /dev/null @@ -1,31 +0,0 @@ -/* int clone(fn, stack, flags, arg, ptid, tls, ctid) - * r3 r4 r5 r6 sp+0 sp+4 sp+8 - * sys_clone(flags, stack, ptid, ctid, tls) - */ -.global __clone -.hidden __clone -.type __clone,@function -__clone: - l.addi r4, r4, -8 - l.sw 0(r4), r3 - l.sw 4(r4), r6 - /* (fn, st, fl, ar, pt, tl, ct) => (fl, st, pt, ct, tl) */ - l.ori r3, r5, 0 - l.lwz r5, 0(r1) - l.lwz r6, 8(r1) - l.lwz r7, 4(r1) - l.ori r11, r0, 220 /* __NR_clone */ - l.sys 1 - - l.sfeqi r11, 0 - l.bf 1f - l.nop - l.jr r9 - l.nop - -1: l.lwz r11, 0(r1) - l.jalr r11 - l.lwz r3, 4(r1) - - l.ori r11, r0, 93 /* __NR_exit */ - l.sys 1 diff --git a/libc-top-half/musl/src/thread/or1k/syscall_cp.s b/libc-top-half/musl/src/thread/or1k/syscall_cp.s deleted file mode 100644 index 7951166ed..000000000 --- a/libc-top-half/musl/src/thread/or1k/syscall_cp.s +++ /dev/null @@ -1,29 +0,0 @@ -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,@function -__syscall_cp_asm: -__cp_begin: - l.lwz r3, 0(r3) - l.sfeqi r3, 0 - l.bnf __cp_cancel - l.ori r11, r4, 0 - l.ori r3, r5, 0 - l.ori r4, r6, 0 - l.ori r5, r7, 0 - l.ori r6, r8, 0 - l.lwz r7, 0(r1) - l.lwz r8, 4(r1) - l.sys 1 -__cp_end: - l.jr r9 - l.nop -__cp_cancel: - l.j __cancel - l.nop diff --git a/libc-top-half/musl/src/thread/powerpc/__set_thread_area.s b/libc-top-half/musl/src/thread/powerpc/__set_thread_area.s deleted file mode 100644 index 86c498fa3..000000000 --- a/libc-top-half/musl/src/thread/powerpc/__set_thread_area.s +++ /dev/null @@ -1,12 +0,0 @@ -.text -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area, %function -__set_thread_area: - # mov pointer in reg3 into r2 - mr 2, 3 - # put 0 into return reg - li 3, 0 - # return - blr - diff --git a/libc-top-half/musl/src/thread/powerpc/__unmapself.s b/libc-top-half/musl/src/thread/powerpc/__unmapself.s deleted file mode 100644 index c9360b47a..000000000 --- a/libc-top-half/musl/src/thread/powerpc/__unmapself.s +++ /dev/null @@ -1,9 +0,0 @@ - .text - .global __unmapself - .type __unmapself,%function -__unmapself: - li 0, 91 # __NR_munmap - sc - li 0, 1 #__NR_exit - sc - blr diff --git a/libc-top-half/musl/src/thread/powerpc/clone.s b/libc-top-half/musl/src/thread/powerpc/clone.s deleted file mode 100644 index da13f446c..000000000 --- a/libc-top-half/musl/src/thread/powerpc/clone.s +++ /dev/null @@ -1,73 +0,0 @@ -.text -.global __clone -.hidden __clone -.type __clone, %function -__clone: -# int clone(fn, stack, flags, arg, ptid, tls, ctid) -# a b c d e f g -# 3 4 5 6 7 8 9 -# pseudo C code: -# tid = syscall(SYS_clone,c,b,e,f,g); -# if (!tid) syscall(SYS_exit, a(d)); -# return tid; - -# SYS_clone = 120 -# SYS_exit = 1 - -# store non-volatile regs r30, r31 on stack in order to put our -# start func and its arg there -stwu 30, -16(1) -stw 31, 4(1) - -# save r3 (func) into r30, and r6(arg) into r31 -mr 30, 3 -mr 31, 6 - -# create initial stack frame for new thread -clrrwi 4, 4, 4 -li 0, 0 -stwu 0, -16(4) - -#move c into first arg -mr 3, 5 -#mr 4, 4 -mr 5, 7 -mr 6, 8 -mr 7, 9 - -# move syscall number into r0 -li 0, 120 - -sc - -# check for syscall error -bns+ 1f # jump to label 1 if no summary overflow. -#else -neg 3, 3 #negate the result (errno) -1: -# compare sc result with 0 -cmpwi cr7, 3, 0 - -# if not 0, jump to end -bne cr7, 2f - -#else: we're the child -#call funcptr: move arg (d) into r3 -mr 3, 31 -#move r30 (funcptr) into CTR reg -mtctr 30 -# call CTR reg -bctrl -# mov SYS_exit into r0 (the exit param is already in r3) -li 0, 1 -sc - -2: - -# restore stack -lwz 30, 0(1) -lwz 31, 4(1) -addi 1, 1, 16 - -blr - diff --git a/libc-top-half/musl/src/thread/powerpc/syscall_cp.s b/libc-top-half/musl/src/thread/powerpc/syscall_cp.s deleted file mode 100644 index 77f8938dc..000000000 --- a/libc-top-half/musl/src/thread/powerpc/syscall_cp.s +++ /dev/null @@ -1,59 +0,0 @@ -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm - -#r0: volatile. may be modified during linkage. -#r1: stack frame: 16 byte alignment. -#r2: tls/thread pointer on pp32 -#r3,r4: return values, first args -#r5-r10: args -#r11-r12: volatile. may be modified during linkage -#r13: "small data area" pointer -#r14 - r30: local vars -#r31: local or environment pointer - -#r1, r14-31: belong to the caller, must be saved and restored -#r0, r3-r12, ctr, xer: volatile, not preserved -#r0,r11,r12: may be altered by cross-module call, -#"a func cannot depend on that these regs have the values placed by the caller" - -#the fields CR2,CR2,CR4 of the cond reg must be preserved -#LR (link reg) shall contain the funcs return address - .text - .type __syscall_cp_asm,%function -__syscall_cp_asm: - # at enter: r3 = pointer to self->cancel, r4: syscall no, r5: first arg, r6: 2nd, r7: 3rd, r8: 4th, r9: 5th, r10: 6th -__cp_begin: - # r3 holds first argument, its a pointer to self->cancel. - # we must compare the dereferenced value with 0 and jump to __cancel if its not - - lwz 0, 0(3) #deref pointer into r0 - - cmpwi cr7, 0, 0 #compare r0 with 0, store result in cr7. - beq+ cr7, 1f #jump to label 1 if r0 was 0 - - b __cp_cancel #else call cancel -1: - #ok, the cancel flag was not set - # syscall: number goes to r0, the rest 3-8 - mr 0, 4 # put the system call number into r0 - mr 3, 5 # Shift the arguments: arg1 - mr 4, 6 # arg2 - mr 5, 7 # arg3 - mr 6, 8 # arg4 - mr 7, 9 # arg5 - mr 8, 10 # arg6 - sc -__cp_end: - bnslr+ # return if no summary overflow. - #else negate result. - neg 3, 3 - blr -__cp_cancel: - b __cancel diff --git a/libc-top-half/musl/src/thread/powerpc64/__set_thread_area.s b/libc-top-half/musl/src/thread/powerpc64/__set_thread_area.s deleted file mode 100644 index bb9c55d6d..000000000 --- a/libc-top-half/musl/src/thread/powerpc64/__set_thread_area.s +++ /dev/null @@ -1,9 +0,0 @@ -.text -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area, %function -__set_thread_area: - mr 13, 3 - li 3, 0 - blr - diff --git a/libc-top-half/musl/src/thread/powerpc64/__unmapself.s b/libc-top-half/musl/src/thread/powerpc64/__unmapself.s deleted file mode 100644 index c9360b47a..000000000 --- a/libc-top-half/musl/src/thread/powerpc64/__unmapself.s +++ /dev/null @@ -1,9 +0,0 @@ - .text - .global __unmapself - .type __unmapself,%function -__unmapself: - li 0, 91 # __NR_munmap - sc - li 0, 1 #__NR_exit - sc - blr diff --git a/libc-top-half/musl/src/thread/powerpc64/clone.s b/libc-top-half/musl/src/thread/powerpc64/clone.s deleted file mode 100644 index 41cb6787a..000000000 --- a/libc-top-half/musl/src/thread/powerpc64/clone.s +++ /dev/null @@ -1,48 +0,0 @@ -.text -.global __clone -.hidden __clone -.type __clone, %function -__clone: - # int clone(fn, stack, flags, arg, ptid, tls, ctid) - # a b c d e f g - # 3 4 5 6 7 8 9 - # pseudo C code: - # tid = syscall(SYS_clone,c,b,e,f,g); - # if (!tid) syscall(SYS_exit, a(d)); - # return tid; - - # create initial stack frame for new thread - clrrdi 4, 4, 4 - li 0, 0 - stdu 0,-32(4) - - # save fn and arg to child stack - std 3, 8(4) - std 6, 16(4) - - # shuffle args into correct registers and call SYS_clone - mr 3, 5 - #mr 4, 4 - mr 5, 7 - mr 6, 8 - mr 7, 9 - li 0, 120 # SYS_clone = 120 - sc - - # if error, negate return (errno) - bns+ 1f - neg 3, 3 - -1: # if we're the parent, return - cmpwi cr7, 3, 0 - bnelr cr7 - - # we're the child. call fn(arg) - ld 3, 16(1) - ld 12, 8(1) - mtctr 12 - bctrl - - # call SYS_exit. exit code is already in r3 from fn return value - li 0, 1 # SYS_exit = 1 - sc diff --git a/libc-top-half/musl/src/thread/powerpc64/syscall_cp.s b/libc-top-half/musl/src/thread/powerpc64/syscall_cp.s deleted file mode 100644 index ef50ed007..000000000 --- a/libc-top-half/musl/src/thread/powerpc64/syscall_cp.s +++ /dev/null @@ -1,44 +0,0 @@ - .global __cp_begin - .hidden __cp_begin - .global __cp_end - .hidden __cp_end - .global __cp_cancel - .hidden __cp_cancel - .hidden __cancel - .global __syscall_cp_asm - .hidden __syscall_cp_asm - .text - .type __syscall_cp_asm,%function -__syscall_cp_asm: - # at enter: r3 = pointer to self->cancel, r4: syscall no, r5: first arg, r6: 2nd, r7: 3rd, r8: 4th, r9: 5th, r10: 6th -__cp_begin: - # if (self->cancel) goto __cp_cancel - lwz 0, 0(3) - cmpwi cr7, 0, 0 - bne- cr7, __cp_cancel - - # make syscall - mr 0, 4 - mr 3, 5 - mr 4, 6 - mr 5, 7 - mr 6, 8 - mr 7, 9 - mr 8, 10 - sc - -__cp_end: - # return error ? -r3 : r3 - bnslr+ - neg 3, 3 - blr - -__cp_cancel: - mflr 0 - bl 1f - .long .TOC.-. -1: mflr 3 - lwa 2, 0(3) - add 2, 2, 3 - mtlr 0 - b __cancel diff --git a/libc-top-half/musl/src/thread/riscv32/__set_thread_area.s b/libc-top-half/musl/src/thread/riscv32/__set_thread_area.s deleted file mode 100644 index 828154d29..000000000 --- a/libc-top-half/musl/src/thread/riscv32/__set_thread_area.s +++ /dev/null @@ -1,6 +0,0 @@ -.global __set_thread_area -.type __set_thread_area, %function -__set_thread_area: - mv tp, a0 - li a0, 0 - ret diff --git a/libc-top-half/musl/src/thread/riscv32/__unmapself.s b/libc-top-half/musl/src/thread/riscv32/__unmapself.s deleted file mode 100644 index 2849119c3..000000000 --- a/libc-top-half/musl/src/thread/riscv32/__unmapself.s +++ /dev/null @@ -1,7 +0,0 @@ -.global __unmapself -.type __unmapself, %function -__unmapself: - li a7, 215 # SYS_munmap - ecall - li a7, 93 # SYS_exit - ecall diff --git a/libc-top-half/musl/src/thread/riscv32/clone.s b/libc-top-half/musl/src/thread/riscv32/clone.s deleted file mode 100644 index 3102239d0..000000000 --- a/libc-top-half/musl/src/thread/riscv32/clone.s +++ /dev/null @@ -1,34 +0,0 @@ -# __clone(func, stack, flags, arg, ptid, tls, ctid) -# a0, a1, a2, a3, a4, a5, a6 - -# syscall(SYS_clone, flags, stack, ptid, tls, ctid) -# a7 a0, a1, a2, a3, a4 - -.global __clone -.type __clone, %function -__clone: - # Save func and arg to stack - addi a1, a1, -16 - sw a0, 0(a1) - sw a3, 4(a1) - - # Call SYS_clone - mv a0, a2 - mv a2, a4 - mv a3, a5 - mv a4, a6 - li a7, 220 # SYS_clone - ecall - - beqz a0, 1f - # Parent - ret - - # Child -1: lw a1, 0(sp) - lw a0, 4(sp) - jalr a1 - - # Exit - li a7, 93 # SYS_exit - ecall diff --git a/libc-top-half/musl/src/thread/riscv32/syscall_cp.s b/libc-top-half/musl/src/thread/riscv32/syscall_cp.s deleted file mode 100644 index 079d1ba01..000000000 --- a/libc-top-half/musl/src/thread/riscv32/syscall_cp.s +++ /dev/null @@ -1,29 +0,0 @@ -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm, %function -__syscall_cp_asm: -__cp_begin: - lw t0, 0(a0) - bnez t0, __cp_cancel - - mv t0, a1 - mv a0, a2 - mv a1, a3 - mv a2, a4 - mv a3, a5 - mv a4, a6 - mv a5, a7 - lw a6, 0(sp) - mv a7, t0 - ecall -__cp_end: - ret -__cp_cancel: - tail __cancel diff --git a/libc-top-half/musl/src/thread/riscv64/__set_thread_area.s b/libc-top-half/musl/src/thread/riscv64/__set_thread_area.s deleted file mode 100644 index 828154d29..000000000 --- a/libc-top-half/musl/src/thread/riscv64/__set_thread_area.s +++ /dev/null @@ -1,6 +0,0 @@ -.global __set_thread_area -.type __set_thread_area, %function -__set_thread_area: - mv tp, a0 - li a0, 0 - ret diff --git a/libc-top-half/musl/src/thread/riscv64/__unmapself.s b/libc-top-half/musl/src/thread/riscv64/__unmapself.s deleted file mode 100644 index 2849119c3..000000000 --- a/libc-top-half/musl/src/thread/riscv64/__unmapself.s +++ /dev/null @@ -1,7 +0,0 @@ -.global __unmapself -.type __unmapself, %function -__unmapself: - li a7, 215 # SYS_munmap - ecall - li a7, 93 # SYS_exit - ecall diff --git a/libc-top-half/musl/src/thread/riscv64/clone.s b/libc-top-half/musl/src/thread/riscv64/clone.s deleted file mode 100644 index db908248c..000000000 --- a/libc-top-half/musl/src/thread/riscv64/clone.s +++ /dev/null @@ -1,34 +0,0 @@ -# __clone(func, stack, flags, arg, ptid, tls, ctid) -# a0, a1, a2, a3, a4, a5, a6 - -# syscall(SYS_clone, flags, stack, ptid, tls, ctid) -# a7 a0, a1, a2, a3, a4 - -.global __clone -.type __clone, %function -__clone: - # Save func and arg to stack - addi a1, a1, -16 - sd a0, 0(a1) - sd a3, 8(a1) - - # Call SYS_clone - mv a0, a2 - mv a2, a4 - mv a3, a5 - mv a4, a6 - li a7, 220 # SYS_clone - ecall - - beqz a0, 1f - # Parent - ret - - # Child -1: ld a1, 0(sp) - ld a0, 8(sp) - jalr a1 - - # Exit - li a7, 93 # SYS_exit - ecall diff --git a/libc-top-half/musl/src/thread/riscv64/syscall_cp.s b/libc-top-half/musl/src/thread/riscv64/syscall_cp.s deleted file mode 100644 index eeef6391b..000000000 --- a/libc-top-half/musl/src/thread/riscv64/syscall_cp.s +++ /dev/null @@ -1,29 +0,0 @@ -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm, %function -__syscall_cp_asm: -__cp_begin: - lw t0, 0(a0) - bnez t0, __cp_cancel - - mv t0, a1 - mv a0, a2 - mv a1, a3 - mv a2, a4 - mv a3, a5 - mv a4, a6 - mv a5, a7 - ld a6, 0(sp) - mv a7, t0 - ecall -__cp_end: - ret -__cp_cancel: - tail __cancel diff --git a/libc-top-half/musl/src/thread/s390x/__set_thread_area.s b/libc-top-half/musl/src/thread/s390x/__set_thread_area.s deleted file mode 100644 index 00a11e254..000000000 --- a/libc-top-half/musl/src/thread/s390x/__set_thread_area.s +++ /dev/null @@ -1,10 +0,0 @@ -.text -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area, %function -__set_thread_area: - sar %a1, %r2 - srlg %r2, %r2, 32 - sar %a0, %r2 - lghi %r2, 0 - br %r14 diff --git a/libc-top-half/musl/src/thread/s390x/__tls_get_offset.s b/libc-top-half/musl/src/thread/s390x/__tls_get_offset.s deleted file mode 100644 index 8ee92de8e..000000000 --- a/libc-top-half/musl/src/thread/s390x/__tls_get_offset.s +++ /dev/null @@ -1,17 +0,0 @@ - .global __tls_get_offset - .type __tls_get_offset,%function -__tls_get_offset: - stmg %r14, %r15, 112(%r15) - aghi %r15, -160 - - la %r2, 0(%r2, %r12) - brasl %r14, __tls_get_addr - - ear %r1, %a0 - sllg %r1, %r1, 32 - ear %r1, %a1 - - sgr %r2, %r1 - - lmg %r14, %r15, 272(%r15) - br %r14 diff --git a/libc-top-half/musl/src/thread/s390x/__unmapself.s b/libc-top-half/musl/src/thread/s390x/__unmapself.s deleted file mode 100644 index 48b312cd3..000000000 --- a/libc-top-half/musl/src/thread/s390x/__unmapself.s +++ /dev/null @@ -1,6 +0,0 @@ -.text -.global __unmapself -.type __unmapself, @function -__unmapself: - svc 91 # SYS_munmap - svc 1 # SYS_exit diff --git a/libc-top-half/musl/src/thread/s390x/clone.s b/libc-top-half/musl/src/thread/s390x/clone.s deleted file mode 100644 index 2125f20b8..000000000 --- a/libc-top-half/musl/src/thread/s390x/clone.s +++ /dev/null @@ -1,54 +0,0 @@ -.text -.global __clone -.hidden __clone -.type __clone, %function -__clone: - # int clone( - # fn, a = r2 - # stack, b = r3 - # flags, c = r4 - # arg, d = r5 - # ptid, e = r6 - # tls, f = *(r15+160) - # ctid) g = *(r15+168) - # - # pseudo C code: - # tid = syscall(SYS_clone,b,c,e,g,f); - # if (!tid) syscall(SYS_exit, a(d)); - # return tid; - - # preserve call-saved register used as syscall arg - stg %r6, 48(%r15) - - # create initial stack frame for new thread - nill %r3, 0xfff8 - aghi %r3, -160 - lghi %r0, 0 - stg %r0, 0(%r3) - - # save fn and arg to child stack - stg %r2, 8(%r3) - stg %r5, 16(%r3) - - # shuffle args into correct registers and call SYS_clone - lgr %r2, %r3 - lgr %r3, %r4 - lgr %r4, %r6 - lg %r5, 168(%r15) - lg %r6, 160(%r15) - svc 120 - - # restore call-saved register - lg %r6, 48(%r15) - - # if error or if we're the parent, return - ltgr %r2, %r2 - bnzr %r14 - - # we're the child. call fn(arg) - lg %r1, 8(%r15) - lg %r2, 16(%r15) - basr %r14, %r1 - - # call SYS_exit. exit code is already in r2 from fn return value - svc 1 diff --git a/libc-top-half/musl/src/thread/s390x/syscall_cp.s b/libc-top-half/musl/src/thread/s390x/syscall_cp.s deleted file mode 100644 index d094cbf5a..000000000 --- a/libc-top-half/musl/src/thread/s390x/syscall_cp.s +++ /dev/null @@ -1,34 +0,0 @@ - .global __cp_begin - .hidden __cp_begin - .global __cp_end - .hidden __cp_end - .global __cp_cancel - .hidden __cp_cancel - .hidden __cancel - .global __syscall_cp_asm - .hidden __syscall_cp_asm - .text - .type __syscall_cp_asm,%function -__syscall_cp_asm: -__cp_begin: - icm %r2, 15, 0(%r2) - jne __cp_cancel - - stg %r6, 48(%r15) - stg %r7, 56(%r15) - lgr %r1, %r3 - lgr %r2, %r4 - lgr %r3, %r5 - lgr %r4, %r6 - lg %r5, 160(%r15) - lg %r6, 168(%r15) - lg %r7, 176(%r15) - svc 0 - -__cp_end: - lg %r7, 56(%r15) - lg %r6, 48(%r15) - br %r14 - -__cp_cancel: - jg __cancel diff --git a/libc-top-half/musl/src/thread/sh/__set_thread_area.c b/libc-top-half/musl/src/thread/sh/__set_thread_area.c deleted file mode 100644 index 34264bddd..000000000 --- a/libc-top-half/musl/src/thread/sh/__set_thread_area.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "pthread_impl.h" -#include "libc.h" -#include - -/* Also perform sh-specific init */ - -#define CPU_HAS_LLSC 0x0040 -#define CPU_HAS_CAS_L 0x0400 - -extern hidden const char __sh_cas_gusa[], __sh_cas_llsc[], __sh_cas_imask[], __sh_cas_cas_l[]; - -hidden const void *__sh_cas_ptr; - -hidden unsigned __sh_nommu; - -int __set_thread_area(void *p) -{ - size_t *aux; - __asm__ __volatile__ ( "ldc %0, gbr" : : "r"(p) : "memory" ); -#ifndef __SH4A__ - __sh_cas_ptr = __sh_cas_gusa; -#if !defined(__SH3__) && !defined(__SH4__) - for (aux=libc.auxv; *aux; aux+=2) { - if (*aux != AT_PLATFORM) continue; - const char *s = (void *)aux[1]; - if (s[0]!='s' || s[1]!='h' || s[2]!='2' || s[3]-'0'<10u) break; - __sh_cas_ptr = __sh_cas_imask; - __sh_nommu = 1; - } -#endif - if (__hwcap & CPU_HAS_CAS_L) - __sh_cas_ptr = __sh_cas_cas_l; - else if (__hwcap & CPU_HAS_LLSC) - __sh_cas_ptr = __sh_cas_llsc; -#endif - return 0; -} diff --git a/libc-top-half/musl/src/thread/sh/__unmapself.c b/libc-top-half/musl/src/thread/sh/__unmapself.c deleted file mode 100644 index 35fb3c92d..000000000 --- a/libc-top-half/musl/src/thread/sh/__unmapself.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "pthread_impl.h" - -hidden void __unmapself_sh_mmu(void *, size_t); -hidden void __unmapself_sh_nommu(void *, size_t); - -#if !defined(__SH3__) && !defined(__SH4__) -#define __unmapself __unmapself_sh_nommu -#include "dynlink.h" -#undef CRTJMP -#define CRTJMP(pc,sp) __asm__ __volatile__( \ - "mov.l @%0+,r0 ; mov.l @%0,r12 ; jmp @r0 ; mov %1,r15" \ - : : "r"(pc), "r"(sp) : "r0", "memory" ) -#include "../__unmapself.c" -#undef __unmapself -extern hidden unsigned __sh_nommu; -#else -#define __sh_nommu 0 -#endif - -void __unmapself(void *base, size_t size) -{ - if (__sh_nommu) __unmapself_sh_nommu(base, size); - else __unmapself_sh_mmu(base, size); -} diff --git a/libc-top-half/musl/src/thread/sh/__unmapself_mmu.s b/libc-top-half/musl/src/thread/sh/__unmapself_mmu.s deleted file mode 100644 index 688087b80..000000000 --- a/libc-top-half/musl/src/thread/sh/__unmapself_mmu.s +++ /dev/null @@ -1,23 +0,0 @@ -.text -.global __unmapself_sh_mmu -.hidden __unmapself_sh_mmu -.type __unmapself_sh_mmu, @function -__unmapself_sh_mmu: - mov #91, r3 ! SYS_munmap - trapa #31 - - or r0, r0 - or r0, r0 - or r0, r0 - or r0, r0 - or r0, r0 - - mov #1, r3 ! SYS_exit - mov #0, r4 - trapa #31 - - or r0, r0 - or r0, r0 - or r0, r0 - or r0, r0 - or r0, r0 diff --git a/libc-top-half/musl/src/thread/sh/atomics.s b/libc-top-half/musl/src/thread/sh/atomics.s deleted file mode 100644 index 9d9fcb6ed..000000000 --- a/libc-top-half/musl/src/thread/sh/atomics.s +++ /dev/null @@ -1,65 +0,0 @@ -/* Contract for all versions is same as cas.l r2,r3,@r0 - * pr and r1 are also clobbered (by jsr & r1 as temp). - * r0,r2,r4-r15 must be preserved. - * r3 contains result (==r2 iff cas succeeded). */ - - .align 2 -.global __sh_cas_gusa -.hidden __sh_cas_gusa -__sh_cas_gusa: - mov.l r5,@-r15 - mov.l r4,@-r15 - mov r0,r4 - mova 1f,r0 - mov r15,r1 - mov #(0f-1f),r15 -0: mov.l @r4,r5 - cmp/eq r5,r2 - bf 1f - mov.l r3,@r4 -1: mov r1,r15 - mov r5,r3 - mov r4,r0 - mov.l @r15+,r4 - rts - mov.l @r15+,r5 - -.global __sh_cas_llsc -.hidden __sh_cas_llsc -__sh_cas_llsc: - mov r0,r1 - .word 0x00ab /* synco */ -0: .word 0x0163 /* movli.l @r1,r0 */ - cmp/eq r0,r2 - bf 1f - mov r3,r0 - .word 0x0173 /* movco.l r0,@r1 */ - bf 0b - mov r2,r0 -1: .word 0x00ab /* synco */ - mov r0,r3 - rts - mov r1,r0 - -.global __sh_cas_imask -.hidden __sh_cas_imask -__sh_cas_imask: - mov r0,r1 - stc sr,r0 - mov.l r0,@-r15 - or #0xf0,r0 - ldc r0,sr - mov.l @r1,r0 - cmp/eq r0,r2 - bf 1f - mov.l r3,@r1 -1: ldc.l @r15+,sr - mov r0,r3 - rts - mov r1,r0 - -.global __sh_cas_cas_l -.hidden __sh_cas_cas_l -__sh_cas_cas_l: - rts - .word 0x2323 /* cas.l r2,r3,@r0 */ diff --git a/libc-top-half/musl/src/thread/sh/clone.s b/libc-top-half/musl/src/thread/sh/clone.s deleted file mode 100644 index 9cfd8623c..000000000 --- a/libc-top-half/musl/src/thread/sh/clone.s +++ /dev/null @@ -1,54 +0,0 @@ -.text -.global __clone -.hidden __clone -.type __clone, @function -__clone: -! incoming: fn stack flags arg ptid tls ctid -! r4 r5 r6 r7 @r15 @(4,r15) @(8,r15) - - mov #-16, r0 - and r0, r5 - - mov r4, r1 ! r1 = fn - mov r7, r2 ! r2 = arg - - mov #120, r3 ! r3 = __NR_clone - mov r6, r4 ! r4 = flags - !mov r5, r5 ! r5 = stack - mov.l @r15, r6 ! r6 = ptid - mov.l @(8,r15), r7 ! r7 = ctid - mov.l @(4,r15), r0 ! r0 = tls - trapa #31 - - or r0, r0 - or r0, r0 - or r0, r0 - or r0, r0 - or r0, r0 - - cmp/eq #0, r0 - bt 1f - - ! we are the parent, return - rts - nop - -1: ! we are the child, call fn(arg) - mov.l 1f, r0 - mov r1, r5 - bsrf r0 - mov r2, r4 - -2: mov #1, r3 ! __NR_exit - mov r0, r4 - trapa #31 - - or r0, r0 - or r0, r0 - or r0, r0 - or r0, r0 - or r0, r0 - -.align 2 -.hidden __shcall -1: .long __shcall@PCREL+(.-2b) diff --git a/libc-top-half/musl/src/thread/sh/syscall_cp.s b/libc-top-half/musl/src/thread/sh/syscall_cp.s deleted file mode 100644 index bb848ef3b..000000000 --- a/libc-top-half/musl/src/thread/sh/syscall_cp.s +++ /dev/null @@ -1,45 +0,0 @@ -.text -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm, @function -__syscall_cp_asm: - -__cp_begin: - mov.l @r4, r4 - tst r4, r4 - bf __cp_cancel - mov r5, r3 - mov r6, r4 - mov r7, r5 - mov.l @r15, r6 - mov.l @(4,r15), r7 - mov.l @(8,r15), r0 - mov.l @(12,r15), r1 - trapa #31 - -__cp_end: - ! work around hardware bug - or r0, r0 - or r0, r0 - or r0, r0 - or r0, r0 - or r0, r0 - - rts - nop - -__cp_cancel: - mov.l 2f, r0 - braf r0 - nop -1: - -.align 2 -2: .long __cancel@PCREL-(1b-.) diff --git a/thread-stub/pthread_barrier_destroy.c b/libc-top-half/musl/src/thread/stubs/pthread_barrier_destroy.c similarity index 100% rename from thread-stub/pthread_barrier_destroy.c rename to libc-top-half/musl/src/thread/stubs/pthread_barrier_destroy.c diff --git a/thread-stub/pthread_barrier_init.c b/libc-top-half/musl/src/thread/stubs/pthread_barrier_init.c similarity index 100% rename from thread-stub/pthread_barrier_init.c rename to libc-top-half/musl/src/thread/stubs/pthread_barrier_init.c diff --git a/thread-stub/pthread_barrier_wait.c b/libc-top-half/musl/src/thread/stubs/pthread_barrier_wait.c similarity index 100% rename from thread-stub/pthread_barrier_wait.c rename to libc-top-half/musl/src/thread/stubs/pthread_barrier_wait.c diff --git a/thread-stub/pthread_cond_broadcast.c b/libc-top-half/musl/src/thread/stubs/pthread_cond_broadcast.c similarity index 100% rename from thread-stub/pthread_cond_broadcast.c rename to libc-top-half/musl/src/thread/stubs/pthread_cond_broadcast.c diff --git a/thread-stub/pthread_cond_destroy.c b/libc-top-half/musl/src/thread/stubs/pthread_cond_destroy.c similarity index 100% rename from thread-stub/pthread_cond_destroy.c rename to libc-top-half/musl/src/thread/stubs/pthread_cond_destroy.c diff --git a/thread-stub/pthread_cond_init.c b/libc-top-half/musl/src/thread/stubs/pthread_cond_init.c similarity index 100% rename from thread-stub/pthread_cond_init.c rename to libc-top-half/musl/src/thread/stubs/pthread_cond_init.c diff --git a/thread-stub/pthread_cond_signal.c b/libc-top-half/musl/src/thread/stubs/pthread_cond_signal.c similarity index 100% rename from thread-stub/pthread_cond_signal.c rename to libc-top-half/musl/src/thread/stubs/pthread_cond_signal.c diff --git a/thread-stub/pthread_cond_timedwait.c b/libc-top-half/musl/src/thread/stubs/pthread_cond_timedwait.c similarity index 100% rename from thread-stub/pthread_cond_timedwait.c rename to libc-top-half/musl/src/thread/stubs/pthread_cond_timedwait.c diff --git a/thread-stub/pthread_cond_wait.c b/libc-top-half/musl/src/thread/stubs/pthread_cond_wait.c similarity index 100% rename from thread-stub/pthread_cond_wait.c rename to libc-top-half/musl/src/thread/stubs/pthread_cond_wait.c diff --git a/thread-stub/pthread_create.c b/libc-top-half/musl/src/thread/stubs/pthread_create.c similarity index 100% rename from thread-stub/pthread_create.c rename to libc-top-half/musl/src/thread/stubs/pthread_create.c diff --git a/thread-stub/pthread_detach.c b/libc-top-half/musl/src/thread/stubs/pthread_detach.c similarity index 100% rename from thread-stub/pthread_detach.c rename to libc-top-half/musl/src/thread/stubs/pthread_detach.c diff --git a/thread-stub/pthread_join.c b/libc-top-half/musl/src/thread/stubs/pthread_join.c similarity index 100% rename from thread-stub/pthread_join.c rename to libc-top-half/musl/src/thread/stubs/pthread_join.c diff --git a/thread-stub/pthread_mutex_consistent.c b/libc-top-half/musl/src/thread/stubs/pthread_mutex_consistent.c similarity index 100% rename from thread-stub/pthread_mutex_consistent.c rename to libc-top-half/musl/src/thread/stubs/pthread_mutex_consistent.c diff --git a/libc-top-half/musl/src/thread/pthread_mutex_getprioceiling.c b/libc-top-half/musl/src/thread/stubs/pthread_mutex_getprioceiling.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutex_getprioceiling.c rename to libc-top-half/musl/src/thread/stubs/pthread_mutex_getprioceiling.c diff --git a/thread-stub/pthread_mutex_lock.c b/libc-top-half/musl/src/thread/stubs/pthread_mutex_lock.c similarity index 100% rename from thread-stub/pthread_mutex_lock.c rename to libc-top-half/musl/src/thread/stubs/pthread_mutex_lock.c diff --git a/thread-stub/pthread_mutex_timedlock.c b/libc-top-half/musl/src/thread/stubs/pthread_mutex_timedlock.c similarity index 100% rename from thread-stub/pthread_mutex_timedlock.c rename to libc-top-half/musl/src/thread/stubs/pthread_mutex_timedlock.c diff --git a/thread-stub/pthread_mutex_trylock.c b/libc-top-half/musl/src/thread/stubs/pthread_mutex_trylock.c similarity index 100% rename from thread-stub/pthread_mutex_trylock.c rename to libc-top-half/musl/src/thread/stubs/pthread_mutex_trylock.c diff --git a/thread-stub/pthread_mutex_unlock.c b/libc-top-half/musl/src/thread/stubs/pthread_mutex_unlock.c similarity index 100% rename from thread-stub/pthread_mutex_unlock.c rename to libc-top-half/musl/src/thread/stubs/pthread_mutex_unlock.c diff --git a/thread-stub/pthread_once.c b/libc-top-half/musl/src/thread/stubs/pthread_once.c similarity index 100% rename from thread-stub/pthread_once.c rename to libc-top-half/musl/src/thread/stubs/pthread_once.c diff --git a/thread-stub/pthread_rwlock_rdlock.c b/libc-top-half/musl/src/thread/stubs/pthread_rwlock_rdlock.c similarity index 100% rename from thread-stub/pthread_rwlock_rdlock.c rename to libc-top-half/musl/src/thread/stubs/pthread_rwlock_rdlock.c diff --git a/thread-stub/pthread_rwlock_timedrdlock.c b/libc-top-half/musl/src/thread/stubs/pthread_rwlock_timedrdlock.c similarity index 100% rename from thread-stub/pthread_rwlock_timedrdlock.c rename to libc-top-half/musl/src/thread/stubs/pthread_rwlock_timedrdlock.c diff --git a/thread-stub/pthread_rwlock_timedwrlock.c b/libc-top-half/musl/src/thread/stubs/pthread_rwlock_timedwrlock.c similarity index 100% rename from thread-stub/pthread_rwlock_timedwrlock.c rename to libc-top-half/musl/src/thread/stubs/pthread_rwlock_timedwrlock.c diff --git a/thread-stub/pthread_rwlock_tryrdlock.c b/libc-top-half/musl/src/thread/stubs/pthread_rwlock_tryrdlock.c similarity index 100% rename from thread-stub/pthread_rwlock_tryrdlock.c rename to libc-top-half/musl/src/thread/stubs/pthread_rwlock_tryrdlock.c diff --git a/thread-stub/pthread_rwlock_trywrlock.c b/libc-top-half/musl/src/thread/stubs/pthread_rwlock_trywrlock.c similarity index 100% rename from thread-stub/pthread_rwlock_trywrlock.c rename to libc-top-half/musl/src/thread/stubs/pthread_rwlock_trywrlock.c diff --git a/thread-stub/pthread_rwlock_unlock.c b/libc-top-half/musl/src/thread/stubs/pthread_rwlock_unlock.c similarity index 100% rename from thread-stub/pthread_rwlock_unlock.c rename to libc-top-half/musl/src/thread/stubs/pthread_rwlock_unlock.c diff --git a/thread-stub/pthread_rwlock_wrlock.c b/libc-top-half/musl/src/thread/stubs/pthread_rwlock_wrlock.c similarity index 100% rename from thread-stub/pthread_rwlock_wrlock.c rename to libc-top-half/musl/src/thread/stubs/pthread_rwlock_wrlock.c diff --git a/thread-stub/pthread_spin_lock.c b/libc-top-half/musl/src/thread/stubs/pthread_spin_lock.c similarity index 100% rename from thread-stub/pthread_spin_lock.c rename to libc-top-half/musl/src/thread/stubs/pthread_spin_lock.c diff --git a/thread-stub/pthread_spin_trylock.c b/libc-top-half/musl/src/thread/stubs/pthread_spin_trylock.c similarity index 100% rename from thread-stub/pthread_spin_trylock.c rename to libc-top-half/musl/src/thread/stubs/pthread_spin_trylock.c diff --git a/thread-stub/pthread_spin_unlock.c b/libc-top-half/musl/src/thread/stubs/pthread_spin_unlock.c similarity index 100% rename from thread-stub/pthread_spin_unlock.c rename to libc-top-half/musl/src/thread/stubs/pthread_spin_unlock.c diff --git a/libc-top-half/musl/src/thread/__lock.c b/libc-top-half/musl/src/thread/wasi-threads/__lock.c similarity index 100% rename from libc-top-half/musl/src/thread/__lock.c rename to libc-top-half/musl/src/thread/wasi-threads/__lock.c diff --git a/libc-top-half/musl/src/thread/__set_thread_area.c b/libc-top-half/musl/src/thread/wasi-threads/__set_thread_area.c similarity index 100% rename from libc-top-half/musl/src/thread/__set_thread_area.c rename to libc-top-half/musl/src/thread/wasi-threads/__set_thread_area.c diff --git a/libc-top-half/musl/src/thread/__syscall_cp.c b/libc-top-half/musl/src/thread/wasi-threads/__syscall_cp.c similarity index 100% rename from libc-top-half/musl/src/thread/__syscall_cp.c rename to libc-top-half/musl/src/thread/wasi-threads/__syscall_cp.c diff --git a/libc-top-half/musl/src/thread/__timedwait.c b/libc-top-half/musl/src/thread/wasi-threads/__timedwait.c similarity index 100% rename from libc-top-half/musl/src/thread/__timedwait.c rename to libc-top-half/musl/src/thread/wasi-threads/__timedwait.c diff --git a/libc-top-half/musl/src/thread/__tls_get_addr.c b/libc-top-half/musl/src/thread/wasi-threads/__tls_get_addr.c similarity index 100% rename from libc-top-half/musl/src/thread/__tls_get_addr.c rename to libc-top-half/musl/src/thread/wasi-threads/__tls_get_addr.c diff --git a/libc-top-half/musl/src/thread/__unmapself.c b/libc-top-half/musl/src/thread/wasi-threads/__unmapself.c similarity index 100% rename from libc-top-half/musl/src/thread/__unmapself.c rename to libc-top-half/musl/src/thread/wasi-threads/__unmapself.c diff --git a/libc-top-half/musl/src/thread/__wait.c b/libc-top-half/musl/src/thread/wasi-threads/__wait.c similarity index 100% rename from libc-top-half/musl/src/thread/__wait.c rename to libc-top-half/musl/src/thread/wasi-threads/__wait.c diff --git a/libc-top-half/musl/src/thread/wasm32/__wasilibc_busywait.c b/libc-top-half/musl/src/thread/wasi-threads/__wasilibc_busywait.c similarity index 100% rename from libc-top-half/musl/src/thread/wasm32/__wasilibc_busywait.c rename to libc-top-half/musl/src/thread/wasi-threads/__wasilibc_busywait.c diff --git a/libc-top-half/musl/src/thread/call_once.c b/libc-top-half/musl/src/thread/wasi-threads/call_once.c similarity index 100% rename from libc-top-half/musl/src/thread/call_once.c rename to libc-top-half/musl/src/thread/wasi-threads/call_once.c diff --git a/libc-top-half/musl/src/thread/clone.c b/libc-top-half/musl/src/thread/wasi-threads/clone.c similarity index 100% rename from libc-top-half/musl/src/thread/clone.c rename to libc-top-half/musl/src/thread/wasi-threads/clone.c diff --git a/libc-top-half/musl/src/thread/cnd_broadcast.c b/libc-top-half/musl/src/thread/wasi-threads/cnd_broadcast.c similarity index 100% rename from libc-top-half/musl/src/thread/cnd_broadcast.c rename to libc-top-half/musl/src/thread/wasi-threads/cnd_broadcast.c diff --git a/libc-top-half/musl/src/thread/cnd_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/cnd_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/cnd_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/cnd_destroy.c diff --git a/libc-top-half/musl/src/thread/cnd_init.c b/libc-top-half/musl/src/thread/wasi-threads/cnd_init.c similarity index 100% rename from libc-top-half/musl/src/thread/cnd_init.c rename to libc-top-half/musl/src/thread/wasi-threads/cnd_init.c diff --git a/libc-top-half/musl/src/thread/cnd_signal.c b/libc-top-half/musl/src/thread/wasi-threads/cnd_signal.c similarity index 100% rename from libc-top-half/musl/src/thread/cnd_signal.c rename to libc-top-half/musl/src/thread/wasi-threads/cnd_signal.c diff --git a/libc-top-half/musl/src/thread/cnd_timedwait.c b/libc-top-half/musl/src/thread/wasi-threads/cnd_timedwait.c similarity index 100% rename from libc-top-half/musl/src/thread/cnd_timedwait.c rename to libc-top-half/musl/src/thread/wasi-threads/cnd_timedwait.c diff --git a/libc-top-half/musl/src/thread/cnd_wait.c b/libc-top-half/musl/src/thread/wasi-threads/cnd_wait.c similarity index 100% rename from libc-top-half/musl/src/thread/cnd_wait.c rename to libc-top-half/musl/src/thread/wasi-threads/cnd_wait.c diff --git a/libc-top-half/musl/src/thread/default_attr.c b/libc-top-half/musl/src/thread/wasi-threads/default_attr.c similarity index 100% rename from libc-top-half/musl/src/thread/default_attr.c rename to libc-top-half/musl/src/thread/wasi-threads/default_attr.c diff --git a/libc-top-half/musl/src/thread/lock_ptc.c b/libc-top-half/musl/src/thread/wasi-threads/lock_ptc.c similarity index 100% rename from libc-top-half/musl/src/thread/lock_ptc.c rename to libc-top-half/musl/src/thread/wasi-threads/lock_ptc.c diff --git a/libc-top-half/musl/src/thread/mtx_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/mtx_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/mtx_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/mtx_destroy.c diff --git a/libc-top-half/musl/src/thread/mtx_init.c b/libc-top-half/musl/src/thread/wasi-threads/mtx_init.c similarity index 100% rename from libc-top-half/musl/src/thread/mtx_init.c rename to libc-top-half/musl/src/thread/wasi-threads/mtx_init.c diff --git a/libc-top-half/musl/src/thread/mtx_lock.c b/libc-top-half/musl/src/thread/wasi-threads/mtx_lock.c similarity index 100% rename from libc-top-half/musl/src/thread/mtx_lock.c rename to libc-top-half/musl/src/thread/wasi-threads/mtx_lock.c diff --git a/libc-top-half/musl/src/thread/mtx_timedlock.c b/libc-top-half/musl/src/thread/wasi-threads/mtx_timedlock.c similarity index 100% rename from libc-top-half/musl/src/thread/mtx_timedlock.c rename to libc-top-half/musl/src/thread/wasi-threads/mtx_timedlock.c diff --git a/libc-top-half/musl/src/thread/mtx_trylock.c b/libc-top-half/musl/src/thread/wasi-threads/mtx_trylock.c similarity index 100% rename from libc-top-half/musl/src/thread/mtx_trylock.c rename to libc-top-half/musl/src/thread/wasi-threads/mtx_trylock.c diff --git a/libc-top-half/musl/src/thread/mtx_unlock.c b/libc-top-half/musl/src/thread/wasi-threads/mtx_unlock.c similarity index 100% rename from libc-top-half/musl/src/thread/mtx_unlock.c rename to libc-top-half/musl/src/thread/wasi-threads/mtx_unlock.c diff --git a/libc-top-half/musl/src/thread/pthread_atfork.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_atfork.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_atfork.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_atfork.c diff --git a/libc-top-half/musl/src/thread/pthread_attr_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_attr_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_attr_destroy.c diff --git a/libc-top-half/musl/src/thread/pthread_attr_get.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_get.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_attr_get.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_attr_get.c diff --git a/libc-top-half/musl/src/thread/pthread_attr_init.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_init.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_attr_init.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_attr_init.c diff --git a/libc-top-half/musl/src/thread/pthread_attr_setdetachstate.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setdetachstate.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_attr_setdetachstate.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setdetachstate.c diff --git a/libc-top-half/musl/src/thread/pthread_attr_setguardsize.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setguardsize.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_attr_setguardsize.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setguardsize.c diff --git a/libc-top-half/musl/src/thread/pthread_attr_setinheritsched.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setinheritsched.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_attr_setinheritsched.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setinheritsched.c diff --git a/libc-top-half/musl/src/thread/pthread_attr_setschedparam.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setschedparam.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_attr_setschedparam.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setschedparam.c diff --git a/libc-top-half/musl/src/thread/pthread_attr_setschedpolicy.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setschedpolicy.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_attr_setschedpolicy.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setschedpolicy.c diff --git a/libc-top-half/musl/src/thread/pthread_attr_setscope.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setscope.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_attr_setscope.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setscope.c diff --git a/libc-top-half/musl/src/thread/pthread_attr_setstack.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setstack.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_attr_setstack.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setstack.c diff --git a/libc-top-half/musl/src/thread/pthread_attr_setstacksize.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setstacksize.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_attr_setstacksize.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setstacksize.c diff --git a/libc-top-half/musl/src/thread/pthread_barrier_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_barrier_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_barrier_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_barrier_destroy.c diff --git a/libc-top-half/musl/src/thread/pthread_barrier_init.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_barrier_init.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_barrier_init.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_barrier_init.c diff --git a/libc-top-half/musl/src/thread/pthread_barrier_wait.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_barrier_wait.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_barrier_wait.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_barrier_wait.c diff --git a/libc-top-half/musl/src/thread/pthread_barrierattr_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_barrierattr_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_destroy.c diff --git a/libc-top-half/musl/src/thread/pthread_barrierattr_init.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_init.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_barrierattr_init.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_init.c diff --git a/libc-top-half/musl/src/thread/pthread_barrierattr_setpshared.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_setpshared.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_barrierattr_setpshared.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_setpshared.c diff --git a/libc-top-half/musl/src/thread/pthread_cancel.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_cancel.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_cancel.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_cancel.c diff --git a/libc-top-half/musl/src/thread/pthread_cleanup_push.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_cleanup_push.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_cleanup_push.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_cleanup_push.c diff --git a/libc-top-half/musl/src/thread/pthread_cond_broadcast.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_cond_broadcast.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_cond_broadcast.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_cond_broadcast.c diff --git a/libc-top-half/musl/src/thread/pthread_cond_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_cond_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_cond_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_cond_destroy.c diff --git a/libc-top-half/musl/src/thread/pthread_cond_init.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_cond_init.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_cond_init.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_cond_init.c diff --git a/libc-top-half/musl/src/thread/pthread_cond_signal.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_cond_signal.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_cond_signal.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_cond_signal.c diff --git a/libc-top-half/musl/src/thread/pthread_cond_timedwait.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_cond_timedwait.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_cond_timedwait.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_cond_timedwait.c diff --git a/libc-top-half/musl/src/thread/pthread_cond_wait.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_cond_wait.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_cond_wait.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_cond_wait.c diff --git a/libc-top-half/musl/src/thread/pthread_condattr_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_condattr_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_destroy.c diff --git a/libc-top-half/musl/src/thread/pthread_condattr_init.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_init.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_condattr_init.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_init.c diff --git a/libc-top-half/musl/src/thread/pthread_condattr_setclock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_setclock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_condattr_setclock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_setclock.c diff --git a/libc-top-half/musl/src/thread/pthread_condattr_setpshared.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_setpshared.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_condattr_setpshared.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_setpshared.c diff --git a/libc-top-half/musl/src/thread/pthread_create.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_create.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_create.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_create.c diff --git a/libc-top-half/musl/src/thread/pthread_detach.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_detach.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_detach.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_detach.c diff --git a/libc-top-half/musl/src/thread/pthread_equal.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_equal.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_equal.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_equal.c diff --git a/libc-top-half/musl/src/thread/pthread_getattr_np.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_getattr_np.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_getattr_np.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_getattr_np.c diff --git a/libc-top-half/musl/src/thread/pthread_getconcurrency.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_getconcurrency.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_getconcurrency.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_getconcurrency.c diff --git a/libc-top-half/musl/src/thread/pthread_getcpuclockid.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_getcpuclockid.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_getcpuclockid.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_getcpuclockid.c diff --git a/libc-top-half/musl/src/thread/pthread_getname_np.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_getname_np.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_getname_np.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_getname_np.c diff --git a/libc-top-half/musl/src/thread/pthread_getschedparam.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_getschedparam.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_getschedparam.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_getschedparam.c diff --git a/libc-top-half/musl/src/thread/pthread_getspecific.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_getspecific.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_getspecific.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_getspecific.c diff --git a/libc-top-half/musl/src/thread/pthread_join.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_join.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_join.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_join.c diff --git a/libc-top-half/musl/src/thread/pthread_key_create.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_key_create.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_key_create.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_key_create.c diff --git a/libc-top-half/musl/src/thread/pthread_kill.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_kill.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_kill.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_kill.c diff --git a/libc-top-half/musl/src/thread/pthread_mutex_consistent.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_consistent.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutex_consistent.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_consistent.c diff --git a/libc-top-half/musl/src/thread/pthread_mutex_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutex_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_destroy.c diff --git a/thread-stub/pthread_mutex_getprioceiling.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_getprioceiling.c similarity index 100% rename from thread-stub/pthread_mutex_getprioceiling.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_getprioceiling.c diff --git a/libc-top-half/musl/src/thread/pthread_mutex_init.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_init.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutex_init.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_init.c diff --git a/libc-top-half/musl/src/thread/pthread_mutex_lock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_lock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutex_lock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_lock.c diff --git a/libc-top-half/musl/src/thread/pthread_mutex_setprioceiling.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_setprioceiling.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutex_setprioceiling.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_setprioceiling.c diff --git a/libc-top-half/musl/src/thread/pthread_mutex_timedlock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_timedlock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutex_timedlock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_timedlock.c diff --git a/libc-top-half/musl/src/thread/pthread_mutex_trylock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_trylock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutex_trylock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_trylock.c diff --git a/libc-top-half/musl/src/thread/pthread_mutex_unlock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_unlock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutex_unlock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_unlock.c diff --git a/libc-top-half/musl/src/thread/pthread_mutexattr_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutexattr_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_destroy.c diff --git a/libc-top-half/musl/src/thread/pthread_mutexattr_init.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_init.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutexattr_init.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_init.c diff --git a/libc-top-half/musl/src/thread/pthread_mutexattr_setprotocol.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setprotocol.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutexattr_setprotocol.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setprotocol.c diff --git a/libc-top-half/musl/src/thread/pthread_mutexattr_setpshared.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setpshared.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutexattr_setpshared.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setpshared.c diff --git a/libc-top-half/musl/src/thread/pthread_mutexattr_setrobust.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setrobust.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutexattr_setrobust.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setrobust.c diff --git a/libc-top-half/musl/src/thread/pthread_mutexattr_settype.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_settype.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_mutexattr_settype.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_settype.c diff --git a/libc-top-half/musl/src/thread/pthread_once.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_once.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_once.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_once.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlock_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlock_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_destroy.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlock_init.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_init.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlock_init.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_init.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlock_rdlock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_rdlock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlock_rdlock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_rdlock.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlock_timedrdlock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_timedrdlock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlock_timedrdlock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_timedrdlock.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlock_timedwrlock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_timedwrlock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlock_timedwrlock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_timedwrlock.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlock_tryrdlock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_tryrdlock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlock_tryrdlock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_tryrdlock.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlock_trywrlock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_trywrlock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlock_trywrlock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_trywrlock.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlock_unlock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_unlock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlock_unlock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_unlock.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlock_wrlock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_wrlock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlock_wrlock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_wrlock.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlockattr_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlockattr_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_destroy.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlockattr_init.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_init.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlockattr_init.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_init.c diff --git a/libc-top-half/musl/src/thread/pthread_rwlockattr_setpshared.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_setpshared.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_rwlockattr_setpshared.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_setpshared.c diff --git a/libc-top-half/musl/src/thread/pthread_self.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_self.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_self.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_self.c diff --git a/libc-top-half/musl/src/thread/pthread_setattr_default_np.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_setattr_default_np.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_setattr_default_np.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_setattr_default_np.c diff --git a/libc-top-half/musl/src/thread/pthread_setcancelstate.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_setcancelstate.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_setcancelstate.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_setcancelstate.c diff --git a/libc-top-half/musl/src/thread/pthread_setcanceltype.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_setcanceltype.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_setcanceltype.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_setcanceltype.c diff --git a/libc-top-half/musl/src/thread/pthread_setconcurrency.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_setconcurrency.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_setconcurrency.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_setconcurrency.c diff --git a/libc-top-half/musl/src/thread/pthread_setname_np.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_setname_np.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_setname_np.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_setname_np.c diff --git a/libc-top-half/musl/src/thread/pthread_setschedparam.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_setschedparam.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_setschedparam.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_setschedparam.c diff --git a/libc-top-half/musl/src/thread/pthread_setschedprio.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_setschedprio.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_setschedprio.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_setschedprio.c diff --git a/libc-top-half/musl/src/thread/pthread_setspecific.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_setspecific.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_setspecific.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_setspecific.c diff --git a/libc-top-half/musl/src/thread/pthread_sigmask.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_sigmask.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_sigmask.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_sigmask.c diff --git a/libc-top-half/musl/src/thread/pthread_spin_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_spin_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_spin_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_spin_destroy.c diff --git a/libc-top-half/musl/src/thread/pthread_spin_init.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_spin_init.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_spin_init.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_spin_init.c diff --git a/libc-top-half/musl/src/thread/pthread_spin_lock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_spin_lock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_spin_lock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_spin_lock.c diff --git a/libc-top-half/musl/src/thread/pthread_spin_trylock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_spin_trylock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_spin_trylock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_spin_trylock.c diff --git a/libc-top-half/musl/src/thread/pthread_spin_unlock.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_spin_unlock.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_spin_unlock.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_spin_unlock.c diff --git a/libc-top-half/musl/src/thread/pthread_testcancel.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_testcancel.c similarity index 100% rename from libc-top-half/musl/src/thread/pthread_testcancel.c rename to libc-top-half/musl/src/thread/wasi-threads/pthread_testcancel.c diff --git a/libc-top-half/musl/src/thread/sem_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/sem_destroy.c rename to libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c diff --git a/libc-top-half/musl/src/thread/sem_getvalue.c b/libc-top-half/musl/src/thread/wasi-threads/sem_getvalue.c similarity index 100% rename from libc-top-half/musl/src/thread/sem_getvalue.c rename to libc-top-half/musl/src/thread/wasi-threads/sem_getvalue.c diff --git a/libc-top-half/musl/src/thread/sem_init.c b/libc-top-half/musl/src/thread/wasi-threads/sem_init.c similarity index 100% rename from libc-top-half/musl/src/thread/sem_init.c rename to libc-top-half/musl/src/thread/wasi-threads/sem_init.c diff --git a/libc-top-half/musl/src/thread/sem_open.c b/libc-top-half/musl/src/thread/wasi-threads/sem_open.c similarity index 100% rename from libc-top-half/musl/src/thread/sem_open.c rename to libc-top-half/musl/src/thread/wasi-threads/sem_open.c diff --git a/libc-top-half/musl/src/thread/sem_post.c b/libc-top-half/musl/src/thread/wasi-threads/sem_post.c similarity index 100% rename from libc-top-half/musl/src/thread/sem_post.c rename to libc-top-half/musl/src/thread/wasi-threads/sem_post.c diff --git a/libc-top-half/musl/src/thread/sem_timedwait.c b/libc-top-half/musl/src/thread/wasi-threads/sem_timedwait.c similarity index 100% rename from libc-top-half/musl/src/thread/sem_timedwait.c rename to libc-top-half/musl/src/thread/wasi-threads/sem_timedwait.c diff --git a/libc-top-half/musl/src/thread/sem_trywait.c b/libc-top-half/musl/src/thread/wasi-threads/sem_trywait.c similarity index 100% rename from libc-top-half/musl/src/thread/sem_trywait.c rename to libc-top-half/musl/src/thread/wasi-threads/sem_trywait.c diff --git a/libc-top-half/musl/src/thread/sem_unlink.c b/libc-top-half/musl/src/thread/wasi-threads/sem_unlink.c similarity index 100% rename from libc-top-half/musl/src/thread/sem_unlink.c rename to libc-top-half/musl/src/thread/wasi-threads/sem_unlink.c diff --git a/libc-top-half/musl/src/thread/sem_wait.c b/libc-top-half/musl/src/thread/wasi-threads/sem_wait.c similarity index 100% rename from libc-top-half/musl/src/thread/sem_wait.c rename to libc-top-half/musl/src/thread/wasi-threads/sem_wait.c diff --git a/libc-top-half/musl/src/thread/synccall.c b/libc-top-half/musl/src/thread/wasi-threads/synccall.c similarity index 100% rename from libc-top-half/musl/src/thread/synccall.c rename to libc-top-half/musl/src/thread/wasi-threads/synccall.c diff --git a/libc-top-half/musl/src/thread/syscall_cp.c b/libc-top-half/musl/src/thread/wasi-threads/syscall_cp.c similarity index 100% rename from libc-top-half/musl/src/thread/syscall_cp.c rename to libc-top-half/musl/src/thread/wasi-threads/syscall_cp.c diff --git a/libc-top-half/musl/src/thread/thrd_create.c b/libc-top-half/musl/src/thread/wasi-threads/thrd_create.c similarity index 100% rename from libc-top-half/musl/src/thread/thrd_create.c rename to libc-top-half/musl/src/thread/wasi-threads/thrd_create.c diff --git a/libc-top-half/musl/src/thread/thrd_exit.c b/libc-top-half/musl/src/thread/wasi-threads/thrd_exit.c similarity index 100% rename from libc-top-half/musl/src/thread/thrd_exit.c rename to libc-top-half/musl/src/thread/wasi-threads/thrd_exit.c diff --git a/libc-top-half/musl/src/thread/thrd_join.c b/libc-top-half/musl/src/thread/wasi-threads/thrd_join.c similarity index 100% rename from libc-top-half/musl/src/thread/thrd_join.c rename to libc-top-half/musl/src/thread/wasi-threads/thrd_join.c diff --git a/libc-top-half/musl/src/thread/thrd_sleep.c b/libc-top-half/musl/src/thread/wasi-threads/thrd_sleep.c similarity index 100% rename from libc-top-half/musl/src/thread/thrd_sleep.c rename to libc-top-half/musl/src/thread/wasi-threads/thrd_sleep.c diff --git a/libc-top-half/musl/src/thread/thrd_yield.c b/libc-top-half/musl/src/thread/wasi-threads/thrd_yield.c similarity index 100% rename from libc-top-half/musl/src/thread/thrd_yield.c rename to libc-top-half/musl/src/thread/wasi-threads/thrd_yield.c diff --git a/libc-top-half/musl/src/thread/tls.c b/libc-top-half/musl/src/thread/wasi-threads/tls.c similarity index 100% rename from libc-top-half/musl/src/thread/tls.c rename to libc-top-half/musl/src/thread/wasi-threads/tls.c diff --git a/libc-top-half/musl/src/thread/tss_create.c b/libc-top-half/musl/src/thread/wasi-threads/tss_create.c similarity index 100% rename from libc-top-half/musl/src/thread/tss_create.c rename to libc-top-half/musl/src/thread/wasi-threads/tss_create.c diff --git a/libc-top-half/musl/src/thread/tss_delete.c b/libc-top-half/musl/src/thread/wasi-threads/tss_delete.c similarity index 100% rename from libc-top-half/musl/src/thread/tss_delete.c rename to libc-top-half/musl/src/thread/wasi-threads/tss_delete.c diff --git a/libc-top-half/musl/src/thread/tss_set.c b/libc-top-half/musl/src/thread/wasi-threads/tss_set.c similarity index 100% rename from libc-top-half/musl/src/thread/tss_set.c rename to libc-top-half/musl/src/thread/wasi-threads/tss_set.c diff --git a/libc-top-half/musl/src/thread/vmlock.c b/libc-top-half/musl/src/thread/wasi-threads/vmlock.c similarity index 100% rename from libc-top-half/musl/src/thread/vmlock.c rename to libc-top-half/musl/src/thread/wasi-threads/vmlock.c diff --git a/libc-top-half/musl/src/thread/wasm32/wasi_thread_start.s b/libc-top-half/musl/src/thread/wasi-threads/wasi_thread_start.s similarity index 100% rename from libc-top-half/musl/src/thread/wasm32/wasi_thread_start.s rename to libc-top-half/musl/src/thread/wasi-threads/wasi_thread_start.s diff --git a/libc-top-half/musl/src/thread/x32/__set_thread_area.s b/libc-top-half/musl/src/thread/x32/__set_thread_area.s deleted file mode 100644 index c0fee87e6..000000000 --- a/libc-top-half/musl/src/thread/x32/__set_thread_area.s +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ -.text -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - mov %edi,%esi /* shift for syscall */ - movl $0x1002,%edi /* SET_FS register */ - movl $0x4000009e,%eax /* set fs segment to */ - syscall /* arch_prctl(SET_FS, arg)*/ - ret diff --git a/libc-top-half/musl/src/thread/x32/__unmapself.s b/libc-top-half/musl/src/thread/x32/__unmapself.s deleted file mode 100644 index d9254601f..000000000 --- a/libc-top-half/musl/src/thread/x32/__unmapself.s +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ -.text -.global __unmapself -.type __unmapself,@function -__unmapself: - movl $0x4000000b,%eax /* SYS_munmap */ - syscall /* munmap(arg2,arg3) */ - xor %rdi,%rdi /* exit() args: always return success */ - movl $0x4000003c,%eax /* SYS_exit */ - syscall /* exit(0) */ diff --git a/libc-top-half/musl/src/thread/x32/clone.s b/libc-top-half/musl/src/thread/x32/clone.s deleted file mode 100644 index b870880f9..000000000 --- a/libc-top-half/musl/src/thread/x32/clone.s +++ /dev/null @@ -1,26 +0,0 @@ -.text -.global __clone -.hidden __clone -.type __clone,@function -__clone: - movl $0x40000038,%eax /* SYS_clone */ - mov %rdi,%r11 - mov %rdx,%rdi - mov %r8,%rdx - mov %r9,%r8 - mov 8(%rsp),%r10 - mov %r11,%r9 - and $-16,%rsi - sub $8,%rsi - mov %rcx,(%rsi) - syscall - test %eax,%eax - jnz 1f - xor %ebp,%ebp - pop %rdi - call *%r9 - mov %eax,%edi - movl $0x4000003c,%eax /* SYS_exit */ - syscall - hlt -1: ret diff --git a/libc-top-half/musl/src/thread/x32/syscall_cp.s b/libc-top-half/musl/src/thread/x32/syscall_cp.s deleted file mode 100644 index 4f101716d..000000000 --- a/libc-top-half/musl/src/thread/x32/syscall_cp.s +++ /dev/null @@ -1,31 +0,0 @@ -.text -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,@function -__syscall_cp_asm: - -__cp_begin: - mov (%rdi),%eax - test %eax,%eax - jnz __cp_cancel - mov %rdi,%r11 - mov %rsi,%rax - mov %rdx,%rdi - mov %rcx,%rsi - mov %r8,%rdx - mov %r9,%r10 - mov 8(%rsp),%r8 - mov 16(%rsp),%r9 - mov %r11,8(%rsp) - syscall -__cp_end: - ret -__cp_cancel: - jmp __cancel diff --git a/libc-top-half/musl/src/thread/x86_64/__set_thread_area.s b/libc-top-half/musl/src/thread/x86_64/__set_thread_area.s deleted file mode 100644 index 7347ff4dc..000000000 --- a/libc-top-half/musl/src/thread/x86_64/__set_thread_area.s +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ -.text -.global __set_thread_area -.hidden __set_thread_area -.type __set_thread_area,@function -__set_thread_area: - mov %rdi,%rsi /* shift for syscall */ - movl $0x1002,%edi /* SET_FS register */ - movl $158,%eax /* set fs segment to */ - syscall /* arch_prctl(SET_FS, arg)*/ - ret diff --git a/libc-top-half/musl/src/thread/x86_64/__unmapself.s b/libc-top-half/musl/src/thread/x86_64/__unmapself.s deleted file mode 100644 index e2689e650..000000000 --- a/libc-top-half/musl/src/thread/x86_64/__unmapself.s +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */ -.text -.global __unmapself -.type __unmapself,@function -__unmapself: - movl $11,%eax /* SYS_munmap */ - syscall /* munmap(arg2,arg3) */ - xor %rdi,%rdi /* exit() args: always return success */ - movl $60,%eax /* SYS_exit */ - syscall /* exit(0) */ diff --git a/libc-top-half/musl/src/thread/x86_64/clone.s b/libc-top-half/musl/src/thread/x86_64/clone.s deleted file mode 100644 index 6e47bc0a3..000000000 --- a/libc-top-half/musl/src/thread/x86_64/clone.s +++ /dev/null @@ -1,28 +0,0 @@ -.text -.global __clone -.hidden __clone -.type __clone,@function -__clone: - xor %eax,%eax - mov $56,%al - mov %rdi,%r11 - mov %rdx,%rdi - mov %r8,%rdx - mov %r9,%r8 - mov 8(%rsp),%r10 - mov %r11,%r9 - and $-16,%rsi - sub $8,%rsi - mov %rcx,(%rsi) - syscall - test %eax,%eax - jnz 1f - xor %ebp,%ebp - pop %rdi - call *%r9 - mov %eax,%edi - xor %eax,%eax - mov $60,%al - syscall - hlt -1: ret diff --git a/libc-top-half/musl/src/thread/x86_64/syscall_cp.s b/libc-top-half/musl/src/thread/x86_64/syscall_cp.s deleted file mode 100644 index 4f101716d..000000000 --- a/libc-top-half/musl/src/thread/x86_64/syscall_cp.s +++ /dev/null @@ -1,31 +0,0 @@ -.text -.global __cp_begin -.hidden __cp_begin -.global __cp_end -.hidden __cp_end -.global __cp_cancel -.hidden __cp_cancel -.hidden __cancel -.global __syscall_cp_asm -.hidden __syscall_cp_asm -.type __syscall_cp_asm,@function -__syscall_cp_asm: - -__cp_begin: - mov (%rdi),%eax - test %eax,%eax - jnz __cp_cancel - mov %rdi,%r11 - mov %rsi,%rax - mov %rdx,%rdi - mov %rcx,%rsi - mov %r8,%rdx - mov %r9,%r10 - mov 8(%rsp),%r8 - mov 16(%rsp),%r9 - mov %r11,8(%rsp) - syscall -__cp_end: - ret -__cp_cancel: - jmp __cancel diff --git a/thread-stub/README.md b/thread-stub/README.md deleted file mode 100644 index 0a78fc2fa..000000000 --- a/thread-stub/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Stub pthreads implementation - -This library provides the foundation for a POSIX conformant implementation of -pthreads API for `THREAD_MODEL=single`. When combined with the appropriate -parts of musl's libc-top-half, it forms a complete pthreads implementation -that is never able to spawn new threads, but otherwise follows the letter of -the specification in every way. From fd62b0b871e8a2884892692388b3077fbbba246e Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Wed, 11 Feb 2026 13:06:18 +0000 Subject: [PATCH 02/43] Cmake fixes --- libc-top-half/CMakeLists.txt | 58 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index 7a476b10f..97ca8e2ba 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -441,35 +441,35 @@ if (THREADS) else() # pthreads stubs for single-threaded environment list(APPEND top_half_sources - musl/src/thread/wasi-threads/pthread_barrier_destroy.c - musl/src/thread/wasi-threads/pthread_barrier_init.c - musl/src/thread/wasi-threads/pthread_barrier_wait.c - musl/src/thread/wasi-threads/pthread_cond_broadcast.c - musl/src/thread/wasi-threads/pthread_cond_destroy.c - musl/src/thread/wasi-threads/pthread_cond_init.c - musl/src/thread/wasi-threads/pthread_cond_signal.c - musl/src/thread/wasi-threads/pthread_cond_timedwait.c - musl/src/thread/wasi-threads/pthread_cond_wait.c - musl/src/thread/wasi-threads/pthread_create.c - musl/src/thread/wasi-threads/pthread_detach.c - musl/src/thread/wasi-threads/pthread_join.c - musl/src/thread/wasi-threads/pthread_mutex_consistent.c - musl/src/thread/wasi-threads/pthread_mutex_getprioceiling.c - musl/src/thread/wasi-threads/pthread_mutex_lock.c - musl/src/thread/wasi-threads/pthread_mutex_timedlock.c - musl/src/thread/wasi-threads/pthread_mutex_trylock.c - musl/src/thread/wasi-threads/pthread_mutex_unlock.c - musl/src/thread/wasi-threads/pthread_once.c - musl/src/thread/wasi-threads/pthread_rwlock_rdlock.c - musl/src/thread/wasi-threads/pthread_rwlock_timedrdlock.c - musl/src/thread/wasi-threads/pthread_rwlock_timedwrlock.c - musl/src/thread/wasi-threads/pthread_rwlock_tryrdlock.c - musl/src/thread/wasi-threads/pthread_rwlock_trywrlock.c - musl/src/thread/wasi-threads/pthread_rwlock_unlock.c - musl/src/thread/wasi-threads/pthread_rwlock_wrlock.c - musl/src/thread/wasi-threads/pthread_spin_lock.c - musl/src/thread/wasi-threads/pthread_spin_trylock.c - musl/src/thread/wasi-threads/pthread_spin_unlock.c + musl/src/thread/stub/pthread_barrier_destroy.c + musl/src/thread/stub/pthread_barrier_init.c + musl/src/thread/stub/pthread_barrier_wait.c + musl/src/thread/stub/pthread_cond_broadcast.c + musl/src/thread/stub/pthread_cond_destroy.c + musl/src/thread/stub/pthread_cond_init.c + musl/src/thread/stub/pthread_cond_signal.c + musl/src/thread/stub/pthread_cond_timedwait.c + musl/src/thread/stub/pthread_cond_wait.c + musl/src/thread/stub/pthread_create.c + musl/src/thread/stub/pthread_detach.c + musl/src/thread/stub/pthread_join.c + musl/src/thread/stub/pthread_mutex_consistent.c + musl/src/thread/stub/pthread_mutex_getprioceiling.c + musl/src/thread/stub/pthread_mutex_lock.c + musl/src/thread/stub/pthread_mutex_timedlock.c + musl/src/thread/stub/pthread_mutex_trylock.c + musl/src/thread/stub/pthread_mutex_unlock.c + musl/src/thread/stub/pthread_once.c + musl/src/thread/stub/pthread_rwlock_rdlock.c + musl/src/thread/stub/pthread_rwlock_timedrdlock.c + musl/src/thread/stub/pthread_rwlock_timedwrlock.c + musl/src/thread/stub/pthread_rwlock_tryrdlock.c + musl/src/thread/stub/pthread_rwlock_trywrlock.c + musl/src/thread/stub/pthread_rwlock_unlock.c + musl/src/thread/stub/pthread_rwlock_wrlock.c + musl/src/thread/stub/pthread_spin_lock.c + musl/src/thread/stub/pthread_spin_trylock.c + musl/src/thread/stub/pthread_spin_unlock.c ) endif() From 974fc8ad679a7767848ca533040cf9640d5ffecb Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Wed, 11 Feb 2026 13:14:55 +0000 Subject: [PATCH 03/43] Common files --- libc-top-half/CMakeLists.txt | 86 +++++++++---------- .../{wasi-threads => common}/default_attr.c | 0 .../pthread_attr_destroy.c | 0 .../pthread_attr_get.c | 0 .../pthread_attr_init.c | 0 .../pthread_attr_setdetachstate.c | 0 .../pthread_attr_setguardsize.c | 0 .../pthread_attr_setschedparam.c | 0 .../pthread_attr_setstack.c | 0 .../pthread_attr_setstacksize.c | 0 .../pthread_barrierattr_destroy.c | 0 .../pthread_barrierattr_init.c | 0 .../pthread_barrierattr_setpshared.c | 0 .../{wasi-threads => common}/pthread_cancel.c | 0 .../pthread_cleanup_push.c | 0 .../pthread_condattr_destroy.c | 0 .../pthread_condattr_init.c | 0 .../pthread_condattr_setclock.c | 0 .../pthread_condattr_setpshared.c | 0 .../{wasi-threads => common}/pthread_equal.c | 0 .../pthread_getattr_np.c | 0 .../pthread_getspecific.c | 0 .../pthread_key_create.c | 0 .../pthread_mutex_destroy.c | 0 .../pthread_mutex_init.c | 0 .../pthread_mutexattr_destroy.c | 0 .../pthread_mutexattr_init.c | 0 .../pthread_mutexattr_setprotocol.c | 0 .../pthread_mutexattr_setpshared.c | 0 .../pthread_mutexattr_setrobust.c | 0 .../pthread_mutexattr_settype.c | 0 .../pthread_rwlock_destroy.c | 0 .../pthread_rwlock_init.c | 0 .../pthread_rwlockattr_destroy.c | 0 .../pthread_rwlockattr_init.c | 0 .../pthread_rwlockattr_setpshared.c | 0 .../{wasi-threads => common}/pthread_self.c | 0 .../pthread_setcancelstate.c | 0 .../pthread_setcanceltype.c | 0 .../pthread_setspecific.c | 0 .../pthread_spin_destroy.c | 0 .../pthread_spin_init.c | 0 .../pthread_testcancel.c | 0 .../{wasi-threads => common}/thrd_sleep.c | 0 44 files changed, 43 insertions(+), 43 deletions(-) rename libc-top-half/musl/src/thread/{wasi-threads => common}/default_attr.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_attr_destroy.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_attr_get.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_attr_init.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_attr_setdetachstate.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_attr_setguardsize.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_attr_setschedparam.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_attr_setstack.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_attr_setstacksize.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_barrierattr_destroy.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_barrierattr_init.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_barrierattr_setpshared.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_cancel.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_cleanup_push.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_condattr_destroy.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_condattr_init.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_condattr_setclock.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_condattr_setpshared.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_equal.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_getattr_np.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_getspecific.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_key_create.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_mutex_destroy.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_mutex_init.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_mutexattr_destroy.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_mutexattr_init.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_mutexattr_setprotocol.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_mutexattr_setpshared.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_mutexattr_setrobust.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_mutexattr_settype.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_rwlock_destroy.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_rwlock_init.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_rwlockattr_destroy.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_rwlockattr_init.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_rwlockattr_setpshared.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_self.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_setcancelstate.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_setcanceltype.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_setspecific.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_spin_destroy.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_spin_init.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_testcancel.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/thrd_sleep.c (100%) diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index 97ca8e2ba..7c6f9fb53 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -224,49 +224,49 @@ set(top_half_sources musl/src/network/ntohl.c musl/src/network/ntohs.c musl/src/stat/futimesat.c - musl/src/thread/default_attr.c - musl/src/thread/pthread_attr_destroy.c - musl/src/thread/pthread_attr_get.c - musl/src/thread/pthread_attr_init.c - musl/src/thread/pthread_attr_setdetachstate.c - musl/src/thread/pthread_attr_setguardsize.c - musl/src/thread/pthread_attr_setschedparam.c - musl/src/thread/pthread_attr_setstack.c - musl/src/thread/pthread_attr_setstacksize.c - musl/src/thread/pthread_barrierattr_destroy.c - musl/src/thread/pthread_barrierattr_init.c - musl/src/thread/pthread_barrierattr_setpshared.c - musl/src/thread/pthread_cancel.c - musl/src/thread/pthread_cleanup_push.c - musl/src/thread/pthread_condattr_destroy.c - musl/src/thread/pthread_condattr_init.c - musl/src/thread/pthread_condattr_setclock.c - musl/src/thread/pthread_condattr_setpshared.c - musl/src/thread/pthread_equal.c - musl/src/thread/pthread_getattr_np.c - musl/src/thread/pthread_getspecific.c - musl/src/thread/pthread_key_create.c - musl/src/thread/pthread_mutex_destroy.c - musl/src/thread/pthread_mutex_init.c - musl/src/thread/pthread_mutexattr_destroy.c - musl/src/thread/pthread_mutexattr_init.c - musl/src/thread/pthread_mutexattr_setprotocol.c - musl/src/thread/pthread_mutexattr_setpshared.c - musl/src/thread/pthread_mutexattr_setrobust.c - musl/src/thread/pthread_mutexattr_settype.c - musl/src/thread/pthread_rwlock_destroy.c - musl/src/thread/pthread_rwlock_init.c - musl/src/thread/pthread_rwlockattr_destroy.c - musl/src/thread/pthread_rwlockattr_init.c - musl/src/thread/pthread_rwlockattr_setpshared.c - musl/src/thread/pthread_self.c - musl/src/thread/pthread_setcancelstate.c - musl/src/thread/pthread_setcanceltype.c - musl/src/thread/pthread_setspecific.c - musl/src/thread/pthread_spin_destroy.c - musl/src/thread/pthread_spin_init.c - musl/src/thread/pthread_testcancel.c - musl/src/thread/thrd_sleep.c + musl/src/thread/common/default_attr.c + musl/src/thread/common/pthread_attr_destroy.c + musl/src/thread/common/pthread_attr_get.c + musl/src/thread/common/pthread_attr_init.c + musl/src/thread/common/pthread_attr_setdetachstate.c + musl/src/thread/common/pthread_attr_setguardsize.c + musl/src/thread/common/pthread_attr_setschedparam.c + musl/src/thread/common/pthread_attr_setstack.c + musl/src/thread/common/pthread_attr_setstacksize.c + musl/src/thread/common/pthread_barrierattr_destroy.c + musl/src/thread/common/pthread_barrierattr_init.c + musl/src/thread/common/pthread_barrierattr_setpshared.c + musl/src/thread/common/pthread_cancel.c + musl/src/thread/common/pthread_cleanup_push.c + musl/src/thread/common/pthread_condattr_destroy.c + musl/src/thread/common/pthread_condattr_init.c + musl/src/thread/common/pthread_condattr_setclock.c + musl/src/thread/common/pthread_condattr_setpshared.c + musl/src/thread/common/pthread_equal.c + musl/src/thread/common/pthread_getattr_np.c + musl/src/thread/common/pthread_getspecific.c + musl/src/thread/common/pthread_key_create.c + musl/src/thread/common/pthread_mutex_destroy.c + musl/src/thread/common/pthread_mutex_init.c + musl/src/thread/common/pthread_mutexattr_destroy.c + musl/src/thread/common/pthread_mutexattr_init.c + musl/src/thread/common/pthread_mutexattr_setprotocol.c + musl/src/thread/common/pthread_mutexattr_setpshared.c + musl/src/thread/common/pthread_mutexattr_setrobust.c + musl/src/thread/common/pthread_mutexattr_settype.c + musl/src/thread/common/pthread_rwlock_destroy.c + musl/src/thread/common/pthread_rwlock_init.c + musl/src/thread/common/pthread_rwlockattr_destroy.c + musl/src/thread/common/pthread_rwlockattr_init.c + musl/src/thread/common/pthread_rwlockattr_setpshared.c + musl/src/thread/common/pthread_self.c + musl/src/thread/common/pthread_setcancelstate.c + musl/src/thread/common/pthread_setcanceltype.c + musl/src/thread/common/pthread_setspecific.c + musl/src/thread/common/pthread_spin_destroy.c + musl/src/thread/common/pthread_spin_init.c + musl/src/thread/common/pthread_testcancel.c + musl/src/thread/common/thrd_sleep.c musl/src/time/__month_to_secs.c musl/src/time/__secs_to_tm.c musl/src/time/__tm_to_secs.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/default_attr.c b/libc-top-half/musl/src/thread/common/default_attr.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/default_attr.c rename to libc-top-half/musl/src/thread/common/default_attr.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_destroy.c b/libc-top-half/musl/src/thread/common/pthread_attr_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_attr_destroy.c rename to libc-top-half/musl/src/thread/common/pthread_attr_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_get.c b/libc-top-half/musl/src/thread/common/pthread_attr_get.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_attr_get.c rename to libc-top-half/musl/src/thread/common/pthread_attr_get.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_init.c b/libc-top-half/musl/src/thread/common/pthread_attr_init.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_attr_init.c rename to libc-top-half/musl/src/thread/common/pthread_attr_init.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setdetachstate.c b/libc-top-half/musl/src/thread/common/pthread_attr_setdetachstate.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setdetachstate.c rename to libc-top-half/musl/src/thread/common/pthread_attr_setdetachstate.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setguardsize.c b/libc-top-half/musl/src/thread/common/pthread_attr_setguardsize.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setguardsize.c rename to libc-top-half/musl/src/thread/common/pthread_attr_setguardsize.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setschedparam.c b/libc-top-half/musl/src/thread/common/pthread_attr_setschedparam.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setschedparam.c rename to libc-top-half/musl/src/thread/common/pthread_attr_setschedparam.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setstack.c b/libc-top-half/musl/src/thread/common/pthread_attr_setstack.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setstack.c rename to libc-top-half/musl/src/thread/common/pthread_attr_setstack.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setstacksize.c b/libc-top-half/musl/src/thread/common/pthread_attr_setstacksize.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_attr_setstacksize.c rename to libc-top-half/musl/src/thread/common/pthread_attr_setstacksize.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_destroy.c b/libc-top-half/musl/src/thread/common/pthread_barrierattr_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_destroy.c rename to libc-top-half/musl/src/thread/common/pthread_barrierattr_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_init.c b/libc-top-half/musl/src/thread/common/pthread_barrierattr_init.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_init.c rename to libc-top-half/musl/src/thread/common/pthread_barrierattr_init.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_setpshared.c b/libc-top-half/musl/src/thread/common/pthread_barrierattr_setpshared.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_barrierattr_setpshared.c rename to libc-top-half/musl/src/thread/common/pthread_barrierattr_setpshared.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_cancel.c b/libc-top-half/musl/src/thread/common/pthread_cancel.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_cancel.c rename to libc-top-half/musl/src/thread/common/pthread_cancel.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_cleanup_push.c b/libc-top-half/musl/src/thread/common/pthread_cleanup_push.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_cleanup_push.c rename to libc-top-half/musl/src/thread/common/pthread_cleanup_push.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_destroy.c b/libc-top-half/musl/src/thread/common/pthread_condattr_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_destroy.c rename to libc-top-half/musl/src/thread/common/pthread_condattr_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_init.c b/libc-top-half/musl/src/thread/common/pthread_condattr_init.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_init.c rename to libc-top-half/musl/src/thread/common/pthread_condattr_init.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_setclock.c b/libc-top-half/musl/src/thread/common/pthread_condattr_setclock.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_setclock.c rename to libc-top-half/musl/src/thread/common/pthread_condattr_setclock.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_setpshared.c b/libc-top-half/musl/src/thread/common/pthread_condattr_setpshared.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_condattr_setpshared.c rename to libc-top-half/musl/src/thread/common/pthread_condattr_setpshared.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_equal.c b/libc-top-half/musl/src/thread/common/pthread_equal.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_equal.c rename to libc-top-half/musl/src/thread/common/pthread_equal.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_getattr_np.c b/libc-top-half/musl/src/thread/common/pthread_getattr_np.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_getattr_np.c rename to libc-top-half/musl/src/thread/common/pthread_getattr_np.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_getspecific.c b/libc-top-half/musl/src/thread/common/pthread_getspecific.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_getspecific.c rename to libc-top-half/musl/src/thread/common/pthread_getspecific.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_key_create.c b/libc-top-half/musl/src/thread/common/pthread_key_create.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_key_create.c rename to libc-top-half/musl/src/thread/common/pthread_key_create.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_destroy.c b/libc-top-half/musl/src/thread/common/pthread_mutex_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_destroy.c rename to libc-top-half/musl/src/thread/common/pthread_mutex_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_init.c b/libc-top-half/musl/src/thread/common/pthread_mutex_init.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_mutex_init.c rename to libc-top-half/musl/src/thread/common/pthread_mutex_init.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_destroy.c b/libc-top-half/musl/src/thread/common/pthread_mutexattr_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_destroy.c rename to libc-top-half/musl/src/thread/common/pthread_mutexattr_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_init.c b/libc-top-half/musl/src/thread/common/pthread_mutexattr_init.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_init.c rename to libc-top-half/musl/src/thread/common/pthread_mutexattr_init.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setprotocol.c b/libc-top-half/musl/src/thread/common/pthread_mutexattr_setprotocol.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setprotocol.c rename to libc-top-half/musl/src/thread/common/pthread_mutexattr_setprotocol.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setpshared.c b/libc-top-half/musl/src/thread/common/pthread_mutexattr_setpshared.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setpshared.c rename to libc-top-half/musl/src/thread/common/pthread_mutexattr_setpshared.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setrobust.c b/libc-top-half/musl/src/thread/common/pthread_mutexattr_setrobust.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_setrobust.c rename to libc-top-half/musl/src/thread/common/pthread_mutexattr_setrobust.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_settype.c b/libc-top-half/musl/src/thread/common/pthread_mutexattr_settype.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_mutexattr_settype.c rename to libc-top-half/musl/src/thread/common/pthread_mutexattr_settype.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_destroy.c b/libc-top-half/musl/src/thread/common/pthread_rwlock_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_destroy.c rename to libc-top-half/musl/src/thread/common/pthread_rwlock_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_init.c b/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_rwlock_init.c rename to libc-top-half/musl/src/thread/common/pthread_rwlock_init.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_destroy.c b/libc-top-half/musl/src/thread/common/pthread_rwlockattr_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_destroy.c rename to libc-top-half/musl/src/thread/common/pthread_rwlockattr_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_init.c b/libc-top-half/musl/src/thread/common/pthread_rwlockattr_init.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_init.c rename to libc-top-half/musl/src/thread/common/pthread_rwlockattr_init.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_setpshared.c b/libc-top-half/musl/src/thread/common/pthread_rwlockattr_setpshared.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_rwlockattr_setpshared.c rename to libc-top-half/musl/src/thread/common/pthread_rwlockattr_setpshared.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_self.c b/libc-top-half/musl/src/thread/common/pthread_self.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_self.c rename to libc-top-half/musl/src/thread/common/pthread_self.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_setcancelstate.c b/libc-top-half/musl/src/thread/common/pthread_setcancelstate.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_setcancelstate.c rename to libc-top-half/musl/src/thread/common/pthread_setcancelstate.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_setcanceltype.c b/libc-top-half/musl/src/thread/common/pthread_setcanceltype.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_setcanceltype.c rename to libc-top-half/musl/src/thread/common/pthread_setcanceltype.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_setspecific.c b/libc-top-half/musl/src/thread/common/pthread_setspecific.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_setspecific.c rename to libc-top-half/musl/src/thread/common/pthread_setspecific.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_spin_destroy.c b/libc-top-half/musl/src/thread/common/pthread_spin_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_spin_destroy.c rename to libc-top-half/musl/src/thread/common/pthread_spin_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_spin_init.c b/libc-top-half/musl/src/thread/common/pthread_spin_init.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_spin_init.c rename to libc-top-half/musl/src/thread/common/pthread_spin_init.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_testcancel.c b/libc-top-half/musl/src/thread/common/pthread_testcancel.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_testcancel.c rename to libc-top-half/musl/src/thread/common/pthread_testcancel.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/thrd_sleep.c b/libc-top-half/musl/src/thread/common/thrd_sleep.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/thrd_sleep.c rename to libc-top-half/musl/src/thread/common/thrd_sleep.c From 2789d8fef8b3c4d02495d2948fa4867760e08284 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Wed, 11 Feb 2026 13:17:04 +0000 Subject: [PATCH 04/43] Rename folder --- libc-top-half/CMakeLists.txt | 58 +++++++++---------- libc-top-half/musl/src/thread/README.md | 2 +- .../pthread_barrier_destroy.c | 0 .../pthread_barrier_init.c | 0 .../pthread_barrier_wait.c | 0 .../pthread_cond_broadcast.c | 0 .../pthread_cond_destroy.c | 0 .../pthread_cond_init.c | 0 .../pthread_cond_signal.c | 0 .../pthread_cond_timedwait.c | 0 .../pthread_cond_wait.c | 0 .../pthread_create.c | 0 .../pthread_detach.c | 0 .../{stubs => single-threaded}/pthread_join.c | 0 .../pthread_mutex_consistent.c | 0 .../pthread_mutex_getprioceiling.c | 0 .../pthread_mutex_lock.c | 0 .../pthread_mutex_timedlock.c | 0 .../pthread_mutex_trylock.c | 0 .../pthread_mutex_unlock.c | 0 .../{stubs => single-threaded}/pthread_once.c | 0 .../pthread_rwlock_rdlock.c | 0 .../pthread_rwlock_timedrdlock.c | 0 .../pthread_rwlock_timedwrlock.c | 0 .../pthread_rwlock_tryrdlock.c | 0 .../pthread_rwlock_trywrlock.c | 0 .../pthread_rwlock_unlock.c | 0 .../pthread_rwlock_wrlock.c | 0 .../pthread_spin_lock.c | 0 .../pthread_spin_trylock.c | 0 .../pthread_spin_unlock.c | 0 31 files changed, 30 insertions(+), 30 deletions(-) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_barrier_destroy.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_barrier_init.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_barrier_wait.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_cond_broadcast.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_cond_destroy.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_cond_init.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_cond_signal.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_cond_timedwait.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_cond_wait.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_create.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_detach.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_join.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_mutex_consistent.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_mutex_getprioceiling.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_mutex_lock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_mutex_timedlock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_mutex_trylock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_mutex_unlock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_once.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_rwlock_rdlock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_rwlock_timedrdlock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_rwlock_timedwrlock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_rwlock_tryrdlock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_rwlock_trywrlock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_rwlock_unlock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_rwlock_wrlock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_spin_lock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_spin_trylock.c (100%) rename libc-top-half/musl/src/thread/{stubs => single-threaded}/pthread_spin_unlock.c (100%) diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index 7c6f9fb53..69f758eb6 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -441,35 +441,35 @@ if (THREADS) else() # pthreads stubs for single-threaded environment list(APPEND top_half_sources - musl/src/thread/stub/pthread_barrier_destroy.c - musl/src/thread/stub/pthread_barrier_init.c - musl/src/thread/stub/pthread_barrier_wait.c - musl/src/thread/stub/pthread_cond_broadcast.c - musl/src/thread/stub/pthread_cond_destroy.c - musl/src/thread/stub/pthread_cond_init.c - musl/src/thread/stub/pthread_cond_signal.c - musl/src/thread/stub/pthread_cond_timedwait.c - musl/src/thread/stub/pthread_cond_wait.c - musl/src/thread/stub/pthread_create.c - musl/src/thread/stub/pthread_detach.c - musl/src/thread/stub/pthread_join.c - musl/src/thread/stub/pthread_mutex_consistent.c - musl/src/thread/stub/pthread_mutex_getprioceiling.c - musl/src/thread/stub/pthread_mutex_lock.c - musl/src/thread/stub/pthread_mutex_timedlock.c - musl/src/thread/stub/pthread_mutex_trylock.c - musl/src/thread/stub/pthread_mutex_unlock.c - musl/src/thread/stub/pthread_once.c - musl/src/thread/stub/pthread_rwlock_rdlock.c - musl/src/thread/stub/pthread_rwlock_timedrdlock.c - musl/src/thread/stub/pthread_rwlock_timedwrlock.c - musl/src/thread/stub/pthread_rwlock_tryrdlock.c - musl/src/thread/stub/pthread_rwlock_trywrlock.c - musl/src/thread/stub/pthread_rwlock_unlock.c - musl/src/thread/stub/pthread_rwlock_wrlock.c - musl/src/thread/stub/pthread_spin_lock.c - musl/src/thread/stub/pthread_spin_trylock.c - musl/src/thread/stub/pthread_spin_unlock.c + musl/src/thread/single-threaded/pthread_barrier_destroy.c + musl/src/thread/single-threaded/pthread_barrier_init.c + musl/src/thread/single-threaded/pthread_barrier_wait.c + musl/src/thread/single-threaded/pthread_cond_broadcast.c + musl/src/thread/single-threaded/pthread_cond_destroy.c + musl/src/thread/single-threaded/pthread_cond_init.c + musl/src/thread/single-threaded/pthread_cond_signal.c + musl/src/thread/single-threaded/pthread_cond_timedwait.c + musl/src/thread/single-threaded/pthread_cond_wait.c + musl/src/thread/single-threaded/pthread_create.c + musl/src/thread/single-threaded/pthread_detach.c + musl/src/thread/single-threaded/pthread_join.c + musl/src/thread/single-threaded/pthread_mutex_consistent.c + musl/src/thread/single-threaded/pthread_mutex_getprioceiling.c + musl/src/thread/single-threaded/pthread_mutex_lock.c + musl/src/thread/single-threaded/pthread_mutex_timedlock.c + musl/src/thread/single-threaded/pthread_mutex_trylock.c + musl/src/thread/single-threaded/pthread_mutex_unlock.c + musl/src/thread/single-threaded/pthread_once.c + musl/src/thread/single-threaded/pthread_rwlock_rdlock.c + musl/src/thread/single-threaded/pthread_rwlock_timedrdlock.c + musl/src/thread/single-threaded/pthread_rwlock_timedwrlock.c + musl/src/thread/single-threaded/pthread_rwlock_tryrdlock.c + musl/src/thread/single-threaded/pthread_rwlock_trywrlock.c + musl/src/thread/single-threaded/pthread_rwlock_unlock.c + musl/src/thread/single-threaded/pthread_rwlock_wrlock.c + musl/src/thread/single-threaded/pthread_spin_lock.c + musl/src/thread/single-threaded/pthread_spin_trylock.c + musl/src/thread/single-threaded/pthread_spin_unlock.c ) endif() diff --git a/libc-top-half/musl/src/thread/README.md b/libc-top-half/musl/src/thread/README.md index b5ec85726..a4023fd9f 100644 --- a/libc-top-half/musl/src/thread/README.md +++ b/libc-top-half/musl/src/thread/README.md @@ -3,4 +3,4 @@ This directory contains two implementations of the `pthreads` library: - `wasi-threads` - based on the original musl implementation, used for the `wasm32-wasip1-threads` target; see [`wasi-threads`](https://github.com/WebAssembly/wasi-threads) for details -- `stubs` - used for single-threaded WASIP1 and WASIP2 targets; is never able to spawn new threads, but otherwise follows the letter of the specification +- `single-threaded` - used for single-threaded WASIP1 and WASIP2 targets; is never able to spawn new threads, but otherwise follows the letter of the specification diff --git a/libc-top-half/musl/src/thread/stubs/pthread_barrier_destroy.c b/libc-top-half/musl/src/thread/single-threaded/pthread_barrier_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_barrier_destroy.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_barrier_destroy.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_barrier_init.c b/libc-top-half/musl/src/thread/single-threaded/pthread_barrier_init.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_barrier_init.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_barrier_init.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_barrier_wait.c b/libc-top-half/musl/src/thread/single-threaded/pthread_barrier_wait.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_barrier_wait.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_barrier_wait.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_cond_broadcast.c b/libc-top-half/musl/src/thread/single-threaded/pthread_cond_broadcast.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_cond_broadcast.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_cond_broadcast.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_cond_destroy.c b/libc-top-half/musl/src/thread/single-threaded/pthread_cond_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_cond_destroy.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_cond_destroy.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_cond_init.c b/libc-top-half/musl/src/thread/single-threaded/pthread_cond_init.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_cond_init.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_cond_init.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_cond_signal.c b/libc-top-half/musl/src/thread/single-threaded/pthread_cond_signal.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_cond_signal.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_cond_signal.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_cond_timedwait.c b/libc-top-half/musl/src/thread/single-threaded/pthread_cond_timedwait.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_cond_timedwait.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_cond_timedwait.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_cond_wait.c b/libc-top-half/musl/src/thread/single-threaded/pthread_cond_wait.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_cond_wait.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_cond_wait.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_create.c b/libc-top-half/musl/src/thread/single-threaded/pthread_create.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_create.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_create.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_detach.c b/libc-top-half/musl/src/thread/single-threaded/pthread_detach.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_detach.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_detach.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_join.c b/libc-top-half/musl/src/thread/single-threaded/pthread_join.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_join.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_join.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_mutex_consistent.c b/libc-top-half/musl/src/thread/single-threaded/pthread_mutex_consistent.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_mutex_consistent.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_mutex_consistent.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_mutex_getprioceiling.c b/libc-top-half/musl/src/thread/single-threaded/pthread_mutex_getprioceiling.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_mutex_getprioceiling.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_mutex_getprioceiling.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_mutex_lock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_mutex_lock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_mutex_lock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_mutex_lock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_mutex_timedlock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_mutex_timedlock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_mutex_timedlock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_mutex_timedlock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_mutex_trylock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_mutex_trylock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_mutex_trylock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_mutex_trylock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_mutex_unlock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_mutex_unlock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_mutex_unlock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_mutex_unlock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_once.c b/libc-top-half/musl/src/thread/single-threaded/pthread_once.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_once.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_once.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_rwlock_rdlock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_rdlock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_rwlock_rdlock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_rdlock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_rwlock_timedrdlock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_timedrdlock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_rwlock_timedrdlock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_timedrdlock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_rwlock_timedwrlock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_timedwrlock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_rwlock_timedwrlock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_timedwrlock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_rwlock_tryrdlock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_tryrdlock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_rwlock_tryrdlock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_tryrdlock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_rwlock_trywrlock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_trywrlock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_rwlock_trywrlock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_trywrlock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_rwlock_unlock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_unlock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_rwlock_unlock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_unlock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_rwlock_wrlock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_wrlock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_rwlock_wrlock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_rwlock_wrlock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_spin_lock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_spin_lock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_spin_lock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_spin_lock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_spin_trylock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_spin_trylock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_spin_trylock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_spin_trylock.c diff --git a/libc-top-half/musl/src/thread/stubs/pthread_spin_unlock.c b/libc-top-half/musl/src/thread/single-threaded/pthread_spin_unlock.c similarity index 100% rename from libc-top-half/musl/src/thread/stubs/pthread_spin_unlock.c rename to libc-top-half/musl/src/thread/single-threaded/pthread_spin_unlock.c From 8bf9a00e18f7ae29e03819752b1ebb3280b0e149 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Fri, 20 Feb 2026 12:30:53 +0000 Subject: [PATCH 05/43] First pass --- .../headers/public/wasi/__generated_wasip2.h | 2 +- .../headers/public/wasi/__generated_wasip3.h | 2 +- libc-bottom-half/sources/wasip2.c | 4 +- libc-bottom-half/sources/wasip3.c | 4 +- libc-top-half/CMakeLists.txt | 53 +++ .../{wasi-threads => common}/call_once.c | 0 .../thread/{wasi-threads => common}/clone.c | 0 .../{wasi-threads => common}/cnd_broadcast.c | 0 .../{wasi-threads => common}/cnd_destroy.c | 0 .../{wasi-threads => common}/cnd_init.c | 0 .../{wasi-threads => common}/cnd_signal.c | 0 .../{wasi-threads => common}/cnd_timedwait.c | 0 .../{wasi-threads => common}/cnd_wait.c | 0 .../{wasi-threads => common}/lock_ptc.c | 0 .../{wasi-threads => common}/mtx_destroy.c | 0 .../{wasi-threads => common}/mtx_init.c | 0 .../{wasi-threads => common}/mtx_timedlock.c | 0 .../{wasi-threads => common}/mtx_unlock.c | 0 .../pthread_cond_wait.c | 0 .../pthread_getconcurrency.c | 0 .../musl/src/thread/common/sem_destroy.c | 6 + .../musl/src/thread/common/thrd_create.c | 12 + .../musl/src/thread/common/thrd_exit.c | 8 + .../musl/src/thread/common/thrd_join.c | 11 + .../musl/src/thread/common/thrd_sleep copy.c | 14 + .../musl/src/thread/common/thrd_yield.c | 7 + .../tss_create.c => common/tss_create copy.c} | 0 .../musl/src/thread/common/tss_create.c | 10 + .../tss_delete.c => common/tss_delete copy.c} | 0 .../musl/src/thread/common/tss_delete.c | 7 + .../tss_set.c => common/tss_set copy.c} | 0 .../musl/src/thread/common/tss_set.c | 13 + .../musl/src/thread/coop-threads/__lock.c | 37 ++ .../musl/src/thread/coop-threads/__wait.c | 47 +++ .../coop-threads/__wasi_coop_thread_start.s | 37 ++ .../musl/src/thread/coop-threads/mtx_lock.c | 14 + .../src/thread/coop-threads/mtx_trylock.c | 21 + .../coop-threads/pthread_barrier_destroy.c | 6 + .../coop-threads/pthread_barrier_init.c | 8 + .../coop-threads/pthread_barrier_setpshared.c | 7 + .../coop-threads/pthread_barrier_wait.c | 23 + .../src/thread/coop-threads/pthread_cancel.c | 6 + .../coop-threads/pthread_cond_broadcast.c | 7 + .../coop-threads/pthread_cond_destroy.c | 6 + .../thread/coop-threads/pthread_cond_init.c | 7 + .../thread/coop-threads/pthread_cond_signal.c | 7 + .../coop-threads/pthread_cond_timedwait.c | 13 + .../src/thread/coop-threads/pthread_create.c | 311 ++++++++++++++ .../src/thread/coop-threads/pthread_detach.c | 22 + .../coop-threads/pthread_getcpuclockid.c | 6 + .../thread/coop-threads/pthread_getname_np.c | 7 + .../coop-threads/pthread_getschedparam.c | 6 + .../src/thread/coop-threads/pthread_join.c | 44 ++ .../src/thread/coop-threads/pthread_kill.c | 6 + .../coop-threads/pthread_mutex_consistent.c | 8 + .../pthread_mutex_setprioceiling.c | 6 + .../coop-threads/pthread_mutex_timedlock.c | 43 ++ .../coop-threads/pthread_mutex_trylock.c | 33 ++ .../coop-threads/pthread_mutex_unlock.c | 30 ++ .../src/thread/coop-threads/pthread_once.c | 43 ++ .../thread/coop-threads/pthread_rwlock_init.c | 7 + .../coop-threads/pthread_rwlock_timedrdlock.c | 27 ++ .../coop-threads/pthread_rwlock_timedwrlock.c | 34 ++ .../coop-threads/pthread_rwlock_tryrdlock.c | 13 + .../coop-threads/pthread_rwlock_trywrlock.c | 13 + .../coop-threads/pthread_rwlock_unlock.c | 25 ++ .../coop-threads/pthread_rwlock_wrlock.c | 8 + .../coop-threads/pthread_setconcurrency.c | 9 + .../thread/coop-threads/pthread_setname_np.c | 6 + .../coop-threads/pthread_setschedparam.c | 6 + .../coop-threads/pthread_setschedprio.c | 6 + .../src/thread/coop-threads/pthread_sigmask.c | 5 + .../thread/coop-threads/pthread_spin_lock.c | 8 + .../coop-threads/pthread_spin_trylock.c | 8 + .../thread/coop-threads/pthread_spin_unlock.c | 7 + .../src/thread/coop-threads/sem_getvalue.c | 7 + .../musl/src/thread/coop-threads/sem_init.c | 15 + .../musl/src/thread/coop-threads/sem_open.c | 12 + .../musl/src/thread/coop-threads/sem_post.c | 23 + .../src/thread/coop-threads/sem_timedwait.c | 34 ++ .../src/thread/coop-threads/sem_trywait.c | 13 + .../musl/src/thread/coop-threads/sem_wait.c | 6 + test/CMakeLists.txt | 399 ++++++++++++++++++ 83 files changed, 1649 insertions(+), 6 deletions(-) rename libc-top-half/musl/src/thread/{wasi-threads => common}/call_once.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/clone.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/cnd_broadcast.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/cnd_destroy.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/cnd_init.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/cnd_signal.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/cnd_timedwait.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/cnd_wait.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/lock_ptc.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/mtx_destroy.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/mtx_init.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/mtx_timedlock.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/mtx_unlock.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_cond_wait.c (100%) rename libc-top-half/musl/src/thread/{wasi-threads => common}/pthread_getconcurrency.c (100%) create mode 100644 libc-top-half/musl/src/thread/common/sem_destroy.c create mode 100644 libc-top-half/musl/src/thread/common/thrd_create.c create mode 100644 libc-top-half/musl/src/thread/common/thrd_exit.c create mode 100644 libc-top-half/musl/src/thread/common/thrd_join.c create mode 100644 libc-top-half/musl/src/thread/common/thrd_sleep copy.c create mode 100644 libc-top-half/musl/src/thread/common/thrd_yield.c rename libc-top-half/musl/src/thread/{wasi-threads/tss_create.c => common/tss_create copy.c} (100%) create mode 100644 libc-top-half/musl/src/thread/common/tss_create.c rename libc-top-half/musl/src/thread/{wasi-threads/tss_delete.c => common/tss_delete copy.c} (100%) create mode 100644 libc-top-half/musl/src/thread/common/tss_delete.c rename libc-top-half/musl/src/thread/{wasi-threads/tss_set.c => common/tss_set copy.c} (100%) create mode 100644 libc-top-half/musl/src/thread/common/tss_set.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/__lock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/__wait.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s create mode 100644 libc-top-half/musl/src/thread/coop-threads/mtx_lock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/mtx_trylock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_barrier_destroy.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_barrier_init.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_barrier_setpshared.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_barrier_wait.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_cancel.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_cond_broadcast.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_cond_destroy.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_cond_init.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_cond_signal.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_cond_timedwait.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_create.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_detach.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_getcpuclockid.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_getname_np.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_getschedparam.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_join.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_kill.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_mutex_consistent.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_mutex_setprioceiling.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_mutex_timedlock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_mutex_trylock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_mutex_unlock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_once.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_init.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedrdlock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_tryrdlock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_trywrlock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_unlock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_wrlock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_setconcurrency.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_setname_np.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_setschedparam.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_setschedprio.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_sigmask.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_spin_lock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_spin_trylock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_spin_unlock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/sem_getvalue.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/sem_init.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/sem_open.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/sem_post.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/sem_timedwait.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/sem_trywait.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/sem_wait.c diff --git a/libc-bottom-half/headers/public/wasi/__generated_wasip2.h b/libc-bottom-half/headers/public/wasi/__generated_wasip2.h index 54ffac264..dc9f1da45 100644 --- a/libc-bottom-half/headers/public/wasi/__generated_wasip2.h +++ b/libc-bottom-half/headers/public/wasi/__generated_wasip2.h @@ -1083,7 +1083,7 @@ extern bool environment_initial_cwd(wasip2_string_t *ret); // Imported Functions from `wasi:cli/exit@0.2.0` // Exit the current instance and any linked instances. -_Noreturn extern void exit_exit(exit_result_void_void_t *status); +extern void exit_exit(exit_result_void_void_t *status); // Imported Functions from `wasi:io/error@0.2.0` // Returns a string that is suitable to assist humans in debugging diff --git a/libc-bottom-half/headers/public/wasi/__generated_wasip3.h b/libc-bottom-half/headers/public/wasi/__generated_wasip3.h index 8618192ab..edf3fb977 100644 --- a/libc-bottom-half/headers/public/wasi/__generated_wasip3.h +++ b/libc-bottom-half/headers/public/wasi/__generated_wasip3.h @@ -914,7 +914,7 @@ extern bool environment_get_initial_cwd(wasip3_string_t *ret); // Imported Functions from `wasi:cli/exit@0.3.0-rc-2025-09-16` // Exit the current instance and any linked instances. -_Noreturn extern void exit_exit(exit_result_void_void_t *status); +extern void exit_exit(exit_result_void_void_t *status); // Imported Functions from `wasi:cli/stdin@0.3.0-rc-2025-09-16` // Return a stream for reading from stdin. diff --git a/libc-bottom-half/sources/wasip2.c b/libc-bottom-half/sources/wasip2.c index ef7c5d627..f350a9fd0 100644 --- a/libc-bottom-half/sources/wasip2.c +++ b/libc-bottom-half/sources/wasip2.c @@ -1,5 +1,5 @@ // Generated by `wit-bindgen` 0.48.0. DO NOT EDIT! -#include "wasi/wasip2.h" +#include "wasip2.h" #include #include @@ -17,7 +17,7 @@ extern void __wasm_import_environment_initial_cwd(uint8_t *); // Imported Functions from `wasi:cli/exit@0.2.0` __attribute__((__import_module__("wasi:cli/exit@0.2.0"), __import_name__("exit"))) -_Noreturn extern void __wasm_import_exit_exit(int32_t); +extern void __wasm_import_exit_exit(int32_t); // Imported Functions from `wasi:io/error@0.2.0` diff --git a/libc-bottom-half/sources/wasip3.c b/libc-bottom-half/sources/wasip3.c index b58e84ded..cd4276037 100644 --- a/libc-bottom-half/sources/wasip3.c +++ b/libc-bottom-half/sources/wasip3.c @@ -1,5 +1,5 @@ // Generated by `wit-bindgen` 0.48.0. DO NOT EDIT! -#include "wasi/wasip3.h" +#include "wasip3.h" #include #include @@ -17,7 +17,7 @@ extern void __wasm_import_environment_get_initial_cwd(uint8_t *); // Imported Functions from `wasi:cli/exit@0.3.0-rc-2025-09-16` __attribute__((__import_module__("wasi:cli/exit@0.3.0-rc-2025-09-16"), __import_name__("exit"))) -_Noreturn extern void __wasm_import_exit_exit(int32_t); +extern void __wasm_import_exit_exit(int32_t); // Imported Functions from `wasi:cli/stdin@0.3.0-rc-2025-09-16` diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index 69f758eb6..3d41b8037 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -438,6 +438,59 @@ if (THREADS) musl/src/thread/wasi-threads/wasi_thread_start.s musl/src/thread/wasi-threads/__wasilibc_busywait.c ) +elseif(WASI STREQUAL "p3") + # cooperative threads implementation for WASI Preview 3 + list(APPEND top_half_sources + musl/src/thread/coop-threads/__lock.c + musl/src/thread/coop-threads/__wait.c + musl/src/thread/coop-threads/__wasi_coop_thread_start.s + musl/src/thread/coop-threads/mtx_lock.c + musl/src/thread/coop-threads/mtx_trylock.c + musl/src/thread/coop-threads/pthread_barrier_destroy.c + musl/src/thread/coop-threads/pthread_barrier_init.c + musl/src/thread/coop-threads/pthread_barrier_setpshared.c + musl/src/thread/coop-threads/pthread_barrier_wait.c + musl/src/thread/coop-threads/pthread_cancel.c + musl/src/thread/coop-threads/pthread_cond_broadcast.c + musl/src/thread/coop-threads/pthread_cond_destroy.c + musl/src/thread/coop-threads/pthread_cond_init.c + musl/src/thread/coop-threads/pthread_cond_signal.c + musl/src/thread/coop-threads/pthread_cond_timedwait.c + musl/src/thread/coop-threads/pthread_create.c + musl/src/thread/coop-threads/pthread_detach.c + musl/src/thread/coop-threads/pthread_getcpuclockid.c + musl/src/thread/coop-threads/pthread_getname_np.c + musl/src/thread/coop-threads/pthread_getschedparam.c + musl/src/thread/coop-threads/pthread_join.c + musl/src/thread/coop-threads/pthread_kill.c + musl/src/thread/coop-threads/pthread_mutex_consistent.c + musl/src/thread/coop-threads/pthread_mutex_setprioceiling.c + musl/src/thread/coop-threads/pthread_mutex_timedlock.c + musl/src/thread/coop-threads/pthread_mutex_trylock.c + musl/src/thread/coop-threads/pthread_mutex_unlock.c + musl/src/thread/coop-threads/pthread_once.c + musl/src/thread/coop-threads/pthread_rwlock_init.c + musl/src/thread/coop-threads/pthread_rwlock_timedrdlock.c + musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c + musl/src/thread/coop-threads/pthread_rwlock_tryrdlock.c + musl/src/thread/coop-threads/pthread_rwlock_trywrlock.c + musl/src/thread/coop-threads/pthread_rwlock_unlock.c + musl/src/thread/coop-threads/pthread_rwlock_wrlock.c + musl/src/thread/coop-threads/pthread_setconcurrency.c + musl/src/thread/coop-threads/pthread_setname_np.c + musl/src/thread/coop-threads/pthread_setschedparam.c + musl/src/thread/coop-threads/pthread_setschedprio.c + musl/src/thread/coop-threads/pthread_sigmask.c + musl/src/thread/coop-threads/pthread_spin_lock.c + musl/src/thread/coop-threads/pthread_spin_trylock.c + musl/src/thread/coop-threads/pthread_spin_unlock.c + musl/src/thread/coop-threads/sem_getvalue.c + musl/src/thread/coop-threads/sem_init.c + musl/src/thread/coop-threads/sem_open.c + musl/src/thread/coop-threads/sem_post.c + musl/src/thread/coop-threads/sem_timedwait.c + musl/src/thread/coop-threads/sem_trywait.c + musl/src/thread/coop-threads/sem_wait.c) else() # pthreads stubs for single-threaded environment list(APPEND top_half_sources diff --git a/libc-top-half/musl/src/thread/wasi-threads/call_once.c b/libc-top-half/musl/src/thread/common/call_once.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/call_once.c rename to libc-top-half/musl/src/thread/common/call_once.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/clone.c b/libc-top-half/musl/src/thread/common/clone.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/clone.c rename to libc-top-half/musl/src/thread/common/clone.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/cnd_broadcast.c b/libc-top-half/musl/src/thread/common/cnd_broadcast.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/cnd_broadcast.c rename to libc-top-half/musl/src/thread/common/cnd_broadcast.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/cnd_destroy.c b/libc-top-half/musl/src/thread/common/cnd_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/cnd_destroy.c rename to libc-top-half/musl/src/thread/common/cnd_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/cnd_init.c b/libc-top-half/musl/src/thread/common/cnd_init.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/cnd_init.c rename to libc-top-half/musl/src/thread/common/cnd_init.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/cnd_signal.c b/libc-top-half/musl/src/thread/common/cnd_signal.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/cnd_signal.c rename to libc-top-half/musl/src/thread/common/cnd_signal.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/cnd_timedwait.c b/libc-top-half/musl/src/thread/common/cnd_timedwait.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/cnd_timedwait.c rename to libc-top-half/musl/src/thread/common/cnd_timedwait.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/cnd_wait.c b/libc-top-half/musl/src/thread/common/cnd_wait.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/cnd_wait.c rename to libc-top-half/musl/src/thread/common/cnd_wait.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/lock_ptc.c b/libc-top-half/musl/src/thread/common/lock_ptc.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/lock_ptc.c rename to libc-top-half/musl/src/thread/common/lock_ptc.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/mtx_destroy.c b/libc-top-half/musl/src/thread/common/mtx_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/mtx_destroy.c rename to libc-top-half/musl/src/thread/common/mtx_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/mtx_init.c b/libc-top-half/musl/src/thread/common/mtx_init.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/mtx_init.c rename to libc-top-half/musl/src/thread/common/mtx_init.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/mtx_timedlock.c b/libc-top-half/musl/src/thread/common/mtx_timedlock.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/mtx_timedlock.c rename to libc-top-half/musl/src/thread/common/mtx_timedlock.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/mtx_unlock.c b/libc-top-half/musl/src/thread/common/mtx_unlock.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/mtx_unlock.c rename to libc-top-half/musl/src/thread/common/mtx_unlock.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_cond_wait.c b/libc-top-half/musl/src/thread/common/pthread_cond_wait.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_cond_wait.c rename to libc-top-half/musl/src/thread/common/pthread_cond_wait.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_getconcurrency.c b/libc-top-half/musl/src/thread/common/pthread_getconcurrency.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/pthread_getconcurrency.c rename to libc-top-half/musl/src/thread/common/pthread_getconcurrency.c diff --git a/libc-top-half/musl/src/thread/common/sem_destroy.c b/libc-top-half/musl/src/thread/common/sem_destroy.c new file mode 100644 index 000000000..f4aced5da --- /dev/null +++ b/libc-top-half/musl/src/thread/common/sem_destroy.c @@ -0,0 +1,6 @@ +#include + +int sem_destroy(sem_t *sem) +{ + return 0; +} diff --git a/libc-top-half/musl/src/thread/common/thrd_create.c b/libc-top-half/musl/src/thread/common/thrd_create.c new file mode 100644 index 000000000..76a683dbf --- /dev/null +++ b/libc-top-half/musl/src/thread/common/thrd_create.c @@ -0,0 +1,12 @@ +#include "pthread_impl.h" +#include + +int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) +{ + int ret = __pthread_create(thr, __ATTRP_C11_THREAD, (void *(*)(void *))func, arg); + switch (ret) { + case 0: return thrd_success; + case EAGAIN: return thrd_nomem; + default: return thrd_error; + } +} diff --git a/libc-top-half/musl/src/thread/common/thrd_exit.c b/libc-top-half/musl/src/thread/common/thrd_exit.c new file mode 100644 index 000000000..9b291ae3d --- /dev/null +++ b/libc-top-half/musl/src/thread/common/thrd_exit.c @@ -0,0 +1,8 @@ +#include +#include +#include + +_Noreturn void thrd_exit(int result) +{ + __pthread_exit((void*)(intptr_t)result); +} diff --git a/libc-top-half/musl/src/thread/common/thrd_join.c b/libc-top-half/musl/src/thread/common/thrd_join.c new file mode 100644 index 000000000..0d5fd302d --- /dev/null +++ b/libc-top-half/musl/src/thread/common/thrd_join.c @@ -0,0 +1,11 @@ +#include +#include +#include + +int thrd_join(thrd_t t, int *res) +{ + void *pthread_res; + __pthread_join(t, &pthread_res); + if (res) *res = (int)(intptr_t)pthread_res; + return thrd_success; +} diff --git a/libc-top-half/musl/src/thread/common/thrd_sleep copy.c b/libc-top-half/musl/src/thread/common/thrd_sleep copy.c new file mode 100644 index 000000000..97de53455 --- /dev/null +++ b/libc-top-half/musl/src/thread/common/thrd_sleep copy.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include "syscall.h" + +int thrd_sleep(const struct timespec *req, struct timespec *rem) +{ + int ret = -__clock_nanosleep(CLOCK_REALTIME, 0, req, rem); + switch (ret) { + case 0: return 0; + case -EINTR: return -1; /* value specified by C11 */ + default: return -2; + } +} diff --git a/libc-top-half/musl/src/thread/common/thrd_yield.c b/libc-top-half/musl/src/thread/common/thrd_yield.c new file mode 100644 index 000000000..171690f9d --- /dev/null +++ b/libc-top-half/musl/src/thread/common/thrd_yield.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +void thrd_yield() +{ + sched_yield(); +} diff --git a/libc-top-half/musl/src/thread/wasi-threads/tss_create.c b/libc-top-half/musl/src/thread/common/tss_create copy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/tss_create.c rename to libc-top-half/musl/src/thread/common/tss_create copy.c diff --git a/libc-top-half/musl/src/thread/common/tss_create.c b/libc-top-half/musl/src/thread/common/tss_create.c new file mode 100644 index 000000000..6d6ef96b4 --- /dev/null +++ b/libc-top-half/musl/src/thread/common/tss_create.c @@ -0,0 +1,10 @@ +#include +#include + +int tss_create(tss_t *tss, tss_dtor_t dtor) +{ + /* Different error returns are possible. C glues them together into + * just failure notification. Can't be optimized to a tail call, + * unless thrd_error equals EAGAIN. */ + return __pthread_key_create(tss, dtor) ? thrd_error : thrd_success; +} diff --git a/libc-top-half/musl/src/thread/wasi-threads/tss_delete.c b/libc-top-half/musl/src/thread/common/tss_delete copy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/tss_delete.c rename to libc-top-half/musl/src/thread/common/tss_delete copy.c diff --git a/libc-top-half/musl/src/thread/common/tss_delete.c b/libc-top-half/musl/src/thread/common/tss_delete.c new file mode 100644 index 000000000..6f51b07eb --- /dev/null +++ b/libc-top-half/musl/src/thread/common/tss_delete.c @@ -0,0 +1,7 @@ +#include +#include + +void tss_delete(tss_t key) +{ + __pthread_key_delete(key); +} diff --git a/libc-top-half/musl/src/thread/wasi-threads/tss_set.c b/libc-top-half/musl/src/thread/common/tss_set copy.c similarity index 100% rename from libc-top-half/musl/src/thread/wasi-threads/tss_set.c rename to libc-top-half/musl/src/thread/common/tss_set copy.c diff --git a/libc-top-half/musl/src/thread/common/tss_set.c b/libc-top-half/musl/src/thread/common/tss_set.c new file mode 100644 index 000000000..70c4fb723 --- /dev/null +++ b/libc-top-half/musl/src/thread/common/tss_set.c @@ -0,0 +1,13 @@ +#include "pthread_impl.h" +#include + +int tss_set(tss_t k, void *x) +{ + struct pthread *self = __pthread_self(); + /* Avoid unnecessary COW */ + if (self->tsd[k] != x) { + self->tsd[k] = x; + self->tsd_used = 1; + } + return thrd_success; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/__lock.c b/libc-top-half/musl/src/thread/coop-threads/__lock.c new file mode 100644 index 000000000..45e397d34 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/__lock.c @@ -0,0 +1,37 @@ +#include "pthread_impl.h" +#include "lock.h" + +#ifndef __wasip3__ +#error "Unknown WASI version" +#endif + +void __lock(struct __coop_lock *lock) +{ + int tid = wasip3_thread_index(); + if (lock->owner == tid) { + /* Trap on recursive locking. */ + __builtin_trap(); + } + + /* Loop until we acquire the lock. */ + while (lock->owner != 0) { + __waitlist_wait_on(&lock->waiters); + /* After waking, the lock might still be held by another + * thread that was scheduled before us, so loop back. */ + } + + lock->owner = tid; +} + +void __unlock(struct __coop_lock *lock) +{ + int tid = wasip3_thread_index(); + if (lock->owner != tid) { + /* We're trying to unlock a lock we don't own. */ + __builtin_trap(); + } + + lock->owner = 0; + /* Awake one waiter; the others will be resumed on future unlocks. */ + __waitlist_wake_one(&lock->waiters); +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/__wait.c b/libc-top-half/musl/src/thread/coop-threads/__wait.c new file mode 100644 index 000000000..1ccae74a5 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/__wait.c @@ -0,0 +1,47 @@ +#include "pthread_impl.h" +#include + +#ifndef __wasip3__ +#error "Unknown WASI version" +#endif + +void __waitlist_wait_on(struct __waitlist_node **list) +{ + struct __waitlist_node node = { + .tid = wasip3_thread_index(), + .next = *list, + }; + *list = &node; + + wasip3_thread_suspend(); +} + +void __waitlist_wake_one(struct __waitlist_node **list) +{ + if (*list == NULL) { + return; + } + struct __waitlist_node *node = *list; + *list = node->next; + wasip3_thread_yield_to_suspended(node->tid); +} + +void __waitlist_wake_all(struct __waitlist_node **list) +{ + struct __waitlist_node **prev = list; + struct __waitlist_node *curr = *list; + + while (curr) { + uint32_t tid = curr->tid; + *prev = curr->next; + // As a scheduling optimization, we always yield directly to the last + // suspended thread instead of just scheduling it to run at some point. + if (curr->next == NULL) { + wasip3_thread_yield_to_suspended(tid); + } + else { + wasip3_thread_unsuspend(tid); + } + curr = *prev; + } +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s b/libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s new file mode 100644 index 000000000..80348320a --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s @@ -0,0 +1,37 @@ + .text + + .export_name __wasi_coop_thread_start, __wasi_coop_thread_start + + .globaltype __init_stack_pointer, i32 + .functype __wasi_coop_thread_start_C (i32, i32) -> () + .functype __wasm_component_model_builtin_context_set_0 (i32) -> () + .import_module __wasm_component_model_builtin_context_set_0, "$root" + .import_name __wasm_component_model_builtin_context_set_0, "[context-set-0]" + .functype __wasm_component_model_builtin_context_set_1 (i32) -> () + .import_module __wasm_component_model_builtin_context_set_1, "$root" + .import_name __wasm_component_model_builtin_context_set_1, "[context-set-1]" + .import_module __wasm_component_model_builtin_thread_index, "$root" + .import_name __wasm_component_model_builtin_thread_index, "[thread-index]" + .functype __wasm_component_model_builtin_thread_index () -> (i32) + + .hidden __wasi_coop_thread_start + .globl __wasi_coop_thread_start + .type __wasi_coop_thread_start,@function + +__wasi_coop_thread_start: + .functype __wasi_coop_thread_start (i32) -> () + + # Set up the minimum C environment. + local.get 0 # start_arg + i32.load 0 # stack + call __wasm_component_model_builtin_context_set_0 + + local.get 0 # start_arg + i32.load 4 # tls_base + call __wasm_component_model_builtin_context_set_1 + # Make the C function do the rest of work. + call __wasm_component_model_builtin_thread_index + local.get 0 # start_arg + call __wasi_coop_thread_start_C + + end_function \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/mtx_lock.c b/libc-top-half/musl/src/thread/coop-threads/mtx_lock.c new file mode 100644 index 000000000..94a7e506f --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/mtx_lock.c @@ -0,0 +1,14 @@ +#include "pthread_impl.h" +#include + +int mtx_lock(mtx_t *m) +{ + if (m->_m_type == PTHREAD_MUTEX_NORMAL && m->_m_lock == 0) { + m->_m_lock = EBUSY; + return thrd_success; + } + /* Calling mtx_timedlock with a null pointer is an extension. + * It is convenient, here to avoid duplication of the logic + * for return values. */ + return mtx_timedlock(m, 0); +} diff --git a/libc-top-half/musl/src/thread/coop-threads/mtx_trylock.c b/libc-top-half/musl/src/thread/coop-threads/mtx_trylock.c new file mode 100644 index 000000000..54ba9c628 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/mtx_trylock.c @@ -0,0 +1,21 @@ +#include "pthread_impl.h" +#include + +int mtx_trylock(mtx_t *m) +{ + if (m->_m_type == PTHREAD_MUTEX_NORMAL) { + if (m->_m_lock == 0) { + m->_m_lock = EBUSY; + return thrd_success; + } + else { + return thrd_busy; + } + } + int ret = __pthread_mutex_trylock((pthread_mutex_t *)m); + switch (ret) { + default: return thrd_error; + case 0: return thrd_success; + case EBUSY: return thrd_busy; + } +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_destroy.c b/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_destroy.c new file mode 100644 index 000000000..0199620b2 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_destroy.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_barrier_destroy(pthread_barrier_t *b) +{ + return 0; +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_init.c b/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_init.c new file mode 100644 index 000000000..2c5ba7eb7 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_init.c @@ -0,0 +1,8 @@ +#include "pthread_impl.h" + +int pthread_barrier_init(pthread_barrier_t *restrict b, const pthread_barrierattr_t *restrict a, unsigned count) +{ + if (count == 0 || count > INT_MAX) return EINVAL; + *b = (pthread_barrier_t){ ._b_limit = count, ._b_count = 0, ._b_waiters = 0 }; + return 0; +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_setpshared.c b/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_setpshared.c new file mode 100644 index 000000000..99c1dfe6d --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_setpshared.c @@ -0,0 +1,7 @@ +#include "pthread_impl.h" + +int pthread_barrierattr_setpshared(pthread_barrierattr_t *a, int pshared) +{ + // Only private barriers are supported + return pshared == PTHREAD_PROCESS_PRIVATE ? 0 : ENOTSUP; +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_wait.c b/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_wait.c new file mode 100644 index 000000000..b858320b5 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_wait.c @@ -0,0 +1,23 @@ +#include "pthread_impl.h" + +int pthread_barrier_wait(pthread_barrier_t *b) +{ + // Trivial case: only one thread needs to reach barrier + if (b->_b_limit == 1) { + return PTHREAD_BARRIER_SERIAL_THREAD; + } + + // Increment count of waiting threads + b->_b_count++; + + // If all threads have arrived, wake them all + if (b->_b_count == b->_b_limit) { + b->_b_count = 0; + __waitlist_wake_all(&b->_b_waiters); + return PTHREAD_BARRIER_SERIAL_THREAD; + } + + // Otherwise, wait for remaining threads to enter + __waitlist_wait_on(&b->_b_waiters); + return 0; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_cancel.c b/libc-top-half/musl/src/thread/coop-threads/pthread_cancel.c new file mode 100644 index 000000000..21f57bc14 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_cancel.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_cancel(pthread_t t) +{ + return ENOTSUP; +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_cond_broadcast.c b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_broadcast.c new file mode 100644 index 000000000..17f5c773f --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_broadcast.c @@ -0,0 +1,7 @@ +#include "pthread_impl.h" + +int pthread_cond_broadcast(pthread_cond_t *c) +{ + __waitlist_wake_all(&c->_c_waiters); + return 0; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_cond_destroy.c b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_destroy.c new file mode 100644 index 000000000..e2ea8c30c --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_destroy.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_cond_destroy(pthread_cond_t *c) +{ + return 0; +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_cond_init.c b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_init.c new file mode 100644 index 000000000..146a270ed --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_init.c @@ -0,0 +1,7 @@ +#include "pthread_impl.h" + +int pthread_cond_init(pthread_cond_t *restrict c, const pthread_condattr_t *restrict a) +{ + *c = (pthread_cond_t){0}; + return 0; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_cond_signal.c b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_signal.c new file mode 100644 index 000000000..17c248c28 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_signal.c @@ -0,0 +1,7 @@ +#include "pthread_impl.h" + +int pthread_cond_signal(pthread_cond_t *c) +{ + __waitlist_wake_one(&c->_c_waiters); + return 0; +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_cond_timedwait.c b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_timedwait.c new file mode 100644 index 000000000..a17e59670 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_timedwait.c @@ -0,0 +1,13 @@ +#include "pthread_impl.h" + +int __pthread_cond_timedwait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m, const struct timespec *restrict ts) +{ + // TODO(wasip3) timed waits + if (ts) { + return ETIMEDOUT; + } + + pthread_mutex_unlock(m); + __waitlist_wait_on(&c->_c_waiters); + return pthread_mutex_lock(m); +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_create.c b/libc-top-half/musl/src/thread/coop-threads/pthread_create.c new file mode 100644 index 000000000..f5471cde8 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_create.c @@ -0,0 +1,311 @@ +#define _GNU_SOURCE +#include "libc.h" +#include "lock.h" +#include "pthread_impl.h" +#include "stdio_impl.h" +#include +#include + +#include +#include +#include + +// These are implemented elsewhere +static void dummy_0() {} +weak_alias(dummy_0, __pthread_tsd_run_dtors); +weak_alias(dummy_0, __do_orphaned_stdio_locks); + +static void *map_base_deferred_free; + +static void process_map_base_deferred_free() { + free(map_base_deferred_free); + map_base_deferred_free = NULL; +} + +// There is currently no thread.exit intrinsic, so pthread_exit +// cannot terminate a thread early. As such, we do not expose it to users. +// TODO(wasip3) revisit this if we add a thread.exit intrinsic +static void __pthread_exit(void *result) +{ + pthread_t self = __pthread_self(); + + self->canceldisable = 1; + self->cancelasync = 0; + self->result = result; + + while (self->cancelbuf) { + void (*f)(void *) = self->cancelbuf->__f; + void *x = self->cancelbuf->__x; + self->cancelbuf = self->cancelbuf->__next; + f(x); + } + + __pthread_tsd_run_dtors(); + + if (self->detach_state == DT_JOINABLE) { + self->detach_state = DT_EXITING; + } + int state = self->detach_state; + + /* If this is the only thread in the list, don't proceed with + * termination of the thread, just exit immediately */ + if (self->next == self) { + self->detach_state = state; + exit(0); + } + + // At this point we are committed to thread termination. + + /* After the kernel thread exits, its tid may be reused. Clear it + * to prevent inadvertent use and inform functions that would use + * it that it's no longer available. */ + self->tid = 0; + + __do_orphaned_stdio_locks(); + + // This is the point where we would handle robust mutexes if we supported them + + // Unlink the thread from the thread list. + if (!--libc.threads_minus_1) + libc.need_locks = -1; + self->next->prev = self->prev; + self->prev->next = self->next; + self->prev = self->next = self; + + if (state == DT_DETACHED && self->map_base) { + /* As we use malloc/free which is considerably more complex + * than mmap/munmap to call and can even require a valid + * thread context, it's difficult to implement __unmapself. + * + * Here we take an alternative approach which simply defers + * the deallocation. An obvious downside of this approach is + * that it keeps the stack longer. (possibly forever.) + * To avoid wasting too much memory, we only defer a single + * item at most. */ + process_map_base_deferred_free(); + map_base_deferred_free = self->map_base; + // Here is where we would call the thread.exit intrinsic + return; + } + + self->detach_state = DT_EXITED; + + // There may be a thread waiting for this thread to exit, in which case + // we wake it up. + __waitlist_wake_all(&self->joiner_waiters); +} + +void __do_cleanup_push(struct __ptcb *cb) { + struct pthread *self = __pthread_self(); + cb->__next = self->cancelbuf; + self->cancelbuf = cb; +} + +void __do_cleanup_pop(struct __ptcb *cb) { + __pthread_self()->cancelbuf = cb->__next; +} + +struct start_args { + /* + * Note: the offset of the "stack" and "tls_base" members + * in this structure is hardcoded in wasip3_thread_start. + */ + void *stack; + void *tls_base; + void *(*start_func)(void *); + void *start_arg; +}; + +/* + * We want to ensure __wasi_coop_thread_start is linked whenever + * pthread_create is used. The following reference is to ensure that. + * Otherwise, the linker doesn't notice the dependency because + * __wasi_coop_thread_start is used indirectly via a wasm export. + */ +void __wasi_coop_thread_start(void *context); +hidden void *__dummy_reference = __wasi_coop_thread_start; + +hidden void __wasi_coop_thread_start_C(int tid, void *context) { + struct start_args *args = context; + __pthread_self()->tid = tid; + __pthread_exit(args->start_func(args->start_arg)); +} + +/* + * As we allocate stack with malloc() instead of mmap/mprotect, + * there is no point to round it up to PAGE_SIZE. + * Instead, round up to a sane alignment. + * Note: PAGE_SIZE is rather big on WASM. (65536) + */ +#define ROUND(x) (((x) + 16 - 1) & -16) + +/* pthread_key_create.c overrides this */ +static volatile size_t dummy = 0; +weak_alias(dummy, __pthread_tsd_size); +static void *dummy_tsd[1] = {0}; +weak_alias(dummy_tsd, __pthread_tsd_main); + +static FILE *volatile dummy_file = 0; +weak_alias(dummy_file, __stdin_used); +weak_alias(dummy_file, __stdout_used); +weak_alias(dummy_file, __stderr_used); + +int __pthread_create(pthread_t *restrict res, + const pthread_attr_t *restrict attrp, + void *(*entry)(void *), void *restrict arg) { + int ret, c11 = (attrp == __ATTRP_C11_THREAD); + size_t size, guard; + struct pthread *self, *new; + unsigned char *map = 0, *stack = 0, *tsd = 0, *stack_limit; + + // Marking this as volatile seems to prevent certain compiler optimizations + // that lead to incorrect code generation. TODO(wasip3) investigate further + volatile pthread_attr_t attr = {0}; + + size_t tls_size = __builtin_wasm_tls_size(); + size_t tls_align = __builtin_wasm_tls_align(); + void *tls_base = __builtin_wasm_tls_base(); + void *new_tls_base; + size_t tls_offset; + /* We'll need to allocate space for a correctly-aligned TLS block, + so adjust the size accordingly. */ + tls_size += tls_align; + + self = __pthread_self(); + + if (!libc.threaded) { + for (FILE *f = *__ofl_lock(); f; f = f->next) + init_file_lock(f); + __ofl_unlock(); + init_file_lock(__stdin_used); + init_file_lock(__stdout_used); + init_file_lock(__stderr_used); + self->tsd = (void **)__pthread_tsd_main; + libc.threaded = 1; + } + if (attrp && !c11) + attr = *attrp; + + if (!attrp || c11) { + attr._a_stacksize = __default_stacksize; + attr._a_guardsize = __default_guardsize; + } + + if (attr._a_stackaddr) { + size_t need = tls_size + __pthread_tsd_size; + size = attr._a_stacksize; + stack = (void *)(attr._a_stackaddr & -16); + stack_limit = (void *)(attr._a_stackaddr - size); + /* Use application-provided stack for TLS only when + * it does not take more than ~12% or 2k of the + * application's stack space. */ + if (need < size / 8 && need < 2048) { + tsd = stack - __pthread_tsd_size; + stack = tsd - tls_size; + memset(stack, 0, need); + } else { + size = ROUND(need); + } + guard = 0; + } else { + guard = ROUND(attr._a_guardsize); + size = guard + ROUND(attr._a_stacksize + + tls_size + __pthread_tsd_size); + } + + if (!tsd) { + /* Process the deferred free request if any before + * allocationg a new one. Hopefully it enables a reuse of the memory. + * + * Note: We can't perform a simple "handoff" becasue allocation + * sizes might be different. (eg. the stack size might differ) */ + __tl_lock(); + process_map_base_deferred_free(); + __tl_unlock(); + map = malloc(size); + if (!map) + goto fail; + tsd = map + size - __pthread_tsd_size; + memset(tsd, 0, __pthread_tsd_size); + if (!stack) { + stack = tsd - tls_size; + stack_limit = map + guard; + } + } + + new_tls_base = __copy_tls(tsd - tls_size); + /* Compute pthread struct offset from old TLS base, apply to new TLS base */ + tls_offset = (uintptr_t)self - (uintptr_t)tls_base; + new = (void *)((uintptr_t)new_tls_base + tls_offset); + + new->map_base = map; + new->map_size = size; + new->stack = stack; + new->stack_size = stack - stack_limit; + new->guard_size = guard; + new->tsd = (void *)tsd; + new->locale = &libc.global_locale; + new->self = new; + if (attr._a_detach) { + new->detach_state = DT_DETACHED; + } else { + new->detach_state = DT_JOINABLE; + } + new->robust_list.head = &new->robust_list.head; + new->canary = self->canary; + new->sysinfo = self->sysinfo; + + // Setup argument structure for the new thread on its stack. + + /* Align the stack to struct start_args */ + stack -= sizeof(struct start_args); + stack -= (uintptr_t)stack % alignof(struct start_args); + struct start_args *args = (void *)stack; + + /* Align the stack to 16 and store it */ + new->stack = (void *)((uintptr_t)stack & -16); + /* Correct the stack size */ + new->stack_size = stack - stack_limit; + + args->stack = new->stack; /* just for convenience of asm trampoline */ + args->start_func = entry; + args->start_arg = arg; + args->tls_base = (void *)new_tls_base; + + if (!libc.threads_minus_1++) + libc.need_locks = 1; + /* Instead of `__clone`, WASIP3 uses a host API to instantiate a new version + * of the current module and start executing the entry function. */ + ret = wasip3_thread_new_indirect(__wasi_coop_thread_start, (void *)args); + + new->tid = ret; + + // Link the new thread into the thread list + if (ret >= 0) { + new->next = self->next; + new->prev = self; + new->next->prev = new; + new->prev->next = new; + } else { + if (!--libc.threads_minus_1) + libc.need_locks = 0; + } + + if (ret < 0) { + free(map); + return -ret; + } + + // Eagerly run the newly-created thread + // TODO(wasip3): make this configurable, perhaps through scheduler options? + wasip3_thread_yield_to_suspended(new->tid); + + *res = new; + return 0; +fail: + __release_ptc(); + return EAGAIN; +} + +// TODO(wasip3) add an alias for pthread_exit when we want to expose it to users +weak_alias(__pthread_create, pthread_create); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_detach.c b/libc-top-half/musl/src/thread/coop-threads/pthread_detach.c new file mode 100644 index 000000000..b7c58a636 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_detach.c @@ -0,0 +1,22 @@ +#include "pthread_impl.h" +#include + +static int __pthread_detach(pthread_t t) +{ + int state = t->detach_state; + + // Detaching from an already-detached thread is an error + if (state == DT_DETACHED) { + return EINVAL; + } + + if (state == DT_EXITING || state == DT_EXITED) { + __pthread_join(t, 0); + } + + t->detach_state = DT_DETACHED; + return 0; +} + +weak_alias(__pthread_detach, pthread_detach); +weak_alias(__pthread_detach, thrd_detach); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_getcpuclockid.c b/libc-top-half/musl/src/thread/coop-threads/pthread_getcpuclockid.c new file mode 100644 index 000000000..0bc217bda --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_getcpuclockid.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_getcpuclockid(pthread_t t, clockid_t *clockid) +{ + return ENOTSUP; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_getname_np.c b/libc-top-half/musl/src/thread/coop-threads/pthread_getname_np.c new file mode 100644 index 000000000..946d03a5e --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_getname_np.c @@ -0,0 +1,7 @@ + +#include "pthread_impl.h" + +int pthread_getname_np(pthread_t thread, char *name, size_t len) +{ + return ENOTSUP; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_getschedparam.c b/libc-top-half/musl/src/thread/coop-threads/pthread_getschedparam.c new file mode 100644 index 000000000..24a153328 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_getschedparam.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_getschedparam(pthread_t t, int *restrict policy, struct sched_param *restrict param) +{ + return ENOTSUP; +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_join.c b/libc-top-half/musl/src/thread/coop-threads/pthread_join.c new file mode 100644 index 000000000..8f1c0154f --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_join.c @@ -0,0 +1,44 @@ +#define _GNU_SOURCE +#include "pthread_impl.h" + +static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec *at) +{ + int state = t->detach_state; + + /* Cannot join a detached thread */ + if (state >= DT_DETACHED) { + return EINVAL; + } + + /* If already exited, just return the result */ + if (state == DT_EXITED) { + if (res) *res = t->result; + if (t->map_base) free(t->map_base); + return 0; + } + + /* Timeouts not supported for cooperative threading */ + if (at) { + return ETIMEDOUT; + } + + __waitlist_wait_on(&t->joiner_waiters); + + if (res) *res = t->result; + if (t->map_base) free(t->map_base); + return 0; +} + +int __pthread_join(pthread_t t, void **res) +{ + return __pthread_timedjoin_np(t, res, 0); +} + +static int __pthread_tryjoin_np(pthread_t t, void **res) +{ + return t->detach_state==DT_JOINABLE ? EBUSY : __pthread_join(t, res); +} + +weak_alias(__pthread_tryjoin_np, pthread_tryjoin_np); +weak_alias(__pthread_timedjoin_np, pthread_timedjoin_np); +weak_alias(__pthread_join, pthread_join); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_kill.c b/libc-top-half/musl/src/thread/coop-threads/pthread_kill.c new file mode 100644 index 000000000..546c12af9 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_kill.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_kill(pthread_t t, int sig) +{ + return ENOTSUP; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_consistent.c b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_consistent.c new file mode 100644 index 000000000..dcf4dc5c7 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_consistent.c @@ -0,0 +1,8 @@ +#include "pthread_impl.h" +#include "atomic.h" + +int pthread_mutex_consistent(pthread_mutex_t *m) +{ + // Robust mutexes are not supported in cooperative threading mode + return ENOTSUP; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_setprioceiling.c b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_setprioceiling.c new file mode 100644 index 000000000..b0bc993c5 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_setprioceiling.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_mutex_setprioceiling(pthread_mutex_t *restrict m, int ceiling, int *restrict old) +{ + return ENOTSUP; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_timedlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_timedlock.c new file mode 100644 index 000000000..7f3f4a612 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_timedlock.c @@ -0,0 +1,43 @@ +#include "pthread_impl.h" + +int __pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec *restrict at) +{ + int tid = wasip3_thread_index(); + int type = m->_m_type & 15; + + /* Fast path: if available, acquire regardless of timeout */ + if (m->_m_lock == 0) { + m->_m_lock = tid; + m->_m_count = 1; + return 0; + } + + /* Check for recursive lock */ + if (m->_m_lock == tid) { + if (type == PTHREAD_MUTEX_RECURSIVE) { + m->_m_count++; + return 0; + } + if (type == PTHREAD_MUTEX_ERRORCHECK) { + return EDEADLK; + } + /* Normal mutex: deadlock */ + __builtin_trap(); + } + + /* Would need to block, but timeouts not supported */ + if (at) { + return ETIMEDOUT; + } + + /* Wait indefinitely */ + while (m->_m_lock != 0) { + __waitlist_wait_on(&m->_m_waiters); + } + + m->_m_lock = tid; + m->_m_count = 1; + return 0; +} + +weak_alias(__pthread_mutex_timedlock, pthread_mutex_timedlock); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_trylock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_trylock.c new file mode 100644 index 000000000..a412d2d90 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_trylock.c @@ -0,0 +1,33 @@ +#include "pthread_impl.h" + +int __pthread_mutex_trylock(pthread_mutex_t *m) +{ + int tid = wasip3_thread_index(); + int type = m->_m_type & 15; + + /* Check for recursive lock */ + if (m->_m_lock == tid) { + if (type == PTHREAD_MUTEX_RECURSIVE) { + if (m->_m_count >= INT_MAX) return EAGAIN; + m->_m_count++; + return 0; + } + if (type == PTHREAD_MUTEX_ERRORCHECK) { + return EBUSY; + } + /* Normal mutex: already locked */ + return EBUSY; + } + + /* Try to acquire the lock */ + if (m->_m_lock != 0) { + return EBUSY; + } + m->_m_lock = tid; + m->_m_count = 1; + + return 0; +} + + +weak_alias(__pthread_mutex_trylock, pthread_mutex_trylock); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_unlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_unlock.c new file mode 100644 index 000000000..9b98cd2ca --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_unlock.c @@ -0,0 +1,30 @@ +#include "pthread_impl.h" + +int __pthread_mutex_unlock(pthread_mutex_t *m) +{ + int tid = wasip3_thread_index(); + int type = m->_m_type & 15; + + /* Check ownership */ + if (m->_m_lock != tid) { + if (type == PTHREAD_MUTEX_ERRORCHECK || type == PTHREAD_MUTEX_RECURSIVE) { + return EPERM; + } + /* Normal mutex: undefined behavior */ + __builtin_trap(); + } + + /* Handle recursive unlock */ + if (type == PTHREAD_MUTEX_RECURSIVE && m->_m_count > 1) { + m->_m_count--; + return 0; + } + + /* Unlock */ + m->_m_lock = 0; + m->_m_count = 0; + __waitlist_wake_one(&m->_m_waiters); + return 0; +} + +weak_alias(__pthread_mutex_unlock, pthread_mutex_unlock); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_once.c b/libc-top-half/musl/src/thread/coop-threads/pthread_once.c new file mode 100644 index 000000000..bbc11742d --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_once.c @@ -0,0 +1,43 @@ +#include "pthread_impl.h" +enum { + PTHREAD_ONCE_STATE_NOT_RUN = 0, + PTHREAD_ONCE_STATE_RUNNING = 1, + PTHREAD_ONCE_STATE_COMPLETED = 2 +} + +static struct { + pthread_once_t *control; + struct __waitlist_node *waiters; +} once_state; + +int __pthread_once(pthread_once_t *control, void (*init)(void)) +{ + /* Fast path: already completed */ + if (*control == PTHREAD_ONCE_STATE_COMPLETED) { + return 0; + } + + /* Try to become the initializer */ + if (*control == PTHREAD_ONCE_STATE_NOT_RUN) { + *control = PTHREAD_ONCE_STATE_RUNNING; + once_state.control = control; + + /* init may do something that blocks, in which case other threads + * may try to run pthread_once on the same control. They will + * see state PTHREAD_ONCE_STATE_RUNNING and wait on our waitlist. */ + init(); + + *control = PTHREAD_ONCE_STATE_COMPLETED; + __waitlist_wake_all(&once_state.waiters); + return 0; + } + + /* Another thread is initializing, wait for completion */ + while (*control == PTHREAD_ONCE_STATE_RUNNING) { + __waitlist_wait_on(&once_state.waiters); + } + + return 0; +} + +weak_alias(__pthread_once, pthread_once); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_init.c b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_init.c new file mode 100644 index 000000000..f3b69d73f --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_init.c @@ -0,0 +1,7 @@ +#include "pthread_impl.h" + +int pthread_rwlock_init(pthread_rwlock_t *restrict rw, const pthread_rwlockattr_t *restrict a) +{ + *rw = (pthread_rwlock_t){0}; + return 0; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedrdlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedrdlock.c new file mode 100644 index 000000000..dcc1b7379 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedrdlock.c @@ -0,0 +1,27 @@ +#include "pthread_impl.h" + +int __pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rw, const struct timespec *restrict at) +{ + /* Fast path: if no writer, increment readers */ + if (rw->_rw_lock >= 0) { + rw->_rw_lock++; + return 0; + } + + /* Would need to wait for writer, but timeouts not supported */ + if (at) { + errno = ENOSYS; + return -1; + } + + /* Wait until no writer holds the lock */ + while (rw->_rw_lock < 0) { + __waitlist_wait_on(&rw->_rw_waiters); + } + + /* Acquired, increment reader count */ + rw->_rw_lock++; + return 0; +} + +weak_alias(__pthread_rwlock_timedrdlock, pthread_rwlock_timedrdlock); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c new file mode 100644 index 000000000..3b62a97ce --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c @@ -0,0 +1,34 @@ +#include "pthread_impl.h" + +int __pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct timespec *restrict at) +{ + int tid = wasip3_thread_index(); + + /* Check for deadlock: trying to write-lock already owned write lock */ + if (rw->_rw_lock == -tid) { + return EDEADLK; + } + + /* Fast path: if no readers or writers, acquire write lock */ + if (rw->_rw_lock == 0) { + rw->_rw_lock = -tid; /* -tid indicates write lock owned by this thread */ + return 0; + } + + /* Would need to wait, but timeouts not supported */ + if (at) { + errno = ENOSYS; + return -1; + } + + /* Wait until no readers and no writers */ + while (rw->_rw_lock != 0) { + __waitlist_wait_on(&rw->_rw_waiters); + } + + /* Acquired, mark as write-locked with owner */ + rw->_rw_lock = -tid; + return 0; +} + +#endif diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_tryrdlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_tryrdlock.c new file mode 100644 index 000000000..3943e838e --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_tryrdlock.c @@ -0,0 +1,13 @@ +#include "pthread_impl.h" + +int __pthread_rwlock_tryrdlock(pthread_rwlock_t *rw) +{ + /* If no writer holds the lock, increment reader count */ + if (rw->_rw_lock >= 0) { + rw->_rw_lock++; + return 0; + } + return EBUSY; +} + +weak_alias(__pthread_rwlock_tryrdlock, pthread_rwlock_tryrdlock); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_trywrlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_trywrlock.c new file mode 100644 index 000000000..3943e838e --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_trywrlock.c @@ -0,0 +1,13 @@ +#include "pthread_impl.h" + +int __pthread_rwlock_tryrdlock(pthread_rwlock_t *rw) +{ + /* If no writer holds the lock, increment reader count */ + if (rw->_rw_lock >= 0) { + rw->_rw_lock++; + return 0; + } + return EBUSY; +} + +weak_alias(__pthread_rwlock_tryrdlock, pthread_rwlock_tryrdlock); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_unlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_unlock.c new file mode 100644 index 000000000..8ace05356 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_unlock.c @@ -0,0 +1,25 @@ +#include "pthread_impl.h" + +int __pthread_rwlock_unlock(pthread_rwlock_t *rw) +{ + if (rw->_rw_lock > 0) { + /* Releasing read lock */ + rw->_rw_lock--; + if (rw->_rw_lock == 0) { + /* Last reader, wake waiting writers */ + __waitlist_wake_all(&rw->_rw_waiters); + } + } else if (rw->_rw_lock < 0) { + /* Releasing write lock (stored as -tid) */ + rw->_rw_lock = 0; + /* Wake all waiters (readers and writers compete) */ + __waitlist_wake_all(&rw->_rw_waiters); + } else { + /* Unlocking when not locked - trap */ + __builtin_trap(); + } + + return 0; +} + +weak_alias(__pthread_rwlock_unlock, pthread_rwlock_unlock); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_wrlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_wrlock.c new file mode 100644 index 000000000..46a3b3a5b --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_wrlock.c @@ -0,0 +1,8 @@ +#include "pthread_impl.h" + +int __pthread_rwlock_wrlock(pthread_rwlock_t *rw) +{ + return __pthread_rwlock_timedwrlock(rw, 0); +} + +weak_alias(__pthread_rwlock_wrlock, pthread_rwlock_wrlock); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_setconcurrency.c b/libc-top-half/musl/src/thread/coop-threads/pthread_setconcurrency.c new file mode 100644 index 000000000..091abf98c --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_setconcurrency.c @@ -0,0 +1,9 @@ +#include +#include + +int pthread_setconcurrency(int val) +{ + if (val < 0) return EINVAL; + if (val > 0) return EAGAIN; + return 0; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_setname_np.c b/libc-top-half/musl/src/thread/coop-threads/pthread_setname_np.c new file mode 100644 index 000000000..19ae3c7d1 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_setname_np.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_setname_np(pthread_t thread, const char *name) +{ + return ENOTSUP; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_setschedparam.c b/libc-top-half/musl/src/thread/coop-threads/pthread_setschedparam.c new file mode 100644 index 000000000..d1e0d98ac --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_setschedparam.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_setschedparam(pthread_t t, int policy, const struct sched_param *param) +{ + return ENOTSUP; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_setschedprio.c b/libc-top-half/musl/src/thread/coop-threads/pthread_setschedprio.c new file mode 100644 index 000000000..8c662c729 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_setschedprio.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_setschedprio(pthread_t t, int prio) +{ + return ENOTSUP; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_sigmask.c b/libc-top-half/musl/src/thread/coop-threads/pthread_sigmask.c new file mode 100644 index 000000000..b01bf0f64 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_sigmask.c @@ -0,0 +1,5 @@ +struct sigset_t; +int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old) +{ + return ENOTSUP; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_spin_lock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_spin_lock.c new file mode 100644 index 000000000..42073d47f --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_spin_lock.c @@ -0,0 +1,8 @@ +#include "pthread_impl.h" + +int pthread_spin_lock(pthread_spinlock_t *s) +{ + if (*s) return EDEADLK; + *s = EBUSY; + return 0; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_spin_trylock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_spin_trylock.c new file mode 100644 index 000000000..c3ffdc602 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_spin_trylock.c @@ -0,0 +1,8 @@ +#include "pthread_impl.h" + +int pthread_spin_trylock(pthread_spinlock_t *s) +{ + if (*s) return EBUSY; + *s = EBUSY; + return 0; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_spin_unlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_spin_unlock.c new file mode 100644 index 000000000..f9d8a23dc --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_spin_unlock.c @@ -0,0 +1,7 @@ +#include "pthread_impl.h" + +int pthread_spin_unlock(pthread_spinlock_t *s) +{ + *s = 0; + return 0; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/sem_getvalue.c b/libc-top-half/musl/src/thread/coop-threads/sem_getvalue.c new file mode 100644 index 000000000..bf66ed5d4 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/sem_getvalue.c @@ -0,0 +1,7 @@ +#include + +int sem_getvalue(sem_t *restrict sem, int *restrict valp) +{ + *valp = sem->__count; + return 0; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/sem_init.c b/libc-top-half/musl/src/thread/coop-threads/sem_init.c new file mode 100644 index 000000000..ff0cba32b --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/sem_init.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +int sem_init(sem_t *sem, int pshared, unsigned value) +{ + if (value > SEM_VALUE_MAX) { + errno = EINVAL; + return -1; + } + sem->__count = value; + sem->__waiters = NULL; + return 0; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/sem_open.c b/libc-top-half/musl/src/thread/coop-threads/sem_open.c new file mode 100644 index 000000000..b5a9c6a50 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/sem_open.c @@ -0,0 +1,12 @@ +#include +#include + +sem_t *sem_open(const char *name, int flags, ...) +{ + return ENOTSUP; +} + +int sem_close(sem_t *sem) +{ + return ENOTSUP; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/sem_post.c b/libc-top-half/musl/src/thread/coop-threads/sem_post.c new file mode 100644 index 000000000..03ff00c31 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/sem_post.c @@ -0,0 +1,23 @@ +#include +#include +#include "pthread_impl.h" + +int sem_post(sem_t *sem) +{ + int val = sem->__count; + + if (val == SEM_VALUE_MAX) { + errno = EOVERFLOW; + return -1; + } + + /* Increment count */ + sem->__count = val + 1; + + /* If count was negative (waiters present), wake one */ + if (val < 0) { + __waitlist_wake_one(&sem->__waiters); + } + + return 0; +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/sem_timedwait.c b/libc-top-half/musl/src/thread/coop-threads/sem_timedwait.c new file mode 100644 index 000000000..ff0415a45 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/sem_timedwait.c @@ -0,0 +1,34 @@ +#include +#include +#include "pthread_impl.h" + +int sem_timedwait(sem_t *restrict sem, const struct timespec *restrict at) +{ + pthread_testcancel(); + + /* Fast path: if permit is available, take it regardless of timeout */ + if (sem->__count > 0) { + sem->__count--; + return 0; + } + + /* Would need to block, but timeouts not supported in cooperative threading. + * There's no way to interrupt a suspended thread after a timeout. */ + if (at) { + errno = ENOSYS; + return -1; + } + + /* Decrement count to indicate we're waiting (goes negative) */ + sem->__count--; + + /* Loop until a permit becomes available */ + while (sem->__count < 0) { + /* No permits available, wait on the waitlist */ + __waitlist_wait_on(&sem->__waiters); + /* After waking, recheck - another thread might have taken the permit */ + } + + /* We've been given a permit (count incremented by sem_post) */ + return 0; +} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/sem_trywait.c b/libc-top-half/musl/src/thread/coop-threads/sem_trywait.c new file mode 100644 index 000000000..eee581940 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/sem_trywait.c @@ -0,0 +1,13 @@ +#include +#include +#include "pthread_impl.h" + +int sem_trywait(sem_t *sem) +{ + if (sem->__count > 0) { + sem->__count--; + return 0; + } + errno = EAGAIN; + return -1; +} diff --git a/libc-top-half/musl/src/thread/coop-threads/sem_wait.c b/libc-top-half/musl/src/thread/coop-threads/sem_wait.c new file mode 100644 index 000000000..264194f97 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/sem_wait.c @@ -0,0 +1,6 @@ +#include + +int sem_wait(sem_t *sem) +{ + return sem_timedwait(sem, 0); +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e33c39a02..6c3d030d4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,6 +17,19 @@ FetchContent_MakeAvailable(libc-test) set(LIBC_TEST "${libc-test_SOURCE_DIR}") message(STATUS "libc-test source directory: ${LIBC_TEST}") +# ======== Clone Open POSIX Test Suite ========================== + +FetchContent_Declare( + posix-testsuite + GIT_REPOSITORY https://github.com/tartanllama/open-posix-test-suite + GIT_TAG 78b3bc8386ef3d933c7f41c95c89cd80e60e60a9 + GIT_SHALLOW true +) +FetchContent_MakeAvailable(posix-testsuite) +set(POSIX_TESTSUITE "${posix-testsuite_SOURCE_DIR}") +message(STATUS "Open POSIX Test Suite source directory: ${POSIX_TESTSUITE}") + + # ========= Download wasmtime as a test runner ================== include(ba-download) @@ -414,6 +427,392 @@ if (TARGET_TRIPLE MATCHES "-threads") set_tests_properties(libc_test_functional_pthread_cond.wasm PROPERTIES LABELS v8fail) endif() + +# ========= Open POSIX Test Suite tests ======================== + +function(add_posix_test test_file) + cmake_path(REPLACE_EXTENSION test_file wasm OUTPUT_VARIABLE test_name) + string(REPLACE "/" "_" test_name ${test_name}) + set(test_name "open_posix_test_${test_name}") + set(test_file "${POSIX_TESTSUITE}/${test_file}") + + add_test_executable(${test_name} "${test_file}" ${ARGN} LDFLAGS -Wl,--export-table) + register_test(${test_name} ${test_name} ${ARGN}) + target_include_directories(${test_name} PRIVATE ${POSIX_TESTSUITE}/include) +endfunction() + +if (WASI STREQUAL "p3") + # unsupported(fork): conformance/interfaces/pthread_atfork/* + + add_posix_test(conformance/interfaces/pthread_attr_destroy/1-1.c) + add_posix_test(conformance/interfaces/pthread_attr_destroy/2-1.c) + add_posix_test(conformance/interfaces/pthread_attr_destroy/3-1.c) + + add_posix_test(conformance/interfaces/pthread_attr_getdetachstate/1-1.c) + add_posix_test(conformance/interfaces/pthread_attr_getdetachstate/1-2.c) + + # unsupported(scheduling): conformance/interfaces/pthread_attr_getinheritsched/* + # unsupported(scheduling): conformance/interfaces/pthread_attr_getschedparam/* + # unsupported(scheduling): conformance/interfaces/pthread_attr_getschedpolicy/* + # unsupported(scheduling): conformance/interfaces/pthread_attr_getscope/* + + add_posix_test(conformance/interfaces/pthread_attr_getstack/1-1.c) + add_posix_test(conformance/interfaces/pthread_attr_getstacksize/1-1.c) + + add_posix_test(conformance/interfaces/pthread_attr_init/1-1.c) + add_posix_test(conformance/interfaces/pthread_attr_init/2-1.c) + add_posix_test(conformance/interfaces/pthread_attr_init/3-1.c) + add_posix_test(conformance/interfaces/pthread_attr_init/4-1.c) + + add_posix_test(conformance/interfaces/pthread_attr_setdetachstate/1-1.c) + add_posix_test(conformance/interfaces/pthread_attr_setdetachstate/1-2.c) + add_posix_test(conformance/interfaces/pthread_attr_setdetachstate/2-1.c) + add_posix_test(conformance/interfaces/pthread_attr_setdetachstate/4-1.c) + + # unsupported(scheduling): conformance/interfaces/pthread_attr_setinheritsched/* + # unsupported(scheduling): conformance/interfaces/pthread_attr_setschedparam/* + # unsupported(scheduling): conformance/interfaces/pthread_attr_setschedpolicy/* + # unsupported(scheduling): conformance/interfaces/pthread_attr_setscope/* + + add_posix_test(conformance/interfaces/pthread_attr_setstack/1-1.c) + # bad test(untouched stack): conformance/interfaces/pthread_attr_setstack/2-1.c + add_posix_test(conformance/interfaces/pthread_attr_setstack/4-1.c) + # bad test(untouched stack): conformance/interfaces/pthread_attr_setstack/6-1.c + add_posix_test(conformance/interfaces/pthread_attr_setstack/7-1.c) + + add_posix_test(conformance/interfaces/pthread_attr_setstacksize/1-1.c) + # bad test(untouched stack): conformance/interfaces/pthread_attr_setstacksize/2-1.c + # bad test(stack/page size): conformance/interfaces/pthread_attr_setstacksize/4-1.c + + add_posix_test(conformance/interfaces/pthread_barrier_destroy/1-1.c) + # unsupported(cancellation): conformance/interfaces/pthread_barrier_destroy/2-1.c + add_posix_test(conformance/interfaces/pthread_barrier_init/1-1.c) + add_posix_test(conformance/interfaces/pthread_barrier_init/3-1.c) + # bad test(undefined behaviour): conformance/interfaces/pthread_barrier_init/4-1.c + add_posix_test(conformance/interfaces/pthread_barrier_wait/1-1.c) + add_posix_test(conformance/interfaces/pthread_barrier_wait/2-1.c) + # unsupported(signals): conformance/interfaces/pthread_barrier_wait/3-1.c + # unsupported(signals): conformance/interfaces/pthread_barrier_wait/3-2.c + # bad test(undefined behaviour): conformance/interfaces/pthread_barrier_wait/6-1.c + + # unsupported(process-shared): conformance/interfaces/pthread_barrierattr_destroy/* + # unsupported(process-shared): conformance/interfaces/pthread_barrierattr_getpshared/* + # unsupported(process-shared): conformance/interfaces/pthread_barrierattr_init/* + # unsupported(process-shared): conformance/interfaces/pthread_barrierattr_setpshared/* + + # unsupported(cancellation): conformance/interfaces/pthread_cancel/* + + # temporarily unsupported(clocks,pthread_exit): conformance/interfaces/pthread_cleanup_pop/1-1.c + # temporarily unsupported(clocks,pthread_exit): conformance/interfaces/pthread_cleanup_pop/1-2.c + # temporarily unsupported(pthread_exit): conformance/interfaces/pthread_cleanup_pop/1-3.c + + # temporarily unsupported(pthread_exit): conformance/interfaces/pthread_cleanup_push/1-1.c + # unsupported(cancellation): conformance/interfaces/pthread_cleanup_push/1-2.c + # unsupported(cancellation): conformance/interfaces/pthread_cleanup_push/1-3.c + + add_posix_test(conformance/interfaces/pthread_cond_broadcast/1-1.c) + # temporarily unsupported(clocks): conformance/interfaces/pthread_cond_broadcast/1-2.c + add_posix_test(conformance/interfaces/pthread_cond_broadcast/2-1.c) + # temporarily unsupported(timed waits): conformance/interfaces/pthread_cond_broadcast/2-2.c + # unsupported(mmap): conformance/interfaces/pthread_cond_broadcast/2-3.c + add_posix_test(conformance/interfaces/pthread_cond_broadcast/4-1.c) + # unsupported(signals): conformance/interfaces/pthread_cond_broadcast/4-2.c + + add_posix_test(conformance/interfaces/pthread_cond_destroy/1-1.c) + # temporarily unsupported(clocks): conformance/interfaces/pthread_cond_destroy/2-1.c + add_posix_test(conformance/interfaces/pthread_cond_destroy/3-1.c) + add_posix_test(conformance/interfaces/pthread_cond_destroy/speculative/4-1.c) + + add_posix_test(conformance/interfaces/pthread_cond_init/1-1.c) + # unsupported(set time): conformance/interfaces/pthread_cond_init/1-2.c + # unsupported(processes): conformance/interfaces/pthread_cond_init/1-3.c + add_posix_test(conformance/interfaces/pthread_cond_init/2-1.c) + # temporarily unsupported(clocks): conformance/interfaces/pthread_cond_init/2-2.c + add_posix_test(conformance/interfaces/pthread_cond_init/3-1.c) + # unsupported(fork): conformance/interfaces/pthread_cond_init/4-1.c + # unsupported(signals): conformance/interfaces/pthread_cond_init/4-2.c + + add_posix_test(conformance/interfaces/pthread_cond_signal/1-1.c) + # temporarily unsupported(clocks): conformance/interfaces/pthread_cond_signal/1-2.c + add_posix_test(conformance/interfaces/pthread_cond_signal/2-1.c) + # temporarily unsupported(timed waits): conformance/interfaces/pthread_cond_signal/2-2.c + add_posix_test(conformance/interfaces/pthread_cond_signal/4-1.c) + # unsupported(signals): conformance/interfaces/pthread_cond_signal/4-2.c + + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/1-1.c + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/2-1.c + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/2-2.c + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/2-3.c + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/2-4.c + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/2-5.c + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/2-6.c + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/2-7.c + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/3-1.c + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/4-1.c + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/4-2.c + # temporarily unsupported(timed wait): conformance/interfaces/pthread_cond_timedwait/4-3.c + + add_posix_test(conformance/interfaces/pthread_cond_wait/1-1.c) + add_posix_test(conformance/interfaces/pthread_cond_wait/2-1.c) + add_posix_test(conformance/interfaces/pthread_cond_wait/2-2.c) + # unsupported(cancellation): conformance/interfaces/pthread_cond_wait/2-3.c + # test needs modified(alarm waking): conformance/interfaces/pthread_cond_wait/3-1.c + # test needs modified(alarm waking): conformance/interfaces/pthread_cond_wait/4-1.c + + add_posix_test(conformance/interfaces/pthread_condattr_destroy/1-1.c) + add_posix_test(conformance/interfaces/pthread_condattr_destroy/2-1.c) + add_posix_test(conformance/interfaces/pthread_condattr_destroy/3-1.c) + add_posix_test(conformance/interfaces/pthread_condattr_destroy/4-1.c) + + add_posix_test(conformance/interfaces/pthread_condattr_getclock/1-1.c) + add_posix_test(conformance/interfaces/pthread_condattr_getclock/1-2.c) + + # unsupported(process-shared): conformance/interfaces/pthread_condattr_getpshared/* + + add_posix_test(conformance/interfaces/pthread_condattr_init/1-1.c) + add_posix_test(conformance/interfaces/pthread_condattr_init/3-1.c) + + # temporarily unsupported(clocks): conformance/interfaces/pthread_condattr_setclock/1-1.c + # temporarily unsupported(clocks): conformance/interfaces/pthread_condattr_setclock/1-2.c + # unsupported(getcpuclockid): conformance/interfaces/pthread_condattr_setclock/1-3.c + # temporarily unsupported(clocks): conformance/interfaces/pthread_condattr_setclock/2-1.c + + # unsupported(process-shared): conformance/interfaces/pthread_condattr_setpshared/* + + add_posix_test(conformance/interfaces/pthread_create/1-1.c) + # unsupported(cancellation): conformance/interfaces/pthread_create/1-2.c + # unsupported(signals): conformance/interfaces/pthread_create/1-3.c + # unsupported(processes): conformance/interfaces/pthread_create/1-4.c + # unsupported(fork): add_posix_test(conformance/interfaces/pthread_create/1-5.c + # unsupported(scheduling): conformance/interfaces/pthread_create/1-6.c + # unsupported(signals): add_posix_test(conformance/interfaces/pthread_create/10-1.c) + # temporarily unsupported(clocks): conformance/interfaces/pthread_create/11-1.c + add_posix_test(conformance/interfaces/pthread_create/12-1.c) + # unsupported(signals): conformance/interfaces/pthread_create/14-1.c + add_posix_test(conformance/interfaces/pthread_create/15-1.c) + add_posix_test(conformance/interfaces/pthread_create/2-1.c) + add_posix_test(conformance/interfaces/pthread_create/3-1.c) + # unsupported(fork): conformance/interfaces/pthread_create/3-2.c + add_posix_test(conformance/interfaces/pthread_create/4-1.c) + add_posix_test(conformance/interfaces/pthread_create/5-1.c) + add_posix_test(conformance/interfaces/pthread_create/5-2.c) + # unsupported(signals): conformance/interfaces/pthread_create/8-1.c + # unsupported(signals): conformance/interfaces/pthread_create/8-2.c + + add_posix_test(conformance/interfaces/pthread_detach/1-1.c) + add_posix_test(conformance/interfaces/pthread_detach/1-2.c) + add_posix_test(conformance/interfaces/pthread_detach/2-1.c) + add_posix_test(conformance/interfaces/pthread_detach/2-2.c) + add_posix_test(conformance/interfaces/pthread_detach/3-1.c) + add_posix_test(conformance/interfaces/pthread_detach/4-1.c) + # bad test(invalid assumption): conformance/interfaces/pthread_detach/4-2.c + # unsupported(signals): conformance/interfaces/pthread_detach/4-3.c + + add_posix_test(conformance/interfaces/pthread_equal/1-1.c) + add_posix_test(conformance/interfaces/pthread_equal/1-2.c) + # unsupported(signals): conformance/interfaces/pthread_equal/2-1.c + + # temporarily unsupported(pthread_exit) conformance/interfaces/pthread_exit/* + # unsupported(fork): conformance/interfaces/pthread_exit/6-1.c + + # unsupported(getcpuclockid): conformance/interfaces/pthread_getcpuclockid/* + # unsupported(scheduling): conformance/interfaces/pthread_getschedparam/* + + add_posix_test(conformance/interfaces/pthread_getspecific/1-1.c) + add_posix_test(conformance/interfaces/pthread_getspecific/3-1.c) + + add_posix_test(conformance/interfaces/pthread_join/1-1.c) + add_posix_test(conformance/interfaces/pthread_join/1-2.c) + add_posix_test(conformance/interfaces/pthread_join/2-1.c) + # unsupported(cancellation): conformance/interfaces/pthread_join/3-1.c + # unsupported(cancellation): conformance/interfaces/pthread_join/4-1.c + add_posix_test(conformance/interfaces/pthread_join/5-1.c) + # bad test(undefined behaviour): conformance/interfaces/pthread_join/6-2.c + # unsupported(signals): conformance/interfaces/pthread_join/6-3.c + add_posix_test(conformance/interfaces/pthread_join/speculative/6-1.c) + + add_posix_test(conformance/interfaces/pthread_key_create/1-1.c) + add_posix_test(conformance/interfaces/pthread_key_create/1-2.c) + add_posix_test(conformance/interfaces/pthread_key_create/2-1.c) + add_posix_test(conformance/interfaces/pthread_key_create/3-1.c) + add_posix_test(conformance/interfaces/pthread_key_create/speculative/5-1.c) + + add_posix_test(conformance/interfaces/pthread_key_delete/1-1.c) + add_posix_test(conformance/interfaces/pthread_key_delete/1-2.c) + add_posix_test(conformance/interfaces/pthread_key_delete/2-1.c) + + # unsupported(signals): conformance/interfaces/pthread_kill/* + + add_posix_test(conformance/interfaces/pthread_mutex_destroy/1-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_destroy/2-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_destroy/2-2.c) + add_posix_test(conformance/interfaces/pthread_mutex_destroy/3-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_destroy/5-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_destroy/5-2.c) + add_posix_test(conformance/interfaces/pthread_mutex_destroy/speculative/4-2.c) + + # unsupported(scheduling): conformance/interfaces/pthread_mutex_getprioceiling/* + + add_posix_test(conformance/interfaces/pthread_mutex_init/1-1.c) + # unsupported(cancellation): conformance/interfaces/pthread_mutex_init/1-2.c + add_posix_test(conformance/interfaces/pthread_mutex_init/2-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_init/3-1.c) + # unsupported(cancellation): conformance/interfaces/pthread_mutex_init/3-2.c + add_posix_test(conformance/interfaces/pthread_mutex_init/4-1.c) + # unsupported(fork): add_posix_test(conformance/interfaces/pthread_mutex_init/5-1.c + # unsupported(signals): conformance/interfaces/pthread_mutex_init/5-3.c + # unsupported(privileges): conformance/interfaces/pthread_mutex_init/speculative/5-2.c + + add_posix_test(conformance/interfaces/pthread_mutex_lock/1-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_lock/2-1.c) + # unsupported(signals): add_posix_test(conformance/interfaces/pthread_mutex_lock/3-1.c + add_posix_test(conformance/interfaces/pthread_mutex_lock/4-1.c) + # unsupported(signals): add_posix_test(conformance/interfaces/pthread_mutex_lock/5-1.c + + # temporarily unsupported(timed lock): conformance/interfaces/pthread_mutex_timedlock/1-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_mutex_timedlock/2-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_mutex_timedlock/4-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_mutex_timedlock/5-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_mutex_timedlock/5-2.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_mutex_timedlock/5-3.c + + add_posix_test(conformance/interfaces/pthread_mutex_trylock/1-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_trylock/1-2.c) + add_posix_test(conformance/interfaces/pthread_mutex_trylock/2-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_trylock/3-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_trylock/4-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_trylock/4-2.c) + # unsupported(signals): conformance/interfaces/pthread_mutex_trylock/4-3.c + + add_posix_test(conformance/interfaces/pthread_mutex_unlock/1-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_unlock/2-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_unlock/3-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_unlock/5-1.c) + add_posix_test(conformance/interfaces/pthread_mutex_unlock/5-2.c) + + add_posix_test(conformance/interfaces/pthread_mutexattr_destroy/1-1.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_destroy/2-1.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_destroy/3-1.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_destroy/4-1.c) + + # unsupported(scheduling): conformance/interfaces/pthread_mutexattr_getprioceiling/* + + add_posix_test(conformance/interfaces/pthread_mutexattr_getprotocol/1-1.c) + # unsupported(scheduling): conformance/interfaces/pthread_mutexattr_getprotocol/1-2.c + + # unsupported(process-shared): conformance/interfaces/pthread_mutexattr_getpshared/* + + add_posix_test(conformance/interfaces/pthread_mutexattr_gettype/1-1.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_gettype/1-2.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_gettype/1-3.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_gettype/1-4.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_gettype/1-5.c) + # bad test(assumes layout): conformance/interfaces/pthread_mutexattr_gettype/speculative/3-1.c + + add_posix_test(conformance/interfaces/pthread_mutexattr_init/1-1.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_init/3-1.c) + + # unsupported(scheduling): conformance/interfaces/pthread_mutexattr_setprioceiling/* + + # unsupported(scheduling): conformance/interfaces/pthread_mutexattr_setprotocol/1-1.c + add_posix_test(conformance/interfaces/pthread_mutexattr_setprotocol/3-1.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_setprotocol/3-2.c) + + # unsupported(process-shared): conformance/interfaces/pthread_mutexattr_setpshared/* + + add_posix_test(conformance/interfaces/pthread_mutexattr_settype/1-1.c) + # bad test(undefined behaviour): conformance/interfaces/pthread_mutexattr_settype/2-1.c + add_posix_test(conformance/interfaces/pthread_mutexattr_settype/3-1.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_settype/3-2.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_settype/3-3.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_settype/3-4.c) + add_posix_test(conformance/interfaces/pthread_mutexattr_settype/7-1.c) + + add_posix_test(conformance/interfaces/pthread_once/1-1.c) + add_posix_test(conformance/interfaces/pthread_once/1-2.c) + add_posix_test(conformance/interfaces/pthread_once/1-3.c) + add_posix_test(conformance/interfaces/pthread_once/2-1.c) + # unsupported(cancellation): conformance/interfaces/pthread_once/3-1.c + add_posix_test(conformance/interfaces/pthread_once/4-1.c) + # unsupported(signals): conformance/interfaces/pthread_once/6-1.c + + add_posix_test(conformance/interfaces/pthread_rwlock_destroy/1-1.c) + add_posix_test(conformance/interfaces/pthread_rwlock_destroy/3-1.c) + + add_posix_test(conformance/interfaces/pthread_rwlock_init/1-1.c) + add_posix_test(conformance/interfaces/pthread_rwlock_init/2-1.c) + add_posix_test(conformance/interfaces/pthread_rwlock_init/3-1.c) + add_posix_test(conformance/interfaces/pthread_rwlock_init/6-1.c) + + add_posix_test(conformance/interfaces/pthread_rwlock_rdlock/1-1.c) + # unsupported(scheduling): conformance/interfaces/pthread_rwlock_rdlock/2-1.c + # unsupported(scheduling): conformance/interfaces/pthread_rwlock_rdlock/2-2.c + # unsupported(scheduling): conformance/interfaces/pthread_rwlock_rdlock/2-3.c + # unsupported(signals): conformance/interfaces/pthread_rwlock_rdlock/4-1.c + add_posix_test(conformance/interfaces/pthread_rwlock_rdlock/5-1.c) + + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedrdlock/1-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedrdlock/2-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedrdlock/3-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedrdlock/5-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedrdlock/6-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedrdlock/6-2.c + + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedwrlock/1-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedwrlock/2-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedwrlock/3-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedwrlock/5-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedwrlock/6-1.c + # temporarily unsupported(timed lock): conformance/interfaces/pthread_rwlock_timedwrlock/6-2.c + + add_posix_test(conformance/interfaces/pthread_rwlock_tryrdlock/1-1.c) + + add_posix_test(conformance/interfaces/pthread_rwlock_trywrlock/1-1.c) + add_posix_test(conformance/interfaces/pthread_rwlock_trywrlock/speculative/3-1.c) + + add_posix_test(conformance/interfaces/pthread_rwlock_unlock/1-1.c) + add_posix_test(conformance/interfaces/pthread_rwlock_unlock/2-1.c) + # unsupported(scheduling): conformance/interfaces/pthread_rwlock_unlock/3-1.c + # bad test(undefined behaviour): conformance/interfaces/pthread_rwlock_unlock/4-1.c + # bad test(undefined behaviour): conformance/interfaces/pthread_rwlock_unlock/4-2.c + + add_posix_test(conformance/interfaces/pthread_rwlock_wrlock/1-1.c) + # unsupported(signals): conformance/interfaces/pthread_rwlock_wrlock/2-1.c + add_posix_test(conformance/interfaces/pthread_rwlock_wrlock/3-1.c) + + add_posix_test(conformance/interfaces/pthread_rwlockattr_destroy/1-1.c) + add_posix_test(conformance/interfaces/pthread_rwlockattr_destroy/2-1.c) + + # unsupported(process-shared): conformance/interfaces/pthread_rwlockattr_getpshared/* + + add_posix_test(conformance/interfaces/pthread_rwlockattr_init/1-1.c) + add_posix_test(conformance/interfaces/pthread_rwlockattr_init/2-1.c) + + # unsupported(process-shared): conformance/interfaces/pthread_rwlockattr_setpshared/* + + add_posix_test(conformance/interfaces/pthread_self/1-1.c) + + # unsupported(cancellation): conformance/interfaces/pthread_setcancelstate/* + + # unsupported(cancellation): conformance/interfaces/pthread_setcanceltype/* + + # unsupported(scheduling): conformance/interfaces/pthread_setschedparam/* + # unsupported(scheduling): conformance/interfaces/pthread_setschedprio/* + + add_posix_test(conformance/interfaces/pthread_setspecific/1-1.c) + add_posix_test(conformance/interfaces/pthread_setspecific/1-2.c) + + # unsupported(signals): conformance/interfaces/pthread_sigmask/* + + # unsupported(spinlocks): conformance/interfaces/pthread_spin_destroy/* + # unsupported(spinlocks): conformance/interfaces/pthread_spin_init/* + # unsupported(spinlocks): conformance/interfaces/pthread_spin_lock/* + # unsupported(spinlocks): conformance/interfaces/pthread_spin_trylock/* + # unsupported(spinlocks): conformance/interfaces/pthread_spin_unlock/* + + # unsupported(cancellation): conformance/interfaces/pthread_testcancel/* +endif() + # If enabled add a copy of Python which is built against `wasi-libc` and run # its tests. if (PYTHON_TESTS) From ed7f5d28e7b39a9238e8b87794decbb21da546d3 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Fri, 20 Feb 2026 17:28:53 +0000 Subject: [PATCH 06/43] Merge in WASIP3 --- CMakeLists.txt | 7 +- cmake/bindings.cmake | 7 +- libc-bottom-half/CMakeLists.txt | 1 + .../cloudlibc/src/libc/sched/sched_yield.c | 10 +- .../headers/public/wasi/__generated_wasip2.h | 4 +- .../headers/public/wasi/__generated_wasip3.h | 20 +++- .../headers/public/wasi/version.h.in | 1 + libc-bottom-half/sources/__main_void.c | 9 ++ libc-bottom-half/sources/__wasm_init_task.s | 98 +++++++++++++++++ libc-bottom-half/sources/getcwd.c | 16 ++- libc-bottom-half/sources/preopens.c | 30 +++--- libc-bottom-half/sources/wasip2.c | 4 +- .../sources/wasip2_component_type.o | Bin 10846 -> 10846 bytes libc-bottom-half/sources/wasip3.c | 101 +++++++++++++++++- .../sources/wasip3_component_type.o | Bin 8099 -> 8099 bytes libc-top-half/CMakeLists.txt | 7 +- libc-top-half/musl/include/alltypes.h.in | 13 ++- libc-top-half/musl/include/pthread.h | 15 ++- libc-top-half/musl/include/semaphore.h | 8 ++ libc-top-half/musl/include/unistd.h | 4 +- libc-top-half/musl/src/conf/sysconf.c | 6 +- libc-top-half/musl/src/env/__init_tls.c | 82 +++++++++----- libc-top-half/musl/src/exit/at_quick_exit.c | 14 +-- libc-top-half/musl/src/exit/atexit.c | 17 +-- libc-top-half/musl/src/internal/locale_impl.h | 3 +- libc-top-half/musl/src/internal/lock.h | 45 +++++++- .../musl/src/internal/pthread_impl.h | 47 ++++---- libc-top-half/musl/src/internal/stdio_impl.h | 14 ++- libc-top-half/musl/src/locale/locale_map.c | 4 +- libc-top-half/musl/src/locale/newlocale.c | 4 +- libc-top-half/musl/src/locale/setlocale.c | 10 +- .../musl/src/malloc/oldmalloc/malloc.c | 11 ++ libc-top-half/musl/src/prng/random.c | 20 ++-- libc-top-half/musl/src/stdio/__fdopen.c | 2 +- libc-top-half/musl/src/stdio/__fopen_rb_ca.c | 2 +- libc-top-half/musl/src/stdio/__lockfile.c | 24 +++++ libc-top-half/musl/src/stdio/fmemopen.c | 2 +- libc-top-half/musl/src/stdio/ftrylockfile.c | 38 ++++++- libc-top-half/musl/src/stdio/getc.h | 13 ++- libc-top-half/musl/src/stdio/ofl.c | 8 +- libc-top-half/musl/src/stdio/open_memstream.c | 2 +- .../musl/src/stdio/open_wmemstream.c | 2 +- libc-top-half/musl/src/stdio/putc.h | 18 +++- libc-top-half/musl/src/stdio/stderr.c | 2 +- libc-top-half/musl/src/stdio/stdin.c | 2 +- libc-top-half/musl/src/stdio/stdout.c | 2 +- libc-top-half/musl/src/stdio/vdprintf.c | 2 +- libc-top-half/musl/src/stdio/vsscanf.c | 5 +- libc-top-half/musl/src/stdio/vswscanf.c | 5 +- libc-top-half/musl/src/stdlib/wcstod.c | 2 +- libc-top-half/musl/src/stdlib/wcstol.c | 2 +- .../src/thread/common/pthread_rwlock_init.c | 2 + .../musl/src/thread/coop-threads/__lock.c | 1 + .../coop-threads/pthread_barrier_setpshared.c | 7 -- .../src/thread/coop-threads/pthread_cancel.c | 6 -- .../src/thread/coop-threads/pthread_create.c | 6 -- .../src/thread/coop-threads/pthread_join.c | 5 + .../src/thread/coop-threads/pthread_once.c | 2 +- .../thread/coop-threads/pthread_rwlock_init.c | 7 -- .../coop-threads/pthread_rwlock_timedwrlock.c | 1 - .../coop-threads/pthread_rwlock_trywrlock.c | 23 ++-- .../src/thread/coop-threads/pthread_sigmask.c | 2 + .../musl/src/thread/coop-threads/sem_open.c | 3 +- 63 files changed, 624 insertions(+), 206 deletions(-) create mode 100644 libc-bottom-half/sources/__wasm_init_task.s delete mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_barrier_setpshared.c delete mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_cancel.c delete mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_init.c diff --git a/CMakeLists.txt b/CMakeLists.txt index c48f41b15..655f98e3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,8 @@ elseif(TARGET_TRIPLE MATCHES "-wasip2$") set(SHARED ON) elseif(TARGET_TRIPLE MATCHES "-wasip3$") set(WASI p3) - set(SHARED ON) + # TODO: wasip3_thread_start.s also uses non-position-independent code. + set(SHARED OFF) else() message(FATAL_ERROR "Unknown WASI target triple: ${TARGET_TRIPLE}") endif() @@ -87,6 +88,9 @@ endif() if(TARGET_TRIPLE MATCHES "-threads$") set(THREADS ON) add_compile_options(-mthread-model posix -pthread -ftls-model=local-exec -matomics) +elseif(TARGET_TRIPLE MATCHES "-wasip3$") + set(THREADS OFF) + add_compile_options(-mthread-model posix -pthread -ftls-model=local-exec) else() set(THREADS OFF) add_compile_options(-mthread-model single) @@ -139,6 +143,7 @@ elseif(WASI STREQUAL "p2") set(__wasip2__ ON) elseif(WASI STREQUAL "p3") set(__wasip3__ ON) + set(__wasi_cooperative_threads__ ON) else() message(FATAL_ERROR "Unknown WASI version: ${WASI}") endif() diff --git a/cmake/bindings.cmake b/cmake/bindings.cmake index 15b8d0593..ed1236ec0 100644 --- a/cmake/bindings.cmake +++ b/cmake/bindings.cmake @@ -15,8 +15,8 @@ if(WIT_BINDGEN_EXECUTABLE) OUTPUT_VARIABLE WIT_BINDGEN_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) - if (NOT (WIT_BINDGEN_VERSION MATCHES "0\\.51\\.0")) - message(WARNING "wit-bindgen version 0.51.0 is required, found: ${WIT_BINDGEN_VERSION}") + if (NOT (WIT_BINDGEN_VERSION MATCHES "0\\.53\\.1")) + message(WARNING "wit-bindgen version 0.53.1 is required, found: ${WIT_BINDGEN_VERSION}") set(WIT_BINDGEN_EXECUTABLE "") endif() endif() @@ -26,7 +26,7 @@ if (NOT WIT_BINDGEN_EXECUTABLE) ba_download( wit-bindgen "https://github.com/bytecodealliance/wit-bindgen" - "0.51.0" + "0.53.1" ) ExternalProject_Get_Property(wit-bindgen SOURCE_DIR) set(wit_bindgen "${SOURCE_DIR}/wit-bindgen") @@ -87,6 +87,7 @@ add_custom_target( --rename-world wasip3 --type-section-suffix __wasi_libc --world wasi:cli/imports@${wasip3-version} + --generate-threading-helpers --rename wasi:clocks/monotonic-clock@${wasip3-version}=monotonic_clock --rename wasi:clocks/system-clock@${wasip3-version}=system_clock --rename wasi:filesystem/preopens@${wasip3-version}=filesystem_preopens diff --git a/libc-bottom-half/CMakeLists.txt b/libc-bottom-half/CMakeLists.txt index c7c8013fe..54fab9b89 100644 --- a/libc-bottom-half/CMakeLists.txt +++ b/libc-bottom-half/CMakeLists.txt @@ -162,6 +162,7 @@ endif() if (WASI STREQUAL "p3") list(APPEND bottom_half_sources + sources/__wasm_init_task.s sources/wasip3.c sources/wasip3_block_on.c sources/wasip3_file.c diff --git a/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c b/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c index fc13322b6..4b1a5b6e3 100644 --- a/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c +++ b/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c @@ -7,7 +7,15 @@ #include int sched_yield(void) { -#ifdef __wasip1__ +#ifdef __wasi_cooperative_threads__ + #ifdef __wasip3__ + wasip3_thread_yield(); + return 0; + #else + #error "Unknown WASI version" + #endif + +#elif defined(__wasip1__) __wasi_errno_t error = __wasi_sched_yield(); if (error != 0) { errno = error; diff --git a/libc-bottom-half/headers/public/wasi/__generated_wasip2.h b/libc-bottom-half/headers/public/wasi/__generated_wasip2.h index 7a343bbc6..2a8718739 100644 --- a/libc-bottom-half/headers/public/wasi/__generated_wasip2.h +++ b/libc-bottom-half/headers/public/wasi/__generated_wasip2.h @@ -1,4 +1,4 @@ -// Generated by `wit-bindgen` 0.51.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.53.1. DO NOT EDIT! #ifndef __BINDINGS_WASIP2_H #define __BINDINGS_WASIP2_H #ifdef __cplusplus @@ -1083,7 +1083,7 @@ extern bool environment_initial_cwd(wasip2_string_t *ret); // Imported Functions from `wasi:cli/exit@0.2.0` // Exit the current instance and any linked instances. -extern void exit_exit(exit_result_void_void_t *status); +_Noreturn extern void exit_exit(exit_result_void_void_t *status); // Imported Functions from `wasi:io/error@0.2.0` // Returns a string that is suitable to assist humans in debugging diff --git a/libc-bottom-half/headers/public/wasi/__generated_wasip3.h b/libc-bottom-half/headers/public/wasi/__generated_wasip3.h index a1302c3a0..2a5d526ce 100644 --- a/libc-bottom-half/headers/public/wasi/__generated_wasip3.h +++ b/libc-bottom-half/headers/public/wasi/__generated_wasip3.h @@ -1,4 +1,4 @@ -// Generated by `wit-bindgen` 0.51.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.53.1. DO NOT EDIT! #ifndef __BINDINGS_WASIP3_H #define __BINDINGS_WASIP3_H #ifdef __cplusplus @@ -80,6 +80,22 @@ void wasip3_context_set_0(void* value); void wasip3_thread_yield(void); +void* wasip3_context_get_1(void); +void wasip3_context_set_1(void* value); +uint32_t wasip3_thread_yield_cancellable(void); +uint32_t wasip3_thread_index(void); +uint32_t wasip3_thread_new_indirect(void (*start_function)(void*), void* arg); +void wasip3_thread_suspend_to(uint32_t thread); +uint32_t wasip3_thread_suspend_to_cancellable(uint32_t thread); +void wasip3_thread_suspend_to_suspended(uint32_t thread); +uint32_t wasip3_thread_suspend_to_suspended_cancellable(uint32_t thread); +void wasip3_thread_unsuspend(uint32_t thread); +void wasip3_thread_yield_to_suspended(uint32_t thread); +uint32_t wasip3_thread_yield_to_suspended_cancellable(uint32_t thread); +void wasip3_thread_suspend(void); +uint32_t wasip3_thread_suspend_cancellable(void); + + typedef struct { wasip3_string_t f0; @@ -928,7 +944,7 @@ extern bool environment_get_initial_cwd(wasip3_string_t *ret); // Imported Functions from `wasi:cli/exit@0.3.0-rc-2026-01-06` // Exit the current instance and any linked instances. -extern void exit_exit(exit_result_void_void_t *status); +_Noreturn extern void exit_exit(exit_result_void_void_t *status); // Imported Functions from `wasi:cli/stdin@0.3.0-rc-2026-01-06` // Return a stream for reading from stdin. diff --git a/libc-bottom-half/headers/public/wasi/version.h.in b/libc-bottom-half/headers/public/wasi/version.h.in index 2cca21efc..8da5d9991 100644 --- a/libc-bottom-half/headers/public/wasi/version.h.in +++ b/libc-bottom-half/headers/public/wasi/version.h.in @@ -10,6 +10,7 @@ #cmakedefine __wasip1__ #cmakedefine __wasip2__ #cmakedefine __wasip3__ +#cmakedefine __wasi_cooperative_threads__ #cmakedefine __wasi_sdk_major__ @__wasi_sdk_major__@ #cmakedefine __wasi_sdk_version__ "@__wasi_sdk_version__@" diff --git a/libc-bottom-half/sources/__main_void.c b/libc-bottom-half/sources/__main_void.c index b6a412470..340e4d42c 100644 --- a/libc-bottom-half/sources/__main_void.c +++ b/libc-bottom-half/sources/__main_void.c @@ -7,6 +7,15 @@ #include #endif +#ifdef __wasm_component_model_thread_context__ +/* Ensure __wasm_init_task and __wasm_init_async_task are always linked. + * These assembly functions are required for wasip3 initialization. */ +void __wasm_init_task(void); +void __wasm_init_async_task(void); +__attribute__((used)) hidden static void *__wasm_init_task_reference = __wasm_init_task; +__attribute__((used)) hidden static void *__wasm_init_async_task_reference = __wasm_init_async_task; +#endif + // The user's `main` function, expecting arguments. // // Note that we make this a weak symbol so that it will have a diff --git a/libc-bottom-half/sources/__wasm_init_task.s b/libc-bottom-half/sources/__wasm_init_task.s new file mode 100644 index 000000000..2bae09681 --- /dev/null +++ b/libc-bottom-half/sources/__wasm_init_task.s @@ -0,0 +1,98 @@ + .text + + .export_name __wasm_init_task, __wasm_init_task + .export_name __wasm_init_async_task, __wasm_init_async_task + + .globaltype __init_stack_pointer, i32 + .globaltype __init_tls_base, i32 + .globaltype __tls_size, i32, immutable + .globaltype __tls_align, i32, immutable + .globaltype __default_stacksize, i32 + + .functype __wasm_component_model_builtin_context_set_0 (i32) -> () + .import_module __wasm_component_model_builtin_context_set_0, "$root" + .import_name __wasm_component_model_builtin_context_set_0, "[context-set-0]" + .functype __wasm_component_model_builtin_context_set_1 (i32) -> () + .import_module __wasm_component_model_builtin_context_set_1, "$root" + .import_name __wasm_component_model_builtin_context_set_1, "[context-set-1]" + + .functype malloc (i32) -> (i32) + .functype __copy_tls (i32) -> (i32) + + .globl __wasm_init_task + .type __wasm_init_task,@function + .globl __wasm_init_async_task + .type __wasm_init_async_task,@function + + .functype __wasi_init_tp() -> () + +# Helper function to allocate and align TLS +# Returns an aligned TLS pointer ready for __copy_tls +__allocate_aligned_tls: + .functype __allocate_aligned_tls () -> (i32) + + # Allocate size + align - 1 to ensure we have room for alignment + global.get __tls_size + global.get __tls_align + i32.add + i32.const 1 + i32.sub + call malloc + + # Align the pointer: (ptr + align - 1) & ~(align - 1) + global.get __tls_align + i32.const 1 + i32.sub + i32.add + + global.get __tls_align + i32.const 1 + i32.sub + i32.const -1 + i32.xor + i32.and + + end_function + +__wasm_init_task: + .functype __wasm_init_task () -> () + + global.get __init_stack_pointer + call __wasm_component_model_builtin_context_set_0 + + global.get __init_tls_base + call __wasm_component_model_builtin_context_set_1 + + # Allocate a new TLS area + call __allocate_aligned_tls + call __copy_tls + call __wasm_component_model_builtin_context_set_1 + + call __wasi_init_tp + + end_function + +__wasm_init_async_task: + .functype __wasm_init_async_task () -> () + + # malloc and __init_tls may use the stack pointer and TLS base, so set those first + # to the statically-allocated values used for synchronous tasks. + global.get __init_stack_pointer + call __wasm_component_model_builtin_context_set_0 + + global.get __init_tls_base + call __wasm_component_model_builtin_context_set_1 + + # Allocate a new stack + global.get __default_stacksize + call malloc + call __wasm_component_model_builtin_context_set_0 + + # Allocate a new TLS area + call __allocate_aligned_tls + call __copy_tls + call __wasm_component_model_builtin_context_set_1 + + call __wasi_init_tp + + end_function \ No newline at end of file diff --git a/libc-bottom-half/sources/getcwd.c b/libc-bottom-half/sources/getcwd.c index 8b0b0b746..576508620 100644 --- a/libc-bottom-half/sources/getcwd.c +++ b/libc-bottom-half/sources/getcwd.c @@ -7,32 +7,28 @@ char *__wasilibc_cwd = "/"; #ifdef _REENTRANT -static volatile int lock[1]; -void __wasilibc_cwd_lock(void) { LOCK(lock); } -void __wasilibc_cwd_unlock(void) { UNLOCK(lock); } -#else -#define __wasilibc_cwd_lock() (void)0 -#define __wasilibc_cwd_unlock() (void)0 +static __lock_t lock[1]; #endif char *getcwd(char *buf, size_t size) { - __wasilibc_cwd_lock(); + // Critical section contains no yield points, so we can use weak locks. + WEAK_LOCK(lock); if (!buf) { buf = strdup(__wasilibc_cwd); if (!buf) { errno = ENOMEM; - __wasilibc_cwd_unlock(); + WEAK_UNLOCK(lock); return NULL; } } else { size_t len = strlen(__wasilibc_cwd); if (size < len + 1) { errno = ERANGE; - __wasilibc_cwd_unlock(); + WEAK_UNLOCK(lock); return NULL; } strcpy(buf, __wasilibc_cwd); } - __wasilibc_cwd_unlock(); + WEAK_UNLOCK(lock); return buf; } diff --git a/libc-bottom-half/sources/preopens.c b/libc-bottom-half/sources/preopens.c index cf91ac016..84738c53f 100644 --- a/libc-bottom-half/sources/preopens.c +++ b/libc-bottom-half/sources/preopens.c @@ -21,6 +21,12 @@ #include #endif +/// Access to the the above preopen must be protected in the presence of +/// threads. +#ifdef _REENTRANT +static __lock_t lock[1]; +#endif + #if defined(__wasip1__) typedef struct { __wasi_fd_t fd; @@ -96,12 +102,6 @@ static preopen *preopens; static size_t num_preopens; static size_t preopen_capacity; -/// Access to the the above preopen must be protected in the presence of -/// threads. -#ifdef _REENTRANT -static volatile int lock[1]; -#endif - #ifdef NDEBUG #define assert_invariants() // assertions disabled #else @@ -220,11 +220,11 @@ static bool prefix_matches(const char *prefix, size_t prefix_len, /// This function takes ownership of `prefix`. static int internal_register_preopened_fd(__wasi_fd_t fd, const char *relprefix) { - LOCK(lock); + STRONG_LOCK(lock); int r = internal_register_preopened_fd_unlocked(fd, relprefix); - UNLOCK(lock); + STRONG_UNLOCK(lock); return r; } @@ -263,7 +263,7 @@ int __wasilibc_find_abspath(const char *path, const char **abs_prefix, // recently added preopens take precedence over less recently addded ones. size_t match_len = 0; int fd = -1; - LOCK(lock); + STRONG_LOCK(lock); for (size_t i = num_preopens; i > 0; --i) { const preopen *pre = &preopens[i - 1]; const char *prefix = pre->prefix; @@ -278,7 +278,7 @@ int __wasilibc_find_abspath(const char *path, const char **abs_prefix, *abs_prefix = prefix; } } - UNLOCK(lock); + STRONG_UNLOCK(lock); if (fd == -1) { errno = ENOENT; @@ -306,11 +306,11 @@ void __wasilibc_populate_preopens(void) { return; } - LOCK(lock); + STRONG_LOCK(lock); // Check whether another thread initialized the preopens already. if (preopens_populated) { - UNLOCK(lock); + STRONG_UNLOCK(lock); return; } @@ -381,7 +381,7 @@ void __wasilibc_populate_preopens(void) { // Preopens are now initialized. preopens_populated = true; - UNLOCK(lock); + STRONG_UNLOCK(lock); return; #ifdef __wasip1__ @@ -393,7 +393,7 @@ void __wasilibc_populate_preopens(void) { } void __wasilibc_reset_preopens(void) { - LOCK(lock); + STRONG_LOCK(lock); if (num_preopens) { for (int i = 0; i < num_preopens; ++i) { @@ -410,5 +410,5 @@ void __wasilibc_reset_preopens(void) { assert_invariants(); - UNLOCK(lock); + STRONG_UNLOCK(lock); } diff --git a/libc-bottom-half/sources/wasip2.c b/libc-bottom-half/sources/wasip2.c index d31823a08..da2a5f141 100644 --- a/libc-bottom-half/sources/wasip2.c +++ b/libc-bottom-half/sources/wasip2.c @@ -1,4 +1,4 @@ -// Generated by `wit-bindgen` 0.51.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.53.1. DO NOT EDIT! #include "wasi/wasip2.h" #include #include @@ -17,7 +17,7 @@ extern void __wasm_import_environment_initial_cwd(uint8_t *); // Imported Functions from `wasi:cli/exit@0.2.0` __attribute__((__import_module__("wasi:cli/exit@0.2.0"), __import_name__("exit"))) -extern void __wasm_import_exit_exit(int32_t); +_Noreturn extern void __wasm_import_exit_exit(int32_t); // Imported Functions from `wasi:io/error@0.2.0` diff --git a/libc-bottom-half/sources/wasip2_component_type.o b/libc-bottom-half/sources/wasip2_component_type.o index abbd242946ebf1c4c3b4933cb92293b05f6a0461..5f85d8c870715ab8d86771b0d2e9457b58533518 100644 GIT binary patch delta 36 rcmcZ?axY{9x0Zydo*{2}W{GZ6W?o8qYMyQ~n}MFGv7X^%Wi4v}=zj|_ delta 36 rcmcZ?axY{9x0Zy7o&j%pW{GZ6W?o8qYMyQ~n}MFGp`O8HWi4v}=r#*1 diff --git a/libc-bottom-half/sources/wasip3.c b/libc-bottom-half/sources/wasip3.c index 26b92a86a..8b0f3d960 100644 --- a/libc-bottom-half/sources/wasip3.c +++ b/libc-bottom-half/sources/wasip3.c @@ -1,4 +1,4 @@ -// Generated by `wit-bindgen` 0.51.0. DO NOT EDIT! +// Generated by `wit-bindgen` 0.53.1. DO NOT EDIT! #include "wasi/wasip3.h" #include #include @@ -1142,6 +1142,105 @@ void wasip3_thread_yield(void) { } +__attribute__((__import_module__("$root"), __import_name__("[context-get-1]"))) +extern void* __context_get_1(void); + +void* wasip3_context_get_1(void) { + return __context_get_1(); +} + +__attribute__((__import_module__("$root"), __import_name__("[context-set-1]"))) +extern void __context_set_1(void*); + +void wasip3_context_set_1(void* value) { + __context_set_1(value); +} + +__attribute__((__import_module__("$root"), __import_name__("[cancellable][thread-yield]"))) +extern uint32_t __thread_yield_cancellable(void); + +uint32_t wasip3_thread_yield_cancellable(void) { + return __thread_yield_cancellable(); +} + +__attribute__((__import_module__("$root"), __import_name__("[thread-index]"))) +extern uint32_t __thread_index(void); + +uint32_t wasip3_thread_index(void) { + return __thread_index(); +} + +__attribute__((__import_module__("$root"), __import_name__("[thread-new-indirect-v0]"))) +extern uint32_t __thread_new_indirect(uint32_t, void*); + +uint32_t wasip3_thread_new_indirect(void (*start_function)(void*), void* arg) { + return __thread_new_indirect((uint32_t)(uintptr_t)start_function, arg + ); +} + +__attribute__((__import_module__("$root"), __import_name__("[thread-suspend-to-suspended]"))) +extern uint32_t __thread_suspend_to_suspended(uint32_t); + +void wasip3_thread_suspend_to_suspended(uint32_t thread) { + __thread_suspend_to_suspended(thread); +} + +__attribute__((__import_module__("$root"), __import_name__("[cancellable][thread-suspend-to-suspended]"))) +extern uint32_t __thread_suspend_to_suspended_cancellable(uint32_t); + +uint32_t wasip3_thread_suspend_to_suspended_cancellable(uint32_t thread) { + return __thread_suspend_to_suspended_cancellable(thread); +} + +__attribute__((__import_module__("$root"), __import_name__("[thread-suspend-to]"))) +extern uint32_t __thread_suspend_to(uint32_t); + +void wasip3_thread_suspend_to(uint32_t thread) { + __thread_suspend_to(thread); +} + +__attribute__((__import_module__("$root"), __import_name__("[cancellable][thread-suspend-to]"))) +extern uint32_t __thread_suspend_to_cancellable(uint32_t); + +uint32_t wasip3_thread_suspend_to_cancellable(uint32_t thread) { + return __thread_suspend_to_cancellable(thread); +} + +__attribute__((__import_module__("$root"), __import_name__("[thread-unsuspend]"))) +extern void __thread_unsuspend(uint32_t); + +void wasip3_thread_unsuspend(uint32_t thread) { + __thread_unsuspend(thread); +} + +__attribute__((__import_module__("$root"), __import_name__("[thread-yield-to-suspended]"))) +extern uint32_t __thread_yield_to_suspended(uint32_t); + +void wasip3_thread_yield_to_suspended(uint32_t thread) { + __thread_yield_to_suspended(thread); +} + +__attribute__((__import_module__("$root"), __import_name__("[cancellable][thread-yield-to-suspended]"))) +extern uint32_t __thread_yield_to_suspended_cancellable(uint32_t); + +uint32_t wasip3_thread_yield_to_suspended_cancellable(uint32_t thread) { + return __thread_yield_to_suspended_cancellable(thread); +} + +__attribute__((__import_module__("$root"), __import_name__("[thread-suspend]"))) +extern uint32_t __thread_suspend(void); + +void wasip3_thread_suspend(void) { + __thread_suspend(); +} + +__attribute__((__import_module__("$root"), __import_name__("[cancellable][thread-suspend]"))) +extern uint32_t __thread_suspend_cancellable(void); +uint32_t wasip3_thread_suspend_cancellable(void) { + return __thread_suspend_cancellable(); +} + + // Component Adapters diff --git a/libc-bottom-half/sources/wasip3_component_type.o b/libc-bottom-half/sources/wasip3_component_type.o index 68f4f3604b601e2b750b65bc5532d01a799cf67a..e92156ffbbf4554b4083803e095e23a5cdefae0b 100644 GIT binary patch delta 36 rcmZ2%zu105fV_mMo*{2}W{GZ6W?o8qYMyQ~n}MFGv7X`N40&q++LH?f delta 36 rcmZ2%zu105fV_l>o&j%pW{GZ6W?o8qYMyQ~n}MFGp`O9y40&q++DZ!m diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index 3d41b8037..47553cd05 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -441,6 +441,10 @@ if (THREADS) elseif(WASI STREQUAL "p3") # cooperative threads implementation for WASI Preview 3 list(APPEND top_half_sources + musl/src/stdio/__lockfile.c + musl/src/stdio/flockfile.c + musl/src/stdio/ftrylockfile.c + musl/src/stdio/funlockfile.c musl/src/thread/coop-threads/__lock.c musl/src/thread/coop-threads/__wait.c musl/src/thread/coop-threads/__wasi_coop_thread_start.s @@ -448,9 +452,7 @@ elseif(WASI STREQUAL "p3") musl/src/thread/coop-threads/mtx_trylock.c musl/src/thread/coop-threads/pthread_barrier_destroy.c musl/src/thread/coop-threads/pthread_barrier_init.c - musl/src/thread/coop-threads/pthread_barrier_setpshared.c musl/src/thread/coop-threads/pthread_barrier_wait.c - musl/src/thread/coop-threads/pthread_cancel.c musl/src/thread/coop-threads/pthread_cond_broadcast.c musl/src/thread/coop-threads/pthread_cond_destroy.c musl/src/thread/coop-threads/pthread_cond_init.c @@ -469,7 +471,6 @@ elseif(WASI STREQUAL "p3") musl/src/thread/coop-threads/pthread_mutex_trylock.c musl/src/thread/coop-threads/pthread_mutex_unlock.c musl/src/thread/coop-threads/pthread_once.c - musl/src/thread/coop-threads/pthread_rwlock_init.c musl/src/thread/coop-threads/pthread_rwlock_timedrdlock.c musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c musl/src/thread/coop-threads/pthread_rwlock_tryrdlock.c diff --git a/libc-top-half/musl/include/alltypes.h.in b/libc-top-half/musl/include/alltypes.h.in index dcd474ff3..b133f3d23 100644 --- a/libc-top-half/musl/include/alltypes.h.in +++ b/libc-top-half/musl/include/alltypes.h.in @@ -1,6 +1,7 @@ #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 #define __USE_TIME_BITS64 1 +#include TYPEDEF unsigned _Addr size_t; TYPEDEF unsigned _Addr uintptr_t; @@ -106,13 +107,23 @@ 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; +#ifdef __wasi_cooperative_threads__ +struct __waitlist_node; +TYPEDEF struct { int _m_type; int _m_lock; int _m_count; struct __waitlist_node *_m_waiters; } pthread_mutex_t; +TYPEDEF struct { int _m_type; int _m_lock; int _m_count; struct __waitlist_node *_m_waiters; } mtx_t; +TYPEDEF struct { struct __waitlist_node *_c_waiters; } pthread_cond_t; +TYPEDEF struct { struct __waitlist_node *_c_waiters; } cnd_t; +TYPEDEF struct { long long _rw_lock; struct __waitlist_node *_rw_waiters; } pthread_rwlock_t; +TYPEDEF struct { int _b_limit; int _b_count; struct __waitlist_node *_b_waiters; } pthread_barrier_t; +#else 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; +#endif #undef _Addr #undef _Int64 -#undef _Reg +#undef _Reg \ No newline at end of file diff --git a/libc-top-half/musl/include/pthread.h b/libc-top-half/musl/include/pthread.h index 111c1fbf8..5b1fc0ce2 100644 --- a/libc-top-half/musl/include/pthread.h +++ b/libc-top-half/musl/include/pthread.h @@ -55,9 +55,16 @@ extern "C" { #define PTHREAD_PROCESS_SHARED 1 +#ifdef __wasi_cooperative_threads__ +#define PTHREAD_MUTEX_INITIALIZER {0, 0, 0, 0} +#define PTHREAD_RWLOCK_INITIALIZER {0, 0} +#define PTHREAD_COND_INITIALIZER {0} +#define PTHREAD_BARRIER_INITIALIZER {0, 0, 0} +#else #define PTHREAD_MUTEX_INITIALIZER {{{0}}} #define PTHREAD_RWLOCK_INITIALIZER {{{0}}} #define PTHREAD_COND_INITIALIZER {{{0}}} +#endif #define PTHREAD_ONCE_INIT 0 @@ -107,11 +114,13 @@ 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. */ +/* wasi-threads takes the approach of not declaring unsupported functions. + For greater compatibility, we stub them for cooperative threading. */ +#ifdef __wasi_cooperative_threads__ /* WASI has no cancellation support. */ int pthread_cancel(pthread_t); #endif -#ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */ +#ifdef __wasi_cooperative_threads__ /* 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 @@ -177,7 +186,7 @@ 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. */ +#ifdef __wasi_cooperative_threads__ /* 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 diff --git a/libc-top-half/musl/include/semaphore.h b/libc-top-half/musl/include/semaphore.h index 3690f4960..09887a381 100644 --- a/libc-top-half/musl/include/semaphore.h +++ b/libc-top-half/musl/include/semaphore.h @@ -14,9 +14,17 @@ extern "C" { #define SEM_FAILED ((sem_t *)0) +#ifdef __wasi_cooperative_threads__ +struct __waitlist_node; +typedef struct { + int __count; + struct __waitlist_node *__waiters; +} sem_t; +#else typedef struct { volatile int __val[4*sizeof(long)/sizeof(int)]; } sem_t; +#endif int sem_close(sem_t *); int sem_destroy(sem_t *); diff --git a/libc-top-half/musl/include/unistd.h b/libc-top-half/musl/include/unistd.h index c3158e6e6..8178c073d 100644 --- a/libc-top-half/musl/include/unistd.h +++ b/libc-top-half/musl/include/unistd.h @@ -359,7 +359,9 @@ pid_t gettid(void); #define _POSIX_BARRIERS _POSIX_VERSION #define _POSIX_SPIN_LOCKS _POSIX_VERSION #define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION -#ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX async I/O, semaphores, or shared memory */ +#ifdef __wasi_cooperative_threads__ +#define _POSIX_SEMAPHORES _POSIX_VERSION +#elif defined(__wasilibc_unmodified_upstream) /* WASI has no POSIX async I/O, semaphores, or shared memory */ #define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION #define _POSIX_SEMAPHORES _POSIX_VERSION #define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_VERSION diff --git a/libc-top-half/musl/src/conf/sysconf.c b/libc-top-half/musl/src/conf/sysconf.c index a935853cb..27efc9788 100644 --- a/libc-top-half/musl/src/conf/sysconf.c +++ b/libc-top-half/musl/src/conf/sysconf.c @@ -21,7 +21,7 @@ #define JT_MQ_PRIO_MAX JT(3) #endif #define JT_PAGE_SIZE JT(4) -#ifdef __wasilibc_unmodified_upstream // WASI has no semaphores +#ifdef __wasi_cooperative_threads__ // wasi-threads has no semaphores #define JT_SEM_VALUE_MAX JT(5) #endif #define JT_NPROCESSORS_CONF JT(6) @@ -88,7 +88,7 @@ long sysconf(int name) // Not supported on wasi. [_SC_RTSIG_MAX] = -1, #endif -#ifdef __wasilibc_unmodified_upstream // WASI has no semaphores +#ifdef __wasi_cooperative_threads__ // wasi-threads has no semaphores [_SC_SEM_NSEMS_MAX] = SEM_NSEMS_MAX, [_SC_SEM_VALUE_MAX] = JT_SEM_VALUE_MAX, #else @@ -249,7 +249,7 @@ long sysconf(int name) #endif case JT_PAGE_SIZE & 255: return PAGE_SIZE; -#ifdef __wasilibc_unmodified_upstream // WASI has no semaphores +#if defined(__wasilibc_unmodified_upstream) || defined(__wasi_cooperative_threads__) // wasi-threads has no semaphores case JT_SEM_VALUE_MAX & 255: return SEM_VALUE_MAX; #endif diff --git a/libc-top-half/musl/src/env/__init_tls.c b/libc-top-half/musl/src/env/__init_tls.c index 7f0d92931..6a636811e 100644 --- a/libc-top-half/musl/src/env/__init_tls.c +++ b/libc-top-half/musl/src/env/__init_tls.c @@ -12,9 +12,11 @@ #include "libc.h" #include "atomic.h" #include "syscall.h" +#include +#include "lock.h" #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -volatile int __thread_list_lock; +__lock_t __thread_list_lock; #endif #ifndef __wasilibc_unmodified_upstream @@ -40,6 +42,26 @@ struct stack_bounds { size_t size; }; +static inline unsigned char *get_stack_pointer() { + unsigned char *sp; +#ifdef __wasm_component_model_thread_context__ + __asm__( + ".functype __wasm_component_model_builtin_context_get_0 () -> (i32)\n" + ".import_module __wasm_component_model_builtin_context_get_0, \"$root\"\n" + ".import_name __wasm_component_model_builtin_context_get_0, " + "\"[context-get-0]\"\n" + "call __wasm_component_model_builtin_context_get_0\n" + "local.set %0\n" + : "=r"(sp)); +#else + __asm__(".globaltype __stack_pointer, i32\n" + "global.get __stack_pointer\n" + "local.set %0\n" + : "=r"(sp)); +#endif + return sp; +} + static inline struct stack_bounds get_stack_bounds() { struct stack_bounds bounds; @@ -52,19 +74,14 @@ static inline struct stack_bounds get_stack_bounds() * how wasm-ld lays out things. For pic, just give up. */ #if !defined(__pic__) - unsigned char *sp; - __asm__( - ".globaltype __stack_pointer, i32\n" - "global.get __stack_pointer\n" - "local.set %0\n" - : "=r"(sp)); - if (sp > &__global_base) { - bounds.base = &__heap_base; - bounds.size = &__heap_base - &__data_end; - } else { - bounds.base = &__global_base; - bounds.size = (size_t)&__global_base; - } + unsigned char *sp = get_stack_pointer(); + if (sp > &__global_base) { + bounds.base = &__heap_base; + bounds.size = &__heap_base - &__data_end; + } else { + bounds.base = &__global_base; + bounds.size = (size_t)&__global_base; + } #else bounds.base = 0; bounds.size = 0; @@ -97,20 +114,27 @@ int __init_tp(void *p) td->stack = bounds.base; td->stack_size = bounds.size; td->guard_size = 0; -#ifdef _REENTRANT - td->detach_state = DT_JOINABLE; - /* - * Initialize the TID to a value which doesn't conflict with - * host-allocated TIDs, so that TID-based locks can work. - * - * Note: - * - Host-allocated TIDs range from 1 to 0x1fffffff. (inclusive) - * - __tl_lock and __lockfile uses TID 0 as "unlocked". - * - __lockfile relies on the fact the most significant two bits - * of TIDs are 0. - */ - td->tid = 0x3fffffff; -#endif + #if defined(__wasi_cooperative_threads__) + td->detach_state = DT_JOINABLE; + #ifdef __wasip3__ + td->tid = wasip3_thread_index(); + #else + #error "Unknown WASI version" + #endif + #elif defined(_REENTRANT) + td->detach_state = DT_JOINABLE; + /* + * Initialize the TID to a value which doesn't conflict with + * host-allocated TIDs, so that TID-based locks can work. + * + * Note: + * - Host-allocated TIDs range from 1 to 0x1fffffff. (inclusive) + * - __tl_lock and __lockfile uses TID 0 as "unlocked". + * - __lockfile relies on the fact the most significant two bits + * of TIDs are 0. + */ + td->tid = 0x3fffffff; + #endif #endif #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) td->locale = &libc.global_locale; @@ -178,9 +202,11 @@ void *__copy_tls(unsigned char *mem) mem += tls_align; mem -= (uintptr_t)mem & (tls_align-1); __wasm_init_tls(mem); + #ifndef __wasm_component_model_thread_context__ __asm__("local.get %0\n" "global.set __tls_base\n" :: "r"(tls_base)); + #endif return mem; #endif } diff --git a/libc-top-half/musl/src/exit/at_quick_exit.c b/libc-top-half/musl/src/exit/at_quick_exit.c index 429d0b033..cd44759c7 100644 --- a/libc-top-half/musl/src/exit/at_quick_exit.c +++ b/libc-top-half/musl/src/exit/at_quick_exit.c @@ -8,28 +8,28 @@ static void (*funcs[COUNT])(void); static int count; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -static volatile int lock[1]; -volatile int *const __at_quick_exit_lockptr = lock; +static __lock_t lock[1]; +__lock_t *const __at_quick_exit_lockptr = lock; #endif void __funcs_on_quick_exit() { void (*func)(void); - LOCK(lock); + WEAK_LOCK(lock); while (count > 0) { func = funcs[--count]; - UNLOCK(lock); + WEAK_UNLOCK(lock); func(); - LOCK(lock); + WEAK_LOCK(lock); } } int at_quick_exit(void (*func)(void)) { int r = 0; - LOCK(lock); + WEAK_LOCK(lock); if (count == 32) r = -1; else funcs[count++] = func; - UNLOCK(lock); + WEAK_UNLOCK(lock); return r; } diff --git a/libc-top-half/musl/src/exit/atexit.c b/libc-top-half/musl/src/exit/atexit.c index 155292d0e..61b15cd40 100644 --- a/libc-top-half/musl/src/exit/atexit.c +++ b/libc-top-half/musl/src/exit/atexit.c @@ -22,20 +22,21 @@ static struct fl static int slot; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -static volatile int lock[1]; -volatile int *const __atexit_lockptr = lock; +#include "lock.h" +__lock_t lock[1]; +__lock_t *const __atexit_lockptr = lock; #endif void __funcs_on_exit() { void (*func)(void *), *arg; - LOCK(lock); + WEAK_LOCK(lock); for (; head; head=head->next, slot=COUNT) while(slot-->0) { func = head->f[slot]; arg = head->a[slot]; - UNLOCK(lock); + WEAK_UNLOCK(lock); func(arg); - LOCK(lock); + WEAK_LOCK(lock); } } @@ -45,7 +46,7 @@ void __cxa_finalize(void *dso) int __cxa_atexit(void (*func)(void *), void *arg, void *dso) { - LOCK(lock); + WEAK_LOCK(lock); /* Defer initialization of head so it can be in BSS */ if (!head) head = &builtin; @@ -54,7 +55,7 @@ int __cxa_atexit(void (*func)(void *), void *arg, void *dso) if (slot==COUNT) { struct fl *new_fl = calloc(sizeof(struct fl), 1); if (!new_fl) { - UNLOCK(lock); + WEAK_UNLOCK(lock); return -1; } new_fl->next = head; @@ -67,7 +68,7 @@ int __cxa_atexit(void (*func)(void *), void *arg, void *dso) head->a[slot] = arg; slot++; - UNLOCK(lock); + WEAK_UNLOCK(lock); return 0; } diff --git a/libc-top-half/musl/src/internal/locale_impl.h b/libc-top-half/musl/src/internal/locale_impl.h index 88f5dcf8f..b792f8d0e 100644 --- a/libc-top-half/musl/src/internal/locale_impl.h +++ b/libc-top-half/musl/src/internal/locale_impl.h @@ -18,7 +18,8 @@ struct __locale_map { }; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -extern hidden volatile int __locale_lock[1]; +#include "lock.h" +extern hidden __lock_t __locale_lock[1]; #endif extern hidden const struct __locale_map __c_dot_utf8; diff --git a/libc-top-half/musl/src/internal/lock.h b/libc-top-half/musl/src/internal/lock.h index 29787fb1f..f8fb8cad5 100644 --- a/libc-top-half/musl/src/internal/lock.h +++ b/libc-top-half/musl/src/internal/lock.h @@ -1,15 +1,50 @@ #ifndef LOCK_H #define LOCK_H -#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) +// Defines internal locking primitives. The main elements defined here are: +// - __lock_t: the type of a lock variable +// - __lock_ptr_t: the type of a pointer to a lock variable +// - __LOCK_INIT: initializer for a lock variable +// - STRONG_LOCK/STRONG_UNLOCK: functions to acquire/release a lock for a critical section that contains +// potential context switch points, and thus must be executed even in cooperative threading mode. +// - WEAK_LOCK/WEAK_UNLOCK: functions to acquire/release a lock for a critical section that does not contain any context switch points, +// and thus can be no-ops in cooperative threading mode. + + +#ifdef __wasi_cooperative_threads__ +struct __waitlist_node; +struct __coop_lock { + int owner; // tid of owning thread, or 0 if unlocked + struct __waitlist_node *waiters; +}; + +typedef struct __coop_lock __lock_t; +typedef struct __coop_lock *__lock_ptr_t; +#define __COOP_LOCK_INIT {0, NULL} +#define __LOCK_INIT __COOP_LOCK_INIT + +hidden void __lock(struct __coop_lock *lock); +hidden void __unlock(struct __coop_lock *lock); +#define STRONG_LOCK(x) __lock(x) +#define STRONG_UNLOCK(x) __unlock(x) +#define WEAK_LOCK(x) ((void)0) +#define WEAK_UNLOCK(x) ((void)0) +#elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) +typedef volatile int __lock_t; +typedef volatile int *__lock_ptr_t; +#define __LOCK_INIT {0} hidden void __lock(volatile int *); hidden void __unlock(volatile int *); -#define LOCK(x) __lock(x) -#define UNLOCK(x) __unlock(x) +#define STRONG_LOCK(x) __lock(x) +#define STRONG_UNLOCK(x) __unlock(x) +#define WEAK_LOCK(x) __lock(x) +#define WEAK_UNLOCK(x) __unlock(x) #else // No locking needed. -#define LOCK(x) ((void)0) -#define UNLOCK(x) ((void)0) +#define STRONG_LOCK(x) ((void)0) +#define STRONG_UNLOCK(x) ((void)0) +#define WEAK_LOCK(x) ((void)0) +#define WEAK_UNLOCK(x) ((void)0) #endif #endif diff --git a/libc-top-half/musl/src/internal/pthread_impl.h b/libc-top-half/musl/src/internal/pthread_impl.h index 0106ac385..d26fdb71e 100644 --- a/libc-top-half/musl/src/internal/pthread_impl.h +++ b/libc-top-half/musl/src/internal/pthread_impl.h @@ -18,6 +18,8 @@ #include "futex.h" #include "pthread_arch.h" +#include "lock.h" +#include #define pthread __pthread @@ -40,7 +42,7 @@ struct pthread { #endif /* Part 2 -- implementation details, non-ABI. */ - int tid; + int tid; int errno_val; volatile int detach_state; volatile int cancel; @@ -66,6 +68,9 @@ struct pthread { volatile int killlock[1]; char *dlerror_buf; void *stdio_locks; + #ifdef __wasi_cooperative_threads__ + struct __waitlist_node *joiner_waiters; + #endif /* Part 3 -- the positions of these fields relative to * the end of the structure is external and internal ABI. */ @@ -91,6 +96,7 @@ enum { #define _a_sched __u.__i[3*__SU+1] #define _a_policy __u.__i[3*__SU+2] #define _a_prio __u.__i[3*__SU+3] +#ifndef __wasi_cooperative_threads__ #define _m_type __u.__i[0] #define _m_lock __u.__vi[1] #define _m_waiters __u.__vi[2] @@ -113,6 +119,7 @@ enum { #define _b_count __u.__vi[3] #define _b_waiters2 __u.__vi[4] #define _b_inst __u.__p[3] +#endif #ifndef TP_OFFSET #define TP_OFFSET 0 @@ -172,35 +179,25 @@ hidden int __libc_sigaction(int, const struct sigaction *, struct sigaction *); #endif hidden void __unmapself(void *, size_t); +#ifdef __wasi_cooperative_threads__ +struct __waitlist_node { + uint32_t tid; + struct __waitlist_node *next; +}; +hidden void __waitlist_wait_on(struct __waitlist_node **list); +hidden void __waitlist_wake_one(struct __waitlist_node **list); +hidden void __waitlist_wake_all(struct __waitlist_node **list); +#else + #ifndef __wasilibc_unmodified_upstream hidden int __wasilibc_futex_wait(volatile void *, int, int, int64_t); #endif hidden int __timedwait(volatile int *, int, clockid_t, const struct timespec *, int); hidden int __timedwait_cp(volatile int *, int, clockid_t, const struct timespec *, int); hidden void __wait(volatile int *, volatile int *, int, int); -static inline void __wake(volatile void *addr, int cnt, int priv) -{ - if (priv) priv = FUTEX_PRIVATE; - if (cnt<0) cnt = INT_MAX; -#ifdef __wasilibc_unmodified_upstream - __syscall(SYS_futex, addr, FUTEX_WAKE|priv, cnt) != -ENOSYS || - __syscall(SYS_futex, addr, FUTEX_WAKE, cnt); -#else -#ifdef _REENTRANT - __builtin_wasm_memory_atomic_notify((int*)addr, cnt); -#endif -#endif -} -static inline void __futexwait(volatile void *addr, int val, int priv) -{ -#ifdef __wasilibc_unmodified_upstream - if (priv) priv = FUTEX_PRIVATE; - __syscall(SYS_futex, addr, FUTEX_WAIT|priv, val, 0) != -ENOSYS || - __syscall(SYS_futex, addr, FUTEX_WAIT, val, 0); -#else - __wait(addr, NULL, val, priv); +hidden void __wake(volatile void *addr, int cnt, int priv); +hidden void __futexwait(volatile void *addr, int val, int priv); #endif -} hidden void __acquire_ptc(void); hidden void __release_ptc(void); @@ -210,9 +207,9 @@ hidden void __tl_lock(void); hidden void __tl_unlock(void); hidden void __tl_sync(pthread_t); -extern hidden volatile int __thread_list_lock; +extern hidden __lock_t __thread_list_lock; -extern hidden volatile int __abort_lock[1]; +extern hidden __lock_t __abort_lock[1]; extern hidden unsigned __default_stacksize; extern hidden unsigned __default_guardsize; diff --git a/libc-top-half/musl/src/internal/stdio_impl.h b/libc-top-half/musl/src/internal/stdio_impl.h index 7f19dd951..ce0e1bc2f 100644 --- a/libc-top-half/musl/src/internal/stdio_impl.h +++ b/libc-top-half/musl/src/internal/stdio_impl.h @@ -8,10 +8,20 @@ #define UNGET 8 -#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) +#include "lock.h" + +#ifdef __wasi_cooperative_threads__ +#define FFINALLOCK(f) __lockfile((f)) +#define FLOCK(f) int __need_unlock = __lockfile((f)) +#define FUNLOCK(f) do { if (__need_unlock) __unlockfile((f)); } while (0) +#define __STDIO_LOCK_INIT {0, 0} +#define __STDIO_LOCK_RESET(lock) do { (lock)->owner = 0; (lock)->waiters = NULL; } while (0) +#elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) #define FFINALLOCK(f) ((f)->lock>=0 ? __lockfile((f)) : 0) #define FLOCK(f) int __need_unlock = ((f)->lock>=0 ? __lockfile((f)) : 0) #define FUNLOCK(f) do { if (__need_unlock) __unlockfile((f)); } while (0) +#define __STDIO_LOCK_INIT -1 +#define __STDIO_LOCK_RESET(lock) do { (*(lock)) = -1; } while (0) #else // No locking needed. #define FFINALLOCK(f) ((void)(f)) @@ -51,7 +61,7 @@ struct _IO_FILE { #endif int mode; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - volatile int lock; + __lock_t lock; #endif int lbf; void *cookie; diff --git a/libc-top-half/musl/src/locale/locale_map.c b/libc-top-half/musl/src/locale/locale_map.c index ebfb158f4..ca25ac827 100644 --- a/libc-top-half/musl/src/locale/locale_map.c +++ b/libc-top-half/musl/src/locale/locale_map.c @@ -31,8 +31,8 @@ static const char envvars[][12] = { }; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -volatile int __locale_lock[1]; -volatile int *const __locale_lockptr = __locale_lock; +__lock_t __locale_lock[1]; +__lock_t *const __locale_lockptr = __locale_lock; #endif const struct __locale_map *__get_locale(int cat, const char *val) diff --git a/libc-top-half/musl/src/locale/newlocale.c b/libc-top-half/musl/src/locale/newlocale.c index 11c778557..b9b16923b 100644 --- a/libc-top-half/musl/src/locale/newlocale.c +++ b/libc-top-half/musl/src/locale/newlocale.c @@ -63,9 +63,9 @@ static locale_t do_newlocale(int mask, const char *name, locale_t loc) locale_t __newlocale(int mask, const char *name, locale_t loc) { - LOCK(__locale_lock); + WEAK_LOCK(__locale_lock); loc = do_newlocale(mask, name, loc); - UNLOCK(__locale_lock); + WEAK_UNLOCK(__locale_lock); return loc; } diff --git a/libc-top-half/musl/src/locale/setlocale.c b/libc-top-half/musl/src/locale/setlocale.c index 360c44376..5d12ad7f7 100644 --- a/libc-top-half/musl/src/locale/setlocale.c +++ b/libc-top-half/musl/src/locale/setlocale.c @@ -13,7 +13,7 @@ char *setlocale(int cat, const char *name) if ((unsigned)cat > LC_ALL) return 0; - LOCK(__locale_lock); + WEAK_LOCK(__locale_lock); /* For LC_ALL, setlocale is required to return a string which * encodes the current setting for all categories. The format of @@ -35,7 +35,7 @@ char *setlocale(int cat, const char *name) } lm = __get_locale(i, part); if (lm == LOC_MAP_FAILED) { - UNLOCK(__locale_lock); + WEAK_UNLOCK(__locale_lock); return 0; } tmp_locale.cat[i] = lm; @@ -56,14 +56,14 @@ char *setlocale(int cat, const char *name) s += l+1; } *--s = 0; - UNLOCK(__locale_lock); + WEAK_UNLOCK(__locale_lock); return same==LC_ALL ? (char *)part : buf; } if (name) { lm = __get_locale(cat, name); if (lm == LOC_MAP_FAILED) { - UNLOCK(__locale_lock); + WEAK_UNLOCK(__locale_lock); return 0; } libc.global_locale.cat[cat] = lm; @@ -72,7 +72,7 @@ char *setlocale(int cat, const char *name) } char *ret = lm ? (char *)lm->name : "C"; - UNLOCK(__locale_lock); + WEAK_UNLOCK(__locale_lock); return ret; } diff --git a/libc-top-half/musl/src/malloc/oldmalloc/malloc.c b/libc-top-half/musl/src/malloc/oldmalloc/malloc.c index 25d00d44d..f4caed87c 100644 --- a/libc-top-half/musl/src/malloc/oldmalloc/malloc.c +++ b/libc-top-half/musl/src/malloc/oldmalloc/malloc.c @@ -27,6 +27,16 @@ static struct { /* Synchronization tools */ +#ifdef __wasi_cooperative_threads__ +/* The implementation has no yield points, so locks can be no-ops. */ +static inline void lock(volatile int *lk) +{ +} + +static inline void unlock(volatile int *lk) +{ +} +#else static inline void lock(volatile int *lk) { int need_locks = libc.need_locks; @@ -43,6 +53,7 @@ static inline void unlock(volatile int *lk) if (lk[1]) __wake(lk, 1, 1); } } +#endif static inline void lock_bin(int i) { diff --git a/libc-top-half/musl/src/prng/random.c b/libc-top-half/musl/src/prng/random.c index daac028d8..1cb860877 100644 --- a/libc-top-half/musl/src/prng/random.c +++ b/libc-top-half/musl/src/prng/random.c @@ -24,8 +24,8 @@ static int i = 3; static int j = 0; static uint32_t *x = init+1; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -static volatile int lock[1]; -volatile int *const __random_lockptr = lock; +static __lock_t lock[1]; +__lock_t *const __random_lockptr = lock; #endif static uint32_t lcg31(uint32_t x) { @@ -67,9 +67,9 @@ static void __srandom(unsigned seed) { } void srandom(unsigned seed) { - LOCK(lock); + WEAK_LOCK(lock); __srandom(seed); - UNLOCK(lock); + WEAK_UNLOCK(lock); } char *initstate(unsigned seed, char *state, size_t size) { @@ -77,7 +77,7 @@ char *initstate(unsigned seed, char *state, size_t size) { if (size < 8) return 0; - LOCK(lock); + WEAK_LOCK(lock); old = savestate(); if (size < 32) n = 0; @@ -92,24 +92,24 @@ char *initstate(unsigned seed, char *state, size_t size) { x = (uint32_t*)state + 1; __srandom(seed); savestate(); - UNLOCK(lock); + WEAK_UNLOCK(lock); return old; } char *setstate(char *state) { void *old; - LOCK(lock); + WEAK_LOCK(lock); old = savestate(); loadstate((uint32_t*)state); - UNLOCK(lock); + WEAK_UNLOCK(lock); return old; } long random(void) { long k; - LOCK(lock); + WEAK_LOCK(lock); if (n == 0) { k = x[0] = lcg31(x[0]); goto end; @@ -121,6 +121,6 @@ long random(void) { if (++j == n) j = 0; end: - UNLOCK(lock); + WEAK_UNLOCK(lock); return k; } diff --git a/libc-top-half/musl/src/stdio/__fdopen.c b/libc-top-half/musl/src/stdio/__fdopen.c index 5c8df495e..205338c2f 100644 --- a/libc-top-half/musl/src/stdio/__fdopen.c +++ b/libc-top-half/musl/src/stdio/__fdopen.c @@ -75,7 +75,7 @@ FILE *__fdopen(int fd, const char *mode) f->close = __stdio_close; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - if (!libc.threaded) f->lock = -1; + if (!libc.threaded) __STDIO_LOCK_RESET(&f->lock); #endif /* Add new FILE to open file list */ diff --git a/libc-top-half/musl/src/stdio/__fopen_rb_ca.c b/libc-top-half/musl/src/stdio/__fopen_rb_ca.c index 192050b00..27c2544fe 100644 --- a/libc-top-half/musl/src/stdio/__fopen_rb_ca.c +++ b/libc-top-half/musl/src/stdio/__fopen_rb_ca.c @@ -25,7 +25,7 @@ FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t le f->seek = __stdio_seek; f->close = __stdio_close; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - f->lock = -1; + __STDIO_LOCK_RESET(&f->lock); #endif return f; diff --git a/libc-top-half/musl/src/stdio/__lockfile.c b/libc-top-half/musl/src/stdio/__lockfile.c index 0f60a1499..81d3b91c3 100644 --- a/libc-top-half/musl/src/stdio/__lockfile.c +++ b/libc-top-half/musl/src/stdio/__lockfile.c @@ -1,6 +1,29 @@ #include "stdio_impl.h" #include "pthread_impl.h" +#ifdef __wasi_cooperative_threads__ +#include "lock.h" +int __lockfile(FILE *f) +{ + #ifdef __wasip3__ + int tid = wasip3_thread_index(); + #else + #error "Unknown WASI version" + #endif + + // Allow recursive locking + if (f->lock.owner == tid) + return 0; + + STRONG_LOCK(&f->lock); + return 1; +} + +void __unlockfile(FILE *f) +{ + STRONG_UNLOCK(&f->lock); +} +#else int __lockfile(FILE *f) { int owner = f->lock, tid = __pthread_self()->tid; @@ -21,3 +44,4 @@ void __unlockfile(FILE *f) if (a_swap(&f->lock, 0) & MAYBE_WAITERS) __wake(&f->lock, 1, 1); } +#endif \ No newline at end of file diff --git a/libc-top-half/musl/src/stdio/fmemopen.c b/libc-top-half/musl/src/stdio/fmemopen.c index 3ee57b9ea..22628e56f 100644 --- a/libc-top-half/musl/src/stdio/fmemopen.c +++ b/libc-top-half/musl/src/stdio/fmemopen.c @@ -130,7 +130,7 @@ FILE *fmemopen(void *restrict buf, size_t size, const char *restrict mode) f->f.close = mclose; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - if (!libc.threaded) f->f.lock = -1; + if (!libc.threaded) __STDIO_LOCK_RESET(&f->f.lock); #endif return __ofl_add(&f->f); diff --git a/libc-top-half/musl/src/stdio/ftrylockfile.c b/libc-top-half/musl/src/stdio/ftrylockfile.c index 50650585b..482cd9ee0 100644 --- a/libc-top-half/musl/src/stdio/ftrylockfile.c +++ b/libc-top-half/musl/src/stdio/ftrylockfile.c @@ -4,9 +4,15 @@ void __do_orphaned_stdio_locks() { - FILE *f; - for (f=__pthread_self()->stdio_locks; f; f=f->next_locked) - a_store(&f->lock, 0x40000000); + FILE *f; + for (f=__pthread_self()->stdio_locks; f; f=f->next_locked) { + #ifdef __wasi_cooperative_threads__ + f->lock.owner = 0; + __waitlist_wake_all(&f->lock.waiters); + #else + a_store(&f->lock, 0x40000000); + #endif + } } void __unlist_locked_file(FILE *f) @@ -27,6 +33,31 @@ void __register_locked_file(FILE *f, pthread_t self) self->stdio_locks = f; } +#ifdef __wasi_cooperative_threads__ +int ftrylockfile(FILE *f) +{ + #ifdef __wasip3__ + uint32_t self_tid = wasip3_thread_index(); + #else + #error "Unknown WASI version" + #endif + + if (f->lock.owner == self_tid) { + if (f->lockcount == LONG_MAX) + return -1; + f->lockcount++; + return 0; + } + + // Try to acquire the lock + if (f->lock.owner != 0) + return -1; + + f->lock.owner = self_tid; + f->lockcount = 1; + return 0; +} +#else int ftrylockfile(FILE *f) { pthread_t self = __pthread_self(); @@ -44,3 +75,4 @@ int ftrylockfile(FILE *f) __register_locked_file(f, self); return 0; } +#endif \ No newline at end of file diff --git a/libc-top-half/musl/src/stdio/getc.h b/libc-top-half/musl/src/stdio/getc.h index e62e3f0da..7502102dc 100644 --- a/libc-top-half/musl/src/stdio/getc.h +++ b/libc-top-half/musl/src/stdio/getc.h @@ -7,17 +7,28 @@ __attribute__((__noinline__)) #endif static int locking_getc(FILE *f) { +#ifdef __wasi_cooperative_threads__ + __lockfile(f); + int c = getc_unlocked(f); + __unlockfile(f); + return c; +#else if (a_cas(&f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); int c = getc_unlocked(f); if (a_swap(&f->lock, 0) & MAYBE_WAITERS) __wake(&f->lock, 1, 1); return c; +#endif } #endif static inline int do_getc(FILE *f) { -#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) +#ifdef __wasi_cooperative_threads__ + if (f->lock.owner == wasip3_thread_index()) + return getc_unlocked(f); + return locking_getc(f); +#elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) int l = f->lock; if (l < 0 || l && (l & ~MAYBE_WAITERS) == __pthread_self()->tid) return getc_unlocked(f); diff --git a/libc-top-half/musl/src/stdio/ofl.c b/libc-top-half/musl/src/stdio/ofl.c index 33a8aa50b..2a298a2f8 100644 --- a/libc-top-half/musl/src/stdio/ofl.c +++ b/libc-top-half/musl/src/stdio/ofl.c @@ -4,17 +4,17 @@ static FILE *ofl_head; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -static volatile int ofl_lock[1]; -volatile int *const __stdio_ofl_lockptr = ofl_lock; +static __lock_t ofl_lock[1]; +__lock_t *const __stdio_ofl_lockptr = ofl_lock; #endif FILE **__ofl_lock() { - LOCK(ofl_lock); + STRONG_LOCK(ofl_lock); return &ofl_head; } void __ofl_unlock() { - UNLOCK(ofl_lock); + STRONG_UNLOCK(ofl_lock); } diff --git a/libc-top-half/musl/src/stdio/open_memstream.c b/libc-top-half/musl/src/stdio/open_memstream.c index aa5022065..9690fe8b3 100644 --- a/libc-top-half/musl/src/stdio/open_memstream.c +++ b/libc-top-half/musl/src/stdio/open_memstream.c @@ -102,7 +102,7 @@ FILE *open_memstream(char **bufp, size_t *sizep) f->f.mode = -1; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - if (!libc.threaded) f->f.lock = -1; + if (!libc.threaded) __STDIO_LOCK_RESET(&f->f.lock); #endif return __ofl_add(&f->f); diff --git a/libc-top-half/musl/src/stdio/open_wmemstream.c b/libc-top-half/musl/src/stdio/open_wmemstream.c index 198d5d439..d06c24db8 100644 --- a/libc-top-half/musl/src/stdio/open_wmemstream.c +++ b/libc-top-half/musl/src/stdio/open_wmemstream.c @@ -107,7 +107,7 @@ FILE *open_wmemstream(wchar_t **bufp, size_t *sizep) f->f.close = wms_close; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - if (!libc.threaded) f->f.lock = -1; + if (!libc.threaded) __STDIO_LOCK_RESET(&f->f.lock); #endif fwide(&f->f, 1); diff --git a/libc-top-half/musl/src/stdio/putc.h b/libc-top-half/musl/src/stdio/putc.h index 2cc63d2db..aae780ab3 100644 --- a/libc-top-half/musl/src/stdio/putc.h +++ b/libc-top-half/musl/src/stdio/putc.h @@ -7,17 +7,33 @@ __attribute__((__noinline__)) #endif static int locking_putc(int c, FILE *f) { +#ifdef __wasi_cooperative_threads__ + __lockfile(f); + c = putc_unlocked(c, f); + __unlockfile(f); + return c; +#else if (a_cas(&f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); c = putc_unlocked(c, f); if (a_swap(&f->lock, 0) & MAYBE_WAITERS) __wake(&f->lock, 1, 1); return c; +#endif } #endif static inline int do_putc(int c, FILE *f) { -#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) +#ifdef __wasi_cooperative_threads__ + #ifdef __wasip3__ + int tid = wasip3_thread_index(); + #else + #error "Unknown WASI version" + #endif + if (f->lock.owner == tid) + return putc_unlocked(c, f); + return locking_putc(c, f); +#elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) int l = f->lock; if (l < 0 || l && (l & ~MAYBE_WAITERS) == __pthread_self()->tid) return putc_unlocked(c, f); diff --git a/libc-top-half/musl/src/stdio/stderr.c b/libc-top-half/musl/src/stdio/stderr.c index 5f24549f8..a14ba5637 100644 --- a/libc-top-half/musl/src/stdio/stderr.c +++ b/libc-top-half/musl/src/stdio/stderr.c @@ -13,7 +13,7 @@ hidden FILE __stderr_FILE = { .seek = __stdio_seek, .close = __stdio_close, #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - .lock = -1, + .lock = __STDIO_LOCK_INIT, #endif }; FILE *const stderr = &__stderr_FILE; diff --git a/libc-top-half/musl/src/stdio/stdin.c b/libc-top-half/musl/src/stdio/stdin.c index 68e1c3f64..ddc1a892a 100644 --- a/libc-top-half/musl/src/stdio/stdin.c +++ b/libc-top-half/musl/src/stdio/stdin.c @@ -12,7 +12,7 @@ hidden FILE __stdin_FILE = { .seek = __stdio_seek, .close = __stdio_close, #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - .lock = -1, + .lock = __STDIO_LOCK_INIT, #endif }; FILE *const stdin = &__stdin_FILE; diff --git a/libc-top-half/musl/src/stdio/stdout.c b/libc-top-half/musl/src/stdio/stdout.c index e0e2bced9..914f5a456 100644 --- a/libc-top-half/musl/src/stdio/stdout.c +++ b/libc-top-half/musl/src/stdio/stdout.c @@ -13,7 +13,7 @@ hidden FILE __stdout_FILE = { .seek = __stdio_seek, .close = __stdio_close, #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - .lock = -1, + .lock = __STDIO_LOCK_INIT, #endif }; FILE *const stdout = &__stdout_FILE; diff --git a/libc-top-half/musl/src/stdio/vdprintf.c b/libc-top-half/musl/src/stdio/vdprintf.c index cef0a1af2..4ab32308a 100644 --- a/libc-top-half/musl/src/stdio/vdprintf.c +++ b/libc-top-half/musl/src/stdio/vdprintf.c @@ -6,7 +6,7 @@ int vdprintf(int fd, const char *restrict fmt, va_list ap) .fd = fd, .lbf = EOF, .write = __stdio_write, .buf = (void *)fmt, .buf_size = 0, #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - .lock = -1 + .lock = __STDIO_LOCK_INIT, #endif }; return vfprintf(&f, fmt, ap); diff --git a/libc-top-half/musl/src/stdio/vsscanf.c b/libc-top-half/musl/src/stdio/vsscanf.c index 0e5b48265..883e1d8c4 100644 --- a/libc-top-half/musl/src/stdio/vsscanf.c +++ b/libc-top-half/musl/src/stdio/vsscanf.c @@ -19,10 +19,9 @@ int vsscanf(const char *restrict s, const char *restrict fmt, va_list ap) { FILE f = { .buf = (void *)s, .cookie = (void *)s, + .read = string_read, #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - .read = string_read, .lock = -1 -#else - .read = string_read + .lock = __STDIO_LOCK_INIT #endif }; return vfscanf(&f, fmt, ap); diff --git a/libc-top-half/musl/src/stdio/vswscanf.c b/libc-top-half/musl/src/stdio/vswscanf.c index ea827102d..feef4e451 100644 --- a/libc-top-half/musl/src/stdio/vswscanf.c +++ b/libc-top-half/musl/src/stdio/vswscanf.c @@ -30,10 +30,9 @@ int vswscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, va_list ap) FILE f = { .buf = buf, .buf_size = sizeof buf, .cookie = (void *)s, + .read = wstring_read, #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - .read = wstring_read, .lock = -1 -#else - .read = wstring_read + .lock = __STDIO_LOCK_INIT #endif }; return vfwscanf(&f, fmt, ap); diff --git a/libc-top-half/musl/src/stdlib/wcstod.c b/libc-top-half/musl/src/stdlib/wcstod.c index 97b894eb2..c198f08c5 100644 --- a/libc-top-half/musl/src/stdlib/wcstod.c +++ b/libc-top-half/musl/src/stdlib/wcstod.c @@ -44,7 +44,7 @@ static long double wcstox(const wchar_t *s, wchar_t **p, int prec) f.rpos = f.rend = f.buf = buf + 4; f.buf_size = sizeof buf - 4; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - f.lock = -1; + __STDIO_LOCK_RESET(&f.lock); #endif f.read = do_read; while (iswspace(*t)) t++; diff --git a/libc-top-half/musl/src/stdlib/wcstol.c b/libc-top-half/musl/src/stdlib/wcstol.c index 3aefd06f4..43439c0d0 100644 --- a/libc-top-half/musl/src/stdlib/wcstol.c +++ b/libc-top-half/musl/src/stdlib/wcstol.c @@ -38,7 +38,7 @@ static unsigned long long wcstox(const wchar_t *s, wchar_t **p, int base, unsign f.rpos = f.rend = f.buf = buf + 4; f.buf_size = sizeof buf - 4; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - f.lock = -1; + __STDIO_LOCK_RESET(&f.lock); #endif f.read = do_read; while (iswspace(*t)) t++; diff --git a/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c b/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c index a2c0b478c..0ae4c8efd 100644 --- a/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c +++ b/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c @@ -3,6 +3,8 @@ int pthread_rwlock_init(pthread_rwlock_t *restrict rw, const pthread_rwlockattr_t *restrict a) { *rw = (pthread_rwlock_t){0}; + #ifndef __wasi_cooperative_threads__ if (a) rw->_rw_shared = a->__attr[0]*128; + #endif return 0; } diff --git a/libc-top-half/musl/src/thread/coop-threads/__lock.c b/libc-top-half/musl/src/thread/coop-threads/__lock.c index 45e397d34..9baeceff0 100644 --- a/libc-top-half/musl/src/thread/coop-threads/__lock.c +++ b/libc-top-half/musl/src/thread/coop-threads/__lock.c @@ -1,5 +1,6 @@ #include "pthread_impl.h" #include "lock.h" +#include #ifndef __wasip3__ #error "Unknown WASI version" diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_setpshared.c b/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_setpshared.c deleted file mode 100644 index 99c1dfe6d..000000000 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_barrier_setpshared.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_barrierattr_setpshared(pthread_barrierattr_t *a, int pshared) -{ - // Only private barriers are supported - return pshared == PTHREAD_PROCESS_PRIVATE ? 0 : ENOTSUP; -} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_cancel.c b/libc-top-half/musl/src/thread/coop-threads/pthread_cancel.c deleted file mode 100644 index 21f57bc14..000000000 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_cancel.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "pthread_impl.h" - -int pthread_cancel(pthread_t t) -{ - return ENOTSUP; -} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_create.c b/libc-top-half/musl/src/thread/coop-threads/pthread_create.c index f5471cde8..175ac0c4b 100644 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_create.c +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_create.c @@ -174,12 +174,6 @@ int __pthread_create(pthread_t *restrict res, self = __pthread_self(); if (!libc.threaded) { - for (FILE *f = *__ofl_lock(); f; f = f->next) - init_file_lock(f); - __ofl_unlock(); - init_file_lock(__stdin_used); - init_file_lock(__stdout_used); - init_file_lock(__stderr_used); self->tsd = (void **)__pthread_tsd_main; libc.threaded = 1; } diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_join.c b/libc-top-half/musl/src/thread/coop-threads/pthread_join.c index 8f1c0154f..b8b8400d8 100644 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_join.c +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_join.c @@ -22,6 +22,11 @@ static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec return ETIMEDOUT; } + if (t->joiner_waiters) { + // Only one thread can wait to join at a time + return EINVAL; + } + __waitlist_wait_on(&t->joiner_waiters); if (res) *res = t->result; diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_once.c b/libc-top-half/musl/src/thread/coop-threads/pthread_once.c index bbc11742d..28e7e22ca 100644 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_once.c +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_once.c @@ -3,7 +3,7 @@ enum { PTHREAD_ONCE_STATE_NOT_RUN = 0, PTHREAD_ONCE_STATE_RUNNING = 1, PTHREAD_ONCE_STATE_COMPLETED = 2 -} +}; static struct { pthread_once_t *control; diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_init.c b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_init.c deleted file mode 100644 index f3b69d73f..000000000 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_init.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "pthread_impl.h" - -int pthread_rwlock_init(pthread_rwlock_t *restrict rw, const pthread_rwlockattr_t *restrict a) -{ - *rw = (pthread_rwlock_t){0}; - return 0; -} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c index 3b62a97ce..0dd2317ba 100644 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c @@ -31,4 +31,3 @@ int __pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct tim return 0; } -#endif diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_trywrlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_trywrlock.c index 3943e838e..2f002cbd7 100644 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_trywrlock.c +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_trywrlock.c @@ -1,13 +1,20 @@ #include "pthread_impl.h" -int __pthread_rwlock_tryrdlock(pthread_rwlock_t *rw) +int __pthread_rwlock_trywrlock(pthread_rwlock_t *rw) { - /* If no writer holds the lock, increment reader count */ - if (rw->_rw_lock >= 0) { - rw->_rw_lock++; - return 0; + int tid = wasip3_thread_index(); + + /* Check for deadlock: trying to write-lock already owned write lock */ + if (rw->_rw_lock == -tid) { + return EDEADLK; } - return EBUSY; -} -weak_alias(__pthread_rwlock_tryrdlock, pthread_rwlock_tryrdlock); + /* Try to acquire write lock */ + if (rw->_rw_lock != 0) { + return EBUSY; + } + + rw->_rw_lock = -tid; + return 0; +} +weak_alias(__pthread_rwlock_trywrlock, pthread_rwlock_trywrlock); diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_sigmask.c b/libc-top-half/musl/src/thread/coop-threads/pthread_sigmask.c index b01bf0f64..0aab2544e 100644 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_sigmask.c +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_sigmask.c @@ -1,3 +1,5 @@ +#include "pthread_impl.h" + struct sigset_t; int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old) { diff --git a/libc-top-half/musl/src/thread/coop-threads/sem_open.c b/libc-top-half/musl/src/thread/coop-threads/sem_open.c index b5a9c6a50..4645a774c 100644 --- a/libc-top-half/musl/src/thread/coop-threads/sem_open.c +++ b/libc-top-half/musl/src/thread/coop-threads/sem_open.c @@ -1,9 +1,10 @@ #include #include +#include sem_t *sem_open(const char *name, int flags, ...) { - return ENOTSUP; + return NULL; } int sem_close(sem_t *sem) From bd108e2e40bcf55701e1714c5932e126637f1bee Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 2 Mar 2026 15:18:01 +0000 Subject: [PATCH 07/43] Linking fixes --- libc-bottom-half/crt/crt1-command.c | 8 ++++++++ libc-bottom-half/crt/crt1-reactor.c | 8 ++++++++ libc-bottom-half/sources/__main_void.c | 9 --------- libc-bottom-half/sources/__wasm_init_task.s | 4 ++-- test/CMakeLists.txt | 7 ++++--- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/libc-bottom-half/crt/crt1-command.c b/libc-bottom-half/crt/crt1-command.c index 6ef297592..d6ee74b7c 100644 --- a/libc-bottom-half/crt/crt1-command.c +++ b/libc-bottom-half/crt/crt1-command.c @@ -9,6 +9,14 @@ extern void __wasm_call_ctors(void); extern int __main_void(void); extern void __wasm_call_dtors(void); +#ifdef __wasm_component_model_thread_context__ +// Force __wasm_init_task and __wasm_init_async_task to be linked in for wasip3 +extern void __wasm_init_task(void); +extern void __wasm_init_async_task(void); +__attribute__((used)) void *__wasm_init_task_ref = __wasm_init_task; +__attribute__((used)) void *__wasm_init_async_task_ref = __wasm_init_async_task; +#endif + #if defined(__wasip1__) __attribute__((export_name("_start"))) void _start(void) #elif defined(__wasip2__) diff --git a/libc-bottom-half/crt/crt1-reactor.c b/libc-bottom-half/crt/crt1-reactor.c index bd693245e..d002f0104 100644 --- a/libc-bottom-half/crt/crt1-reactor.c +++ b/libc-bottom-half/crt/crt1-reactor.c @@ -4,6 +4,14 @@ extern void __wasi_init_tp(void); extern void __wasm_call_ctors(void); +#ifdef __wasm_component_model_thread_context__ +// Force __wasm_init_task and __wasm_init_async_task to be linked in for wasip3 +extern void __wasm_init_task(void); +extern void __wasm_init_async_task(void); +__attribute__((used)) static void *__wasm_init_task_ref = __wasm_init_task; +__attribute__((used)) static void *__wasm_init_async_task_ref = __wasm_init_async_task; +#endif + __attribute__((export_name("_initialize"))) void _initialize(void) { #if defined(_REENTRANT) static volatile atomic_int initialized = 0; diff --git a/libc-bottom-half/sources/__main_void.c b/libc-bottom-half/sources/__main_void.c index 340e4d42c..b6a412470 100644 --- a/libc-bottom-half/sources/__main_void.c +++ b/libc-bottom-half/sources/__main_void.c @@ -7,15 +7,6 @@ #include #endif -#ifdef __wasm_component_model_thread_context__ -/* Ensure __wasm_init_task and __wasm_init_async_task are always linked. - * These assembly functions are required for wasip3 initialization. */ -void __wasm_init_task(void); -void __wasm_init_async_task(void); -__attribute__((used)) hidden static void *__wasm_init_task_reference = __wasm_init_task; -__attribute__((used)) hidden static void *__wasm_init_async_task_reference = __wasm_init_async_task; -#endif - // The user's `main` function, expecting arguments. // // Note that we make this a weak symbol so that it will have a diff --git a/libc-bottom-half/sources/__wasm_init_task.s b/libc-bottom-half/sources/__wasm_init_task.s index 2bae09681..2f11ce7fa 100644 --- a/libc-bottom-half/sources/__wasm_init_task.s +++ b/libc-bottom-half/sources/__wasm_init_task.s @@ -7,7 +7,7 @@ .globaltype __init_tls_base, i32 .globaltype __tls_size, i32, immutable .globaltype __tls_align, i32, immutable - .globaltype __default_stacksize, i32 + .globl __default_stacksize .functype __wasm_component_model_builtin_context_set_0 (i32) -> () .import_module __wasm_component_model_builtin_context_set_0, "$root" @@ -84,7 +84,7 @@ __wasm_init_async_task: call __wasm_component_model_builtin_context_set_1 # Allocate a new stack - global.get __default_stacksize + i32.const __default_stacksize call malloc call __wasm_component_model_builtin_context_set_0 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 08b6db492..837548a75 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,8 +21,8 @@ message(STATUS "libc-test source directory: ${LIBC_TEST}") FetchContent_Declare( posix-testsuite - GIT_REPOSITORY https://github.com/tartanllama/open-posix-test-suite - GIT_TAG 78b3bc8386ef3d933c7f41c95c89cd80e60e60a9 + GIT_REPOSITORY https://github.com/bytecodealliance/open-posix-test-suite + GIT_TAG 18321461ce8381c359b439f5231908208718d230 GIT_SHALLOW true ) FetchContent_MakeAvailable(posix-testsuite) @@ -37,7 +37,7 @@ if(NOT ENGINE OR ENGINE STREQUAL "") ba_download( wasmtime "https://github.com/bytecodealliance/wasmtime" - "v41.0.0" + "v42.0.1" ) ExternalProject_Get_Property(wasmtime SOURCE_DIR) set(ENGINE "${SOURCE_DIR}/wasmtime") @@ -139,6 +139,7 @@ function(register_test test_name executable_name) endif() if (WASI STREQUAL "p3") list(APPEND wasmtime_args --wasm component-model-async) + list(APPEND wasmtime_args --wasm component-model-threading) list(APPEND wasmtime_args --wasi p3) endif() From 5f6f5ae79362262f0bd2e2c3269d346f3314ee73 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 2 Mar 2026 16:24:06 +0000 Subject: [PATCH 08/43] Various clocks and build fixes --- libc-top-half/CMakeLists.txt | 4 +++ .../musl/src/thread/common/pthread_attr_get.c | 4 +-- .../src/thread/common/pthread_condattr_init.c | 1 + .../coop-threads/pthread_cond_timedwait.c | 4 ++- .../thread/coop-threads/pthread_cond_wait.c | 6 ++++ .../src/thread/coop-threads/pthread_create.c | 1 - .../thread/coop-threads/pthread_mutex_lock.c | 31 +++++++++++++++++++ .../coop-threads/pthread_rwlock_rdlock.c | 8 +++++ .../thread/wasi-threads/pthread_cond_wait.c | 6 ++++ test/CMakeLists.txt | 2 +- 10 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_cond_wait.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_mutex_lock.c create mode 100644 libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_rdlock.c create mode 100644 libc-top-half/musl/src/thread/wasi-threads/pthread_cond_wait.c diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index 47553cd05..78a03570e 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -225,6 +225,7 @@ set(top_half_sources musl/src/network/ntohs.c musl/src/stat/futimesat.c musl/src/thread/common/default_attr.c + musl/src/thread/common/lock_ptc.c musl/src/thread/common/pthread_attr_destroy.c musl/src/thread/common/pthread_attr_get.c musl/src/thread/common/pthread_attr_init.c @@ -458,6 +459,7 @@ elseif(WASI STREQUAL "p3") musl/src/thread/coop-threads/pthread_cond_init.c musl/src/thread/coop-threads/pthread_cond_signal.c musl/src/thread/coop-threads/pthread_cond_timedwait.c + musl/src/thread/coop-threads/pthread_cond_wait.c musl/src/thread/coop-threads/pthread_create.c musl/src/thread/coop-threads/pthread_detach.c musl/src/thread/coop-threads/pthread_getcpuclockid.c @@ -466,11 +468,13 @@ elseif(WASI STREQUAL "p3") musl/src/thread/coop-threads/pthread_join.c musl/src/thread/coop-threads/pthread_kill.c musl/src/thread/coop-threads/pthread_mutex_consistent.c + musl/src/thread/coop-threads/pthread_mutex_lock.c musl/src/thread/coop-threads/pthread_mutex_setprioceiling.c musl/src/thread/coop-threads/pthread_mutex_timedlock.c musl/src/thread/coop-threads/pthread_mutex_trylock.c musl/src/thread/coop-threads/pthread_mutex_unlock.c musl/src/thread/coop-threads/pthread_once.c + musl/src/thread/wasi-threads/pthread_rwlock_rdlock.c musl/src/thread/coop-threads/pthread_rwlock_timedrdlock.c musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c musl/src/thread/coop-threads/pthread_rwlock_tryrdlock.c diff --git a/libc-top-half/musl/src/thread/common/pthread_attr_get.c b/libc-top-half/musl/src/thread/common/pthread_attr_get.c index 503c5b85a..98b7b0802 100644 --- a/libc-top-half/musl/src/thread/common/pthread_attr_get.c +++ b/libc-top-half/musl/src/thread/common/pthread_attr_get.c @@ -77,9 +77,9 @@ int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *r #else int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk) { - if (a->__attr & 0x7fffffff == CLOCKID_REALTIME) + if ((a->__attr & 0x7fffffff) == CLOCKID_REALTIME) *clk = CLOCK_REALTIME; - if (a->__attr & 0x7fffffff == CLOCKID_MONOTONIC) + else if ((a->__attr & 0x7fffffff) == CLOCKID_MONOTONIC) *clk = CLOCK_MONOTONIC; return 0; } diff --git a/libc-top-half/musl/src/thread/common/pthread_condattr_init.c b/libc-top-half/musl/src/thread/common/pthread_condattr_init.c index a41741b4e..2451c47fd 100644 --- a/libc-top-half/musl/src/thread/common/pthread_condattr_init.c +++ b/libc-top-half/musl/src/thread/common/pthread_condattr_init.c @@ -3,5 +3,6 @@ int pthread_condattr_init(pthread_condattr_t *a) { *a = (pthread_condattr_t){0}; + pthread_condattr_setclock(a, CLOCK_REALTIME); return 0; } diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_cond_timedwait.c b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_timedwait.c index a17e59670..121501329 100644 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_cond_timedwait.c +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_timedwait.c @@ -10,4 +10,6 @@ int __pthread_cond_timedwait(pthread_cond_t *restrict c, pthread_mutex_t *restri pthread_mutex_unlock(m); __waitlist_wait_on(&c->_c_waiters); return pthread_mutex_lock(m); -} \ No newline at end of file +} + +weak_alias(__pthread_cond_timedwait, pthread_cond_timedwait); \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_cond_wait.c b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_wait.c new file mode 100644 index 000000000..8735bf147 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_cond_wait.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_cond_wait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m) +{ + return pthread_cond_timedwait(c, m, 0); +} diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_create.c b/libc-top-half/musl/src/thread/coop-threads/pthread_create.c index 175ac0c4b..ff81bcd45 100644 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_create.c +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_create.c @@ -297,7 +297,6 @@ int __pthread_create(pthread_t *restrict res, *res = new; return 0; fail: - __release_ptc(); return EAGAIN; } diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_lock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_lock.c new file mode 100644 index 000000000..7038a707e --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_mutex_lock.c @@ -0,0 +1,31 @@ +#include "pthread_impl.h" + +int __pthread_mutex_lock(pthread_mutex_t *m) +{ + int tid = wasip3_thread_index(); + int type = m->_m_type & 15; + + /* Check for recursive lock */ + if (m->_m_lock == tid) { + if (type == PTHREAD_MUTEX_RECURSIVE) { + m->_m_count++; + return 0; + } + if (type == PTHREAD_MUTEX_ERRORCHECK) { + return EDEADLK; + } + /* Normal mutex: deadlock */ + __builtin_trap(); + } + + /* Wait until unlocked */ + while (m->_m_lock != 0) { + __waitlist_wait_on(&m->_m_waiters); + } + + m->_m_lock = tid; + m->_m_count = 1; + return 0; +} + +weak_alias(__pthread_mutex_lock, pthread_mutex_lock); \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_rdlock.c b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_rdlock.c new file mode 100644 index 000000000..8546c07d2 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_rwlock_rdlock.c @@ -0,0 +1,8 @@ +#include "pthread_impl.h" + +int __pthread_rwlock_rdlock(pthread_rwlock_t *rw) +{ + return __pthread_rwlock_timedrdlock(rw, 0); +} + +weak_alias(__pthread_rwlock_rdlock, pthread_rwlock_rdlock); diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_cond_wait.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_cond_wait.c new file mode 100644 index 000000000..8735bf147 --- /dev/null +++ b/libc-top-half/musl/src/thread/wasi-threads/pthread_cond_wait.c @@ -0,0 +1,6 @@ +#include "pthread_impl.h" + +int pthread_cond_wait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m) +{ + return pthread_cond_timedwait(c, m, 0); +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 837548a75..6633fe1a9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -544,7 +544,7 @@ if (WASI STREQUAL "p3") # unsupported(signals): conformance/interfaces/pthread_cond_init/4-2.c add_posix_test(conformance/interfaces/pthread_cond_signal/1-1.c) - # temporarily unsupported(clocks): conformance/interfaces/pthread_cond_signal/1-2.c + # temporarily unsupported(timed waits): conformance/interfaces/pthread_cond_signal/1-2.c add_posix_test(conformance/interfaces/pthread_cond_signal/2-1.c) # temporarily unsupported(timed waits): conformance/interfaces/pthread_cond_signal/2-2.c add_posix_test(conformance/interfaces/pthread_cond_signal/4-1.c) From 6bc21e1e0792b609587a6d5b9a7ffb827e49b5a6 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 2 Mar 2026 16:24:29 +0000 Subject: [PATCH 09/43] Lock fixes --- libc-bottom-half/sources/chdir.c | 21 +++++++------------ libc-bottom-half/sources/getcwd.c | 10 ++++----- .../musl/src/thread/common/lock_ptc.c | 6 ++++++ .../src/thread/common/pthread_cond_wait.c | 6 ------ 4 files changed, 19 insertions(+), 24 deletions(-) delete mode 100644 libc-top-half/musl/src/thread/common/pthread_cond_wait.c diff --git a/libc-bottom-half/sources/chdir.c b/libc-bottom-half/sources/chdir.c index 838459e9c..ac0293cf0 100644 --- a/libc-bottom-half/sources/chdir.c +++ b/libc-bottom-half/sources/chdir.c @@ -7,14 +7,9 @@ #include #include #include +#include "lock.h" -#ifdef _REENTRANT -void __wasilibc_cwd_lock(void); -void __wasilibc_cwd_unlock(void); -#else -#define __wasilibc_cwd_lock() (void)0 -#define __wasilibc_cwd_unlock() (void)0 -#endif +extern __lock_t __wasilibc_cwd_lock; extern char *__wasilibc_cwd; static int __wasilibc_cwd_mallocd = 0; @@ -64,10 +59,10 @@ int chdir(const char *path) { // And set our new malloc'd buffer into the global cwd, freeing the // previous one if necessary. - __wasilibc_cwd_lock(); + WEAK_LOCK(__wasilibc_cwd_lock); char *prev_cwd = __wasilibc_cwd; __wasilibc_cwd = new_cwd; - __wasilibc_cwd_unlock(); + WEAK_UNLOCK(__wasilibc_cwd_lock); if (__wasilibc_cwd_mallocd) free(prev_cwd); __wasilibc_cwd_mallocd = 1; @@ -98,23 +93,23 @@ static const char *make_absolute(const char *path) { // Otherwise we'll take the current directory, add a `/`, and then add the // input `path`. Note that this doesn't do any normalization (like removing // `/./`). - __wasilibc_cwd_lock(); + WEAK_LOCK(__wasilibc_cwd_lock); size_t cwd_len = strlen(__wasilibc_cwd); size_t path_len = path ? strlen(path) : 0; - __wasilibc_cwd_unlock(); + WEAK_UNLOCK(__wasilibc_cwd_lock); int need_slash = __wasilibc_cwd[cwd_len - 1] == '/' ? 0 : 1; size_t alloc_len = cwd_len + path_len + 1 + need_slash; if (alloc_len > make_absolute_len) { char *tmp = realloc(make_absolute_buf, alloc_len); if (tmp == NULL) { - __wasilibc_cwd_unlock(); + WEAK_UNLOCK(__wasilibc_cwd_lock); return NULL; } make_absolute_buf = tmp; make_absolute_len = alloc_len; } strcpy(make_absolute_buf, __wasilibc_cwd); - __wasilibc_cwd_unlock(); + WEAK_UNLOCK(__wasilibc_cwd_lock); #ifdef _REENTRANT if (path[0] == 0 || !strcmp(path, ".") || !strcmp(path, "./")) { diff --git a/libc-bottom-half/sources/getcwd.c b/libc-bottom-half/sources/getcwd.c index 576508620..d158e412f 100644 --- a/libc-bottom-half/sources/getcwd.c +++ b/libc-bottom-half/sources/getcwd.c @@ -7,28 +7,28 @@ char *__wasilibc_cwd = "/"; #ifdef _REENTRANT -static __lock_t lock[1]; +static __lock_t __wasilibc_cwd_lock[1]; #endif char *getcwd(char *buf, size_t size) { // Critical section contains no yield points, so we can use weak locks. - WEAK_LOCK(lock); + WEAK_LOCK(__wasilibc_cwd_lock); if (!buf) { buf = strdup(__wasilibc_cwd); if (!buf) { errno = ENOMEM; - WEAK_UNLOCK(lock); + WEAK_UNLOCK(__wasilibc_cwd_lock); return NULL; } } else { size_t len = strlen(__wasilibc_cwd); if (size < len + 1) { errno = ERANGE; - WEAK_UNLOCK(lock); + WEAK_UNLOCK(__wasilibc_cwd_lock); return NULL; } strcpy(buf, __wasilibc_cwd); } - WEAK_UNLOCK(lock); + WEAK_UNLOCK(__wasilibc_cwd_lock); return buf; } diff --git a/libc-top-half/musl/src/thread/common/lock_ptc.c b/libc-top-half/musl/src/thread/common/lock_ptc.c index 7adedab75..20021da62 100644 --- a/libc-top-half/musl/src/thread/common/lock_ptc.c +++ b/libc-top-half/musl/src/thread/common/lock_ptc.c @@ -1,5 +1,6 @@ #include +#if defined(_REENTRANT) && !defined(__wasi_cooperative_threads__) static pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER; void __inhibit_ptc() @@ -16,3 +17,8 @@ void __release_ptc() { pthread_rwlock_unlock(&lock); } +#else +void __inhibit_ptc(){} +void __acquire_ptc(){} +void __release_ptc(){} +#endif \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/common/pthread_cond_wait.c b/libc-top-half/musl/src/thread/common/pthread_cond_wait.c deleted file mode 100644 index 8735bf147..000000000 --- a/libc-top-half/musl/src/thread/common/pthread_cond_wait.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "pthread_impl.h" - -int pthread_cond_wait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m) -{ - return pthread_cond_timedwait(c, m, 0); -} From 2f613cceca455114e15df1f0763a390fd33a4b0b Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 2 Mar 2026 17:14:30 +0000 Subject: [PATCH 10/43] Sysconf changes --- libc-top-half/musl/src/conf/sysconf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc-top-half/musl/src/conf/sysconf.c b/libc-top-half/musl/src/conf/sysconf.c index 27efc9788..79ddbd4e8 100644 --- a/libc-top-half/musl/src/conf/sysconf.c +++ b/libc-top-half/musl/src/conf/sysconf.c @@ -138,10 +138,10 @@ long sysconf(int name) [_SC_THREAD_THREADS_MAX] = -1, [_SC_THREAD_ATTR_STACKADDR] = VER, [_SC_THREAD_ATTR_STACKSIZE] = VER, - [_SC_THREAD_PRIORITY_SCHEDULING] = VER, + [_SC_THREAD_PRIORITY_SCHEDULING] = -1, [_SC_THREAD_PRIO_INHERIT] = -1, [_SC_THREAD_PRIO_PROTECT] = -1, - [_SC_THREAD_PROCESS_SHARED] = VER, + [_SC_THREAD_PROCESS_SHARED] = -1, [_SC_NPROCESSORS_CONF] = JT_NPROCESSORS_CONF, [_SC_NPROCESSORS_ONLN] = JT_NPROCESSORS_ONLN, [_SC_PHYS_PAGES] = JT_PHYS_PAGES, From 8f2a99c2e74aaa7babba428be1464e4eebe8b1d6 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 2 Mar 2026 17:14:44 +0000 Subject: [PATCH 11/43] sem_destroy fixes --- libc-top-half/CMakeLists.txt | 1 + .../musl/src/thread/{common => coop-threads}/sem_destroy.c | 0 libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c | 6 ------ 3 files changed, 1 insertion(+), 6 deletions(-) rename libc-top-half/musl/src/thread/{common => coop-threads}/sem_destroy.c (100%) delete mode 100644 libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index 78a03570e..22b68310c 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -489,6 +489,7 @@ elseif(WASI STREQUAL "p3") musl/src/thread/coop-threads/pthread_spin_lock.c musl/src/thread/coop-threads/pthread_spin_trylock.c musl/src/thread/coop-threads/pthread_spin_unlock.c + musl/src/thread/coop-threads/sem_destroy.c musl/src/thread/coop-threads/sem_getvalue.c musl/src/thread/coop-threads/sem_init.c musl/src/thread/coop-threads/sem_open.c diff --git a/libc-top-half/musl/src/thread/common/sem_destroy.c b/libc-top-half/musl/src/thread/coop-threads/sem_destroy.c similarity index 100% rename from libc-top-half/musl/src/thread/common/sem_destroy.c rename to libc-top-half/musl/src/thread/coop-threads/sem_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c deleted file mode 100644 index f4aced5da..000000000 --- a/libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int sem_destroy(sem_t *sem) -{ - return 0; -} From 16d406aea24a6676bd7cd382784d0f5882305148 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Wed, 4 Mar 2026 09:34:53 +0000 Subject: [PATCH 12/43] Link and test updates --- libc-bottom-half/sources/__wasm_init_task.s | 6 ++++-- test/CMakeLists.txt | 14 +++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libc-bottom-half/sources/__wasm_init_task.s b/libc-bottom-half/sources/__wasm_init_task.s index 2f11ce7fa..c6411ba72 100644 --- a/libc-bottom-half/sources/__wasm_init_task.s +++ b/libc-bottom-half/sources/__wasm_init_task.s @@ -7,7 +7,6 @@ .globaltype __init_tls_base, i32 .globaltype __tls_size, i32, immutable .globaltype __tls_align, i32, immutable - .globl __default_stacksize .functype __wasm_component_model_builtin_context_set_0 (i32) -> () .import_module __wasm_component_model_builtin_context_set_0, "$root" @@ -84,7 +83,10 @@ __wasm_init_async_task: call __wasm_component_model_builtin_context_set_1 # Allocate a new stack - i32.const __default_stacksize + # Constant copied from __default_stacksize, TODO(wasip3) find a way + # to reference this constant without linking failing for shared libraries, + # i.e. a position-independent data reference. + i32.const 131072 call malloc call __wasm_component_model_builtin_context_set_0 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6633fe1a9..8caab0b08 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -522,7 +522,7 @@ if (WASI STREQUAL "p3") # unsupported(cancellation): conformance/interfaces/pthread_cleanup_push/1-3.c add_posix_test(conformance/interfaces/pthread_cond_broadcast/1-1.c) - # temporarily unsupported(clocks): conformance/interfaces/pthread_cond_broadcast/1-2.c + # temporarily unsupported(timed waits): conformance/interfaces/pthread_cond_broadcast/1-2.c add_posix_test(conformance/interfaces/pthread_cond_broadcast/2-1.c) # temporarily unsupported(timed waits): conformance/interfaces/pthread_cond_broadcast/2-2.c # unsupported(mmap): conformance/interfaces/pthread_cond_broadcast/2-3.c @@ -530,7 +530,7 @@ if (WASI STREQUAL "p3") # unsupported(signals): conformance/interfaces/pthread_cond_broadcast/4-2.c add_posix_test(conformance/interfaces/pthread_cond_destroy/1-1.c) - # temporarily unsupported(clocks): conformance/interfaces/pthread_cond_destroy/2-1.c + # temporarily unsupported(timed waits): conformance/interfaces/pthread_cond_destroy/2-1.c add_posix_test(conformance/interfaces/pthread_cond_destroy/3-1.c) add_posix_test(conformance/interfaces/pthread_cond_destroy/speculative/4-1.c) @@ -538,7 +538,7 @@ if (WASI STREQUAL "p3") # unsupported(set time): conformance/interfaces/pthread_cond_init/1-2.c # unsupported(processes): conformance/interfaces/pthread_cond_init/1-3.c add_posix_test(conformance/interfaces/pthread_cond_init/2-1.c) - # temporarily unsupported(clocks): conformance/interfaces/pthread_cond_init/2-2.c + # unsupported(set time): conformance/interfaces/pthread_cond_init/2-2.c add_posix_test(conformance/interfaces/pthread_cond_init/3-1.c) # unsupported(fork): conformance/interfaces/pthread_cond_init/4-1.c # unsupported(signals): conformance/interfaces/pthread_cond_init/4-2.c @@ -583,10 +583,10 @@ if (WASI STREQUAL "p3") add_posix_test(conformance/interfaces/pthread_condattr_init/1-1.c) add_posix_test(conformance/interfaces/pthread_condattr_init/3-1.c) - # temporarily unsupported(clocks): conformance/interfaces/pthread_condattr_setclock/1-1.c - # temporarily unsupported(clocks): conformance/interfaces/pthread_condattr_setclock/1-2.c + add_posix_test(conformance/interfaces/pthread_condattr_setclock/1-1.c) + add_posix_test(conformance/interfaces/pthread_condattr_setclock/1-2.c) # unsupported(getcpuclockid): conformance/interfaces/pthread_condattr_setclock/1-3.c - # temporarily unsupported(clocks): conformance/interfaces/pthread_condattr_setclock/2-1.c + add_posix_test(conformance/interfaces/pthread_condattr_setclock/2-1.c) # unsupported(process-shared): conformance/interfaces/pthread_condattr_setpshared/* @@ -597,7 +597,7 @@ if (WASI STREQUAL "p3") # unsupported(fork): add_posix_test(conformance/interfaces/pthread_create/1-5.c # unsupported(scheduling): conformance/interfaces/pthread_create/1-6.c # unsupported(signals): add_posix_test(conformance/interfaces/pthread_create/10-1.c) - # temporarily unsupported(clocks): conformance/interfaces/pthread_create/11-1.c + # bad test(incorrect assumption):conformance/interfaces/pthread_create/11-1.c add_posix_test(conformance/interfaces/pthread_create/12-1.c) # unsupported(signals): conformance/interfaces/pthread_create/14-1.c add_posix_test(conformance/interfaces/pthread_create/15-1.c) From 72ac6f8cb2e7d321896ebea7896aa9ce2ca18c2d Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Wed, 4 Mar 2026 14:09:31 +0000 Subject: [PATCH 13/43] WASIp3 bump --- CMakeLists.txt | 2 +- cmake/wasi-wits.cmake | 6 +- .../cloudlibc/src/libc/unistd/pwrite.c | 12 +- .../headers/private/wasi/wasip3_block.h | 2 +- .../headers/public/wasi/__generated_wasip3.h | 76 ++- libc-bottom-half/sources/file.c | 38 +- libc-bottom-half/sources/wasip3.c | 459 +++++++++++------- .../sources/wasip3_component_type.o | Bin 8099 -> 8107 bytes libc-bottom-half/sources/wasip3_stdio.c | 36 +- .../package.wit | 158 +++--- .../package.wit | 34 +- .../package.wit | 125 ++--- .../package.wit | 70 ++- .../package.wit | 26 +- .../package.wit | 134 ++--- wasi/p3/wit/wasi-libc.wit | 12 +- wasi/p3/wkg.lock | 36 +- 17 files changed, 695 insertions(+), 531 deletions(-) rename wasi/p3/wit/deps/{wasi-cli-0.3.0-rc-2026-01-06 => wasi-cli-0.3.0-rc-2026-02-09}/package.wit (60%) rename wasi/p3/wit/deps/{wasi-clocks-0.3.0-rc-2026-01-06 => wasi-clocks-0.3.0-rc-2026-02-09}/package.wit (89%) rename wasi/p3/wit/deps/{wasi-filesystem-0.3.0-rc-2026-01-06 => wasi-filesystem-0.3.0-rc-2026-02-09}/package.wit (87%) rename wasi/p3/wit/deps/{wasi-http-0.3.0-rc-2026-01-06 => wasi-http-0.3.0-rc-2026-02-09}/package.wit (90%) rename wasi/p3/wit/deps/{wasi-random-0.3.0-rc-2026-01-06 => wasi-random-0.3.0-rc-2026-02-09}/package.wit (85%) rename wasi/p3/wit/deps/{wasi-sockets-0.3.0-rc-2026-01-06 => wasi-sockets-0.3.0-rc-2026-02-09}/package.wit (92%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 768551edb..ebff722c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,7 +150,7 @@ else() endif() set(wasip2-version 0.2.0) -set(wasip3-version 0.3.0-rc-2026-01-06) +set(wasip3-version 0.3.0-rc-2026-02-09) include(bindings) include(builtins) diff --git a/cmake/wasi-wits.cmake b/cmake/wasi-wits.cmake index e21ab0258..18cc127f2 100644 --- a/cmake/wasi-wits.cmake +++ b/cmake/wasi-wits.cmake @@ -12,8 +12,8 @@ if(WKG_EXECUTABLE) OUTPUT_VARIABLE WKG_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) - if (NOT (WKG_VERSION MATCHES "0\\.13\\.0")) - message(WARNING "wkg version 0.13.0 is required, found: ${WKG_VERSION}") + if (NOT (WKG_VERSION MATCHES "0\\.15\\.0")) + message(WARNING "wkg version 0.15.0 is required, found: ${WKG_VERSION}") set(WKG_EXECUTABLE "") endif() endif() @@ -23,7 +23,7 @@ if (NOT WKG_EXECUTABLE) ba_download( wkg "https://github.com/bytecodealliance/wasm-pkg-tools" - "0.13.0" + "0.15.0" ) ExternalProject_Get_Property(wkg DOWNLOADED_FILE) set(wkg_bin ${DOWNLOADED_FILE}) diff --git a/libc-bottom-half/cloudlibc/src/libc/unistd/pwrite.c b/libc-bottom-half/cloudlibc/src/libc/unistd/pwrite.c index 1caaa445d..cc3240477 100644 --- a/libc-bottom-half/cloudlibc/src/libc/unistd/pwrite.c +++ b/libc-bottom-half/cloudlibc/src/libc/unistd/pwrite.c @@ -75,8 +75,8 @@ ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset) { filesystem_stream_u8_writer_t writer; filesystem_stream_u8_t reader = filesystem_stream_u8_new(&writer); filesystem_result_void_error_code_t result; - wasip3_subtask_status_t subtask_status = - filesystem_method_descriptor_write_via_stream(file_handle, reader, offset, &result); + filesystem_future_result_void_error_code_t future = + filesystem_method_descriptor_write_via_stream(file_handle, reader, offset); bool closed; size_t ret = __wasilibc_stream_block_on( filesystem_stream_u8_write(writer, buf, nbyte), @@ -84,11 +84,13 @@ ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset) { &closed); filesystem_stream_u8_drop_writable(writer); - // Wait for the subtask to resolve now that the writer half is closed and if + // Wait for the future to resolve now that the writer half is closed and if // we failed to write bytes (0 bytes written) and the result is an error we // can return -1. - if (WASIP3_SUBTASK_STATE(subtask_status) != WASIP3_SUBTASK_RETURNED) - __wasilibc_subtask_block_on_and_drop(WASIP3_SUBTASK_HANDLE(subtask_status)); + __wasilibc_future_block_on( + filesystem_future_result_void_error_code_read(future, &result), + future); + filesystem_future_result_void_error_code_drop_readable(future); if (ret == 0 && result.is_err) { translate_error(result.val.err); return -1; diff --git a/libc-bottom-half/headers/private/wasi/wasip3_block.h b/libc-bottom-half/headers/private/wasi/wasip3_block.h index 27ae486f3..ec4447e70 100644 --- a/libc-bottom-half/headers/private/wasi/wasip3_block.h +++ b/libc-bottom-half/headers/private/wasi/wasip3_block.h @@ -16,7 +16,7 @@ void __wasilibc_subtask_block_on_and_drop(wasip3_subtask_t status); /// This function will block if `status` indicates that the future is blocked, /// and this function won't return until the future has become ready again. This is /// suitable, for example, for waiting for future reads to complete. -void __wasilibc_future_block_on(wasip3_subtask_status_t status, uint32_t future); +void __wasilibc_future_block_on(wasip3_waitable_status_t status, uint32_t future); /// Waits for `stream` to be resolved after a previous operation yielded /// `status` as a result. diff --git a/libc-bottom-half/headers/public/wasi/__generated_wasip3.h b/libc-bottom-half/headers/public/wasi/__generated_wasip3.h index b956e3e48..0f4ecbc7e 100644 --- a/libc-bottom-half/headers/public/wasi/__generated_wasip3.h +++ b/libc-bottom-half/headers/public/wasi/__generated_wasip3.h @@ -157,6 +157,8 @@ typedef struct { } val; } stdout_result_void_error_code_t; +typedef uint32_t stdout_future_result_void_error_code_t; + typedef wasi_cli_types_error_code_t stderr_error_code_t; typedef struct { @@ -166,6 +168,8 @@ typedef struct { } val; } stderr_result_void_error_code_t; +typedef uint32_t stderr_future_result_void_error_code_t; + typedef struct terminal_input_own_terminal_input_t { int32_t __handle; } terminal_input_own_terminal_input_t; @@ -889,7 +893,7 @@ typedef struct { uint64_t f1; } wasip3_tuple2_u64_u64_t; -// Imported Functions from `wasi:cli/environment@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/environment@0.3.0-rc-2026-02-09` // Get the POSIX-style environment variables. // // Each environment variable is provided as a pair of string variable names @@ -905,11 +909,11 @@ extern void environment_get_arguments(wasip3_list_string_t *ret); // directory, interpreting `.` as shorthand for this. extern bool environment_get_initial_cwd(wasip3_string_t *ret); -// Imported Functions from `wasi:cli/exit@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/exit@0.3.0-rc-2026-02-09` // Exit the current instance and any linked instances. _Noreturn extern void exit_exit(exit_result_void_void_t *status); -// Imported Functions from `wasi:cli/stdin@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/stdin@0.3.0-rc-2026-02-09` // Return a stream for reading from stdin. // // This function returns a stream which provides data read from stdin, @@ -925,7 +929,7 @@ _Noreturn extern void exit_exit(exit_result_void_void_t *status); // reads is implementation-specific. extern void stdin_read_via_stream(stdin_tuple2_stream_u8_future_result_void_error_code_t *ret); -// Imported Functions from `wasi:cli/stdout@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/stdout@0.3.0-rc-2026-02-09` // Write the given stream to stdout. // // If the stream's writable end is dropped this function will either return @@ -934,9 +938,9 @@ extern void stdin_read_via_stream(stdin_tuple2_stream_u8_future_result_void_erro // // Otherwise if there is an error the readable end of the stream will be // dropped and this function will return an error-code. -extern wasip3_subtask_status_t stdout_write_via_stream(stdin_stream_u8_t data, stdout_result_void_error_code_t *result); +extern stdout_future_result_void_error_code_t stdout_write_via_stream(stdin_stream_u8_t data); -// Imported Functions from `wasi:cli/stderr@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/stderr@0.3.0-rc-2026-02-09` // Write the given stream to stderr. // // If the stream's writable end is dropped this function will either return @@ -945,24 +949,24 @@ extern wasip3_subtask_status_t stdout_write_via_stream(stdin_stream_u8_t data, s // // Otherwise if there is an error the readable end of the stream will be // dropped and this function will return an error-code. -extern wasip3_subtask_status_t stderr_write_via_stream(stdin_stream_u8_t data, stderr_result_void_error_code_t *result); +extern stderr_future_result_void_error_code_t stderr_write_via_stream(stdin_stream_u8_t data); -// Imported Functions from `wasi:cli/terminal-stdin@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/terminal-stdin@0.3.0-rc-2026-02-09` // If stdin is connected to a terminal, return a `terminal-input` handle // allowing further interaction with it. extern bool terminal_stdin_get_terminal_stdin(terminal_stdin_own_terminal_input_t *ret); -// Imported Functions from `wasi:cli/terminal-stdout@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/terminal-stdout@0.3.0-rc-2026-02-09` // If stdout is connected to a terminal, return a `terminal-output` handle // allowing further interaction with it. extern bool terminal_stdout_get_terminal_stdout(terminal_stdout_own_terminal_output_t *ret); -// Imported Functions from `wasi:cli/terminal-stderr@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/terminal-stderr@0.3.0-rc-2026-02-09` // If stderr is connected to a terminal, return a `terminal-output` handle // allowing further interaction with it. extern bool terminal_stderr_get_terminal_stderr(terminal_stderr_own_terminal_output_t *ret); -// Imported Functions from `wasi:clocks/monotonic-clock@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09` // Read the current value of the clock. // // The clock is monotonic, therefore calling this function repeatedly will @@ -981,7 +985,7 @@ extern void monotonic_clock_wait_until(monotonic_clock_mark_t when); // Wait for the specified duration to elapse. extern void monotonic_clock_wait_for(monotonic_clock_duration_t how_long); -// Imported Functions from `wasi:clocks/system-clock@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:clocks/system-clock@0.3.0-rc-2026-02-09` // Read the current value of the clock. // // This clock is not monotonic, therefore calling this function repeatedly @@ -993,7 +997,7 @@ extern void system_clock_now(system_clock_instant_t *ret); // that the implementation permits distinguishing. extern system_clock_duration_t system_clock_get_resolution(void); -// Imported Functions from `wasi:filesystem/types@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:filesystem/types@0.3.0-rc-2026-02-09` // Return a stream for reading from a file. // // Multiple read, write, and append streams may be active on the same open @@ -1023,7 +1027,7 @@ extern void filesystem_method_descriptor_read_via_stream(filesystem_borrow_descr // written or an error is encountered. // // Note: This is similar to `pwrite` in POSIX. -extern wasip3_subtask_status_t filesystem_method_descriptor_write_via_stream(filesystem_borrow_descriptor_t self, filesystem_stream_u8_t data, filesystem_filesize_t offset, filesystem_result_void_error_code_t *result); +extern filesystem_future_result_void_error_code_t filesystem_method_descriptor_write_via_stream(filesystem_borrow_descriptor_t self, filesystem_stream_u8_t data, filesystem_filesize_t offset); // Return a stream for appending to a file, if available. // // May fail with an error-code describing why the file cannot be appended. @@ -1032,7 +1036,7 @@ extern wasip3_subtask_status_t filesystem_method_descriptor_write_via_stream(fil // written or an error is encountered. // // Note: This is similar to `write` with `O_APPEND` in POSIX. -extern wasip3_subtask_status_t filesystem_method_descriptor_append_via_stream(filesystem_borrow_descriptor_t self, filesystem_stream_u8_t data, filesystem_result_void_error_code_t *result); +extern filesystem_future_result_void_error_code_t filesystem_method_descriptor_append_via_stream(filesystem_borrow_descriptor_t self, filesystem_stream_u8_t data); // Provide file advisory information on a descriptor. // // This is similar to `posix_fadvise` in POSIX. @@ -1205,11 +1209,11 @@ extern bool filesystem_method_descriptor_metadata_hash(filesystem_borrow_descrip // This performs the same hash computation as `metadata-hash`. extern bool filesystem_method_descriptor_metadata_hash_at(filesystem_borrow_descriptor_t self, filesystem_path_flags_t path_flags, wasip3_string_t *path, filesystem_metadata_hash_value_t *ret, filesystem_error_code_t *err); -// Imported Functions from `wasi:filesystem/preopens@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:filesystem/preopens@0.3.0-rc-2026-02-09` // Return the set of preopened directories, and their paths. extern void filesystem_preopens_get_directories(filesystem_preopens_list_tuple2_own_descriptor_string_t *ret); -// Imported Functions from `wasi:sockets/types@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:sockets/types@0.3.0-rc-2026-02-09` // Create a new TCP socket. // // Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX. @@ -1342,6 +1346,12 @@ extern wasip3_subtask_status_t sockets_method_tcp_socket_connect(sockets_method_ // In either case, the stream returned by this `listen` method remains // operational. // +// WASI requires `listen` to perform an implicit bind if the socket +// has not already been bound. Not all platforms (notably Windows) +// exhibit this behavior out of the box. On platforms that require it, +// the WASI implementation can emulate this behavior by performing +// the bind itself if the guest hasn't already done so. +// // # References // - // - @@ -1372,7 +1382,7 @@ extern bool sockets_method_tcp_socket_listen(sockets_borrow_tcp_socket_t self, s // - // - // - -extern wasip3_subtask_status_t sockets_method_tcp_socket_send(sockets_borrow_tcp_socket_t self, sockets_stream_u8_t data, sockets_result_void_error_code_t *result); +extern sockets_future_result_void_error_code_t sockets_method_tcp_socket_send(sockets_borrow_tcp_socket_t self, sockets_stream_u8_t data); // Read data from peer. // // This function returns a `stream` which provides the data received from the @@ -1722,7 +1732,7 @@ extern bool sockets_method_udp_socket_set_receive_buffer_size(sockets_borrow_udp extern bool sockets_method_udp_socket_get_send_buffer_size(sockets_borrow_udp_socket_t self, uint64_t *ret, sockets_error_code_t *err); extern bool sockets_method_udp_socket_set_send_buffer_size(sockets_borrow_udp_socket_t self, uint64_t value, sockets_error_code_t *err); -// Imported Functions from `wasi:sockets/ip-name-lookup@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:sockets/ip-name-lookup@0.3.0-rc-2026-02-09` // Resolve an internet host name to a list of IP addresses. // // Unicode domain names are automatically converted to ASCII using IDNA encoding. @@ -1747,7 +1757,7 @@ extern bool sockets_method_udp_socket_set_send_buffer_size(sockets_borrow_udp_so // - extern wasip3_subtask_status_t ip_name_lookup_resolve_addresses(wasip3_string_t name, ip_name_lookup_result_list_ip_address_error_code_t *result); -// Imported Functions from `wasi:random/random@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:random/random@0.3.0-rc-2026-02-09` // Return `len` cryptographically-secure random or pseudo-random bytes. // // This function must produce data at least as cryptographically secure and @@ -1767,7 +1777,7 @@ extern void random_get_random_bytes(uint64_t len, wasip3_list_u8_t *ret); // represented as a `u64`. extern uint64_t random_get_random_u64(void); -// Imported Functions from `wasi:random/insecure@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:random/insecure@0.3.0-rc-2026-02-09` // Return `len` insecure pseudo-random bytes. // // This function is not cryptographically secure. Do not use it for @@ -1783,7 +1793,7 @@ extern void random_insecure_get_insecure_random_bytes(uint64_t len, wasip3_list_ // `get-insecure-random-bytes`, represented as a `u64`. extern uint64_t random_insecure_get_insecure_random_u64(void); -// Imported Functions from `wasi:random/insecure-seed@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:random/insecure-seed@0.3.0-rc-2026-02-09` // Return a 128-bit value that may contain a pseudo-random value. // // The returned value is not required to be computed from a CSPRNG, and may @@ -1841,8 +1851,30 @@ void stdin_future_result_void_error_code_drop_writable(stdin_future_result_void_ void stdout_result_void_error_code_free(stdout_result_void_error_code_t *ptr); +typedef uint32_t stdout_future_result_void_error_code_writer_t; + +stdout_future_result_void_error_code_t stdout_future_result_void_error_code_new(stdout_future_result_void_error_code_writer_t *writer); +wasip3_waitable_status_t stdout_future_result_void_error_code_read(stdout_future_result_void_error_code_t reader, stdout_result_void_error_code_t *buf); +wasip3_waitable_status_t stdout_future_result_void_error_code_write(stdout_future_result_void_error_code_writer_t writer, const stdout_result_void_error_code_t *buf); +wasip3_waitable_status_t stdout_future_result_void_error_code_cancel_read(stdout_future_result_void_error_code_t reader); +wasip3_waitable_status_t stdout_future_result_void_error_code_cancel_write(stdout_future_result_void_error_code_writer_t writer); +void stdout_future_result_void_error_code_drop_readable(stdout_future_result_void_error_code_t reader); +void stdout_future_result_void_error_code_drop_writable(stdout_future_result_void_error_code_writer_t writer); + + void stderr_result_void_error_code_free(stderr_result_void_error_code_t *ptr); +typedef uint32_t stderr_future_result_void_error_code_writer_t; + +stderr_future_result_void_error_code_t stderr_future_result_void_error_code_new(stderr_future_result_void_error_code_writer_t *writer); +wasip3_waitable_status_t stderr_future_result_void_error_code_read(stderr_future_result_void_error_code_t reader, stderr_result_void_error_code_t *buf); +wasip3_waitable_status_t stderr_future_result_void_error_code_write(stderr_future_result_void_error_code_writer_t writer, const stderr_result_void_error_code_t *buf); +wasip3_waitable_status_t stderr_future_result_void_error_code_cancel_read(stderr_future_result_void_error_code_t reader); +wasip3_waitable_status_t stderr_future_result_void_error_code_cancel_write(stderr_future_result_void_error_code_writer_t writer); +void stderr_future_result_void_error_code_drop_readable(stderr_future_result_void_error_code_t reader); +void stderr_future_result_void_error_code_drop_writable(stderr_future_result_void_error_code_writer_t writer); + + extern void terminal_input_terminal_input_drop_own(terminal_input_own_terminal_input_t handle); extern terminal_input_borrow_terminal_input_t terminal_input_borrow_terminal_input(terminal_input_own_terminal_input_t handle); diff --git a/libc-bottom-half/sources/file.c b/libc-bottom-half/sources/file.c index 6f1d87c3e..e96a8a60d 100644 --- a/libc-bottom-half/sources/file.c +++ b/libc-bottom-half/sources/file.c @@ -28,7 +28,7 @@ typedef struct { #else filesystem_tuple2_stream_u8_future_result_void_error_code_t read; filesystem_stream_u8_writer_t write; - wasip3_subtask_t write_subtask; + filesystem_future_result_void_error_code_t write_future; filesystem_result_void_error_code_t write_pending_result; bool write_done; #endif @@ -66,15 +66,9 @@ static void file_close_streams(void *data) { filesystem_stream_u8_drop_writable(file->write); file->write = 0; } - if (file->write_subtask != 0) { - // TODO: this should use `wasip3_subtask_cancel` but right now that's buggy - // in Wasmtime. For now assume closing the stream above is enough to have - // the subtask here finish promptly, so block on the result. - // - // Once Wasmtime 43.0.0 is released and used in wasi-libc's CI that can be - // used here instead. - __wasilibc_subtask_block_on_and_drop(file->write_subtask); - file->write_subtask = 0; + if (file->write_future != 0) { + filesystem_future_result_void_error_code_drop_readable(file->write_future); + file->write_future = 0; } file->write_done = false; #endif @@ -142,9 +136,11 @@ static int file_get_read_stream(void *data, wasi_read_t *read) { static int file_write_eof(void *data) { file_t *file = (file_t *)data; - if (file->write_subtask != 0) { - __wasilibc_subtask_block_on_and_drop(file->write_subtask); - file->write_subtask = 0; + if (file->write_future != 0) { + __wasilibc_future_block_on( + filesystem_future_result_void_error_code_read(file->write_future, &file->write_pending_result), + file->write_future); + file->write_future = 0; } if (file->write_pending_result.is_err) { translate_error(file->write_pending_result.val.err); @@ -179,20 +175,18 @@ static int file_get_write_stream(void *data, wasi_write_t *write) { write->pollable = &file->write_pollable; #else if (file->write == 0) { - assert(file->write_subtask == 0); + assert(file->write_future == 0); filesystem_stream_u8_t write_read = filesystem_stream_u8_new(&file->write); - wasip3_subtask_status_t status; + filesystem_future_result_void_error_code_t future; if (file->oflag & O_APPEND) { - status = filesystem_method_descriptor_append_via_stream( - filesystem_borrow_descriptor(file->file_handle), write_read, - &file->write_pending_result); + future = filesystem_method_descriptor_append_via_stream( + filesystem_borrow_descriptor(file->file_handle), write_read); } else { - status = filesystem_method_descriptor_write_via_stream( + future = filesystem_method_descriptor_write_via_stream( filesystem_borrow_descriptor(file->file_handle), write_read, - file->offset, &file->write_pending_result); + file->offset); } - if (WASIP3_SUBTASK_STATE(status) != WASIP3_SUBTASK_RETURNED) - file->write_subtask = WASIP3_SUBTASK_HANDLE(status); + file->write_future = future; } write->output = file->write; write->eof = file_write_eof; diff --git a/libc-bottom-half/sources/wasip3.c b/libc-bottom-half/sources/wasip3.c index 6dc0f9521..d8e0a715b 100644 --- a/libc-bottom-half/sources/wasip3.c +++ b/libc-bottom-half/sources/wasip3.c @@ -3,302 +3,302 @@ #include #include -// Imported Functions from `wasi:cli/environment@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/environment@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:cli/environment@0.3.0-rc-2026-01-06"), __import_name__("get-environment"))) +__attribute__((__import_module__("wasi:cli/environment@0.3.0-rc-2026-02-09"), __import_name__("get-environment"))) extern void __wasm_import_environment_get_environment(uint8_t *); -__attribute__((__import_module__("wasi:cli/environment@0.3.0-rc-2026-01-06"), __import_name__("get-arguments"))) +__attribute__((__import_module__("wasi:cli/environment@0.3.0-rc-2026-02-09"), __import_name__("get-arguments"))) extern void __wasm_import_environment_get_arguments(uint8_t *); -__attribute__((__import_module__("wasi:cli/environment@0.3.0-rc-2026-01-06"), __import_name__("get-initial-cwd"))) +__attribute__((__import_module__("wasi:cli/environment@0.3.0-rc-2026-02-09"), __import_name__("get-initial-cwd"))) extern void __wasm_import_environment_get_initial_cwd(uint8_t *); -// Imported Functions from `wasi:cli/exit@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/exit@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:cli/exit@0.3.0-rc-2026-01-06"), __import_name__("exit"))) +__attribute__((__import_module__("wasi:cli/exit@0.3.0-rc-2026-02-09"), __import_name__("exit"))) _Noreturn extern void __wasm_import_exit_exit(int32_t); -// Imported Functions from `wasi:cli/stdin@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/stdin@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("read-via-stream"))) extern void __wasm_import_stdin_read_via_stream(uint8_t *); -// Imported Functions from `wasi:cli/stdout@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/stdout@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-01-06"), __import_name__("[async-lower]write-via-stream"))) -extern int32_t __wasm_import_stdout_write_via_stream(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-02-09"), __import_name__("write-via-stream"))) +extern int32_t __wasm_import_stdout_write_via_stream(int32_t); -// Imported Functions from `wasi:cli/stderr@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/stderr@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-01-06"), __import_name__("[async-lower]write-via-stream"))) -extern int32_t __wasm_import_stderr_write_via_stream(int32_t, uint8_t *); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-02-09"), __import_name__("write-via-stream"))) +extern int32_t __wasm_import_stderr_write_via_stream(int32_t); -// Imported Functions from `wasi:cli/terminal-stdin@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/terminal-stdin@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:cli/terminal-stdin@0.3.0-rc-2026-01-06"), __import_name__("get-terminal-stdin"))) +__attribute__((__import_module__("wasi:cli/terminal-stdin@0.3.0-rc-2026-02-09"), __import_name__("get-terminal-stdin"))) extern void __wasm_import_terminal_stdin_get_terminal_stdin(uint8_t *); -// Imported Functions from `wasi:cli/terminal-stdout@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/terminal-stdout@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:cli/terminal-stdout@0.3.0-rc-2026-01-06"), __import_name__("get-terminal-stdout"))) +__attribute__((__import_module__("wasi:cli/terminal-stdout@0.3.0-rc-2026-02-09"), __import_name__("get-terminal-stdout"))) extern void __wasm_import_terminal_stdout_get_terminal_stdout(uint8_t *); -// Imported Functions from `wasi:cli/terminal-stderr@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:cli/terminal-stderr@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:cli/terminal-stderr@0.3.0-rc-2026-01-06"), __import_name__("get-terminal-stderr"))) +__attribute__((__import_module__("wasi:cli/terminal-stderr@0.3.0-rc-2026-02-09"), __import_name__("get-terminal-stderr"))) extern void __wasm_import_terminal_stderr_get_terminal_stderr(uint8_t *); -// Imported Functions from `wasi:clocks/monotonic-clock@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-01-06"), __import_name__("now"))) +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09"), __import_name__("now"))) extern int64_t __wasm_import_monotonic_clock_now(void); -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-01-06"), __import_name__("get-resolution"))) +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09"), __import_name__("get-resolution"))) extern int64_t __wasm_import_monotonic_clock_get_resolution(void); -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-01-06"), __import_name__("wait-until"))) +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09"), __import_name__("wait-until"))) extern void __wasm_import_monotonic_clock_wait_until(int64_t); -__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-01-06"), __import_name__("wait-for"))) +__attribute__((__import_module__("wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09"), __import_name__("wait-for"))) extern void __wasm_import_monotonic_clock_wait_for(int64_t); -// Imported Functions from `wasi:clocks/system-clock@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:clocks/system-clock@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:clocks/system-clock@0.3.0-rc-2026-01-06"), __import_name__("now"))) +__attribute__((__import_module__("wasi:clocks/system-clock@0.3.0-rc-2026-02-09"), __import_name__("now"))) extern void __wasm_import_system_clock_now(uint8_t *); -__attribute__((__import_module__("wasi:clocks/system-clock@0.3.0-rc-2026-01-06"), __import_name__("get-resolution"))) +__attribute__((__import_module__("wasi:clocks/system-clock@0.3.0-rc-2026-02-09"), __import_name__("get-resolution"))) extern int64_t __wasm_import_system_clock_get_resolution(void); -// Imported Functions from `wasi:filesystem/types@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:filesystem/types@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.read-via-stream"))) extern void __wasm_import_filesystem_method_descriptor_read_via_stream(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][method]descriptor.write-via-stream"))) -extern int32_t __wasm_import_filesystem_method_descriptor_write_via_stream(int32_t, int32_t, int64_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.write-via-stream"))) +extern int32_t __wasm_import_filesystem_method_descriptor_write_via_stream(int32_t, int32_t, int64_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][method]descriptor.append-via-stream"))) -extern int32_t __wasm_import_filesystem_method_descriptor_append_via_stream(int32_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.append-via-stream"))) +extern int32_t __wasm_import_filesystem_method_descriptor_append_via_stream(int32_t, int32_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.advise"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.advise"))) extern void __wasm_import_filesystem_method_descriptor_advise(int32_t, int64_t, int64_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.sync-data"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.sync-data"))) extern void __wasm_import_filesystem_method_descriptor_sync_data(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.get-flags"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.get-flags"))) extern void __wasm_import_filesystem_method_descriptor_get_flags(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][method]descriptor.get-type"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][method]descriptor.get-type"))) extern int32_t __wasm_import_filesystem_method_descriptor_get_type(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.set-size"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.set-size"))) extern void __wasm_import_filesystem_method_descriptor_set_size(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.set-times"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.set-times"))) extern void __wasm_import_filesystem_method_descriptor_set_times(int32_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.read-directory"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.read-directory"))) extern void __wasm_import_filesystem_method_descriptor_read_directory(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.sync"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.sync"))) extern void __wasm_import_filesystem_method_descriptor_sync(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.create-directory-at"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.create-directory-at"))) extern void __wasm_import_filesystem_method_descriptor_create_directory_at(int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.stat"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.stat"))) extern void __wasm_import_filesystem_method_descriptor_stat(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.stat-at"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.stat-at"))) extern void __wasm_import_filesystem_method_descriptor_stat_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.set-times-at"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.set-times-at"))) extern void __wasm_import_filesystem_method_descriptor_set_times_at(int32_t, int32_t, uint8_t *, size_t, int32_t, int64_t, int32_t, int32_t, int64_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.link-at"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.link-at"))) extern void __wasm_import_filesystem_method_descriptor_link_at(int32_t, int32_t, uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.open-at"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.open-at"))) extern void __wasm_import_filesystem_method_descriptor_open_at(int32_t, int32_t, uint8_t *, size_t, int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.readlink-at"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.readlink-at"))) extern void __wasm_import_filesystem_method_descriptor_readlink_at(int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.remove-directory-at"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.remove-directory-at"))) extern void __wasm_import_filesystem_method_descriptor_remove_directory_at(int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.rename-at"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.rename-at"))) extern void __wasm_import_filesystem_method_descriptor_rename_at(int32_t, uint8_t *, size_t, int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.symlink-at"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.symlink-at"))) extern void __wasm_import_filesystem_method_descriptor_symlink_at(int32_t, uint8_t *, size_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.unlink-file-at"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.unlink-file-at"))) extern void __wasm_import_filesystem_method_descriptor_unlink_file_at(int32_t, uint8_t *, size_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][method]descriptor.is-same-object"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][method]descriptor.is-same-object"))) extern int32_t __wasm_import_filesystem_method_descriptor_is_same_object(int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.metadata-hash"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.metadata-hash"))) extern void __wasm_import_filesystem_method_descriptor_metadata_hash(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[method]descriptor.metadata-hash-at"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[method]descriptor.metadata-hash-at"))) extern void __wasm_import_filesystem_method_descriptor_metadata_hash_at(int32_t, int32_t, uint8_t *, size_t, uint8_t *); -// Imported Functions from `wasi:filesystem/preopens@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:filesystem/preopens@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:filesystem/preopens@0.3.0-rc-2026-01-06"), __import_name__("get-directories"))) +__attribute__((__import_module__("wasi:filesystem/preopens@0.3.0-rc-2026-02-09"), __import_name__("get-directories"))) extern void __wasm_import_filesystem_preopens_get_directories(uint8_t *); -// Imported Functions from `wasi:sockets/types@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:sockets/types@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[static]tcp-socket.create"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[static]tcp-socket.create"))) extern void __wasm_import_sockets_static_tcp_socket_create(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.bind"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.bind"))) extern void __wasm_import_sockets_method_tcp_socket_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][method]tcp-socket.connect"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][method]tcp-socket.connect"))) extern int32_t __wasm_import_sockets_method_tcp_socket_connect(uint8_t *, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.listen"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.listen"))) extern void __wasm_import_sockets_method_tcp_socket_listen(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][method]tcp-socket.send"))) -extern int32_t __wasm_import_sockets_method_tcp_socket_send(int32_t, int32_t, uint8_t *); +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.send"))) +extern int32_t __wasm_import_sockets_method_tcp_socket_send(int32_t, int32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.receive"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.receive"))) extern void __wasm_import_sockets_method_tcp_socket_receive(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.get-local-address"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.get-local-address"))) extern void __wasm_import_sockets_method_tcp_socket_get_local_address(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.get-remote-address"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.get-remote-address"))) extern void __wasm_import_sockets_method_tcp_socket_get_remote_address(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.get-is-listening"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.get-is-listening"))) extern int32_t __wasm_import_sockets_method_tcp_socket_get_is_listening(int32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.get-address-family"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.get-address-family"))) extern int32_t __wasm_import_sockets_method_tcp_socket_get_address_family(int32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.set-listen-backlog-size"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.set-listen-backlog-size"))) extern void __wasm_import_sockets_method_tcp_socket_set_listen_backlog_size(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.get-keep-alive-enabled"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.get-keep-alive-enabled"))) extern void __wasm_import_sockets_method_tcp_socket_get_keep_alive_enabled(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.set-keep-alive-enabled"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.set-keep-alive-enabled"))) extern void __wasm_import_sockets_method_tcp_socket_set_keep_alive_enabled(int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.get-keep-alive-idle-time"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.get-keep-alive-idle-time"))) extern void __wasm_import_sockets_method_tcp_socket_get_keep_alive_idle_time(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.set-keep-alive-idle-time"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.set-keep-alive-idle-time"))) extern void __wasm_import_sockets_method_tcp_socket_set_keep_alive_idle_time(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.get-keep-alive-interval"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.get-keep-alive-interval"))) extern void __wasm_import_sockets_method_tcp_socket_get_keep_alive_interval(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.set-keep-alive-interval"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.set-keep-alive-interval"))) extern void __wasm_import_sockets_method_tcp_socket_set_keep_alive_interval(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.get-keep-alive-count"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.get-keep-alive-count"))) extern void __wasm_import_sockets_method_tcp_socket_get_keep_alive_count(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.set-keep-alive-count"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.set-keep-alive-count"))) extern void __wasm_import_sockets_method_tcp_socket_set_keep_alive_count(int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.get-hop-limit"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.get-hop-limit"))) extern void __wasm_import_sockets_method_tcp_socket_get_hop_limit(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.set-hop-limit"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.set-hop-limit"))) extern void __wasm_import_sockets_method_tcp_socket_set_hop_limit(int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.get-receive-buffer-size"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.get-receive-buffer-size"))) extern void __wasm_import_sockets_method_tcp_socket_get_receive_buffer_size(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.set-receive-buffer-size"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.set-receive-buffer-size"))) extern void __wasm_import_sockets_method_tcp_socket_set_receive_buffer_size(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.get-send-buffer-size"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.get-send-buffer-size"))) extern void __wasm_import_sockets_method_tcp_socket_get_send_buffer_size(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]tcp-socket.set-send-buffer-size"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]tcp-socket.set-send-buffer-size"))) extern void __wasm_import_sockets_method_tcp_socket_set_send_buffer_size(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[static]udp-socket.create"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[static]udp-socket.create"))) extern void __wasm_import_sockets_static_udp_socket_create(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.bind"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.bind"))) extern void __wasm_import_sockets_method_udp_socket_bind(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.connect"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.connect"))) extern void __wasm_import_sockets_method_udp_socket_connect(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.disconnect"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.disconnect"))) extern void __wasm_import_sockets_method_udp_socket_disconnect(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][method]udp-socket.send"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][method]udp-socket.send"))) extern int32_t __wasm_import_sockets_method_udp_socket_send(uint8_t *, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][method]udp-socket.receive"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][method]udp-socket.receive"))) extern int32_t __wasm_import_sockets_method_udp_socket_receive(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.get-local-address"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.get-local-address"))) extern void __wasm_import_sockets_method_udp_socket_get_local_address(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.get-remote-address"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.get-remote-address"))) extern void __wasm_import_sockets_method_udp_socket_get_remote_address(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.get-address-family"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.get-address-family"))) extern int32_t __wasm_import_sockets_method_udp_socket_get_address_family(int32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.get-unicast-hop-limit"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.get-unicast-hop-limit"))) extern void __wasm_import_sockets_method_udp_socket_get_unicast_hop_limit(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.set-unicast-hop-limit"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.set-unicast-hop-limit"))) extern void __wasm_import_sockets_method_udp_socket_set_unicast_hop_limit(int32_t, int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.get-receive-buffer-size"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.get-receive-buffer-size"))) extern void __wasm_import_sockets_method_udp_socket_get_receive_buffer_size(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.set-receive-buffer-size"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.set-receive-buffer-size"))) extern void __wasm_import_sockets_method_udp_socket_set_receive_buffer_size(int32_t, int64_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.get-send-buffer-size"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.get-send-buffer-size"))) extern void __wasm_import_sockets_method_udp_socket_get_send_buffer_size(int32_t, uint8_t *); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[method]udp-socket.set-send-buffer-size"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[method]udp-socket.set-send-buffer-size"))) extern void __wasm_import_sockets_method_udp_socket_set_send_buffer_size(int32_t, int64_t, uint8_t *); -// Imported Functions from `wasi:sockets/ip-name-lookup@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:sockets/ip-name-lookup@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.3.0-rc-2026-01-06"), __import_name__("[async-lower]resolve-addresses"))) +__attribute__((__import_module__("wasi:sockets/ip-name-lookup@0.3.0-rc-2026-02-09"), __import_name__("[async-lower]resolve-addresses"))) extern int32_t __wasm_import_ip_name_lookup_resolve_addresses(uint8_t *, size_t, uint8_t *); -// Imported Functions from `wasi:random/random@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:random/random@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:random/random@0.3.0-rc-2026-01-06"), __import_name__("get-random-bytes"))) +__attribute__((__import_module__("wasi:random/random@0.3.0-rc-2026-02-09"), __import_name__("get-random-bytes"))) extern void __wasm_import_random_get_random_bytes(int64_t, uint8_t *); -__attribute__((__import_module__("wasi:random/random@0.3.0-rc-2026-01-06"), __import_name__("get-random-u64"))) +__attribute__((__import_module__("wasi:random/random@0.3.0-rc-2026-02-09"), __import_name__("get-random-u64"))) extern int64_t __wasm_import_random_get_random_u64(void); -// Imported Functions from `wasi:random/insecure@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:random/insecure@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:random/insecure@0.3.0-rc-2026-01-06"), __import_name__("get-insecure-random-bytes"))) +__attribute__((__import_module__("wasi:random/insecure@0.3.0-rc-2026-02-09"), __import_name__("get-insecure-random-bytes"))) extern void __wasm_import_random_insecure_get_insecure_random_bytes(int64_t, uint8_t *); -__attribute__((__import_module__("wasi:random/insecure@0.3.0-rc-2026-01-06"), __import_name__("get-insecure-random-u64"))) +__attribute__((__import_module__("wasi:random/insecure@0.3.0-rc-2026-02-09"), __import_name__("get-insecure-random-u64"))) extern int64_t __wasm_import_random_insecure_get_insecure_random_u64(void); -// Imported Functions from `wasi:random/insecure-seed@0.3.0-rc-2026-01-06` +// Imported Functions from `wasi:random/insecure-seed@0.3.0-rc-2026-02-09` -__attribute__((__import_module__("wasi:random/insecure-seed@0.3.0-rc-2026-01-06"), __import_name__("get-insecure-seed"))) +__attribute__((__import_module__("wasi:random/insecure-seed@0.3.0-rc-2026-02-09"), __import_name__("get-insecure-seed"))) extern void __wasm_import_random_insecure_seed_get_insecure_seed(uint8_t *); // Canonical ABI intrinsics @@ -358,19 +358,19 @@ void stdin_result_void_error_code_free(stdin_result_void_error_code_t *ptr) { } } -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[stream-new-0]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[stream-new-0]read-via-stream"))) extern uint64_t stdin_stream_u8__new(void); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][stream-read-0]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][stream-read-0]read-via-stream"))) extern uint32_t stdin_stream_u8__read(uint32_t, uint8_t*, size_t); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][stream-write-0]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][stream-write-0]read-via-stream"))) extern uint32_t stdin_stream_u8__write(uint32_t, const uint8_t*, size_t); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[stream-cancel-read-0]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[stream-cancel-read-0]read-via-stream"))) extern uint32_t stdin_stream_u8__cancel_read(uint32_t); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[stream-cancel-write-0]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[stream-cancel-write-0]read-via-stream"))) extern uint32_t stdin_stream_u8__cancel_write(uint32_t); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[stream-drop-readable-0]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[stream-drop-readable-0]read-via-stream"))) extern void stdin_stream_u8__drop_readable(uint32_t); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[stream-drop-writable-0]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[stream-drop-writable-0]read-via-stream"))) extern void stdin_stream_u8__drop_writable(uint32_t); stdin_stream_u8_t stdin_stream_u8_new(stdin_stream_u8_writer_t *writer) { @@ -404,19 +404,19 @@ void stdin_stream_u8_drop_writable(stdin_stream_u8_writer_t writer) { } -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[future-new-1]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[future-new-1]read-via-stream"))) extern uint64_t stdin_future_result_void_error_code__new(void); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][future-read-1]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][future-read-1]read-via-stream"))) extern uint32_t stdin_future_result_void_error_code__read(uint32_t, uint8_t*); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][future-write-1]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][future-write-1]read-via-stream"))) extern uint32_t stdin_future_result_void_error_code__write(uint32_t, const uint8_t*); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[future-cancel-read-1]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[future-cancel-read-1]read-via-stream"))) extern uint32_t stdin_future_result_void_error_code__cancel_read(uint32_t); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[future-cancel-write-1]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[future-cancel-write-1]read-via-stream"))) extern uint32_t stdin_future_result_void_error_code__cancel_write(uint32_t); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[future-drop-readable-1]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[future-drop-readable-1]read-via-stream"))) extern void stdin_future_result_void_error_code__drop_readable(uint32_t); -__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-01-06"), __import_name__("[future-drop-writable-1]read-via-stream"))) +__attribute__((__import_module__("wasi:cli/stdin@0.3.0-rc-2026-02-09"), __import_name__("[future-drop-writable-1]read-via-stream"))) extern void stdin_future_result_void_error_code__drop_writable(uint32_t); stdin_future_result_void_error_code_t stdin_future_result_void_error_code_new(stdin_future_result_void_error_code_writer_t *writer) { @@ -456,13 +456,105 @@ void stdout_result_void_error_code_free(stdout_result_void_error_code_t *ptr) { } } +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-02-09"), __import_name__("[future-new-1]write-via-stream"))) +extern uint64_t stdout_future_result_void_error_code__new(void); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][future-read-1]write-via-stream"))) +extern uint32_t stdout_future_result_void_error_code__read(uint32_t, uint8_t*); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][future-write-1]write-via-stream"))) +extern uint32_t stdout_future_result_void_error_code__write(uint32_t, const uint8_t*); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-02-09"), __import_name__("[future-cancel-read-1]write-via-stream"))) +extern uint32_t stdout_future_result_void_error_code__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-02-09"), __import_name__("[future-cancel-write-1]write-via-stream"))) +extern uint32_t stdout_future_result_void_error_code__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-02-09"), __import_name__("[future-drop-readable-1]write-via-stream"))) +extern void stdout_future_result_void_error_code__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:cli/stdout@0.3.0-rc-2026-02-09"), __import_name__("[future-drop-writable-1]write-via-stream"))) +extern void stdout_future_result_void_error_code__drop_writable(uint32_t); + +stdout_future_result_void_error_code_t stdout_future_result_void_error_code_new(stdout_future_result_void_error_code_writer_t *writer) { + uint64_t packed = stdout_future_result_void_error_code__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; +} + +wasip3_waitable_status_t stdout_future_result_void_error_code_read(stdout_future_result_void_error_code_t reader, stdout_result_void_error_code_t *buf) { + return stdout_future_result_void_error_code__read(reader, (uint8_t*) buf); +} + +wasip3_waitable_status_t stdout_future_result_void_error_code_write(stdout_future_result_void_error_code_writer_t writer, const stdout_result_void_error_code_t *buf) { + return stdout_future_result_void_error_code__write(writer, (const uint8_t*) buf); +} + +wasip3_waitable_status_t stdout_future_result_void_error_code_cancel_read(stdout_future_result_void_error_code_t reader){ + return stdout_future_result_void_error_code__cancel_read(reader); +} + +wasip3_waitable_status_t stdout_future_result_void_error_code_cancel_write(stdout_future_result_void_error_code_writer_t writer) { + return stdout_future_result_void_error_code__cancel_write(writer); +} + +void stdout_future_result_void_error_code_drop_readable(stdout_future_result_void_error_code_t reader){ + stdout_future_result_void_error_code__drop_readable(reader); +} + +void stdout_future_result_void_error_code_drop_writable(stdout_future_result_void_error_code_writer_t writer) { + stdout_future_result_void_error_code__drop_writable(writer); +} + + void stderr_result_void_error_code_free(stderr_result_void_error_code_t *ptr) { if (!ptr->is_err) { } else { } } -__attribute__((__import_module__("wasi:cli/terminal-input@0.3.0-rc-2026-01-06"), __import_name__("[resource-drop]terminal-input"))) +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-02-09"), __import_name__("[future-new-1]write-via-stream"))) +extern uint64_t stderr_future_result_void_error_code__new(void); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][future-read-1]write-via-stream"))) +extern uint32_t stderr_future_result_void_error_code__read(uint32_t, uint8_t*); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][future-write-1]write-via-stream"))) +extern uint32_t stderr_future_result_void_error_code__write(uint32_t, const uint8_t*); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-02-09"), __import_name__("[future-cancel-read-1]write-via-stream"))) +extern uint32_t stderr_future_result_void_error_code__cancel_read(uint32_t); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-02-09"), __import_name__("[future-cancel-write-1]write-via-stream"))) +extern uint32_t stderr_future_result_void_error_code__cancel_write(uint32_t); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-02-09"), __import_name__("[future-drop-readable-1]write-via-stream"))) +extern void stderr_future_result_void_error_code__drop_readable(uint32_t); +__attribute__((__import_module__("wasi:cli/stderr@0.3.0-rc-2026-02-09"), __import_name__("[future-drop-writable-1]write-via-stream"))) +extern void stderr_future_result_void_error_code__drop_writable(uint32_t); + +stderr_future_result_void_error_code_t stderr_future_result_void_error_code_new(stderr_future_result_void_error_code_writer_t *writer) { + uint64_t packed = stderr_future_result_void_error_code__new(); + *writer = (uint32_t) (packed >> 32); + return (uint32_t) packed; +} + +wasip3_waitable_status_t stderr_future_result_void_error_code_read(stderr_future_result_void_error_code_t reader, stderr_result_void_error_code_t *buf) { + return stderr_future_result_void_error_code__read(reader, (uint8_t*) buf); +} + +wasip3_waitable_status_t stderr_future_result_void_error_code_write(stderr_future_result_void_error_code_writer_t writer, const stderr_result_void_error_code_t *buf) { + return stderr_future_result_void_error_code__write(writer, (const uint8_t*) buf); +} + +wasip3_waitable_status_t stderr_future_result_void_error_code_cancel_read(stderr_future_result_void_error_code_t reader){ + return stderr_future_result_void_error_code__cancel_read(reader); +} + +wasip3_waitable_status_t stderr_future_result_void_error_code_cancel_write(stderr_future_result_void_error_code_writer_t writer) { + return stderr_future_result_void_error_code__cancel_write(writer); +} + +void stderr_future_result_void_error_code_drop_readable(stderr_future_result_void_error_code_t reader){ + stderr_future_result_void_error_code__drop_readable(reader); +} + +void stderr_future_result_void_error_code_drop_writable(stderr_future_result_void_error_code_writer_t writer) { + stderr_future_result_void_error_code__drop_writable(writer); +} + + +__attribute__((__import_module__("wasi:cli/terminal-input@0.3.0-rc-2026-02-09"), __import_name__("[resource-drop]terminal-input"))) extern void __wasm_import_terminal_input_terminal_input_drop(int32_t handle); void terminal_input_terminal_input_drop_own(terminal_input_own_terminal_input_t handle) { @@ -473,7 +565,7 @@ terminal_input_borrow_terminal_input_t terminal_input_borrow_terminal_input(term return (terminal_input_borrow_terminal_input_t) { arg.__handle }; } -__attribute__((__import_module__("wasi:cli/terminal-output@0.3.0-rc-2026-01-06"), __import_name__("[resource-drop]terminal-output"))) +__attribute__((__import_module__("wasi:cli/terminal-output@0.3.0-rc-2026-02-09"), __import_name__("[resource-drop]terminal-output"))) extern void __wasm_import_terminal_output_terminal_output_drop(int32_t handle); void terminal_output_terminal_output_drop_own(terminal_output_own_terminal_output_t handle) { @@ -522,7 +614,7 @@ void filesystem_directory_entry_free(filesystem_directory_entry_t *ptr) { wasip3_string_free(&ptr->name); } -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[resource-drop]descriptor"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[resource-drop]descriptor"))) extern void __wasm_import_filesystem_descriptor_drop(int32_t handle); void filesystem_descriptor_drop_own(filesystem_own_descriptor_t handle) { @@ -577,19 +669,19 @@ void filesystem_result_metadata_hash_value_error_code_free(filesystem_result_met } } -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-new-0][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-new-0][method]descriptor.read-via-stream"))) extern uint64_t filesystem_stream_u8__new(void); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][stream-read-0][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][stream-read-0][method]descriptor.read-via-stream"))) extern uint32_t filesystem_stream_u8__read(uint32_t, uint8_t*, size_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][stream-write-0][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][stream-write-0][method]descriptor.read-via-stream"))) extern uint32_t filesystem_stream_u8__write(uint32_t, const uint8_t*, size_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-cancel-read-0][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-cancel-read-0][method]descriptor.read-via-stream"))) extern uint32_t filesystem_stream_u8__cancel_read(uint32_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-cancel-write-0][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-cancel-write-0][method]descriptor.read-via-stream"))) extern uint32_t filesystem_stream_u8__cancel_write(uint32_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-drop-readable-0][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-drop-readable-0][method]descriptor.read-via-stream"))) extern void filesystem_stream_u8__drop_readable(uint32_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-drop-writable-0][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-drop-writable-0][method]descriptor.read-via-stream"))) extern void filesystem_stream_u8__drop_writable(uint32_t); filesystem_stream_u8_t filesystem_stream_u8_new(filesystem_stream_u8_writer_t *writer) { @@ -623,19 +715,19 @@ void filesystem_stream_u8_drop_writable(filesystem_stream_u8_writer_t writer) { } -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[future-new-1][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[future-new-1][method]descriptor.read-via-stream"))) extern uint64_t filesystem_future_result_void_error_code__new(void); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][future-read-1][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][future-read-1][method]descriptor.read-via-stream"))) extern uint32_t filesystem_future_result_void_error_code__read(uint32_t, uint8_t*); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][future-write-1][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][future-write-1][method]descriptor.read-via-stream"))) extern uint32_t filesystem_future_result_void_error_code__write(uint32_t, const uint8_t*); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[future-cancel-read-1][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[future-cancel-read-1][method]descriptor.read-via-stream"))) extern uint32_t filesystem_future_result_void_error_code__cancel_read(uint32_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[future-cancel-write-1][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[future-cancel-write-1][method]descriptor.read-via-stream"))) extern uint32_t filesystem_future_result_void_error_code__cancel_write(uint32_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[future-drop-readable-1][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[future-drop-readable-1][method]descriptor.read-via-stream"))) extern void filesystem_future_result_void_error_code__drop_readable(uint32_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[future-drop-writable-1][method]descriptor.read-via-stream"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[future-drop-writable-1][method]descriptor.read-via-stream"))) extern void filesystem_future_result_void_error_code__drop_writable(uint32_t); filesystem_future_result_void_error_code_t filesystem_future_result_void_error_code_new(filesystem_future_result_void_error_code_writer_t *writer) { @@ -669,19 +761,19 @@ void filesystem_future_result_void_error_code_drop_writable(filesystem_future_re } -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-new-0][method]descriptor.read-directory"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-new-0][method]descriptor.read-directory"))) extern uint64_t filesystem_stream_directory_entry__new(void); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][stream-read-0][method]descriptor.read-directory"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][stream-read-0][method]descriptor.read-directory"))) extern uint32_t filesystem_stream_directory_entry__read(uint32_t, uint8_t*, size_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][stream-write-0][method]descriptor.read-directory"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][stream-write-0][method]descriptor.read-directory"))) extern uint32_t filesystem_stream_directory_entry__write(uint32_t, const uint8_t*, size_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-cancel-read-0][method]descriptor.read-directory"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-cancel-read-0][method]descriptor.read-directory"))) extern uint32_t filesystem_stream_directory_entry__cancel_read(uint32_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-cancel-write-0][method]descriptor.read-directory"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-cancel-write-0][method]descriptor.read-directory"))) extern uint32_t filesystem_stream_directory_entry__cancel_write(uint32_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-drop-readable-0][method]descriptor.read-directory"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-drop-readable-0][method]descriptor.read-directory"))) extern void filesystem_stream_directory_entry__drop_readable(uint32_t); -__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-drop-writable-0][method]descriptor.read-directory"))) +__attribute__((__import_module__("wasi:filesystem/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-drop-writable-0][method]descriptor.read-directory"))) extern void filesystem_stream_directory_entry__drop_writable(uint32_t); filesystem_stream_directory_entry_t filesystem_stream_directory_entry_new(filesystem_stream_directory_entry_writer_t *writer) { @@ -752,7 +844,7 @@ void sockets_ip_socket_address_free(sockets_ip_socket_address_t *ptr) { } } -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[resource-drop]tcp-socket"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[resource-drop]tcp-socket"))) extern void __wasm_import_sockets_tcp_socket_drop(int32_t handle); void sockets_tcp_socket_drop_own(sockets_own_tcp_socket_t handle) { @@ -763,7 +855,7 @@ sockets_borrow_tcp_socket_t sockets_borrow_tcp_socket(sockets_own_tcp_socket_t a return (sockets_borrow_tcp_socket_t) { arg.__handle }; } -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[resource-drop]udp-socket"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[resource-drop]udp-socket"))) extern void __wasm_import_sockets_udp_socket_drop(int32_t handle); void sockets_udp_socket_drop_own(sockets_own_udp_socket_t handle) { @@ -863,19 +955,19 @@ void sockets_result_tuple2_list_u8_ip_socket_address_error_code_free(sockets_res } } -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-new-0][method]tcp-socket.listen"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-new-0][method]tcp-socket.listen"))) extern uint64_t sockets_stream_own_tcp_socket__new(void); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][stream-read-0][method]tcp-socket.listen"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][stream-read-0][method]tcp-socket.listen"))) extern uint32_t sockets_stream_own_tcp_socket__read(uint32_t, uint8_t*, size_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][stream-write-0][method]tcp-socket.listen"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][stream-write-0][method]tcp-socket.listen"))) extern uint32_t sockets_stream_own_tcp_socket__write(uint32_t, const uint8_t*, size_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-cancel-read-0][method]tcp-socket.listen"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-cancel-read-0][method]tcp-socket.listen"))) extern uint32_t sockets_stream_own_tcp_socket__cancel_read(uint32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-cancel-write-0][method]tcp-socket.listen"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-cancel-write-0][method]tcp-socket.listen"))) extern uint32_t sockets_stream_own_tcp_socket__cancel_write(uint32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-drop-readable-0][method]tcp-socket.listen"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-drop-readable-0][method]tcp-socket.listen"))) extern void sockets_stream_own_tcp_socket__drop_readable(uint32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-drop-writable-0][method]tcp-socket.listen"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-drop-writable-0][method]tcp-socket.listen"))) extern void sockets_stream_own_tcp_socket__drop_writable(uint32_t); sockets_stream_own_tcp_socket_t sockets_stream_own_tcp_socket_new(sockets_stream_own_tcp_socket_writer_t *writer) { @@ -909,19 +1001,19 @@ void sockets_stream_own_tcp_socket_drop_writable(sockets_stream_own_tcp_socket_w } -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-new-0][method]tcp-socket.send"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-new-0][method]tcp-socket.send"))) extern uint64_t sockets_stream_u8__new(void); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][stream-read-0][method]tcp-socket.send"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][stream-read-0][method]tcp-socket.send"))) extern uint32_t sockets_stream_u8__read(uint32_t, uint8_t*, size_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][stream-write-0][method]tcp-socket.send"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][stream-write-0][method]tcp-socket.send"))) extern uint32_t sockets_stream_u8__write(uint32_t, const uint8_t*, size_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-cancel-read-0][method]tcp-socket.send"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-cancel-read-0][method]tcp-socket.send"))) extern uint32_t sockets_stream_u8__cancel_read(uint32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-cancel-write-0][method]tcp-socket.send"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-cancel-write-0][method]tcp-socket.send"))) extern uint32_t sockets_stream_u8__cancel_write(uint32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-drop-readable-0][method]tcp-socket.send"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-drop-readable-0][method]tcp-socket.send"))) extern void sockets_stream_u8__drop_readable(uint32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[stream-drop-writable-0][method]tcp-socket.send"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[stream-drop-writable-0][method]tcp-socket.send"))) extern void sockets_stream_u8__drop_writable(uint32_t); sockets_stream_u8_t sockets_stream_u8_new(sockets_stream_u8_writer_t *writer) { @@ -955,19 +1047,19 @@ void sockets_stream_u8_drop_writable(sockets_stream_u8_writer_t writer) { } -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[future-new-1][method]tcp-socket.receive"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[future-new-1][method]tcp-socket.send"))) extern uint64_t sockets_future_result_void_error_code__new(void); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][future-read-1][method]tcp-socket.receive"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][future-read-1][method]tcp-socket.send"))) extern uint32_t sockets_future_result_void_error_code__read(uint32_t, uint8_t*); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[async-lower][future-write-1][method]tcp-socket.receive"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[async-lower][future-write-1][method]tcp-socket.send"))) extern uint32_t sockets_future_result_void_error_code__write(uint32_t, const uint8_t*); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[future-cancel-read-1][method]tcp-socket.receive"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[future-cancel-read-1][method]tcp-socket.send"))) extern uint32_t sockets_future_result_void_error_code__cancel_read(uint32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[future-cancel-write-1][method]tcp-socket.receive"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[future-cancel-write-1][method]tcp-socket.send"))) extern uint32_t sockets_future_result_void_error_code__cancel_write(uint32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[future-drop-readable-1][method]tcp-socket.receive"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[future-drop-readable-1][method]tcp-socket.send"))) extern void sockets_future_result_void_error_code__drop_readable(uint32_t); -__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-01-06"), __import_name__("[future-drop-writable-1][method]tcp-socket.receive"))) +__attribute__((__import_module__("wasi:sockets/types@0.3.0-rc-2026-02-09"), __import_name__("[future-drop-writable-1][method]tcp-socket.send"))) extern void sockets_future_result_void_error_code__drop_writable(uint32_t); sockets_future_result_void_error_code_t sockets_future_result_void_error_code_new(sockets_future_result_void_error_code_writer_t *writer) { @@ -1302,12 +1394,14 @@ void stdin_read_via_stream(stdin_tuple2_stream_u8_future_result_void_error_code_ }; } -wasip3_subtask_status_t stdout_write_via_stream(stdin_stream_u8_t data, stdout_result_void_error_code_t *result) { - return __wasm_import_stdout_write_via_stream(((int32_t) data), (uint8_t*) result); +stdout_future_result_void_error_code_t stdout_write_via_stream(stdin_stream_u8_t data) { + int32_t ret = __wasm_import_stdout_write_via_stream(((int32_t) data)); + return ((uint32_t) ret); } -wasip3_subtask_status_t stderr_write_via_stream(stdin_stream_u8_t data, stderr_result_void_error_code_t *result) { - return __wasm_import_stderr_write_via_stream(((int32_t) data), (uint8_t*) result); +stderr_future_result_void_error_code_t stderr_write_via_stream(stdin_stream_u8_t data) { + int32_t ret = __wasm_import_stderr_write_via_stream(((int32_t) data)); + return ((uint32_t) ret); } bool terminal_stdin_get_terminal_stdin(terminal_stdin_own_terminal_input_t *ret) { @@ -1418,12 +1512,14 @@ void filesystem_method_descriptor_read_via_stream(filesystem_borrow_descriptor_t }; } -wasip3_subtask_status_t filesystem_method_descriptor_write_via_stream(filesystem_borrow_descriptor_t self, filesystem_stream_u8_t data, filesystem_filesize_t offset, filesystem_result_void_error_code_t *result) { - return __wasm_import_filesystem_method_descriptor_write_via_stream((self).__handle, ((int32_t) data), (int64_t) (offset), (uint8_t*) result); +filesystem_future_result_void_error_code_t filesystem_method_descriptor_write_via_stream(filesystem_borrow_descriptor_t self, filesystem_stream_u8_t data, filesystem_filesize_t offset) { + int32_t ret = __wasm_import_filesystem_method_descriptor_write_via_stream((self).__handle, ((int32_t) data), (int64_t) (offset)); + return ((uint32_t) ret); } -wasip3_subtask_status_t filesystem_method_descriptor_append_via_stream(filesystem_borrow_descriptor_t self, filesystem_stream_u8_t data, filesystem_result_void_error_code_t *result) { - return __wasm_import_filesystem_method_descriptor_append_via_stream((self).__handle, ((int32_t) data), (uint8_t*) result); +filesystem_future_result_void_error_code_t filesystem_method_descriptor_append_via_stream(filesystem_borrow_descriptor_t self, filesystem_stream_u8_t data) { + int32_t ret = __wasm_import_filesystem_method_descriptor_append_via_stream((self).__handle, ((int32_t) data)); + return ((uint32_t) ret); } bool filesystem_method_descriptor_advise(filesystem_borrow_descriptor_t self, filesystem_filesize_t offset, filesystem_filesize_t length, filesystem_advice_t advice, filesystem_error_code_t *err) { @@ -2279,8 +2375,9 @@ bool sockets_method_tcp_socket_listen(sockets_borrow_tcp_socket_t self, sockets_ } } -wasip3_subtask_status_t sockets_method_tcp_socket_send(sockets_borrow_tcp_socket_t self, sockets_stream_u8_t data, sockets_result_void_error_code_t *result) { - return __wasm_import_sockets_method_tcp_socket_send((self).__handle, ((int32_t) data), (uint8_t*) result); +sockets_future_result_void_error_code_t sockets_method_tcp_socket_send(sockets_borrow_tcp_socket_t self, sockets_stream_u8_t data) { + int32_t ret = __wasm_import_sockets_method_tcp_socket_send((self).__handle, ((int32_t) data)); + return ((uint32_t) ret); } void sockets_method_tcp_socket_receive(sockets_borrow_tcp_socket_t self, sockets_tuple2_stream_u8_future_result_void_error_code_t *ret) { diff --git a/libc-bottom-half/sources/wasip3_component_type.o b/libc-bottom-half/sources/wasip3_component_type.o index e92156ffbbf4554b4083803e095e23a5cdefae0b..263393eb8c9060c6d4bff09b616dc7fae24530c4 100644 GIT binary patch delta 400 zcmZ2%zuJC+B;(bIQf`bpCnk2V80i{VPJC+*rY9RPhC>+LjHR3)8CDiXC-%wn8I|Q7 z7+F#hOA?tFSXdYY%8N2fQgzER6LpJAic%AE8CfU0GburIuoA0d1CtWOvTICE5QYr1 z3xtuvTnk}5Wp0EpvRHB2ydRxUB}4iuvv~*hy`M%iC_i9%ngEy%p$3b z5{yu-;$U;-faX0Ek!Dk1%x995-^?aDj~$|Xg$y$z#Dw*-DG-LZ9K@)}ljQ;-A}{1r JAq+wJNdQ*+LjHR3)8CDiXC$`D+8Rg}j z8Cg;iOA?tFm{}ME%8N2fQgzER6LpJAic%AE8CfQKGburIuoA0d2a^)SvU^NU5QYk~ z3xtuwTnk~mWp0Epidb?XjK?gN5QYNlE(qfuYaf`gxq$5g3#0R7M{Y3|ITi-x$p?9b zC+Bes3pg{e6sP8-$$&i|%OJOTBKH(VM(53Hyh1DxBWwgKAV%yERAd&0suu^Vmt&A% zVGy6ZP(ql$I5jVYQJyiCQGzj_NlsxipXfYxh_($f%#09|w#%kK81ixuBPY+63xtS# MkW+;)B;_Xo0Ag`s-~a#s diff --git a/libc-bottom-half/sources/wasip3_stdio.c b/libc-bottom-half/sources/wasip3_stdio.c index 370704420..ee6df2dd2 100644 --- a/libc-bottom-half/sources/wasip3_stdio.c +++ b/libc-bottom-half/sources/wasip3_stdio.c @@ -20,16 +20,16 @@ typedef struct { } stdin3_t; typedef struct { - // contains stream, result storage and result subtask - wasip3_subtask_t subtask; + // contains stream, result storage and result future + stdout_future_result_void_error_code_t future; stdin_stream_u8_writer_t output; bool output_done; stdout_result_void_error_code_t pending_result; // tristate: zero=unknown, valid handle=yes, -1=no terminal_output_own_terminal_output_t terminal_out; // stream creation function (delayed) - wasip3_subtask_status_t (*stream_func)( - stdin_stream_u8_t data, stdout_result_void_error_code_t *result); + stdout_future_result_void_error_code_t (*stream_func)( + stdin_stream_u8_t data); // function to determine whether this is a terminal (delayed) bool (*terminal_func)(terminal_stdout_own_terminal_output_t *ret); } stdout3_t; @@ -68,16 +68,18 @@ static void stdout3_free(void *data) { terminal_output_terminal_output_drop_own(stdio->terminal_out); if (stdio->output) stdin_stream_u8_drop_writable(stdio->output); - if (stdio->subtask) - __wasilibc_subtask_block_on_and_drop(stdio->subtask); + if (stdio->future) { + stdout_future_result_void_error_code_drop_readable(stdio->future); + stdio->future = 0; + } free(stdio); } static int stdout3_write_eof(void *data) { stdout3_t *stdio = (stdout3_t *)data; - if (stdio->subtask != 0) { - __wasilibc_subtask_block_on_and_drop(stdio->subtask); - stdio->subtask = 0; + if (stdio->future != 0) { + stdout_future_result_void_error_code_drop_readable(stdio->future); + stdio->future = 0; } if (stdio->pending_result.is_err) { translate_error(stdio->pending_result.val.err); @@ -89,12 +91,9 @@ static int stdout3_write_eof(void *data) { static int stdout3_write(void *data, wasi_write_t *out) { stdout3_t *stdio = (stdout3_t *)data; if (!stdio->output) { - assert(!stdio->subtask); + assert(!stdio->future); stdin_stream_u8_t read_side = stdin_stream_u8_new(&stdio->output); - wasip3_subtask_status_t status = - (*stdio->stream_func)(read_side, &stdio->pending_result); - if (WASIP3_SUBTASK_STATE(status) != WASIP3_SUBTASK_RETURNED) - stdio->subtask = WASIP3_SUBTASK_HANDLE(status); + stdio->future = (*stdio->stream_func)(read_side); } out->offset = NULL; out->blocking = true; @@ -202,8 +201,8 @@ static int stdio_add_input() { } static int stdio3_add_output( - wasip3_subtask_status_t (*stream_func)( - stdin_stream_u8_t data, stdout_result_void_error_code_t *result), + stdout_future_result_void_error_code_t (*stream_func)( + stdin_stream_u8_t data), bool (*terminal_func)(terminal_stdout_own_terminal_output_t *ret)) { stdout3_t *stdio = calloc(1, sizeof(stdout3_t)); if (!stdio) { @@ -227,9 +226,8 @@ int __wasilibc_init_stdio() { return -1; // assuming that stdout and stderr functions are compatible if (stdio3_add_output( - (wasip3_subtask_status_t(*)( - stdin_stream_u8_t, - stdout_result_void_error_code_t *))stderr_write_via_stream, + (stdout_future_result_void_error_code_t(*)( + stdin_stream_u8_t))stderr_write_via_stream, terminal_stderr_get_terminal_stderr) < 0) return -1; return 0; diff --git a/wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-01-06/package.wit b/wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit similarity index 60% rename from wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-01-06/package.wit rename to wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit index 0f987bf38..4f8bbf8a2 100644 --- a/wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-01-06/package.wit +++ b/wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit @@ -1,6 +1,6 @@ -package wasi:cli@0.3.0-rc-2026-01-06; +package wasi:cli@0.3.0-rc-2026-02-09; -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface environment { /// Get the POSIX-style environment variables. /// @@ -10,23 +10,23 @@ interface environment { /// Morally, these are a value import, but until value imports are available /// in the component model, this import function should return the same /// values each time it is called. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-environment: func() -> list>; /// Get the POSIX-style arguments to the program. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-arguments: func() -> list; /// Return a path that programs should use as their initial current working /// directory, interpreting `.` as shorthand for this. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-initial-cwd: func() -> option; } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface exit { /// Exit the current instance and any linked instances. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) exit: func(status: result); /// Exit the current instance and any linked instances, reporting the @@ -41,16 +41,16 @@ interface exit { exit-with-code: func(status-code: u8); } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface run { /// Run the program. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) run: async func() -> result; } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface types { - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) enum error-code { /// Input/output error io, @@ -61,7 +61,7 @@ interface types { } } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface stdin { use types.{error-code}; @@ -78,11 +78,11 @@ interface stdin { /// /// Multiple streams may be active at the same time. The behavior of concurrent /// reads is implementation-specific. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) read-via-stream: func() -> tuple, future>>; } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface stdout { use types.{error-code}; @@ -94,11 +94,11 @@ interface stdout { /// /// Otherwise if there is an error the readable end of the stream will be /// dropped and this function will return an error-code. - @since(version = 0.3.0-rc-2026-01-06) - write-via-stream: async func(data: stream) -> result<_, error-code>; + @since(version = 0.3.0-rc-2026-02-09) + write-via-stream: func(data: stream) -> future>; } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface stderr { use types.{error-code}; @@ -110,8 +110,8 @@ interface stderr { /// /// Otherwise if there is an error the readable end of the stream will be /// dropped and this function will return an error-code. - @since(version = 0.3.0-rc-2026-01-06) - write-via-stream: async func(data: stream) -> result<_, error-code>; + @since(version = 0.3.0-rc-2026-02-09) + write-via-stream: func(data: stream) -> future>; } /// Terminal input. @@ -119,10 +119,10 @@ interface stderr { /// In the future, this may include functions for disabling echoing, /// disabling input buffering so that keyboard events are sent through /// immediately, querying supported features, and so on. -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface terminal-input { /// The input side of a terminal. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) resource terminal-input; } @@ -131,126 +131,126 @@ interface terminal-input { /// In the future, this may include functions for querying the terminal /// size, being notified of terminal size changes, querying supported /// features, and so on. -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface terminal-output { /// The output side of a terminal. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) resource terminal-output; } /// An interface providing an optional `terminal-input` for stdin as a /// link-time authority. -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface terminal-stdin { - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) use terminal-input.{terminal-input}; /// If stdin is connected to a terminal, return a `terminal-input` handle /// allowing further interaction with it. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-terminal-stdin: func() -> option; } /// An interface providing an optional `terminal-output` for stdout as a /// link-time authority. -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface terminal-stdout { - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) use terminal-output.{terminal-output}; /// If stdout is connected to a terminal, return a `terminal-output` handle /// allowing further interaction with it. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-terminal-stdout: func() -> option; } /// An interface providing an optional `terminal-output` for stderr as a /// link-time authority. -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface terminal-stderr { - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) use terminal-output.{terminal-output}; /// If stderr is connected to a terminal, return a `terminal-output` handle /// allowing further interaction with it. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-terminal-stderr: func() -> option; } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) world imports { - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import environment; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import exit; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import types; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import stdin; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import stdout; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import stderr; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import terminal-input; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import terminal-output; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import terminal-stdin; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import terminal-stdout; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import terminal-stderr; - import wasi:clocks/types@0.3.0-rc-2026-01-06; - import wasi:clocks/monotonic-clock@0.3.0-rc-2026-01-06; - import wasi:clocks/system-clock@0.3.0-rc-2026-01-06; + import wasi:clocks/types@0.3.0-rc-2026-02-09; + import wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09; + import wasi:clocks/system-clock@0.3.0-rc-2026-02-09; @unstable(feature = clocks-timezone) - import wasi:clocks/timezone@0.3.0-rc-2026-01-06; - import wasi:filesystem/types@0.3.0-rc-2026-01-06; - import wasi:filesystem/preopens@0.3.0-rc-2026-01-06; - import wasi:sockets/types@0.3.0-rc-2026-01-06; - import wasi:sockets/ip-name-lookup@0.3.0-rc-2026-01-06; - import wasi:random/random@0.3.0-rc-2026-01-06; - import wasi:random/insecure@0.3.0-rc-2026-01-06; - import wasi:random/insecure-seed@0.3.0-rc-2026-01-06; + import wasi:clocks/timezone@0.3.0-rc-2026-02-09; + import wasi:filesystem/types@0.3.0-rc-2026-02-09; + import wasi:filesystem/preopens@0.3.0-rc-2026-02-09; + import wasi:sockets/types@0.3.0-rc-2026-02-09; + import wasi:sockets/ip-name-lookup@0.3.0-rc-2026-02-09; + import wasi:random/random@0.3.0-rc-2026-02-09; + import wasi:random/insecure@0.3.0-rc-2026-02-09; + import wasi:random/insecure-seed@0.3.0-rc-2026-02-09; } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) world command { - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import environment; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import exit; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import types; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import stdin; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import stdout; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import stderr; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import terminal-input; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import terminal-output; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import terminal-stdin; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import terminal-stdout; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import terminal-stderr; - import wasi:clocks/types@0.3.0-rc-2026-01-06; - import wasi:clocks/monotonic-clock@0.3.0-rc-2026-01-06; - import wasi:clocks/system-clock@0.3.0-rc-2026-01-06; + import wasi:clocks/types@0.3.0-rc-2026-02-09; + import wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09; + import wasi:clocks/system-clock@0.3.0-rc-2026-02-09; @unstable(feature = clocks-timezone) - import wasi:clocks/timezone@0.3.0-rc-2026-01-06; - import wasi:filesystem/types@0.3.0-rc-2026-01-06; - import wasi:filesystem/preopens@0.3.0-rc-2026-01-06; - import wasi:sockets/types@0.3.0-rc-2026-01-06; - import wasi:sockets/ip-name-lookup@0.3.0-rc-2026-01-06; - import wasi:random/random@0.3.0-rc-2026-01-06; - import wasi:random/insecure@0.3.0-rc-2026-01-06; - import wasi:random/insecure-seed@0.3.0-rc-2026-01-06; + import wasi:clocks/timezone@0.3.0-rc-2026-02-09; + import wasi:filesystem/types@0.3.0-rc-2026-02-09; + import wasi:filesystem/preopens@0.3.0-rc-2026-02-09; + import wasi:sockets/types@0.3.0-rc-2026-02-09; + import wasi:sockets/ip-name-lookup@0.3.0-rc-2026-02-09; + import wasi:random/random@0.3.0-rc-2026-02-09; + import wasi:random/insecure@0.3.0-rc-2026-02-09; + import wasi:random/insecure-seed@0.3.0-rc-2026-02-09; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) export run; } diff --git a/wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-01-06/package.wit b/wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit similarity index 89% rename from wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-01-06/package.wit rename to wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit index fc59f5a21..71986bab2 100644 --- a/wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-01-06/package.wit +++ b/wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit @@ -1,10 +1,10 @@ -package wasi:clocks@0.3.0-rc-2026-01-06; +package wasi:clocks@0.3.0-rc-2026-02-09; /// This interface common types used throughout wasi:clocks. -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface types { /// A duration of time, in nanoseconds. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) type duration = u64; } @@ -16,14 +16,14 @@ interface types { /// /// A monotonic clock is a clock which has an unspecified initial value, and /// successive reads of the clock will produce non-decreasing values. -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface monotonic-clock { use types.{duration}; /// A mark on a monotonic clock is a number of nanoseconds since an /// unspecified initial value, and can only be compared to instances from /// the same monotonic-clock. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) type mark = u64; /// Read the current value of the clock. @@ -35,20 +35,20 @@ interface monotonic-clock { /// the value of the clock in a `mark`. Consequently, implementations /// should ensure that the starting time is low enough to avoid the /// possibility of overflow in practice. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) now: func() -> mark; /// Query the resolution of the clock. Returns the duration of time /// corresponding to a clock tick. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-resolution: func() -> duration; /// Wait until the specified mark has occurred. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) wait-until: async func(when: mark); /// Wait for the specified duration to elapse. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) wait-for: async func(how-long: duration); } @@ -62,7 +62,7 @@ interface monotonic-clock { /// monotonic, making it unsuitable for measuring elapsed time. /// /// It is intended for reporting the current date and time for humans. -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface system-clock { use types.{duration}; @@ -82,7 +82,7 @@ interface system-clock { /// /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) record instant { seconds: s64, nanoseconds: u32, @@ -94,12 +94,12 @@ interface system-clock { /// will not necessarily produce a sequence of non-decreasing values. /// /// The nanoseconds field of the output is always less than 1000000000. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) now: func() -> instant; /// Query the resolution of the clock. Returns the smallest duration of time /// that the implementation permits distinguishing. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-resolution: func() -> duration; } @@ -148,13 +148,13 @@ interface timezone { to-debug-string: func() -> string; } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) world imports { - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import types; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import monotonic-clock; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import system-clock; @unstable(feature = clocks-timezone) import timezone; diff --git a/wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-01-06/package.wit b/wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit similarity index 87% rename from wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-01-06/package.wit rename to wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit index 0ac149cb7..8fb83041a 100644 --- a/wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-01-06/package.wit +++ b/wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit @@ -1,12 +1,9 @@ -package wasi:filesystem@0.3.0-rc-2026-01-06; +package wasi:filesystem@0.3.0-rc-2026-02-09; /// WASI filesystem is a filesystem API primarily intended to let users run WASI /// programs that access their files on their existing filesystems, without /// significant overhead. /// -/// It is intended to be roughly portable between Unix-family platforms and -/// Windows, though it does not hide many of the major differences. -/// /// Paths are passed as interface-type `string`s, meaning they must consist of /// a sequence of Unicode Scalar Values (USVs). Some filesystems may contain /// paths which are not accessible by this API. @@ -23,20 +20,34 @@ package wasi:filesystem@0.3.0-rc-2026-01-06; /// For more information about WASI path resolution and sandboxing, see /// [WASI filesystem path resolution]. /// +/// Though this package presents a portable interface modelled on POSIX, it +/// prioritizes compatibility over portability: allowing users to access their +/// files on their machine is more important than exposing a single semantics +/// across all platforms. Notably, depending on the underlying operating system +/// and file system: +/// * Paths may be case-folded or not. +/// * Deleting (unlinking) a file may fail if there are other file descriptors +/// open. +/// * Durability and atomicity of changes to underlying files when there are +/// concurrent writers. +/// +/// Users that need well-defined, portable semantics should use a key-value +/// store or a database instead. +/// /// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface types { - @since(version = 0.3.0-rc-2026-01-06) - use wasi:clocks/system-clock@0.3.0-rc-2026-01-06.{instant}; + @since(version = 0.3.0-rc-2026-02-09) + use wasi:clocks/system-clock@0.3.0-rc-2026-02-09.{instant}; /// File size or length of a region within a file. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) type filesize = u64; /// The type of a filesystem object referenced by a descriptor. /// /// Note: This was called `filetype` in earlier versions of WASI. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) enum descriptor-type { /// The type of the descriptor or file is unknown or is different from /// any of the other types specified. @@ -60,7 +71,7 @@ interface types { /// Descriptor flags. /// /// Note: This was called `fdflags` in earlier versions of WASI. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) flags descriptor-flags { /// Read mode: Data can be read. read, @@ -102,7 +113,7 @@ interface types { } /// Flags determining the method of how paths are resolved. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) flags path-flags { /// As long as the resolved path corresponds to a symbolic link, it is /// expanded. @@ -110,7 +121,7 @@ interface types { } /// Open flags used by `open-at`. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) flags open-flags { /// Create file if it does not exist, similar to `O_CREAT` in POSIX. create, @@ -123,13 +134,13 @@ interface types { } /// Number of hard links to an inode. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) type link-count = u64; /// File attributes. /// /// Note: This was called `filestat` in earlier versions of WASI. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) record descriptor-stat { /// File type. %type: descriptor-type, @@ -156,7 +167,7 @@ interface types { } /// When setting a timestamp, this gives the value to set it to. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) variant new-timestamp { /// Leave the timestamp set to its previous value. no-change, @@ -168,6 +179,7 @@ interface types { } /// A directory entry. + @since(version = 0.3.0-rc-2026-02-09) record directory-entry { /// The type of the file referred to by this directory entry. %type: descriptor-type, @@ -179,6 +191,7 @@ interface types { /// Not all of these error codes are returned by the functions provided by this /// API; some are used in higher-level library layers, and others are provided /// merely for alignment with POSIX. + @since(version = 0.3.0-rc-2026-02-09) enum error-code { /// Permission denied, similar to `EACCES` in POSIX. access, @@ -255,7 +268,7 @@ interface types { } /// File or memory access pattern advisory information. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) enum advice { /// The application has no advice to give on its behavior with respect /// to the specified data. @@ -279,7 +292,7 @@ interface types { /// A 128-bit hash value, split into parts because wasm doesn't have a /// 128-bit integer type. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) record metadata-hash-value { /// 64 bits of a 128-bit hash value. lower: u64, @@ -290,7 +303,7 @@ interface types { /// A descriptor is a reference to a filesystem object, which may be a file, /// directory, named pipe, special file, or other object on which filesystem /// calls may be made. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) resource descriptor { /// Return a stream for reading from a file. /// @@ -308,7 +321,7 @@ interface types { /// resolves to `err` with an `error-code`. /// /// Note: This is similar to `pread` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) read-via-stream: func(offset: filesize) -> tuple, future>>; /// Return a stream for writing to a file, if available. /// @@ -322,8 +335,8 @@ interface types { /// written or an error is encountered. /// /// Note: This is similar to `pwrite` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) - write-via-stream: async func(data: stream, offset: filesize) -> result<_, error-code>; + @since(version = 0.3.0-rc-2026-02-09) + write-via-stream: func(data: stream, offset: filesize) -> future>; /// Return a stream for appending to a file, if available. /// /// May fail with an error-code describing why the file cannot be appended. @@ -332,12 +345,12 @@ interface types { /// written or an error is encountered. /// /// Note: This is similar to `write` with `O_APPEND` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) - append-via-stream: async func(data: stream) -> result<_, error-code>; + @since(version = 0.3.0-rc-2026-02-09) + append-via-stream: func(data: stream) -> future>; /// Provide file advisory information on a descriptor. /// /// This is similar to `posix_fadvise` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) advise: async func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>; /// Synchronize the data of a file to disk. /// @@ -345,7 +358,7 @@ interface types { /// opened for writing. /// /// Note: This is similar to `fdatasync` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) sync-data: async func() -> result<_, error-code>; /// Get flags associated with a descriptor. /// @@ -353,7 +366,7 @@ interface types { /// /// Note: This returns the value that was the `fs_flags` value returned /// from `fdstat_get` in earlier versions of WASI. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-flags: async func() -> result; /// Get the dynamic type of a descriptor. /// @@ -365,20 +378,20 @@ interface types { /// /// Note: This returns the value that was the `fs_filetype` value returned /// from `fdstat_get` in earlier versions of WASI. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-type: async func() -> result; /// Adjust the size of an open file. If this increases the file's size, the /// extra bytes are filled with zeros. /// /// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-size: async func(size: filesize) -> result<_, error-code>; /// Adjust the timestamps of an open file or directory. /// /// Note: This is similar to `futimens` in POSIX. /// /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-times: async func(data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; /// Read directory entries from a directory. /// @@ -392,20 +405,20 @@ interface types { /// /// This function returns a future, which will resolve to an error code if /// reading full contents of the directory fails. - @since(version = 0.3.0-rc-2026-01-06) - read-directory: async func() -> tuple, future>>; + @since(version = 0.3.0-rc-2026-02-09) + read-directory: func() -> tuple, future>>; /// Synchronize the data and metadata of a file to disk. /// /// This function succeeds with no effect if the file descriptor is not /// opened for writing. /// /// Note: This is similar to `fsync` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) sync: async func() -> result<_, error-code>; /// Create a directory. /// /// Note: This is similar to `mkdirat` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) create-directory-at: async func(path: string) -> result<_, error-code>; /// Return the attributes of an open file or directory. /// @@ -416,7 +429,7 @@ interface types { /// modified, use `metadata-hash`. /// /// Note: This was called `fd_filestat_get` in earlier versions of WASI. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) stat: async func() -> result; /// Return the attributes of a file or directory. /// @@ -425,7 +438,7 @@ interface types { /// discussion of alternatives. /// /// Note: This was called `path_filestat_get` in earlier versions of WASI. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) stat-at: async func(path-flags: path-flags, path: string) -> result; /// Adjust the timestamps of a file or directory. /// @@ -433,7 +446,7 @@ interface types { /// /// Note: This was called `path_filestat_set_times` in earlier versions of /// WASI. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-times-at: async func(path-flags: path-flags, path: string, data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; /// Create a hard link. /// @@ -442,7 +455,7 @@ interface types { /// `error-code::not-permitted` if the old path is not a file. /// /// Note: This is similar to `linkat` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) link-at: async func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; /// Open a file or directory. /// @@ -456,7 +469,7 @@ interface types { /// `error-code::read-only`. /// /// Note: This is similar to `openat` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) open-at: async func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result; /// Read the contents of a symbolic link. /// @@ -464,19 +477,19 @@ interface types { /// filesystem, this function fails with `error-code::not-permitted`. /// /// Note: This is similar to `readlinkat` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) readlink-at: async func(path: string) -> result; /// Remove a directory. /// /// Return `error-code::not-empty` if the directory is not empty. /// /// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) remove-directory-at: async func(path: string) -> result<_, error-code>; /// Rename a filesystem object. /// /// Note: This is similar to `renameat` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) rename-at: async func(old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; /// Create a symbolic link (also known as a "symlink"). /// @@ -484,13 +497,13 @@ interface types { /// `error-code::not-permitted`. /// /// Note: This is similar to `symlinkat` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) symlink-at: async func(old-path: string, new-path: string) -> result<_, error-code>; /// Unlink a filesystem object that is not a directory. /// /// Return `error-code::is-directory` if the path refers to a directory. /// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) unlink-file-at: async func(path: string) -> result<_, error-code>; /// Test whether two descriptors refer to the same filesystem object. /// @@ -498,7 +511,7 @@ interface types { /// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. /// wasi-filesystem does not expose device and inode numbers, so this function /// may be used instead. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) is-same-object: async func(other: borrow) -> bool; /// Return a hash of the metadata associated with a filesystem object referred /// to by a descriptor. @@ -519,35 +532,35 @@ interface types { /// computed hash. /// /// However, none of these is required. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) metadata-hash: async func() -> result; /// Return a hash of the metadata associated with a filesystem object referred /// to by a directory descriptor and a relative path. /// /// This performs the same hash computation as `metadata-hash`. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) metadata-hash-at: async func(path-flags: path-flags, path: string) -> result; } } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface preopens { - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) use types.{descriptor}; /// Return the set of preopened directories, and their paths. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-directories: func() -> list>; } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) world imports { - @since(version = 0.3.0-rc-2026-01-06) - import wasi:clocks/types@0.3.0-rc-2026-01-06; - @since(version = 0.3.0-rc-2026-01-06) - import wasi:clocks/system-clock@0.3.0-rc-2026-01-06; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) + import wasi:clocks/types@0.3.0-rc-2026-02-09; + @since(version = 0.3.0-rc-2026-02-09) + import wasi:clocks/system-clock@0.3.0-rc-2026-02-09; + @since(version = 0.3.0-rc-2026-02-09) import types; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import preopens; } diff --git a/wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-01-06/package.wit b/wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit similarity index 90% rename from wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-01-06/package.wit rename to wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit index 3860af767..442b18ea1 100644 --- a/wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-01-06/package.wit +++ b/wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit @@ -1,11 +1,13 @@ -package wasi:http@0.3.0-rc-2026-01-06; +package wasi:http@0.3.0-rc-2026-02-09; /// This interface defines all of the types and methods for implementing HTTP /// Requests and Responses, as well as their headers, trailers, and bodies. +@since(version = 0.3.0-rc-2026-02-09) interface types { - use wasi:clocks/types@0.3.0-rc-2026-01-06.{duration}; + use wasi:clocks/types@0.3.0-rc-2026-02-09.{duration}; /// This type corresponds to HTTP standard Methods. + @since(version = 0.3.0-rc-2026-02-09) variant method { get, head, @@ -20,6 +22,7 @@ interface types { } /// This type corresponds to HTTP standard Related Schemes. + @since(version = 0.3.0-rc-2026-02-09) variant scheme { HTTP, HTTPS, @@ -27,18 +30,21 @@ interface types { } /// Defines the case payload type for `DNS-error` above: + @since(version = 0.3.0-rc-2026-02-09) record DNS-error-payload { rcode: option, info-code: option, } /// Defines the case payload type for `TLS-alert-received` above: + @since(version = 0.3.0-rc-2026-02-09) record TLS-alert-received-payload { alert-id: option, alert-message: option, } /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: + @since(version = 0.3.0-rc-2026-02-09) record field-size-payload { field-name: option, field-size: option, @@ -46,6 +52,7 @@ interface types { /// These cases are inspired by the IANA HTTP Proxy Error Types: /// + @since(version = 0.3.0-rc-2026-02-09) variant error-code { DNS-timeout, DNS-error(DNS-error-payload), @@ -95,6 +102,7 @@ interface types { /// This type enumerates the different kinds of errors that may occur when /// setting or appending to a `fields` resource. + @since(version = 0.3.0-rc-2026-02-09) variant header-error { /// This error indicates that a `field-name` or `field-value` was /// syntactically invalid when used with an operation that sets headers in a @@ -110,6 +118,7 @@ interface types { /// This type enumerates the different kinds of errors that may occur when /// setting fields of a `request-options` resource. + @since(version = 0.3.0-rc-2026-02-09) variant request-options-error { /// Indicates the specified field is not supported by this implementation. not-supported, @@ -122,11 +131,13 @@ interface types { /// /// Field names should always be treated as case insensitive by the `fields` /// resource for the purposes of equality checking. + @since(version = 0.3.0-rc-2026-02-09) type field-name = string; /// Field values should always be ASCII strings. However, in /// reality, HTTP implementations often have to interpret malformed values, /// so they are provided as a list of bytes. + @since(version = 0.3.0-rc-2026-02-09) type field-value = list; /// This following block defines the `fields` resource which corresponds to @@ -144,6 +155,7 @@ interface types { /// original casing used to construct or mutate the `fields` resource. The `fields` /// resource should use that original casing when serializing the fields for /// transport or when returning them from a method. + @since(version = 0.3.0-rc-2026-02-09) resource fields { /// Construct an empty HTTP Fields. /// @@ -212,12 +224,15 @@ interface types { } /// Headers is an alias for Fields. + @since(version = 0.3.0-rc-2026-02-09) type headers = fields; /// Trailers is an alias for Fields. + @since(version = 0.3.0-rc-2026-02-09) type trailers = fields; /// Represents an HTTP Request. + @since(version = 0.3.0-rc-2026-02-09) resource request { /// Construct a new `request` with a default `method` of `GET`, and /// `none` values for `path-with-query`, `scheme`, and `authority`. @@ -304,6 +319,7 @@ interface types { /// /// These timeouts are separate from any the user may use to bound an /// asynchronous call. + @since(version = 0.3.0-rc-2026-02-09) resource request-options { /// Construct a default `request-options` value. constructor(); @@ -332,9 +348,11 @@ interface types { } /// This type corresponds to the HTTP standard Status Code. + @since(version = 0.3.0-rc-2026-02-09) type status-code = u16; /// Represents an HTTP Response. + @since(version = 0.3.0-rc-2026-02-09) resource response { /// Construct a new `response`, with a default `status-code` of `200`. /// If a different `status-code` is needed, it must be set via the @@ -383,6 +401,7 @@ interface types { /// /// In `wasi:http/middleware` this interface is both exported and imported as /// the "downstream" and "upstream" directions of the middleware chain. +@since(version = 0.3.0-rc-2026-02-09) interface handler { use types.{request, response, error-code}; @@ -401,6 +420,7 @@ interface handler { /// (including WIT itself) is unable to represent a component importing two /// instances of the same interface. A `client.send` import may be linked /// directly to a `handler.handle` export to bypass the network. +@since(version = 0.3.0-rc-2026-02-09) interface client { use types.{request, response, error-code}; @@ -412,21 +432,22 @@ interface client { /// The `wasi:http/service` world captures a broad category of HTTP services /// including web applications, API servers, and proxies. It may be `include`d /// in more specific worlds such as `wasi:http/middleware`. +@since(version = 0.3.0-rc-2026-02-09) world service { - import wasi:cli/types@0.3.0-rc-2026-01-06; - import wasi:cli/stdout@0.3.0-rc-2026-01-06; - import wasi:cli/stderr@0.3.0-rc-2026-01-06; - import wasi:cli/stdin@0.3.0-rc-2026-01-06; - import wasi:clocks/types@0.3.0-rc-2026-01-06; + import wasi:cli/types@0.3.0-rc-2026-02-09; + import wasi:cli/stdout@0.3.0-rc-2026-02-09; + import wasi:cli/stderr@0.3.0-rc-2026-02-09; + import wasi:cli/stdin@0.3.0-rc-2026-02-09; + import wasi:clocks/types@0.3.0-rc-2026-02-09; import types; import client; - import wasi:clocks/monotonic-clock@0.3.0-rc-2026-01-06; - import wasi:clocks/system-clock@0.3.0-rc-2026-01-06; + import wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09; + import wasi:clocks/system-clock@0.3.0-rc-2026-02-09; @unstable(feature = clocks-timezone) - import wasi:clocks/timezone@0.3.0-rc-2026-01-06; - import wasi:random/random@0.3.0-rc-2026-01-06; - import wasi:random/insecure@0.3.0-rc-2026-01-06; - import wasi:random/insecure-seed@0.3.0-rc-2026-01-06; + import wasi:clocks/timezone@0.3.0-rc-2026-02-09; + import wasi:random/random@0.3.0-rc-2026-02-09; + import wasi:random/insecure@0.3.0-rc-2026-02-09; + import wasi:random/insecure-seed@0.3.0-rc-2026-02-09; export handler; } @@ -436,22 +457,23 @@ world service { /// Components may implement this world to allow them to participate in handler /// "chains" where a `request` flows through handlers on its way to some terminal /// `service` and corresponding `response` flows in the opposite direction. +@since(version = 0.3.0-rc-2026-02-09) world middleware { - import wasi:clocks/types@0.3.0-rc-2026-01-06; + import wasi:clocks/types@0.3.0-rc-2026-02-09; import types; import handler; - import wasi:cli/types@0.3.0-rc-2026-01-06; - import wasi:cli/stdout@0.3.0-rc-2026-01-06; - import wasi:cli/stderr@0.3.0-rc-2026-01-06; - import wasi:cli/stdin@0.3.0-rc-2026-01-06; + import wasi:cli/types@0.3.0-rc-2026-02-09; + import wasi:cli/stdout@0.3.0-rc-2026-02-09; + import wasi:cli/stderr@0.3.0-rc-2026-02-09; + import wasi:cli/stdin@0.3.0-rc-2026-02-09; import client; - import wasi:clocks/monotonic-clock@0.3.0-rc-2026-01-06; - import wasi:clocks/system-clock@0.3.0-rc-2026-01-06; + import wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09; + import wasi:clocks/system-clock@0.3.0-rc-2026-02-09; @unstable(feature = clocks-timezone) - import wasi:clocks/timezone@0.3.0-rc-2026-01-06; - import wasi:random/random@0.3.0-rc-2026-01-06; - import wasi:random/insecure@0.3.0-rc-2026-01-06; - import wasi:random/insecure-seed@0.3.0-rc-2026-01-06; + import wasi:clocks/timezone@0.3.0-rc-2026-02-09; + import wasi:random/random@0.3.0-rc-2026-02-09; + import wasi:random/insecure@0.3.0-rc-2026-02-09; + import wasi:random/insecure-seed@0.3.0-rc-2026-02-09; export handler; } diff --git a/wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-01-06/package.wit b/wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit similarity index 85% rename from wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-01-06/package.wit rename to wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit index 8bb873145..521df6e50 100644 --- a/wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-01-06/package.wit +++ b/wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit @@ -1,10 +1,10 @@ -package wasi:random@0.3.0-rc-2026-01-06; +package wasi:random@0.3.0-rc-2026-02-09; /// The insecure-seed interface for seeding hash-map DoS resistance. /// /// It is intended to be portable at least between Unix-family platforms and /// Windows. -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface insecure-seed { /// Return a 128-bit value that may contain a pseudo-random value. /// @@ -23,7 +23,7 @@ interface insecure-seed { /// This will likely be changed to a value import, to prevent it from being /// called multiple times and potentially used for purposes other than DoS /// protection. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-insecure-seed: func() -> tuple; } @@ -31,7 +31,7 @@ interface insecure-seed { /// /// It is intended to be portable at least between Unix-family platforms and /// Windows. -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface insecure { /// Return `len` insecure pseudo-random bytes. /// @@ -41,14 +41,14 @@ interface insecure { /// There are no requirements on the values of the returned bytes, however /// implementations are encouraged to return evenly distributed values with /// a long period. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-insecure-random-bytes: func(len: u64) -> list; /// Return an insecure pseudo-random `u64` value. /// /// This function returns the same type of pseudo-random data as /// `get-insecure-random-bytes`, represented as a `u64`. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-insecure-random-u64: func() -> u64; } @@ -56,7 +56,7 @@ interface insecure { /// /// It is intended to be portable at least between Unix-family platforms and /// Windows. -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface random { /// Return `len` cryptographically-secure random or pseudo-random bytes. /// @@ -70,23 +70,23 @@ interface random { /// This function must always return fresh data. Deterministic environments /// must omit this function, rather than implementing it with deterministic /// data. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-random-bytes: func(len: u64) -> list; /// Return a cryptographically-secure random or pseudo-random `u64` value. /// /// This function returns the same type of data as `get-random-bytes`, /// represented as a `u64`. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-random-u64: func() -> u64; } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) world imports { - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import random; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import insecure; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import insecure-seed; } diff --git a/wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-01-06/package.wit b/wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit similarity index 92% rename from wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-01-06/package.wit rename to wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit index d7ebe150b..aa9d4d7f0 100644 --- a/wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-01-06/package.wit +++ b/wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit @@ -1,9 +1,9 @@ -package wasi:sockets@0.3.0-rc-2026-01-06; +package wasi:sockets@0.3.0-rc-2026-02-09; -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface types { - @since(version = 0.3.0-rc-2026-01-06) - use wasi:clocks/types@0.3.0-rc-2026-01-06.{duration}; + @since(version = 0.3.0-rc-2026-02-09) + use wasi:clocks/types@0.3.0-rc-2026-02-09.{duration}; /// Error codes. /// @@ -16,7 +16,7 @@ interface types { /// - `out-of-memory` /// /// See each individual API for what the POSIX equivalents are. They sometimes differ per API. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) enum error-code { /// Unknown error unknown, @@ -57,7 +57,7 @@ interface types { datagram-too-large, } - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) enum ip-address-family { /// Similar to `AF_INET` in POSIX. ipv4, @@ -65,19 +65,19 @@ interface types { ipv6, } - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) type ipv4-address = tuple; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) type ipv6-address = tuple; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) variant ip-address { ipv4(ipv4-address), ipv6(ipv6-address), } - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) record ipv4-socket-address { /// sin_port port: u16, @@ -85,7 +85,7 @@ interface types { address: ipv4-address, } - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) record ipv6-socket-address { /// sin6_port port: u16, @@ -97,7 +97,7 @@ interface types { scope-id: u32, } - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) variant ip-socket-address { ipv4(ipv4-socket-address), ipv6(ipv6-socket-address), @@ -122,7 +122,7 @@ interface types { /// In addition to the general error codes documented on the /// `types::error-code` type, TCP socket methods may always return /// `error(invalid-state)` when in the `closed` state. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) resource tcp-socket { /// Create a new TCP socket. /// @@ -138,7 +138,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) create: static func(address-family: ip-address-family) -> result; /// Bind the socket to the provided IP address and port. /// @@ -171,7 +171,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) bind: func(local-address: ip-socket-address) -> result<_, error-code>; /// Connect to a remote endpoint. /// @@ -202,7 +202,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) connect: async func(remote-address: ip-socket-address) -> result<_, error-code>; /// Start listening and return a stream of new inbound connections. /// @@ -259,6 +259,12 @@ interface types { /// In either case, the stream returned by this `listen` method remains /// operational. /// + /// WASI requires `listen` to perform an implicit bind if the socket + /// has not already been bound. Not all platforms (notably Windows) + /// exhibit this behavior out of the box. On platforms that require it, + /// the WASI implementation can emulate this behavior by performing + /// the bind itself if the guest hasn't already done so. + /// /// # References /// - /// - @@ -268,7 +274,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) listen: func() -> result, error-code>; /// Transmit data to peer. /// @@ -290,8 +296,8 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) - send: async func(data: stream) -> result<_, error-code>; + @since(version = 0.3.0-rc-2026-02-09) + send: func(data: stream) -> future>; /// Read data from peer. /// /// This function returns a `stream` which provides the data received from the @@ -323,7 +329,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) receive: func() -> tuple, future>>; /// Get the bound local address. /// @@ -341,7 +347,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-local-address: func() -> result; /// Get the remote address. /// @@ -353,19 +359,19 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-remote-address: func() -> result; /// Whether the socket is in the `listening` state. /// /// Equivalent to the SO_ACCEPTCONN socket option. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-is-listening: func() -> bool; /// Whether this is a IPv4 or IPv6 socket. /// /// This is the value passed to the constructor. /// /// Equivalent to the SO_DOMAIN socket option. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-address-family: func() -> ip-address-family; /// Hints the desired listen queue size. Implementations are free to ignore this. /// @@ -376,7 +382,7 @@ interface types { /// - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen. /// - `invalid-argument`: (set) The provided value was 0. /// - `invalid-state`: (set) The socket is in the `connecting` or `connected` state. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-listen-backlog-size: func(value: u64) -> result<_, error-code>; /// Enables or disables keepalive. /// @@ -387,9 +393,9 @@ interface types { /// These properties can be configured while `keep-alive-enabled` is false, but only come into effect when `keep-alive-enabled` is true. /// /// Equivalent to the SO_KEEPALIVE socket option. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-keep-alive-enabled: func() -> result; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-keep-alive-enabled: func(value: bool) -> result<_, error-code>; /// Amount of time the connection has to be idle before TCP starts sending keepalive packets. /// @@ -401,9 +407,9 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-keep-alive-idle-time: func() -> result; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>; /// The time between keepalive packets. /// @@ -415,9 +421,9 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-keep-alive-interval: func() -> result; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-keep-alive-interval: func(value: duration) -> result<_, error-code>; /// The maximum amount of keepalive packets TCP should send before aborting the connection. /// @@ -429,9 +435,9 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-keep-alive-count: func() -> result; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-keep-alive-count: func(value: u32) -> result<_, error-code>; /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. /// @@ -439,9 +445,9 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The TTL value must be 1 or higher. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-hop-limit: func() -> result; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-hop-limit: func(value: u8) -> result<_, error-code>; /// The kernel buffer space reserved for sends/receives on this socket. /// @@ -453,18 +459,18 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-receive-buffer-size: func() -> result; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-receive-buffer-size: func(value: u64) -> result<_, error-code>; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-send-buffer-size: func() -> result; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-send-buffer-size: func(value: u64) -> result<_, error-code>; } /// A UDP socket handle. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) resource udp-socket { /// Create a new UDP socket. /// @@ -480,7 +486,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) create: static func(address-family: ip-address-family) -> result; /// Bind the socket to the provided IP address and port. /// @@ -500,7 +506,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) bind: func(local-address: ip-socket-address) -> result<_, error-code>; /// Associate this socket with a specific peer address. /// @@ -538,7 +544,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) connect: func(remote-address: ip-socket-address) -> result<_, error-code>; /// Dissociate this socket from its peer address. /// @@ -555,7 +561,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) disconnect: func() -> result<_, error-code>; /// Send a message on the socket to a particular peer. /// @@ -588,7 +594,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) send: async func(data: list, remote-address: option) -> result<_, error-code>; /// Receive a message on the socket. /// @@ -613,7 +619,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) receive: async func() -> result, ip-socket-address>, error-code>; /// Get the current bound address. /// @@ -631,7 +637,7 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-local-address: func() -> result; /// Get the address the socket is currently "connected" to. /// @@ -643,14 +649,14 @@ interface types { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-remote-address: func() -> result; /// Whether this is a IPv4 or IPv6 socket. /// /// This is the value passed to the constructor. /// /// Equivalent to the SO_DOMAIN socket option. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-address-family: func() -> ip-address-family; /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. /// @@ -658,9 +664,9 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The TTL value must be 1 or higher. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-unicast-hop-limit: func() -> result; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-unicast-hop-limit: func(value: u8) -> result<_, error-code>; /// The kernel buffer space reserved for sends/receives on this socket. /// @@ -672,24 +678,24 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-receive-buffer-size: func() -> result; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-receive-buffer-size: func(value: u64) -> result<_, error-code>; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) get-send-buffer-size: func() -> result; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) set-send-buffer-size: func(value: u64) -> result<_, error-code>; } } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) interface ip-name-lookup { - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) use types.{ip-address}; /// Lookup error codes. - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) enum error-code { /// Unknown error unknown, @@ -737,16 +743,16 @@ interface ip-name-lookup { /// - /// - /// - - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) resolve-addresses: async func(name: string) -> result, error-code>; } -@since(version = 0.3.0-rc-2026-01-06) +@since(version = 0.3.0-rc-2026-02-09) world imports { - @since(version = 0.3.0-rc-2026-01-06) - import wasi:clocks/types@0.3.0-rc-2026-01-06; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) + import wasi:clocks/types@0.3.0-rc-2026-02-09; + @since(version = 0.3.0-rc-2026-02-09) import types; - @since(version = 0.3.0-rc-2026-01-06) + @since(version = 0.3.0-rc-2026-02-09) import ip-name-lookup; } diff --git a/wasi/p3/wit/wasi-libc.wit b/wasi/p3/wit/wasi-libc.wit index 6cfa12f3c..acb02290d 100644 --- a/wasi/p3/wit/wasi-libc.wit +++ b/wasi/p3/wit/wasi-libc.wit @@ -1,10 +1,10 @@ package wasi-libc:wasip3; world wasip3 { - include wasi:cli/command@0.3.0-rc-2026-01-06; - include wasi:clocks/imports@0.3.0-rc-2026-01-06; - include wasi:filesystem/imports@0.3.0-rc-2026-01-06; - include wasi:http/middleware@0.3.0-rc-2026-01-06; - include wasi:random/imports@0.3.0-rc-2026-01-06; - include wasi:sockets/imports@0.3.0-rc-2026-01-06; + include wasi:cli/command@0.3.0-rc-2026-02-09; + include wasi:clocks/imports@0.3.0-rc-2026-02-09; + include wasi:filesystem/imports@0.3.0-rc-2026-02-09; + include wasi:http/middleware@0.3.0-rc-2026-02-09; + include wasi:random/imports@0.3.0-rc-2026-02-09; + include wasi:sockets/imports@0.3.0-rc-2026-02-09; } diff --git a/wasi/p3/wkg.lock b/wasi/p3/wkg.lock index dbe310903..8bfa9dd73 100644 --- a/wasi/p3/wkg.lock +++ b/wasi/p3/wkg.lock @@ -7,51 +7,51 @@ name = "wasi:cli" registry = "wasi.dev" [[packages.versions]] -requirement = "=0.3.0-rc-2026-01-06" -version = "0.3.0-rc-2026-01-06" -digest = "sha256:295f741000493314dbb09ac659943fb70fa37510a71e97281859255656dd74b8" +requirement = "=0.3.0-rc-2026-02-09" +version = "0.3.0-rc-2026-02-09" +digest = "sha256:d3f07fc00d81731517b50f4a9dca08168e299e856d4931246c8c54e028cec2ff" [[packages]] name = "wasi:clocks" registry = "wasi.dev" [[packages.versions]] -requirement = "=0.3.0-rc-2026-01-06" -version = "0.3.0-rc-2026-01-06" -digest = "sha256:0e741d66b40dde06113adb4b0b0130d9572c219ef6dae2e89f2ad399ea7ef7e2" +requirement = "=0.3.0-rc-2026-02-09" +version = "0.3.0-rc-2026-02-09" +digest = "sha256:419ee877c995ea7c3beb8c5068ca7bc38fe93584a8b4a4d4ac387b8196f0a88c" [[packages]] name = "wasi:filesystem" registry = "wasi.dev" [[packages.versions]] -requirement = "=0.3.0-rc-2026-01-06" -version = "0.3.0-rc-2026-01-06" -digest = "sha256:a346b1be8030480cd85b203dc77e323d666bcf93e0b68bf0092e206d43d6abd6" +requirement = "=0.3.0-rc-2026-02-09" +version = "0.3.0-rc-2026-02-09" +digest = "sha256:f8f503cf9547915272660d452ddc23cf965cdbf64aad0b68975d07b1da2637ac" [[packages]] name = "wasi:http" registry = "wasi.dev" [[packages.versions]] -requirement = "=0.3.0-rc-2026-01-06" -version = "0.3.0-rc-2026-01-06" -digest = "sha256:7ad86c4dea99c4cd63790483f26903ac7538f7d8be4d3f4e6fb4ef10123dbdeb" +requirement = "=0.3.0-rc-2026-02-09" +version = "0.3.0-rc-2026-02-09" +digest = "sha256:e47b9f1ac046656177dc0a57f5db00e3f9a4a4060450f76f56d93cd2844e94e6" [[packages]] name = "wasi:random" registry = "wasi.dev" [[packages.versions]] -requirement = "=0.3.0-rc-2026-01-06" -version = "0.3.0-rc-2026-01-06" -digest = "sha256:07196dc99781089c9732b29a202e3346e0bb2141fd76d89491af2087741bc7d2" +requirement = "=0.3.0-rc-2026-02-09" +version = "0.3.0-rc-2026-02-09" +digest = "sha256:2262570bf958a5c3c29fac590720a27527eaa509d1ca6ec5b5e48d937325b538" [[packages]] name = "wasi:sockets" registry = "wasi.dev" [[packages.versions]] -requirement = "=0.3.0-rc-2026-01-06" -version = "0.3.0-rc-2026-01-06" -digest = "sha256:59f03ca9048fa614fc99bfafc3bd61ebc821f78aa29a3da5f5b3df78dfab709f" +requirement = "=0.3.0-rc-2026-02-09" +version = "0.3.0-rc-2026-02-09" +digest = "sha256:d5ab258fb7307ec53859c79ca379801c317cbfcc6b235dfcc59282f90dd0c9a0" From 36d2c170d7d71daf2cae71727d446a1fc5211b18 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Wed, 4 Mar 2026 14:41:09 +0000 Subject: [PATCH 14/43] crt1 bump --- libc-bottom-half/crt/crt1-command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-bottom-half/crt/crt1-command.c b/libc-bottom-half/crt/crt1-command.c index d6ee74b7c..47cfb11a6 100644 --- a/libc-bottom-half/crt/crt1-command.c +++ b/libc-bottom-half/crt/crt1-command.c @@ -26,7 +26,7 @@ __attribute__((export_name("_start"))) void _start(void) // that this shouldn't be too problematic (in theory). __attribute__((export_name("wasi:cli/run@0.2.0#run"))) int _start(void) #elif defined(__wasip3__) -__attribute__((export_name("wasi:cli/run@0.3.0-rc-2026-01-06#run"))) int +__attribute__((export_name("wasi:cli/run@0.3.0-rc-2026-02-09#run"))) int _start(void) #else #error "Unsupported WASI version" From aba8568450d64f3816c931815ff7ba4f9e6a5db1 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 07:59:27 +0000 Subject: [PATCH 15/43] Fix bad lock initializations --- libc-top-half/musl/src/stdio/vsnprintf.c | 2 +- libc-top-half/musl/src/stdio/vswprintf.c | 2 +- test/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libc-top-half/musl/src/stdio/vsnprintf.c b/libc-top-half/musl/src/stdio/vsnprintf.c index 48c3aef7e..4d8366baf 100644 --- a/libc-top-half/musl/src/stdio/vsnprintf.c +++ b/libc-top-half/musl/src/stdio/vsnprintf.c @@ -41,7 +41,7 @@ int vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap) .lbf = EOF, .write = sn_write, #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - .lock = -1, + .lock = __STDIO_LOCK_INIT, #endif .buf = buf, .cookie = &c, diff --git a/libc-top-half/musl/src/stdio/vswprintf.c b/libc-top-half/musl/src/stdio/vswprintf.c index cab94cba7..d17da02ba 100644 --- a/libc-top-half/musl/src/stdio/vswprintf.c +++ b/libc-top-half/musl/src/stdio/vswprintf.c @@ -44,7 +44,7 @@ int vswprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, va_lis .lbf = EOF, .write = sw_write, #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - .lock = -1, + .lock = __STDIO_LOCK_INIT, #endif .buf = buf, .buf_size = sizeof buf, diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index adf1f61fd..97a4fe86a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,7 +22,7 @@ message(STATUS "libc-test source directory: ${LIBC_TEST}") FetchContent_Declare( posix-testsuite GIT_REPOSITORY https://github.com/bytecodealliance/open-posix-test-suite - GIT_TAG 18321461ce8381c359b439f5231908208718d230 + GIT_TAG 7cbbe794ddcfec55b071776ed84a5dfa31331db9 GIT_SHALLOW true ) FetchContent_MakeAvailable(posix-testsuite) From 3647168fe81ebe3f3a8b0f239e46f0e68c469483 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 08:06:42 +0000 Subject: [PATCH 16/43] Ifdef lock --- libc-bottom-half/sources/chdir.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libc-bottom-half/sources/chdir.c b/libc-bottom-half/sources/chdir.c index ac0293cf0..f12ff33c3 100644 --- a/libc-bottom-half/sources/chdir.c +++ b/libc-bottom-half/sources/chdir.c @@ -9,7 +9,9 @@ #include #include "lock.h" +#ifdef _REENTRANT extern __lock_t __wasilibc_cwd_lock; +#endif extern char *__wasilibc_cwd; static int __wasilibc_cwd_mallocd = 0; From e055edffd3e488b35d707ee2c5c37bf344912c7b Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 08:12:44 +0000 Subject: [PATCH 17/43] typedef locks with no threading --- libc-top-half/musl/src/internal/lock.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libc-top-half/musl/src/internal/lock.h b/libc-top-half/musl/src/internal/lock.h index f8fb8cad5..34b0a6fe3 100644 --- a/libc-top-half/musl/src/internal/lock.h +++ b/libc-top-half/musl/src/internal/lock.h @@ -40,7 +40,10 @@ hidden void __unlock(volatile int *); #define WEAK_LOCK(x) __lock(x) #define WEAK_UNLOCK(x) __unlock(x) #else -// No locking needed. +// No locking needed, typedefs defined to avoid needing to ifdef out all locks +typedef volatile int __lock_t; +typedef volatile int *__lock_ptr_t; +#define __LOCK_INIT {0} #define STRONG_LOCK(x) ((void)0) #define STRONG_UNLOCK(x) ((void)0) #define WEAK_LOCK(x) ((void)0) From c10da0618cc0d48e2d5660989760a19493c93e7c Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 08:17:35 +0000 Subject: [PATCH 18/43] Unused variable warnings --- libc-top-half/musl/src/internal/lock.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libc-top-half/musl/src/internal/lock.h b/libc-top-half/musl/src/internal/lock.h index 34b0a6fe3..f0fd15899 100644 --- a/libc-top-half/musl/src/internal/lock.h +++ b/libc-top-half/musl/src/internal/lock.h @@ -27,8 +27,8 @@ hidden void __lock(struct __coop_lock *lock); hidden void __unlock(struct __coop_lock *lock); #define STRONG_LOCK(x) __lock(x) #define STRONG_UNLOCK(x) __unlock(x) -#define WEAK_LOCK(x) ((void)0) -#define WEAK_UNLOCK(x) ((void)0) +#define WEAK_LOCK(x) ((void)x) +#define WEAK_UNLOCK(x) ((void)x) #elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) typedef volatile int __lock_t; typedef volatile int *__lock_ptr_t; @@ -44,10 +44,10 @@ hidden void __unlock(volatile int *); typedef volatile int __lock_t; typedef volatile int *__lock_ptr_t; #define __LOCK_INIT {0} -#define STRONG_LOCK(x) ((void)0) -#define STRONG_UNLOCK(x) ((void)0) -#define WEAK_LOCK(x) ((void)0) -#define WEAK_UNLOCK(x) ((void)0) +#define STRONG_LOCK(x) ((void)x) +#define STRONG_UNLOCK(x) ((void)x) +#define WEAK_LOCK(x) ((void)x) +#define WEAK_UNLOCK(x) ((void)x) #endif #endif From 7b431f128cc96e7a9a89bea34bc117631521566b Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 08:22:54 +0000 Subject: [PATCH 19/43] More lock nonsense --- libc-bottom-half/sources/chdir.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libc-bottom-half/sources/chdir.c b/libc-bottom-half/sources/chdir.c index f12ff33c3..ac0293cf0 100644 --- a/libc-bottom-half/sources/chdir.c +++ b/libc-bottom-half/sources/chdir.c @@ -9,9 +9,7 @@ #include #include "lock.h" -#ifdef _REENTRANT extern __lock_t __wasilibc_cwd_lock; -#endif extern char *__wasilibc_cwd; static int __wasilibc_cwd_mallocd = 0; From 787c289336d0ef68dea5288b8dd893b850d1e769 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 08:53:41 +0000 Subject: [PATCH 20/43] Redo lock changes --- libc-bottom-half/sources/chdir.c | 2 +- libc-bottom-half/sources/getcwd.c | 4 +-- libc-bottom-half/sources/preopens.c | 5 ++-- libc-top-half/musl/src/env/__init_tls.c | 4 +-- libc-top-half/musl/src/exit/abort_lock.c | 3 ++- libc-top-half/musl/src/exit/at_quick_exit.c | 5 +--- libc-top-half/musl/src/exit/atexit.c | 6 +---- libc-top-half/musl/src/internal/locale_impl.h | 6 ++--- libc-top-half/musl/src/internal/lock.h | 27 +++++++++---------- .../musl/src/internal/pthread_impl.h | 5 ++-- libc-top-half/musl/src/internal/stdio_impl.h | 2 +- libc-top-half/musl/src/locale/locale_map.c | 5 +--- libc-top-half/musl/src/prng/random.c | 5 +--- libc-top-half/musl/src/stdio/__fdopen.c | 2 +- libc-top-half/musl/src/stdio/__fopen_rb_ca.c | 2 +- libc-top-half/musl/src/stdio/__lockfile.c | 6 ++--- libc-top-half/musl/src/stdio/fmemopen.c | 2 +- libc-top-half/musl/src/stdio/ftrylockfile.c | 10 +++---- libc-top-half/musl/src/stdio/getc.h | 2 +- libc-top-half/musl/src/stdio/ofl.c | 5 +--- libc-top-half/musl/src/stdio/open_memstream.c | 2 +- .../musl/src/stdio/open_wmemstream.c | 2 +- libc-top-half/musl/src/stdio/putc.h | 2 +- libc-top-half/musl/src/stdlib/wcstod.c | 2 +- libc-top-half/musl/src/stdlib/wcstol.c | 2 +- 25 files changed, 47 insertions(+), 71 deletions(-) diff --git a/libc-bottom-half/sources/chdir.c b/libc-bottom-half/sources/chdir.c index ac0293cf0..ddb82790a 100644 --- a/libc-bottom-half/sources/chdir.c +++ b/libc-bottom-half/sources/chdir.c @@ -9,7 +9,7 @@ #include #include "lock.h" -extern __lock_t __wasilibc_cwd_lock; +DECLARE_WEAK_LOCK(__wasilibc_cwd_lock, extern); extern char *__wasilibc_cwd; static int __wasilibc_cwd_mallocd = 0; diff --git a/libc-bottom-half/sources/getcwd.c b/libc-bottom-half/sources/getcwd.c index d158e412f..ee5723582 100644 --- a/libc-bottom-half/sources/getcwd.c +++ b/libc-bottom-half/sources/getcwd.c @@ -5,10 +5,8 @@ #include "lock.h" char *__wasilibc_cwd = "/"; +DECLARE_WEAK_LOCK(__wasilibc_cwd_lock, static); -#ifdef _REENTRANT -static __lock_t __wasilibc_cwd_lock[1]; -#endif char *getcwd(char *buf, size_t size) { // Critical section contains no yield points, so we can use weak locks. diff --git a/libc-bottom-half/sources/preopens.c b/libc-bottom-half/sources/preopens.c index 2288f545c..275b531e1 100644 --- a/libc-bottom-half/sources/preopens.c +++ b/libc-bottom-half/sources/preopens.c @@ -23,9 +23,8 @@ /// Access to the the above preopen must be protected in the presence of /// threads. -#ifdef _REENTRANT -static __lock_t lock[1]; -#endif +DECLARE_STRONG_LOCK(lock, static); + #if defined(__wasip1__) typedef struct { diff --git a/libc-top-half/musl/src/env/__init_tls.c b/libc-top-half/musl/src/env/__init_tls.c index 6a636811e..eca399302 100644 --- a/libc-top-half/musl/src/env/__init_tls.c +++ b/libc-top-half/musl/src/env/__init_tls.c @@ -15,9 +15,7 @@ #include #include "lock.h" -#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -__lock_t __thread_list_lock; -#endif +DECLARE_WEAK_LOCK(__thread_list_lock); #ifndef __wasilibc_unmodified_upstream diff --git a/libc-top-half/musl/src/exit/abort_lock.c b/libc-top-half/musl/src/exit/abort_lock.c index 3af72c7b6..6ab59771c 100644 --- a/libc-top-half/musl/src/exit/abort_lock.c +++ b/libc-top-half/musl/src/exit/abort_lock.c @@ -1,3 +1,4 @@ #include "pthread_impl.h" +#include "lock.h" -volatile int __abort_lock[1]; +DECLARE_STRONG_LOCK(__abort_lock); diff --git a/libc-top-half/musl/src/exit/at_quick_exit.c b/libc-top-half/musl/src/exit/at_quick_exit.c index cd44759c7..25b329e40 100644 --- a/libc-top-half/musl/src/exit/at_quick_exit.c +++ b/libc-top-half/musl/src/exit/at_quick_exit.c @@ -7,10 +7,7 @@ static void (*funcs[COUNT])(void); static int count; -#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -static __lock_t lock[1]; -__lock_t *const __at_quick_exit_lockptr = lock; -#endif +DECLARE_STRONG_LOCK(lock, static); void __funcs_on_quick_exit() { diff --git a/libc-top-half/musl/src/exit/atexit.c b/libc-top-half/musl/src/exit/atexit.c index 61b15cd40..bf3fa2ddc 100644 --- a/libc-top-half/musl/src/exit/atexit.c +++ b/libc-top-half/musl/src/exit/atexit.c @@ -21,11 +21,7 @@ static struct fl static int slot; -#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -#include "lock.h" -__lock_t lock[1]; -__lock_t *const __atexit_lockptr = lock; -#endif +DECLARE_WEAK_LOCK(lock, static); void __funcs_on_exit() { diff --git a/libc-top-half/musl/src/internal/locale_impl.h b/libc-top-half/musl/src/internal/locale_impl.h index b792f8d0e..93d3de4df 100644 --- a/libc-top-half/musl/src/internal/locale_impl.h +++ b/libc-top-half/musl/src/internal/locale_impl.h @@ -4,6 +4,7 @@ #include #include #include "libc.h" +#include "lock.h" #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) #include "pthread_impl.h" #endif @@ -17,10 +18,7 @@ struct __locale_map { const struct __locale_map *next; }; -#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -#include "lock.h" -extern hidden __lock_t __locale_lock[1]; -#endif +DECLARE_WEAK_LOCK(__locale_lock, extern hidden); extern hidden const struct __locale_map __c_dot_utf8; extern hidden const struct __locale_struct __c_locale; diff --git a/libc-top-half/musl/src/internal/lock.h b/libc-top-half/musl/src/internal/lock.h index f0fd15899..d8ae91106 100644 --- a/libc-top-half/musl/src/internal/lock.h +++ b/libc-top-half/musl/src/internal/lock.h @@ -18,8 +18,8 @@ struct __coop_lock { struct __waitlist_node *waiters; }; -typedef struct __coop_lock __lock_t; -typedef struct __coop_lock *__lock_ptr_t; +#define DECLARE_STRONG_LOCK(name, ...) __VA_ARGS__ struct __coop_lock name[1] +#define DECLARE_WEAK_LOCK(name, ...) #define __COOP_LOCK_INIT {0, NULL} #define __LOCK_INIT __COOP_LOCK_INIT @@ -27,11 +27,11 @@ hidden void __lock(struct __coop_lock *lock); hidden void __unlock(struct __coop_lock *lock); #define STRONG_LOCK(x) __lock(x) #define STRONG_UNLOCK(x) __unlock(x) -#define WEAK_LOCK(x) ((void)x) -#define WEAK_UNLOCK(x) ((void)x) -#elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -typedef volatile int __lock_t; -typedef volatile int *__lock_ptr_t; +#define WEAK_LOCK(x) ((void)0) +#define WEAK_UNLOCK(x) ((void)0) +#elif defined(_REENTRANT) +#define DECLARE_STRONG_LOCK(name, ...) __VA_ARGS__ volatile int name[1] +#define DECLARE_WEAK_LOCK(name, ...) __VA_ARGS__ volatile int name[1] #define __LOCK_INIT {0} hidden void __lock(volatile int *); hidden void __unlock(volatile int *); @@ -40,14 +40,13 @@ hidden void __unlock(volatile int *); #define WEAK_LOCK(x) __lock(x) #define WEAK_UNLOCK(x) __unlock(x) #else -// No locking needed, typedefs defined to avoid needing to ifdef out all locks -typedef volatile int __lock_t; -typedef volatile int *__lock_ptr_t; +#define DECLARE_STRONG_LOCK(name, ...) +#define DECLARE_WEAK_LOCK(name, ...) #define __LOCK_INIT {0} -#define STRONG_LOCK(x) ((void)x) -#define STRONG_UNLOCK(x) ((void)x) -#define WEAK_LOCK(x) ((void)x) -#define WEAK_UNLOCK(x) ((void)x) +#define STRONG_LOCK(x) ((void)0) +#define STRONG_UNLOCK(x) ((void)0) +#define WEAK_LOCK(x) ((void)0) +#define WEAK_UNLOCK(x) ((void)0) #endif #endif diff --git a/libc-top-half/musl/src/internal/pthread_impl.h b/libc-top-half/musl/src/internal/pthread_impl.h index d26fdb71e..8b9bd7999 100644 --- a/libc-top-half/musl/src/internal/pthread_impl.h +++ b/libc-top-half/musl/src/internal/pthread_impl.h @@ -207,9 +207,8 @@ hidden void __tl_lock(void); hidden void __tl_unlock(void); hidden void __tl_sync(pthread_t); -extern hidden __lock_t __thread_list_lock; - -extern hidden __lock_t __abort_lock[1]; +DECLARE_WEAK_LOCK(__thread_list_lock, extern hidden); +DECLARE_STRONG_LOCK(__abort_lock, extern hidden); extern hidden unsigned __default_stacksize; extern hidden unsigned __default_guardsize; diff --git a/libc-top-half/musl/src/internal/stdio_impl.h b/libc-top-half/musl/src/internal/stdio_impl.h index ce0e1bc2f..0df02704c 100644 --- a/libc-top-half/musl/src/internal/stdio_impl.h +++ b/libc-top-half/musl/src/internal/stdio_impl.h @@ -61,7 +61,7 @@ struct _IO_FILE { #endif int mode; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - __lock_t lock; + DECLARE_STRONG_LOCK(lock); #endif int lbf; void *cookie; diff --git a/libc-top-half/musl/src/locale/locale_map.c b/libc-top-half/musl/src/locale/locale_map.c index ca25ac827..0d84be29e 100644 --- a/libc-top-half/musl/src/locale/locale_map.c +++ b/libc-top-half/musl/src/locale/locale_map.c @@ -30,10 +30,7 @@ static const char envvars[][12] = { "LC_MESSAGES", }; -#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -__lock_t __locale_lock[1]; -__lock_t *const __locale_lockptr = __locale_lock; -#endif +DECLARE_WEAK_LOCK(__locale_lock); const struct __locale_map *__get_locale(int cat, const char *val) { diff --git a/libc-top-half/musl/src/prng/random.c b/libc-top-half/musl/src/prng/random.c index 1cb860877..3be96df15 100644 --- a/libc-top-half/musl/src/prng/random.c +++ b/libc-top-half/musl/src/prng/random.c @@ -23,10 +23,7 @@ static int n = 31; static int i = 3; static int j = 0; static uint32_t *x = init+1; -#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -static __lock_t lock[1]; -__lock_t *const __random_lockptr = lock; -#endif +DECLARE_WEAK_LOCK(lock, static); static uint32_t lcg31(uint32_t x) { return (1103515245*x + 12345) & 0x7fffffff; diff --git a/libc-top-half/musl/src/stdio/__fdopen.c b/libc-top-half/musl/src/stdio/__fdopen.c index 205338c2f..e37ae0d40 100644 --- a/libc-top-half/musl/src/stdio/__fdopen.c +++ b/libc-top-half/musl/src/stdio/__fdopen.c @@ -75,7 +75,7 @@ FILE *__fdopen(int fd, const char *mode) f->close = __stdio_close; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - if (!libc.threaded) __STDIO_LOCK_RESET(&f->lock); + if (!libc.threaded) __STDIO_LOCK_RESET(f->lock); #endif /* Add new FILE to open file list */ diff --git a/libc-top-half/musl/src/stdio/__fopen_rb_ca.c b/libc-top-half/musl/src/stdio/__fopen_rb_ca.c index 27c2544fe..aaf4e0d12 100644 --- a/libc-top-half/musl/src/stdio/__fopen_rb_ca.c +++ b/libc-top-half/musl/src/stdio/__fopen_rb_ca.c @@ -25,7 +25,7 @@ FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t le f->seek = __stdio_seek; f->close = __stdio_close; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - __STDIO_LOCK_RESET(&f->lock); + __STDIO_LOCK_RESET(f->lock); #endif return f; diff --git a/libc-top-half/musl/src/stdio/__lockfile.c b/libc-top-half/musl/src/stdio/__lockfile.c index 81d3b91c3..ed92e8a77 100644 --- a/libc-top-half/musl/src/stdio/__lockfile.c +++ b/libc-top-half/musl/src/stdio/__lockfile.c @@ -12,16 +12,16 @@ int __lockfile(FILE *f) #endif // Allow recursive locking - if (f->lock.owner == tid) + if (f->lock->owner == tid) return 0; - STRONG_LOCK(&f->lock); + STRONG_LOCK(f->lock); return 1; } void __unlockfile(FILE *f) { - STRONG_UNLOCK(&f->lock); + STRONG_UNLOCK(f->lock); } #else int __lockfile(FILE *f) diff --git a/libc-top-half/musl/src/stdio/fmemopen.c b/libc-top-half/musl/src/stdio/fmemopen.c index 22628e56f..821157dc6 100644 --- a/libc-top-half/musl/src/stdio/fmemopen.c +++ b/libc-top-half/musl/src/stdio/fmemopen.c @@ -130,7 +130,7 @@ FILE *fmemopen(void *restrict buf, size_t size, const char *restrict mode) f->f.close = mclose; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - if (!libc.threaded) __STDIO_LOCK_RESET(&f->f.lock); + if (!libc.threaded) __STDIO_LOCK_RESET(f->f.lock); #endif return __ofl_add(&f->f); diff --git a/libc-top-half/musl/src/stdio/ftrylockfile.c b/libc-top-half/musl/src/stdio/ftrylockfile.c index 482cd9ee0..86e322a6b 100644 --- a/libc-top-half/musl/src/stdio/ftrylockfile.c +++ b/libc-top-half/musl/src/stdio/ftrylockfile.c @@ -7,8 +7,8 @@ void __do_orphaned_stdio_locks() FILE *f; for (f=__pthread_self()->stdio_locks; f; f=f->next_locked) { #ifdef __wasi_cooperative_threads__ - f->lock.owner = 0; - __waitlist_wake_all(&f->lock.waiters); + f->lock->owner = 0; + __waitlist_wake_all(&f->lock->waiters); #else a_store(&f->lock, 0x40000000); #endif @@ -42,7 +42,7 @@ int ftrylockfile(FILE *f) #error "Unknown WASI version" #endif - if (f->lock.owner == self_tid) { + if (f->lock->owner == self_tid) { if (f->lockcount == LONG_MAX) return -1; f->lockcount++; @@ -50,10 +50,10 @@ int ftrylockfile(FILE *f) } // Try to acquire the lock - if (f->lock.owner != 0) + if (f->lock->owner != 0) return -1; - f->lock.owner = self_tid; + f->lock->owner = self_tid; f->lockcount = 1; return 0; } diff --git a/libc-top-half/musl/src/stdio/getc.h b/libc-top-half/musl/src/stdio/getc.h index 7502102dc..cb81c36a6 100644 --- a/libc-top-half/musl/src/stdio/getc.h +++ b/libc-top-half/musl/src/stdio/getc.h @@ -25,7 +25,7 @@ static int locking_getc(FILE *f) static inline int do_getc(FILE *f) { #ifdef __wasi_cooperative_threads__ - if (f->lock.owner == wasip3_thread_index()) + if (f->lock->owner == wasip3_thread_index()) return getc_unlocked(f); return locking_getc(f); #elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) diff --git a/libc-top-half/musl/src/stdio/ofl.c b/libc-top-half/musl/src/stdio/ofl.c index 2a298a2f8..a93fff07b 100644 --- a/libc-top-half/musl/src/stdio/ofl.c +++ b/libc-top-half/musl/src/stdio/ofl.c @@ -3,10 +3,7 @@ #include "fork_impl.h" static FILE *ofl_head; -#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -static __lock_t ofl_lock[1]; -__lock_t *const __stdio_ofl_lockptr = ofl_lock; -#endif +static DECLARE_STRONG_LOCK(ofl_lock); FILE **__ofl_lock() { diff --git a/libc-top-half/musl/src/stdio/open_memstream.c b/libc-top-half/musl/src/stdio/open_memstream.c index 9690fe8b3..34f93e563 100644 --- a/libc-top-half/musl/src/stdio/open_memstream.c +++ b/libc-top-half/musl/src/stdio/open_memstream.c @@ -102,7 +102,7 @@ FILE *open_memstream(char **bufp, size_t *sizep) f->f.mode = -1; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - if (!libc.threaded) __STDIO_LOCK_RESET(&f->f.lock); + if (!libc.threaded) __STDIO_LOCK_RESET(f->f.lock); #endif return __ofl_add(&f->f); diff --git a/libc-top-half/musl/src/stdio/open_wmemstream.c b/libc-top-half/musl/src/stdio/open_wmemstream.c index d06c24db8..7484ada2c 100644 --- a/libc-top-half/musl/src/stdio/open_wmemstream.c +++ b/libc-top-half/musl/src/stdio/open_wmemstream.c @@ -107,7 +107,7 @@ FILE *open_wmemstream(wchar_t **bufp, size_t *sizep) f->f.close = wms_close; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - if (!libc.threaded) __STDIO_LOCK_RESET(&f->f.lock); + if (!libc.threaded) __STDIO_LOCK_RESET(f->f.lock); #endif fwide(&f->f, 1); diff --git a/libc-top-half/musl/src/stdio/putc.h b/libc-top-half/musl/src/stdio/putc.h index aae780ab3..37c001041 100644 --- a/libc-top-half/musl/src/stdio/putc.h +++ b/libc-top-half/musl/src/stdio/putc.h @@ -30,7 +30,7 @@ static inline int do_putc(int c, FILE *f) #else #error "Unknown WASI version" #endif - if (f->lock.owner == tid) + if (f->lock->owner == tid) return putc_unlocked(c, f); return locking_putc(c, f); #elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) diff --git a/libc-top-half/musl/src/stdlib/wcstod.c b/libc-top-half/musl/src/stdlib/wcstod.c index c198f08c5..9c853e155 100644 --- a/libc-top-half/musl/src/stdlib/wcstod.c +++ b/libc-top-half/musl/src/stdlib/wcstod.c @@ -44,7 +44,7 @@ static long double wcstox(const wchar_t *s, wchar_t **p, int prec) f.rpos = f.rend = f.buf = buf + 4; f.buf_size = sizeof buf - 4; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - __STDIO_LOCK_RESET(&f.lock); + __STDIO_LOCK_RESET(f.lock); #endif f.read = do_read; while (iswspace(*t)) t++; diff --git a/libc-top-half/musl/src/stdlib/wcstol.c b/libc-top-half/musl/src/stdlib/wcstol.c index 43439c0d0..2771b3cf0 100644 --- a/libc-top-half/musl/src/stdlib/wcstol.c +++ b/libc-top-half/musl/src/stdlib/wcstol.c @@ -38,7 +38,7 @@ static unsigned long long wcstox(const wchar_t *s, wchar_t **p, int base, unsign f.rpos = f.rend = f.buf = buf + 4; f.buf_size = sizeof buf - 4; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - __STDIO_LOCK_RESET(&f.lock); + __STDIO_LOCK_RESET(f.lock); #endif f.read = do_read; while (iswspace(*t)) t++; From 1000351ec2af1c4ca07653e943246f795ee28d38 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 09:24:08 +0000 Subject: [PATCH 21/43] Move lock_ptc --- libc-top-half/CMakeLists.txt | 3 ++- libc-top-half/musl/src/thread/coop-threads/lock_ptc.c | 3 +++ .../musl/src/thread/{common => wasi-threads}/lock_ptc.c | 8 +------- 3 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 libc-top-half/musl/src/thread/coop-threads/lock_ptc.c rename libc-top-half/musl/src/thread/{common => wasi-threads}/lock_ptc.c (62%) diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index aa60731a5..7e714b434 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -236,7 +236,6 @@ set(top_half_sources musl/src/network/ntohs.c musl/src/stat/futimesat.c musl/src/thread/common/default_attr.c - musl/src/thread/common/lock_ptc.c musl/src/thread/common/pthread_attr_destroy.c musl/src/thread/common/pthread_attr_get.c musl/src/thread/common/pthread_attr_init.c @@ -411,6 +410,7 @@ if (THREADS) musl/src/thread/wasi-threads/__lock.c musl/src/thread/wasi-threads/__wait.c musl/src/thread/wasi-threads/__timedwait.c + musl/src/thread/wasi-threads/lock_ptc.c musl/src/thread/wasi-threads/pthread_barrier_destroy.c musl/src/thread/wasi-threads/pthread_barrier_init.c musl/src/thread/wasi-threads/pthread_barrier_wait.c @@ -460,6 +460,7 @@ elseif(WASI STREQUAL "p3") musl/src/thread/coop-threads/__lock.c musl/src/thread/coop-threads/__wait.c musl/src/thread/coop-threads/__wasi_coop_thread_start.s + musl/src/thread/coop-threads/lock_ptc.c musl/src/thread/coop-threads/mtx_lock.c musl/src/thread/coop-threads/mtx_trylock.c musl/src/thread/coop-threads/pthread_barrier_destroy.c diff --git a/libc-top-half/musl/src/thread/coop-threads/lock_ptc.c b/libc-top-half/musl/src/thread/coop-threads/lock_ptc.c new file mode 100644 index 000000000..28c7a831c --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/lock_ptc.c @@ -0,0 +1,3 @@ +void __inhibit_ptc(){} +void __acquire_ptc(){} +void __release_ptc(){} \ No newline at end of file diff --git a/libc-top-half/musl/src/thread/common/lock_ptc.c b/libc-top-half/musl/src/thread/wasi-threads/lock_ptc.c similarity index 62% rename from libc-top-half/musl/src/thread/common/lock_ptc.c rename to libc-top-half/musl/src/thread/wasi-threads/lock_ptc.c index 20021da62..ec0e05bbe 100644 --- a/libc-top-half/musl/src/thread/common/lock_ptc.c +++ b/libc-top-half/musl/src/thread/wasi-threads/lock_ptc.c @@ -1,6 +1,5 @@ #include -#if defined(_REENTRANT) && !defined(__wasi_cooperative_threads__) static pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER; void __inhibit_ptc() @@ -16,9 +15,4 @@ void __acquire_ptc() void __release_ptc() { pthread_rwlock_unlock(&lock); -} -#else -void __inhibit_ptc(){} -void __acquire_ptc(){} -void __release_ptc(){} -#endif \ No newline at end of file +} \ No newline at end of file From 1fc2a40a9f517c2e90a505f393702e7b6abb66b0 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 09:26:33 +0000 Subject: [PATCH 22/43] OFL lock fix --- libc-top-half/musl/src/stdio/ofl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-top-half/musl/src/stdio/ofl.c b/libc-top-half/musl/src/stdio/ofl.c index a93fff07b..f9f430b6c 100644 --- a/libc-top-half/musl/src/stdio/ofl.c +++ b/libc-top-half/musl/src/stdio/ofl.c @@ -3,7 +3,7 @@ #include "fork_impl.h" static FILE *ofl_head; -static DECLARE_STRONG_LOCK(ofl_lock); +DECLARE_STRONG_LOCK(ofl_lock, static); FILE **__ofl_lock() { From c37f7712d1219f5a6bd951559dab6092034d33ad Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 09:27:51 +0000 Subject: [PATCH 23/43] Add wasi-threads sem_destroy --- libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c diff --git a/libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c b/libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c new file mode 100644 index 000000000..f4aced5da --- /dev/null +++ b/libc-top-half/musl/src/thread/wasi-threads/sem_destroy.c @@ -0,0 +1,6 @@ +#include + +int sem_destroy(sem_t *sem) +{ + return 0; +} From 0ef525a5794c6afa5c1b1a2c412a10cece4f539c Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 09:52:21 +0000 Subject: [PATCH 24/43] wasi-threads fixes --- libc-top-half/musl/src/stdio/getc.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libc-top-half/musl/src/stdio/getc.h b/libc-top-half/musl/src/stdio/getc.h index cb81c36a6..69babd42b 100644 --- a/libc-top-half/musl/src/stdio/getc.h +++ b/libc-top-half/musl/src/stdio/getc.h @@ -13,10 +13,10 @@ static int locking_getc(FILE *f) __unlockfile(f); return c; #else - if (a_cas(&f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); + if (a_cas(f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); int c = getc_unlocked(f); - if (a_swap(&f->lock, 0) & MAYBE_WAITERS) - __wake(&f->lock, 1, 1); + if (a_swap(f->lock, 0) & MAYBE_WAITERS) + __wake(f->lock, 1, 1); return c; #endif } @@ -29,7 +29,7 @@ static inline int do_getc(FILE *f) return getc_unlocked(f); return locking_getc(f); #elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - int l = f->lock; + int l = *f->lock; if (l < 0 || l && (l & ~MAYBE_WAITERS) == __pthread_self()->tid) return getc_unlocked(f); return locking_getc(f); From cfec5f13961093a31dc6feba92a0085274c0adb8 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 09:55:21 +0000 Subject: [PATCH 25/43] wasi-threads fixes --- libc-top-half/musl/src/stdio/putc.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libc-top-half/musl/src/stdio/putc.h b/libc-top-half/musl/src/stdio/putc.h index 37c001041..ee0b39e89 100644 --- a/libc-top-half/musl/src/stdio/putc.h +++ b/libc-top-half/musl/src/stdio/putc.h @@ -13,10 +13,10 @@ static int locking_putc(int c, FILE *f) __unlockfile(f); return c; #else - if (a_cas(&f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); + if (a_cas(f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); c = putc_unlocked(c, f); - if (a_swap(&f->lock, 0) & MAYBE_WAITERS) - __wake(&f->lock, 1, 1); + if (a_swap(f->lock, 0) & MAYBE_WAITERS) + __wake(f->lock, 1, 1); return c; #endif } @@ -34,7 +34,7 @@ static inline int do_putc(int c, FILE *f) return putc_unlocked(c, f); return locking_putc(c, f); #elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - int l = f->lock; + int l = *f->lock; if (l < 0 || l && (l & ~MAYBE_WAITERS) == __pthread_self()->tid) return putc_unlocked(c, f); return locking_putc(c, f); From c78d35cd27dd2da5879249cc6e5bc2882da378c1 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 09:58:24 +0000 Subject: [PATCH 26/43] wasi-threads fixes --- libc-top-half/musl/src/stdio/ftrylockfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc-top-half/musl/src/stdio/ftrylockfile.c b/libc-top-half/musl/src/stdio/ftrylockfile.c index 86e322a6b..cc42af468 100644 --- a/libc-top-half/musl/src/stdio/ftrylockfile.c +++ b/libc-top-half/musl/src/stdio/ftrylockfile.c @@ -62,7 +62,7 @@ int ftrylockfile(FILE *f) { pthread_t self = __pthread_self(); int tid = self->tid; - int owner = f->lock; + int owner = *f->lock; if ((owner & ~MAYBE_WAITERS) == tid) { if (f->lockcount == LONG_MAX) return -1; @@ -70,7 +70,7 @@ int ftrylockfile(FILE *f) return 0; } if (owner < 0) f->lock = owner = 0; - if (owner || a_cas(&f->lock, 0, tid)) + if (owner || a_cas(f->lock, 0, tid)) return -1; __register_locked_file(f, self); return 0; From 73dff1acd7a9a8e5110094607a94905d929b6f9b Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 09:58:51 +0000 Subject: [PATCH 27/43] wasi-threads fixes --- libc-top-half/musl/src/stdio/ftrylockfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc-top-half/musl/src/stdio/ftrylockfile.c b/libc-top-half/musl/src/stdio/ftrylockfile.c index cc42af468..18faaf13d 100644 --- a/libc-top-half/musl/src/stdio/ftrylockfile.c +++ b/libc-top-half/musl/src/stdio/ftrylockfile.c @@ -69,7 +69,7 @@ int ftrylockfile(FILE *f) f->lockcount++; return 0; } - if (owner < 0) f->lock = owner = 0; + if (owner < 0) *f->lock = owner = 0; if (owner || a_cas(f->lock, 0, tid)) return -1; __register_locked_file(f, self); From df6a4dabc4c0ba3fe9bec91711363967fc83f6ed Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 10:06:02 +0000 Subject: [PATCH 28/43] Pointer shenanigans --- libc-top-half/musl/src/internal/lock.h | 18 +++++++++--------- libc-top-half/musl/src/internal/stdio_impl.h | 4 ++-- libc-top-half/musl/src/stdio/ftrylockfile.c | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libc-top-half/musl/src/internal/lock.h b/libc-top-half/musl/src/internal/lock.h index d8ae91106..6f1aa8d36 100644 --- a/libc-top-half/musl/src/internal/lock.h +++ b/libc-top-half/musl/src/internal/lock.h @@ -18,27 +18,27 @@ struct __coop_lock { struct __waitlist_node *waiters; }; -#define DECLARE_STRONG_LOCK(name, ...) __VA_ARGS__ struct __coop_lock name[1] +#define DECLARE_STRONG_LOCK(name, ...) __VA_ARGS__ struct __coop_lock name #define DECLARE_WEAK_LOCK(name, ...) #define __COOP_LOCK_INIT {0, NULL} #define __LOCK_INIT __COOP_LOCK_INIT hidden void __lock(struct __coop_lock *lock); hidden void __unlock(struct __coop_lock *lock); -#define STRONG_LOCK(x) __lock(x) -#define STRONG_UNLOCK(x) __unlock(x) +#define STRONG_LOCK(x) __lock(&x) +#define STRONG_UNLOCK(x) __unlock(&x) #define WEAK_LOCK(x) ((void)0) #define WEAK_UNLOCK(x) ((void)0) #elif defined(_REENTRANT) -#define DECLARE_STRONG_LOCK(name, ...) __VA_ARGS__ volatile int name[1] -#define DECLARE_WEAK_LOCK(name, ...) __VA_ARGS__ volatile int name[1] +#define DECLARE_STRONG_LOCK(name, ...) __VA_ARGS__ volatile int name +#define DECLARE_WEAK_LOCK(name, ...) __VA_ARGS__ volatile int name #define __LOCK_INIT {0} hidden void __lock(volatile int *); hidden void __unlock(volatile int *); -#define STRONG_LOCK(x) __lock(x) -#define STRONG_UNLOCK(x) __unlock(x) -#define WEAK_LOCK(x) __lock(x) -#define WEAK_UNLOCK(x) __unlock(x) +#define STRONG_LOCK(x) __lock(&x) +#define STRONG_UNLOCK(x) __unlock(&x) +#define WEAK_LOCK(x) __lock(&x) +#define WEAK_UNLOCK(x) __unlock(&x) #else #define DECLARE_STRONG_LOCK(name, ...) #define DECLARE_WEAK_LOCK(name, ...) diff --git a/libc-top-half/musl/src/internal/stdio_impl.h b/libc-top-half/musl/src/internal/stdio_impl.h index 0df02704c..aaaa17151 100644 --- a/libc-top-half/musl/src/internal/stdio_impl.h +++ b/libc-top-half/musl/src/internal/stdio_impl.h @@ -15,13 +15,13 @@ #define FLOCK(f) int __need_unlock = __lockfile((f)) #define FUNLOCK(f) do { if (__need_unlock) __unlockfile((f)); } while (0) #define __STDIO_LOCK_INIT {0, 0} -#define __STDIO_LOCK_RESET(lock) do { (lock)->owner = 0; (lock)->waiters = NULL; } while (0) +#define __STDIO_LOCK_RESET(lock) do { (lock).owner = 0; (lock).waiters = NULL; } while (0) #elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) #define FFINALLOCK(f) ((f)->lock>=0 ? __lockfile((f)) : 0) #define FLOCK(f) int __need_unlock = ((f)->lock>=0 ? __lockfile((f)) : 0) #define FUNLOCK(f) do { if (__need_unlock) __unlockfile((f)); } while (0) #define __STDIO_LOCK_INIT -1 -#define __STDIO_LOCK_RESET(lock) do { (*(lock)) = -1; } while (0) +#define __STDIO_LOCK_RESET(lock) do { (lock) = -1; } while (0) #else // No locking needed. #define FFINALLOCK(f) ((void)(f)) diff --git a/libc-top-half/musl/src/stdio/ftrylockfile.c b/libc-top-half/musl/src/stdio/ftrylockfile.c index 18faaf13d..b983f2ba6 100644 --- a/libc-top-half/musl/src/stdio/ftrylockfile.c +++ b/libc-top-half/musl/src/stdio/ftrylockfile.c @@ -7,8 +7,8 @@ void __do_orphaned_stdio_locks() FILE *f; for (f=__pthread_self()->stdio_locks; f; f=f->next_locked) { #ifdef __wasi_cooperative_threads__ - f->lock->owner = 0; - __waitlist_wake_all(&f->lock->waiters); + f->lock.owner = 0; + __waitlist_wake_all(&f->lock.waiters); #else a_store(&f->lock, 0x40000000); #endif @@ -42,7 +42,7 @@ int ftrylockfile(FILE *f) #error "Unknown WASI version" #endif - if (f->lock->owner == self_tid) { + if (f->lock.owner == self_tid) { if (f->lockcount == LONG_MAX) return -1; f->lockcount++; @@ -50,10 +50,10 @@ int ftrylockfile(FILE *f) } // Try to acquire the lock - if (f->lock->owner != 0) + if (f->lock.owner != 0) return -1; - f->lock->owner = self_tid; + f->lock.owner = self_tid; f->lockcount = 1; return 0; } From 35b1ed9bc885b36e96c2c399617ac2ec775258a2 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 10:08:41 +0000 Subject: [PATCH 29/43] Pointer shenanigans --- libc-top-half/musl/src/stdio/__lockfile.c | 2 +- libc-top-half/musl/src/stdio/getc.h | 10 +++++----- libc-top-half/musl/src/stdio/putc.h | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libc-top-half/musl/src/stdio/__lockfile.c b/libc-top-half/musl/src/stdio/__lockfile.c index ed92e8a77..107d753c0 100644 --- a/libc-top-half/musl/src/stdio/__lockfile.c +++ b/libc-top-half/musl/src/stdio/__lockfile.c @@ -12,7 +12,7 @@ int __lockfile(FILE *f) #endif // Allow recursive locking - if (f->lock->owner == tid) + if (f->lock.owner == tid) return 0; STRONG_LOCK(f->lock); diff --git a/libc-top-half/musl/src/stdio/getc.h b/libc-top-half/musl/src/stdio/getc.h index 69babd42b..7502102dc 100644 --- a/libc-top-half/musl/src/stdio/getc.h +++ b/libc-top-half/musl/src/stdio/getc.h @@ -13,10 +13,10 @@ static int locking_getc(FILE *f) __unlockfile(f); return c; #else - if (a_cas(f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); + if (a_cas(&f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); int c = getc_unlocked(f); - if (a_swap(f->lock, 0) & MAYBE_WAITERS) - __wake(f->lock, 1, 1); + if (a_swap(&f->lock, 0) & MAYBE_WAITERS) + __wake(&f->lock, 1, 1); return c; #endif } @@ -25,11 +25,11 @@ static int locking_getc(FILE *f) static inline int do_getc(FILE *f) { #ifdef __wasi_cooperative_threads__ - if (f->lock->owner == wasip3_thread_index()) + if (f->lock.owner == wasip3_thread_index()) return getc_unlocked(f); return locking_getc(f); #elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - int l = *f->lock; + int l = f->lock; if (l < 0 || l && (l & ~MAYBE_WAITERS) == __pthread_self()->tid) return getc_unlocked(f); return locking_getc(f); diff --git a/libc-top-half/musl/src/stdio/putc.h b/libc-top-half/musl/src/stdio/putc.h index ee0b39e89..aae780ab3 100644 --- a/libc-top-half/musl/src/stdio/putc.h +++ b/libc-top-half/musl/src/stdio/putc.h @@ -13,10 +13,10 @@ static int locking_putc(int c, FILE *f) __unlockfile(f); return c; #else - if (a_cas(f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); + if (a_cas(&f->lock, 0, MAYBE_WAITERS-1)) __lockfile(f); c = putc_unlocked(c, f); - if (a_swap(f->lock, 0) & MAYBE_WAITERS) - __wake(f->lock, 1, 1); + if (a_swap(&f->lock, 0) & MAYBE_WAITERS) + __wake(&f->lock, 1, 1); return c; #endif } @@ -30,11 +30,11 @@ static inline int do_putc(int c, FILE *f) #else #error "Unknown WASI version" #endif - if (f->lock->owner == tid) + if (f->lock.owner == tid) return putc_unlocked(c, f); return locking_putc(c, f); #elif defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) - int l = *f->lock; + int l = f->lock; if (l < 0 || l && (l & ~MAYBE_WAITERS) == __pthread_self()->tid) return putc_unlocked(c, f); return locking_putc(c, f); From d8fb9a6d3d56412f0177a11b6bb2941ce9cd5277 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 10:11:11 +0000 Subject: [PATCH 30/43] Pointer shenanigans --- libc-top-half/musl/src/stdio/ftrylockfile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libc-top-half/musl/src/stdio/ftrylockfile.c b/libc-top-half/musl/src/stdio/ftrylockfile.c index b983f2ba6..482cd9ee0 100644 --- a/libc-top-half/musl/src/stdio/ftrylockfile.c +++ b/libc-top-half/musl/src/stdio/ftrylockfile.c @@ -62,15 +62,15 @@ int ftrylockfile(FILE *f) { pthread_t self = __pthread_self(); int tid = self->tid; - int owner = *f->lock; + int owner = f->lock; if ((owner & ~MAYBE_WAITERS) == tid) { if (f->lockcount == LONG_MAX) return -1; f->lockcount++; return 0; } - if (owner < 0) *f->lock = owner = 0; - if (owner || a_cas(f->lock, 0, tid)) + if (owner < 0) f->lock = owner = 0; + if (owner || a_cas(&f->lock, 0, tid)) return -1; __register_locked_file(f, self); return 0; From cb5f6a40e175a148d7631aa27c0ad7a684d5df45 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 10:16:40 +0000 Subject: [PATCH 31/43] More lock changes --- libc-top-half/musl/src/internal/pthread_impl.h | 2 +- libc-top-half/musl/src/thread/wasi-threads/pthread_create.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libc-top-half/musl/src/internal/pthread_impl.h b/libc-top-half/musl/src/internal/pthread_impl.h index 8b9bd7999..f0e615309 100644 --- a/libc-top-half/musl/src/internal/pthread_impl.h +++ b/libc-top-half/musl/src/internal/pthread_impl.h @@ -65,7 +65,7 @@ struct pthread { int h_errno_val; volatile int timer_id; locale_t locale; - volatile int killlock[1]; + DECLARE_WEAK_LOCK(killlock); char *dlerror_buf; void *stdio_locks; #ifdef __wasi_cooperative_threads__ diff --git a/libc-top-half/musl/src/thread/wasi-threads/pthread_create.c b/libc-top-half/musl/src/thread/wasi-threads/pthread_create.c index 879b48c1f..f6ff846cf 100644 --- a/libc-top-half/musl/src/thread/wasi-threads/pthread_create.c +++ b/libc-top-half/musl/src/thread/wasi-threads/pthread_create.c @@ -118,7 +118,7 @@ static void __pthread_exit(void *result) * any use past this point would have undefined behavior, but for * joinable threads it's a valid usage that must be handled. * Signals must be blocked since pthread_kill must be AS-safe. */ - LOCK(self->killlock); + WEAK_LOCK(self->killlock); /* The thread list lock must be AS-safe, and thus depends on * application signals being blocked above. */ @@ -129,7 +129,7 @@ static void __pthread_exit(void *result) * signal state to prepare for exit to call atexit handlers. */ if (self->next == self) { __tl_unlock(); - UNLOCK(self->killlock); + WEAK_UNLOCK(self->killlock); self->detach_state = state; #ifdef __wasilibc_unmodified_upstream __restore_sigs(&set); @@ -147,7 +147,7 @@ static void __pthread_exit(void *result) * remaining locks (except thread list) are held if we end up * resetting need_locks below. */ self->tid = 0; - UNLOCK(self->killlock); + WEAK_UNLOCK(self->killlock); #ifdef __wasilibc_unmodified_upstream /* Process robust list in userspace to handle non-pshared mutexes From cce6bc011ca4a1471f960d5578053f5d39d01723 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 10:55:12 +0000 Subject: [PATCH 32/43] Defined symbol changes --- expected/wasm32-wasip1-threads/defined-symbols.txt | 9 +++------ libc-bottom-half/sources/getcwd.c | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/expected/wasm32-wasip1-threads/defined-symbols.txt b/expected/wasm32-wasip1-threads/defined-symbols.txt index 4fb5d53fc..4eb71cb2a 100644 --- a/expected/wasm32-wasip1-threads/defined-symbols.txt +++ b/expected/wasm32-wasip1-threads/defined-symbols.txt @@ -15,8 +15,6 @@ __acquire_ptc __aio_close __asctime_r __assert_fail -__at_quick_exit_lockptr -__atexit_lockptr __c_dot_utf8 __c_dot_utf8_locale __c_locale @@ -81,6 +79,7 @@ __ftello __ftello_unlocked __funcs_on_exit __funcs_on_quick_exit +__futexwait __futimesat __fwritable __fwritex @@ -92,6 +91,7 @@ __getopt_msg __gmtime_r __hwcap __inet_aton +__inhibit_ptc __init_ssp __init_tp __intscan @@ -148,7 +148,6 @@ __libc_free __libc_malloc __loc_is_allocated __locale_lock -__locale_lockptr __localtime_r __lock __lockfile @@ -219,7 +218,6 @@ __pthread_tsd_size __putenv __qsort_r __rand48_step -__random_lockptr __reallocarray __register_locked_file __release_ptc @@ -248,7 +246,6 @@ __stdin_used __stdio_close __stdio_exit __stdio_exit_needed -__stdio_ofl_lockptr __stdio_read __stdio_seek __stdio_write @@ -308,6 +305,7 @@ __unlockfile __uselocale __utc __wait +__wake __wasi_args_get __wasi_args_sizes_get __wasi_clock_res_get @@ -359,7 +357,6 @@ __wasi_thread_start_C __wasilibc_access __wasilibc_cwd __wasilibc_cwd_lock -__wasilibc_cwd_unlock __wasilibc_deinitialize_environ __wasilibc_dttoif __wasilibc_enable_futex_busywait_on_current_thread diff --git a/libc-bottom-half/sources/getcwd.c b/libc-bottom-half/sources/getcwd.c index ee5723582..b5622695c 100644 --- a/libc-bottom-half/sources/getcwd.c +++ b/libc-bottom-half/sources/getcwd.c @@ -5,7 +5,7 @@ #include "lock.h" char *__wasilibc_cwd = "/"; -DECLARE_WEAK_LOCK(__wasilibc_cwd_lock, static); +DECLARE_WEAK_LOCK(__wasilibc_cwd_lock); char *getcwd(char *buf, size_t size) { From 53be6e50da14cf65e10de0065fe1382ec94e1838 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Thu, 12 Mar 2026 12:25:04 +0000 Subject: [PATCH 33/43] Bump test suite --- test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 97a4fe86a..99924fc5a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,7 +22,7 @@ message(STATUS "libc-test source directory: ${LIBC_TEST}") FetchContent_Declare( posix-testsuite GIT_REPOSITORY https://github.com/bytecodealliance/open-posix-test-suite - GIT_TAG 7cbbe794ddcfec55b071776ed84a5dfa31331db9 + GIT_TAG dc7c7d54fc4f6219bb4c7af348be2290335bf17e GIT_SHALLOW true ) FetchContent_MakeAvailable(posix-testsuite) @@ -37,7 +37,7 @@ if(NOT ENGINE OR ENGINE STREQUAL "") ba_download( wasmtime "https://github.com/bytecodealliance/wasmtime" - "v42.0.1" + "dev" ) ExternalProject_Get_Property(wasmtime SOURCE_DIR) set(ENGINE "${SOURCE_DIR}/wasmtime") From 6e3518a45b51b42bd1b74ffefffd0102498f2079 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 23 Mar 2026 16:02:11 +0000 Subject: [PATCH 34/43] Call compiler-rt --- CMakeLists.txt | 5 ++--- libc-bottom-half/sources/__wasm_init_task.s | 22 ++++++++----------- libc-top-half/CMakeLists.txt | 5 ++++- libc-top-half/musl/src/env/__init_tls.c | 7 ++---- libc-top-half/musl/src/internal/stdio_impl.h | 4 ++-- .../coop-threads/__wasi_coop_thread_start.s | 12 ++++------ 6 files changed, 23 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ebff722c6..5c42fead6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,8 +69,7 @@ elseif(TARGET_TRIPLE MATCHES "-wasip2$") set(SHARED ON) elseif(TARGET_TRIPLE MATCHES "-wasip3$") set(WASI p3) - # TODO: wasip3_thread_start.s also uses non-position-independent code. - set(SHARED OFF) + set(SHARED ON) else() message(FATAL_ERROR "Unknown WASI target triple: ${TARGET_TRIPLE}") endif() @@ -150,7 +149,7 @@ else() endif() set(wasip2-version 0.2.0) -set(wasip3-version 0.3.0-rc-2026-02-09) +set(wasip3-version 0.3.0-rc-2026-03-15) include(bindings) include(builtins) diff --git a/libc-bottom-half/sources/__wasm_init_task.s b/libc-bottom-half/sources/__wasm_init_task.s index c6411ba72..fcc61cc3b 100644 --- a/libc-bottom-half/sources/__wasm_init_task.s +++ b/libc-bottom-half/sources/__wasm_init_task.s @@ -8,12 +8,8 @@ .globaltype __tls_size, i32, immutable .globaltype __tls_align, i32, immutable - .functype __wasm_component_model_builtin_context_set_0 (i32) -> () - .import_module __wasm_component_model_builtin_context_set_0, "$root" - .import_name __wasm_component_model_builtin_context_set_0, "[context-set-0]" - .functype __wasm_component_model_builtin_context_set_1 (i32) -> () - .import_module __wasm_component_model_builtin_context_set_1, "$root" - .import_name __wasm_component_model_builtin_context_set_1, "[context-set-1]" + .functype __wasm_set_stack_pointer (i32) -> () + .functype __wasm_set_tls_base (i32) -> () .functype malloc (i32) -> (i32) .functype __copy_tls (i32) -> (i32) @@ -57,15 +53,15 @@ __wasm_init_task: .functype __wasm_init_task () -> () global.get __init_stack_pointer - call __wasm_component_model_builtin_context_set_0 + call __wasm_set_stack_pointer global.get __init_tls_base - call __wasm_component_model_builtin_context_set_1 + call __wasm_set_tls_base # Allocate a new TLS area call __allocate_aligned_tls call __copy_tls - call __wasm_component_model_builtin_context_set_1 + call __wasm_set_tls_base call __wasi_init_tp @@ -77,10 +73,10 @@ __wasm_init_async_task: # malloc and __init_tls may use the stack pointer and TLS base, so set those first # to the statically-allocated values used for synchronous tasks. global.get __init_stack_pointer - call __wasm_component_model_builtin_context_set_0 + call __wasm_set_stack_pointer global.get __init_tls_base - call __wasm_component_model_builtin_context_set_1 + call __wasm_set_tls_base # Allocate a new stack # Constant copied from __default_stacksize, TODO(wasip3) find a way @@ -88,12 +84,12 @@ __wasm_init_async_task: # i.e. a position-independent data reference. i32.const 131072 call malloc - call __wasm_component_model_builtin_context_set_0 + call __wasm_set_stack_pointer # Allocate a new TLS area call __allocate_aligned_tls call __copy_tls - call __wasm_component_model_builtin_context_set_1 + call __wasm_set_tls_base call __wasi_init_tp diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index 7e714b434..422c4361b 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -277,6 +277,9 @@ set(top_half_sources musl/src/thread/common/pthread_spin_destroy.c musl/src/thread/common/pthread_spin_init.c musl/src/thread/common/pthread_testcancel.c + musl/src/thread/common/mtx_timedlock.c + musl/src/thread/common/mtx_init.c + musl/src/thread/common/mtx_destroy.c musl/src/thread/common/thrd_sleep.c musl/src/time/__month_to_secs.c musl/src/time/__secs_to_tm.c @@ -486,7 +489,7 @@ elseif(WASI STREQUAL "p3") musl/src/thread/coop-threads/pthread_mutex_trylock.c musl/src/thread/coop-threads/pthread_mutex_unlock.c musl/src/thread/coop-threads/pthread_once.c - musl/src/thread/wasi-threads/pthread_rwlock_rdlock.c + musl/src/thread/coop-threads/pthread_rwlock_rdlock.c musl/src/thread/coop-threads/pthread_rwlock_timedrdlock.c musl/src/thread/coop-threads/pthread_rwlock_timedwrlock.c musl/src/thread/coop-threads/pthread_rwlock_tryrdlock.c diff --git a/libc-top-half/musl/src/env/__init_tls.c b/libc-top-half/musl/src/env/__init_tls.c index eca399302..54d9a0289 100644 --- a/libc-top-half/musl/src/env/__init_tls.c +++ b/libc-top-half/musl/src/env/__init_tls.c @@ -44,11 +44,8 @@ static inline unsigned char *get_stack_pointer() { unsigned char *sp; #ifdef __wasm_component_model_thread_context__ __asm__( - ".functype __wasm_component_model_builtin_context_get_0 () -> (i32)\n" - ".import_module __wasm_component_model_builtin_context_get_0, \"$root\"\n" - ".import_name __wasm_component_model_builtin_context_get_0, " - "\"[context-get-0]\"\n" - "call __wasm_component_model_builtin_context_get_0\n" + ".functype __wasm_get_stack_pointer () -> (i32)\n" + "call __wasm_get_stack_pointer\n" "local.set %0\n" : "=r"(sp)); #else diff --git a/libc-top-half/musl/src/internal/stdio_impl.h b/libc-top-half/musl/src/internal/stdio_impl.h index aaaa17151..64c476f16 100644 --- a/libc-top-half/musl/src/internal/stdio_impl.h +++ b/libc-top-half/musl/src/internal/stdio_impl.h @@ -83,8 +83,8 @@ extern hidden FILE *volatile __stdout_used; extern hidden FILE *volatile __stderr_used; #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) -hidden int __lockfile(FILE *); -hidden void __unlockfile(FILE *); +int __lockfile(FILE *); +void __unlockfile(FILE *); #endif hidden size_t __stdio_read(FILE *, unsigned char *, size_t); diff --git a/libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s b/libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s index 80348320a..62c386129 100644 --- a/libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s +++ b/libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s @@ -4,12 +4,8 @@ .globaltype __init_stack_pointer, i32 .functype __wasi_coop_thread_start_C (i32, i32) -> () - .functype __wasm_component_model_builtin_context_set_0 (i32) -> () - .import_module __wasm_component_model_builtin_context_set_0, "$root" - .import_name __wasm_component_model_builtin_context_set_0, "[context-set-0]" - .functype __wasm_component_model_builtin_context_set_1 (i32) -> () - .import_module __wasm_component_model_builtin_context_set_1, "$root" - .import_name __wasm_component_model_builtin_context_set_1, "[context-set-1]" + .functype __wasm_set_tls_base (i32) -> () + .functype __wasm_set_stack_pointer (i32) -> () .import_module __wasm_component_model_builtin_thread_index, "$root" .import_name __wasm_component_model_builtin_thread_index, "[thread-index]" .functype __wasm_component_model_builtin_thread_index () -> (i32) @@ -24,11 +20,11 @@ __wasi_coop_thread_start: # Set up the minimum C environment. local.get 0 # start_arg i32.load 0 # stack - call __wasm_component_model_builtin_context_set_0 + call __wasm_set_stack_pointer local.get 0 # start_arg i32.load 4 # tls_base - call __wasm_component_model_builtin_context_set_1 + call __wasm_set_tls_base # Make the C function do the rest of work. call __wasm_component_model_builtin_thread_index local.get 0 # start_arg From fd5840e1ba9d23cbf610abe99f5ff59a4f1bec0e Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 23 Mar 2026 16:24:50 +0000 Subject: [PATCH 35/43] Correct mtx cmake --- libc-top-half/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index 422c4361b..b56522644 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -277,9 +277,6 @@ set(top_half_sources musl/src/thread/common/pthread_spin_destroy.c musl/src/thread/common/pthread_spin_init.c musl/src/thread/common/pthread_testcancel.c - musl/src/thread/common/mtx_timedlock.c - musl/src/thread/common/mtx_init.c - musl/src/thread/common/mtx_destroy.c musl/src/thread/common/thrd_sleep.c musl/src/time/__month_to_secs.c musl/src/time/__secs_to_tm.c @@ -452,6 +449,9 @@ if (THREADS) musl/src/thread/wasi-threads/sem_wait.c musl/src/thread/wasi-threads/wasi_thread_start.s musl/src/thread/wasi-threads/__wasilibc_busywait.c + musl/src/thread/common/mtx_timedlock.c + musl/src/thread/common/mtx_init.c + musl/src/thread/common/mtx_destroy.c ) elseif(WASI STREQUAL "p3") # cooperative threads implementation for WASI Preview 3 @@ -511,7 +511,10 @@ elseif(WASI STREQUAL "p3") musl/src/thread/coop-threads/sem_post.c musl/src/thread/coop-threads/sem_timedwait.c musl/src/thread/coop-threads/sem_trywait.c - musl/src/thread/coop-threads/sem_wait.c) + musl/src/thread/coop-threads/sem_wait.c + musl/src/thread/common/mtx_timedlock.c + musl/src/thread/common/mtx_init.c + musl/src/thread/common/mtx_destroy.c) else() # pthreads stubs for single-threaded environment list(APPEND top_half_sources From ddd75e1c81655364714bc6fefc6e8ac94903411b Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 1 Jun 2026 17:46:03 +0100 Subject: [PATCH 36/43] Update --- libc-bottom-half/crt/crt1-command.c | 2 +- libc-bottom-half/crt/crt1-reactor.c | 2 +- libc-bottom-half/sources/__wasm_init_task.s | 4 +- libc-top-half/CMakeLists.txt | 1 + libc-top-half/musl/src/env/__init_tls.c | 7 +- .../coop-threads/__libcall_thread_context.s | 45 ++++ .../src/thread/coop-threads/pthread_create.c | 1 + test/CMakeLists.txt | 4 + test/socket-test.cmake | 4 +- .../wasi-cli-0.3.0-rc-2026-03-15/package.wit | 184 --------------- .../package.wit | 60 ----- .../package.wit | 191 ---------------- .../wasi-http-0.3.0-rc-2026-03-15/package.wit | 124 ---------- .../package.wit | 48 ---- .../package.wit | 213 ------------------ 15 files changed, 62 insertions(+), 828 deletions(-) create mode 100644 libc-top-half/musl/src/thread/coop-threads/__libcall_thread_context.s diff --git a/libc-bottom-half/crt/crt1-command.c b/libc-bottom-half/crt/crt1-command.c index da678bc0d..85a405b7a 100644 --- a/libc-bottom-half/crt/crt1-command.c +++ b/libc-bottom-half/crt/crt1-command.c @@ -9,7 +9,7 @@ extern void __wasm_call_ctors(void); extern int __main_void(void); extern void __wasm_call_dtors(void); -#ifdef __wasm_component_model_thread_context__ +#ifdef __wasm_libcall_thread_context__ // Force __wasm_init_task and __wasm_init_async_task to be linked in for wasip3 extern void __wasm_init_task(void); extern void __wasm_init_async_task(void); diff --git a/libc-bottom-half/crt/crt1-reactor.c b/libc-bottom-half/crt/crt1-reactor.c index d002f0104..f77fdf49f 100644 --- a/libc-bottom-half/crt/crt1-reactor.c +++ b/libc-bottom-half/crt/crt1-reactor.c @@ -4,7 +4,7 @@ extern void __wasi_init_tp(void); extern void __wasm_call_ctors(void); -#ifdef __wasm_component_model_thread_context__ +#ifdef __wasm_libcall_thread_context__ // Force __wasm_init_task and __wasm_init_async_task to be linked in for wasip3 extern void __wasm_init_task(void); extern void __wasm_init_async_task(void); diff --git a/libc-bottom-half/sources/__wasm_init_task.s b/libc-bottom-half/sources/__wasm_init_task.s index fcc61cc3b..8b52ef0ae 100644 --- a/libc-bottom-half/sources/__wasm_init_task.s +++ b/libc-bottom-half/sources/__wasm_init_task.s @@ -3,8 +3,8 @@ .export_name __wasm_init_task, __wasm_init_task .export_name __wasm_init_async_task, __wasm_init_async_task - .globaltype __init_stack_pointer, i32 - .globaltype __init_tls_base, i32 + .globaltype __init_stack_pointer, i32, immutable + .globaltype __init_tls_base, i32, immutable .globaltype __tls_size, i32, immutable .globaltype __tls_align, i32, immutable diff --git a/libc-top-half/CMakeLists.txt b/libc-top-half/CMakeLists.txt index b56522644..6faf0ee27 100644 --- a/libc-top-half/CMakeLists.txt +++ b/libc-top-half/CMakeLists.txt @@ -460,6 +460,7 @@ elseif(WASI STREQUAL "p3") musl/src/stdio/flockfile.c musl/src/stdio/ftrylockfile.c musl/src/stdio/funlockfile.c + musl/src/thread/coop-threads/__libcall_thread_context.s musl/src/thread/coop-threads/__lock.c musl/src/thread/coop-threads/__wait.c musl/src/thread/coop-threads/__wasi_coop_thread_start.s diff --git a/libc-top-half/musl/src/env/__init_tls.c b/libc-top-half/musl/src/env/__init_tls.c index 54d9a0289..58308609f 100644 --- a/libc-top-half/musl/src/env/__init_tls.c +++ b/libc-top-half/musl/src/env/__init_tls.c @@ -42,7 +42,7 @@ struct stack_bounds { static inline unsigned char *get_stack_pointer() { unsigned char *sp; -#ifdef __wasm_component_model_thread_context__ +#ifdef __wasm_libcall_thread_context__ __asm__( ".functype __wasm_get_stack_pointer () -> (i32)\n" "call __wasm_get_stack_pointer\n" @@ -197,7 +197,10 @@ void *__copy_tls(unsigned char *mem) mem += tls_align; mem -= (uintptr_t)mem & (tls_align-1); __wasm_init_tls(mem); - #ifndef __wasm_component_model_thread_context__ + #ifdef __wasm_libcall_thread_context__ + void __wasm_set_tls_base(volatile void *ptr); + __wasm_set_tls_base(tls_base); + #else __asm__("local.get %0\n" "global.set __tls_base\n" :: "r"(tls_base)); diff --git a/libc-top-half/musl/src/thread/coop-threads/__libcall_thread_context.s b/libc-top-half/musl/src/thread/coop-threads/__libcall_thread_context.s new file mode 100644 index 000000000..4959746b4 --- /dev/null +++ b/libc-top-half/musl/src/thread/coop-threads/__libcall_thread_context.s @@ -0,0 +1,45 @@ +# LLVM emits calls to the following functions when the libcall-thread-context feature is enabled (default on WASIp3) + + .globl __wasm_get_stack_pointer + .type __wasm_get_stack_pointer,@function + .globl __wasm_set_stack_pointer + .type __wasm_set_stack_pointer,@function + .globl __wasm_get_tls_base + .type __wasm_get_tls_base,@function + .globl __wasm_set_tls_base + .type __wasm_set_tls_base,@function + + .functype __wasm_component_model_builtin_context_get_0 () -> (i32) + .import_module __wasm_component_model_builtin_context_get_0, "$root" + .import_name __wasm_component_model_builtin_context_get_0, "[context-get-0]" + .functype __wasm_component_model_builtin_context_set_0 (i32) -> () + .import_module __wasm_component_model_builtin_context_set_0, "$root" + .import_name __wasm_component_model_builtin_context_set_0, "[context-set-0]" + .functype __wasm_component_model_builtin_context_get_1 () -> (i32) + .import_module __wasm_component_model_builtin_context_get_1, "$root" + .import_name __wasm_component_model_builtin_context_get_1, "[context-get-1]" + .functype __wasm_component_model_builtin_context_set_1 (i32) -> () + .import_module __wasm_component_model_builtin_context_set_1, "$root" + .import_name __wasm_component_model_builtin_context_set_1, "[context-set-1]" + +__wasm_get_stack_pointer: + .functype __wasm_get_stack_pointer () -> (i32) + call __wasm_component_model_builtin_context_get_0 + end_function + +__wasm_set_stack_pointer: + .functype __wasm_set_stack_pointer (i32) -> () + local.get 0 + call __wasm_component_model_builtin_context_set_0 + end_function + +__wasm_get_tls_base: + .functype __wasm_get_tls_base () -> (i32) + call __wasm_component_model_builtin_context_get_1 + end_function + +__wasm_set_tls_base: + .functype __wasm_set_tls_base (i32) -> () + local.get 0 + call __wasm_component_model_builtin_context_set_1 + end_function diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_create.c b/libc-top-half/musl/src/thread/coop-threads/pthread_create.c index ff81bcd45..a5692cb19 100644 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_create.c +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_create.c @@ -217,6 +217,7 @@ int __pthread_create(pthread_t *restrict res, process_map_base_deferred_free(); __tl_unlock(); map = malloc(size); + printf("pthread_create: map=%p size=%zu\n", map, size); if (!map) goto fail; tsd = map + size - __pthread_tsd_size; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8759f3305..f0485047c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -63,6 +63,9 @@ function(add_wasilibc_flags target) target_link_options(${target} PRIVATE -pthread -Wl,--import-memory,--export-memory,--shared-memory,--max-memory=1073741824) endif() + if (WASI STREQUAL "p3") + target_link_options(${target} PRIVATE -pthread) + endif() endfunction() add_library(libc_test_support STATIC @@ -148,6 +151,7 @@ function(register_test test_name executable_name) if (WASI STREQUAL "p3") list(APPEND wasmtime_args --wasm component-model-async) list(APPEND wasmtime_args --wasm component-model-threading) + list(APPEND wasmtime_args --wasm shared-memory) list(APPEND wasmtime_args --wasi p3) endif() if (arg_SETJMP) diff --git a/test/socket-test.cmake b/test/socket-test.cmake index 91bd40a5f..37a76d62c 100644 --- a/test/socket-test.cmake +++ b/test/socket-test.cmake @@ -36,13 +36,13 @@ read port # read the first line of stdin from the previous process echo $port # forward this line to the next process, or out to cmake itself exec 2>&1 # close our stdout and replace it with stderr cat <&0 & # forward the rest of stdin to stderr so it shows up in cmake -exec ${ENGINE} -Wcomponent-model-async -Sp3,inherit-network ${CLIENT} \"$port\" +exec ${ENGINE} -Wcomponent-model-async -Wcomponent-model-threading -Sp3,inherit-network ${CLIENT} \"$port\" ") list(APPEND CLIENTS COMMAND bash -c ${client_script}) endforeach() execute_process( - COMMAND ${ENGINE} -Wcomponent-model-async -Sp3,inherit-network ${SERVER} + COMMAND ${ENGINE} -Wcomponent-model-async -Wcomponent-model-threading -Sp3,inherit-network ${SERVER} ${CLIENTS} TIMEOUT 5 COMMAND_ERROR_IS_FATAL ANY diff --git a/wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit b/wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit index 67789f5f9..8ba52c5cd 100644 --- a/wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit +++ b/wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit @@ -1,12 +1,6 @@ -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit -package wasi:cli@0.3.0-rc-2026-02-09; - -@since(version = 0.3.0-rc-2026-02-09) -======== package wasi:cli@0.3.0-rc-2026-03-15; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit interface environment { /// Get the POSIX-style environment variables. /// @@ -16,33 +10,15 @@ interface environment { /// Morally, these are a value import, but until value imports are available /// in the component model, this import function should return the same /// values each time it is called. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-environment: func() -> list>; - - /// Get the POSIX-style arguments to the program. - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-environment: func() -> list>; /// Get the POSIX-style arguments to the program. @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit get-arguments: func() -> list; /// Return a path that programs should use as their initial current working /// directory, interpreting `.` as shorthand for this. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-initial-cwd: func() -> option; -} - -@since(version = 0.3.0-rc-2026-02-09) -interface exit { - /// Exit the current instance and any linked instances. - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-initial-cwd: func() -> option; } @@ -51,7 +27,6 @@ interface exit { interface exit { /// Exit the current instance and any linked instances. @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit exit: func(status: result); /// Exit the current instance and any linked instances, reporting the @@ -66,18 +41,6 @@ interface exit { exit-with-code: func(status-code: u8); } -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -interface run { - /// Run the program. - @since(version = 0.3.0-rc-2026-02-09) - run: async func() -> result; -} - -@since(version = 0.3.0-rc-2026-02-09) -interface types { - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) interface run { /// Run the program. @@ -88,7 +51,6 @@ interface run { @since(version = 0.3.0-rc-2026-03-15) interface types { @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit enum error-code { /// Input/output error io, @@ -99,11 +61,7 @@ interface types { } } -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit interface stdin { use types.{error-code}; @@ -120,19 +78,11 @@ interface stdin { /// /// Multiple streams may be active at the same time. The behavior of concurrent /// reads is implementation-specific. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - read-via-stream: func() -> tuple, future>>; -} - -@since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) read-via-stream: func() -> tuple, future>>; } @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit interface stdout { use types.{error-code}; @@ -144,19 +94,11 @@ interface stdout { /// /// Otherwise if there is an error the readable end of the stream will be /// dropped and this function will return an error-code. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - write-via-stream: func(data: stream) -> future>; -} - -@since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) write-via-stream: func(data: stream) -> future>; } @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit interface stderr { use types.{error-code}; @@ -168,11 +110,7 @@ interface stderr { /// /// Otherwise if there is an error the readable end of the stream will be /// dropped and this function will return an error-code. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit write-via-stream: func(data: stream) -> future>; } @@ -181,17 +119,10 @@ interface stderr { /// In the future, this may include functions for disabling echoing, /// disabling input buffering so that keyboard events are sent through /// immediately, querying supported features, and so on. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -interface terminal-input { - /// The input side of a terminal. - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) interface terminal-input { /// The input side of a terminal. @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit resource terminal-input; } @@ -200,162 +131,48 @@ interface terminal-input { /// In the future, this may include functions for querying the terminal /// size, being notified of terminal size changes, querying supported /// features, and so on. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -interface terminal-output { - /// The output side of a terminal. - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) interface terminal-output { /// The output side of a terminal. @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit resource terminal-output; } /// An interface providing an optional `terminal-input` for stdin as a /// link-time authority. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -interface terminal-stdin { - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) interface terminal-stdin { @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit use terminal-input.{terminal-input}; /// If stdin is connected to a terminal, return a `terminal-input` handle /// allowing further interaction with it. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit get-terminal-stdin: func() -> option; } /// An interface providing an optional `terminal-output` for stdout as a /// link-time authority. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -interface terminal-stdout { - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) interface terminal-stdout { @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit use terminal-output.{terminal-output}; /// If stdout is connected to a terminal, return a `terminal-output` handle /// allowing further interaction with it. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit get-terminal-stdout: func() -> option; } /// An interface providing an optional `terminal-output` for stderr as a /// link-time authority. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -interface terminal-stderr { - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) interface terminal-stderr { @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit use terminal-output.{terminal-output}; /// If stderr is connected to a terminal, return a `terminal-output` handle /// allowing further interaction with it. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-terminal-stderr: func() -> option; -} - -@since(version = 0.3.0-rc-2026-02-09) -world imports { - @since(version = 0.3.0-rc-2026-02-09) - import environment; - @since(version = 0.3.0-rc-2026-02-09) - import exit; - @since(version = 0.3.0-rc-2026-02-09) - import types; - @since(version = 0.3.0-rc-2026-02-09) - import stdin; - @since(version = 0.3.0-rc-2026-02-09) - import stdout; - @since(version = 0.3.0-rc-2026-02-09) - import stderr; - @since(version = 0.3.0-rc-2026-02-09) - import terminal-input; - @since(version = 0.3.0-rc-2026-02-09) - import terminal-output; - @since(version = 0.3.0-rc-2026-02-09) - import terminal-stdin; - @since(version = 0.3.0-rc-2026-02-09) - import terminal-stdout; - @since(version = 0.3.0-rc-2026-02-09) - import terminal-stderr; - import wasi:clocks/types@0.3.0-rc-2026-02-09; - import wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09; - import wasi:clocks/system-clock@0.3.0-rc-2026-02-09; - @unstable(feature = clocks-timezone) - import wasi:clocks/timezone@0.3.0-rc-2026-02-09; - import wasi:filesystem/types@0.3.0-rc-2026-02-09; - import wasi:filesystem/preopens@0.3.0-rc-2026-02-09; - import wasi:sockets/types@0.3.0-rc-2026-02-09; - import wasi:sockets/ip-name-lookup@0.3.0-rc-2026-02-09; - import wasi:random/random@0.3.0-rc-2026-02-09; - import wasi:random/insecure@0.3.0-rc-2026-02-09; - import wasi:random/insecure-seed@0.3.0-rc-2026-02-09; -} -@since(version = 0.3.0-rc-2026-02-09) -world command { - @since(version = 0.3.0-rc-2026-02-09) - import environment; - @since(version = 0.3.0-rc-2026-02-09) - import exit; - @since(version = 0.3.0-rc-2026-02-09) - import types; - @since(version = 0.3.0-rc-2026-02-09) - import stdin; - @since(version = 0.3.0-rc-2026-02-09) - import stdout; - @since(version = 0.3.0-rc-2026-02-09) - import stderr; - @since(version = 0.3.0-rc-2026-02-09) - import terminal-input; - @since(version = 0.3.0-rc-2026-02-09) - import terminal-output; - @since(version = 0.3.0-rc-2026-02-09) - import terminal-stdin; - @since(version = 0.3.0-rc-2026-02-09) - import terminal-stdout; - @since(version = 0.3.0-rc-2026-02-09) - import terminal-stderr; - import wasi:clocks/types@0.3.0-rc-2026-02-09; - import wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09; - import wasi:clocks/system-clock@0.3.0-rc-2026-02-09; - @unstable(feature = clocks-timezone) - import wasi:clocks/timezone@0.3.0-rc-2026-02-09; - import wasi:filesystem/types@0.3.0-rc-2026-02-09; - import wasi:filesystem/preopens@0.3.0-rc-2026-02-09; - import wasi:sockets/types@0.3.0-rc-2026-02-09; - import wasi:sockets/ip-name-lookup@0.3.0-rc-2026-02-09; - import wasi:random/random@0.3.0-rc-2026-02-09; - import wasi:random/insecure@0.3.0-rc-2026-02-09; - import wasi:random/insecure-seed@0.3.0-rc-2026-02-09; - - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-terminal-stderr: func() -> option; } @@ -435,6 +252,5 @@ world command { import wasi:random/insecure-seed@0.3.0-rc-2026-03-15; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-cli-0.3.0-rc-2026-03-15/package.wit export run; } diff --git a/wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit b/wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit index 51bd6f4aa..19fc4bcd5 100644 --- a/wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit +++ b/wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit @@ -1,12 +1,3 @@ -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit -package wasi:clocks@0.3.0-rc-2026-02-09; - -/// This interface common types used throughout wasi:clocks. -@since(version = 0.3.0-rc-2026-02-09) -interface types { - /// A duration of time, in nanoseconds. - @since(version = 0.3.0-rc-2026-02-09) -======== package wasi:clocks@0.3.0-rc-2026-03-15; /// This interface common types used throughout wasi:clocks. @@ -14,7 +5,6 @@ package wasi:clocks@0.3.0-rc-2026-03-15; interface types { /// A duration of time, in nanoseconds. @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit type duration = u64; } @@ -26,22 +16,14 @@ interface types { /// /// A monotonic clock is a clock which has an unspecified initial value, and /// successive reads of the clock will produce non-decreasing values. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit interface monotonic-clock { use types.{duration}; /// A mark on a monotonic clock is a number of nanoseconds since an /// unspecified initial value, and can only be compared to instances from /// the same monotonic-clock. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit type mark = u64; /// Read the current value of the clock. @@ -53,26 +35,11 @@ interface monotonic-clock { /// the value of the clock in a `mark`. Consequently, implementations /// should ensure that the starting time is low enough to avoid the /// possibility of overflow in practice. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit now: func() -> mark; /// Query the resolution of the clock. Returns the duration of time /// corresponding to a clock tick. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-resolution: func() -> duration; - - /// Wait until the specified mark has occurred. - @since(version = 0.3.0-rc-2026-02-09) - wait-until: async func(when: mark); - - /// Wait for the specified duration to elapse. - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-resolution: func() -> duration; @@ -82,7 +49,6 @@ interface monotonic-clock { /// Wait for the specified duration to elapse. @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit wait-for: async func(how-long: duration); } @@ -96,11 +62,7 @@ interface monotonic-clock { /// monotonic, making it unsuitable for measuring elapsed time. /// /// It is intended for reporting the current date and time for humans. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit interface system-clock { use types.{duration}; @@ -120,11 +82,7 @@ interface system-clock { /// /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit record instant { seconds: s64, nanoseconds: u32, @@ -136,20 +94,12 @@ interface system-clock { /// will not necessarily produce a sequence of non-decreasing values. /// /// The nanoseconds field of the output is always less than 1000000000. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit now: func() -> instant; /// Query the resolution of the clock. Returns the smallest duration of time /// that the implementation permits distinguishing. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit get-resolution: func() -> duration; } @@ -198,15 +148,6 @@ interface timezone { to-debug-string: func() -> string; } -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -world imports { - @since(version = 0.3.0-rc-2026-02-09) - import types; - @since(version = 0.3.0-rc-2026-02-09) - import monotonic-clock; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) world imports { @since(version = 0.3.0-rc-2026-03-15) @@ -214,7 +155,6 @@ world imports { @since(version = 0.3.0-rc-2026-03-15) import monotonic-clock; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-clocks-0.3.0-rc-2026-03-15/package.wit import system-clock; @unstable(feature = clocks-timezone) import timezone; diff --git a/wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit b/wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit index 330c0cfba..697681f30 100644 --- a/wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit +++ b/wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit @@ -1,8 +1,4 @@ -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit -package wasi:filesystem@0.3.0-rc-2026-02-09; -======== package wasi:filesystem@0.3.0-rc-2026-03-15; ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit /// WASI filesystem is a filesystem API primarily intended to let users run WASI /// programs that access their files on their existing filesystems, without @@ -39,15 +35,6 @@ package wasi:filesystem@0.3.0-rc-2026-03-15; /// store or a database instead. /// /// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -interface types { - @since(version = 0.3.0-rc-2026-02-09) - use wasi:clocks/system-clock@0.3.0-rc-2026-02-09.{instant}; - - /// File size or length of a region within a file. - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) interface types { @since(version = 0.3.0-rc-2026-03-15) @@ -55,22 +42,13 @@ interface types { /// File size or length of a region within a file. @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit type filesize = u64; /// The type of a filesystem object referenced by a descriptor. /// /// Note: This was called `filetype` in earlier versions of WASI. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - enum descriptor-type { - /// The type of the descriptor or file is unknown or is different from - /// any of the other types specified. - unknown, -======== @since(version = 0.3.0-rc-2026-03-15) variant descriptor-type { ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit /// The descriptor refers to a block device inode. block-device, /// The descriptor refers to a character device inode. @@ -93,11 +71,7 @@ interface types { /// Descriptor flags. /// /// Note: This was called `fdflags` in earlier versions of WASI. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit flags descriptor-flags { /// Read mode: Data can be read. read, @@ -139,11 +113,7 @@ interface types { } /// Flags determining the method of how paths are resolved. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit flags path-flags { /// As long as the resolved path corresponds to a symbolic link, it is /// expanded. @@ -151,11 +121,7 @@ interface types { } /// Open flags used by `open-at`. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit flags open-flags { /// Create file if it does not exist, similar to `O_CREAT` in POSIX. create, @@ -168,21 +134,13 @@ interface types { } /// Number of hard links to an inode. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit type link-count = u64; /// File attributes. /// /// Note: This was called `filestat` in earlier versions of WASI. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit record descriptor-stat { /// File type. %type: descriptor-type, @@ -209,11 +167,7 @@ interface types { } /// When setting a timestamp, this gives the value to set it to. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit variant new-timestamp { /// Leave the timestamp set to its previous value. no-change, @@ -225,11 +179,7 @@ interface types { } /// A directory entry. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit record directory-entry { /// The type of the file referred to by this directory entry. %type: descriptor-type, @@ -241,13 +191,8 @@ interface types { /// Not all of these error codes are returned by the functions provided by this /// API; some are used in higher-level library layers, and others are provided /// merely for alignment with POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - enum error-code { -======== @since(version = 0.3.0-rc-2026-03-15) variant error-code { ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit /// Permission denied, similar to `EACCES` in POSIX. access, /// Connection already in progress, similar to `EALREADY` in POSIX. @@ -327,11 +272,7 @@ interface types { } /// File or memory access pattern advisory information. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit enum advice { /// The application has no advice to give on its behavior with respect /// to the specified data. @@ -355,11 +296,7 @@ interface types { /// A 128-bit hash value, split into parts because wasm doesn't have a /// 128-bit integer type. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit record metadata-hash-value { /// 64 bits of a 128-bit hash value. lower: u64, @@ -370,11 +307,7 @@ interface types { /// A descriptor is a reference to a filesystem object, which may be a file, /// directory, named pipe, special file, or other object on which filesystem /// calls may be made. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit resource descriptor { /// Return a stream for reading from a file. /// @@ -392,11 +325,7 @@ interface types { /// resolves to `err` with an `error-code`. /// /// Note: This is similar to `pread` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit read-via-stream: func(offset: filesize) -> tuple, future>>; /// Return a stream for writing to a file, if available. /// @@ -410,11 +339,7 @@ interface types { /// written or an error is encountered. /// /// Note: This is similar to `pwrite` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit write-via-stream: func(data: stream, offset: filesize) -> future>; /// Return a stream for appending to a file, if available. /// @@ -424,20 +349,12 @@ interface types { /// written or an error is encountered. /// /// Note: This is similar to `write` with `O_APPEND` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit append-via-stream: func(data: stream) -> future>; /// Provide file advisory information on a descriptor. /// /// This is similar to `posix_fadvise` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit advise: async func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>; /// Synchronize the data of a file to disk. /// @@ -445,11 +362,7 @@ interface types { /// opened for writing. /// /// Note: This is similar to `fdatasync` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit sync-data: async func() -> result<_, error-code>; /// Get flags associated with a descriptor. /// @@ -457,11 +370,7 @@ interface types { /// /// Note: This returns the value that was the `fs_flags` value returned /// from `fdstat_get` in earlier versions of WASI. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit get-flags: async func() -> result; /// Get the dynamic type of a descriptor. /// @@ -473,32 +382,20 @@ interface types { /// /// Note: This returns the value that was the `fs_filetype` value returned /// from `fdstat_get` in earlier versions of WASI. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit get-type: async func() -> result; /// Adjust the size of an open file. If this increases the file's size, the /// extra bytes are filled with zeros. /// /// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit set-size: async func(size: filesize) -> result<_, error-code>; /// Adjust the timestamps of an open file or directory. /// /// Note: This is similar to `futimens` in POSIX. /// /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit set-times: async func(data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; /// Read directory entries from a directory. /// @@ -512,11 +409,7 @@ interface types { /// /// This function returns a future, which will resolve to an error code if /// reading full contents of the directory fails. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit read-directory: func() -> tuple, future>>; /// Synchronize the data and metadata of a file to disk. /// @@ -524,20 +417,12 @@ interface types { /// opened for writing. /// /// Note: This is similar to `fsync` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit sync: async func() -> result<_, error-code>; /// Create a directory. /// /// Note: This is similar to `mkdirat` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit create-directory-at: async func(path: string) -> result<_, error-code>; /// Return the attributes of an open file or directory. /// @@ -548,11 +433,7 @@ interface types { /// modified, use `metadata-hash`. /// /// Note: This was called `fd_filestat_get` in earlier versions of WASI. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit stat: async func() -> result; /// Return the attributes of a file or directory. /// @@ -561,11 +442,7 @@ interface types { /// discussion of alternatives. /// /// Note: This was called `path_filestat_get` in earlier versions of WASI. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit stat-at: async func(path-flags: path-flags, path: string) -> result; /// Adjust the timestamps of a file or directory. /// @@ -573,11 +450,7 @@ interface types { /// /// Note: This was called `path_filestat_set_times` in earlier versions of /// WASI. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit set-times-at: async func(path-flags: path-flags, path: string, data-access-timestamp: new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>; /// Create a hard link. /// @@ -586,11 +459,7 @@ interface types { /// `error-code::not-permitted` if the old path is not a file. /// /// Note: This is similar to `linkat` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit link-at: async func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; /// Open a file or directory. /// @@ -604,11 +473,7 @@ interface types { /// `error-code::read-only`. /// /// Note: This is similar to `openat` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit open-at: async func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result; /// Read the contents of a symbolic link. /// @@ -616,31 +481,19 @@ interface types { /// filesystem, this function fails with `error-code::not-permitted`. /// /// Note: This is similar to `readlinkat` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit readlink-at: async func(path: string) -> result; /// Remove a directory. /// /// Return `error-code::not-empty` if the directory is not empty. /// /// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit remove-directory-at: async func(path: string) -> result<_, error-code>; /// Rename a filesystem object. /// /// Note: This is similar to `renameat` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit rename-at: async func(old-path: string, new-descriptor: borrow, new-path: string) -> result<_, error-code>; /// Create a symbolic link (also known as a "symlink"). /// @@ -648,15 +501,6 @@ interface types { /// `error-code::not-permitted`. /// /// Note: This is similar to `symlinkat` in POSIX. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - symlink-at: async func(old-path: string, new-path: string) -> result<_, error-code>; - /// Unlink a filesystem object that is not a directory. - /// - /// Return `error-code::is-directory` if the path refers to a directory. - /// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) symlink-at: async func(old-path: string, new-path: string) -> result<_, error-code>; /// Unlink a filesystem object that is not a directory. @@ -669,7 +513,6 @@ interface types { /// `error-code::is-directory` may be returned instead of the /// POSIX-specified `error-code::not-permitted`. @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit unlink-file-at: async func(path: string) -> result<_, error-code>; /// Test whether two descriptors refer to the same filesystem object. /// @@ -677,11 +520,7 @@ interface types { /// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. /// wasi-filesystem does not expose device and inode numbers, so this function /// may be used instead. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit is-same-object: async func(other: borrow) -> bool; /// Return a hash of the metadata associated with a filesystem object referred /// to by a descriptor. @@ -702,46 +541,17 @@ interface types { /// computed hash. /// /// However, none of these is required. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit metadata-hash: async func() -> result; /// Return a hash of the metadata associated with a filesystem object referred /// to by a directory descriptor and a relative path. /// /// This performs the same hash computation as `metadata-hash`. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit metadata-hash-at: async func(path-flags: path-flags, path: string) -> result; } } -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -interface preopens { - @since(version = 0.3.0-rc-2026-02-09) - use types.{descriptor}; - - /// Return the set of preopened directories, and their paths. - @since(version = 0.3.0-rc-2026-02-09) - get-directories: func() -> list>; -} - -@since(version = 0.3.0-rc-2026-02-09) -world imports { - @since(version = 0.3.0-rc-2026-02-09) - import wasi:clocks/types@0.3.0-rc-2026-02-09; - @since(version = 0.3.0-rc-2026-02-09) - import wasi:clocks/system-clock@0.3.0-rc-2026-02-09; - @since(version = 0.3.0-rc-2026-02-09) - import types; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) interface preopens { @since(version = 0.3.0-rc-2026-03-15) @@ -761,6 +571,5 @@ world imports { @since(version = 0.3.0-rc-2026-03-15) import types; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-filesystem-0.3.0-rc-2026-03-15/package.wit import preopens; } diff --git a/wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit b/wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit index 9cda567f0..c1c1e68e7 100644 --- a/wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit +++ b/wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit @@ -1,15 +1,3 @@ -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit -package wasi:http@0.3.0-rc-2026-02-09; - -/// This interface defines all of the types and methods for implementing HTTP -/// Requests and Responses, as well as their headers, trailers, and bodies. -@since(version = 0.3.0-rc-2026-02-09) -interface types { - use wasi:clocks/types@0.3.0-rc-2026-02-09.{duration}; - - /// This type corresponds to HTTP standard Methods. - @since(version = 0.3.0-rc-2026-02-09) -======== package wasi:http@0.3.0-rc-2026-03-15; /// This interface defines all of the types and methods for implementing HTTP @@ -20,7 +8,6 @@ interface types { /// This type corresponds to HTTP standard Methods. @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit variant method { get, head, @@ -35,11 +22,7 @@ interface types { } /// This type corresponds to HTTP standard Related Schemes. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit variant scheme { HTTP, HTTPS, @@ -47,33 +30,21 @@ interface types { } /// Defines the case payload type for `DNS-error` above: -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit record DNS-error-payload { rcode: option, info-code: option, } /// Defines the case payload type for `TLS-alert-received` above: -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit record TLS-alert-received-payload { alert-id: option, alert-message: option, } /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit record field-size-payload { field-name: option, field-size: option, @@ -81,11 +52,7 @@ interface types { /// These cases are inspired by the IANA HTTP Proxy Error Types: /// -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit variant error-code { DNS-timeout, DNS-error(DNS-error-payload), @@ -135,11 +102,7 @@ interface types { /// This type enumerates the different kinds of errors that may occur when /// setting or appending to a `fields` resource. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit variant header-error { /// This error indicates that a `field-name` or `field-value` was /// syntactically invalid when used with an operation that sets headers in a @@ -167,11 +130,7 @@ interface types { /// This type enumerates the different kinds of errors that may occur when /// setting fields of a `request-options` resource. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit variant request-options-error { /// Indicates the specified field is not supported by this implementation. not-supported, @@ -191,21 +150,13 @@ interface types { /// /// Field names should always be treated as case insensitive by the `fields` /// resource for the purposes of equality checking. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit type field-name = string; /// Field values should always be ASCII strings. However, in /// reality, HTTP implementations often have to interpret malformed values, /// so they are provided as a list of bytes. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit type field-value = list; /// This following block defines the `fields` resource which corresponds to @@ -223,15 +174,11 @@ interface types { /// original casing used to construct or mutate the `fields` resource. The `fields` /// resource should use that original casing when serializing the fields for /// transport or when returning them from a method. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== /// /// Implementations may impose limits on individual field values and on total /// aggregate field section size. Operations that would exceed these limits /// fail with `header-error.size-exceeded` @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit resource fields { /// Construct an empty HTTP Fields. /// @@ -307,17 +254,6 @@ interface types { } /// Headers is an alias for Fields. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - type headers = fields; - - /// Trailers is an alias for Fields. - @since(version = 0.3.0-rc-2026-02-09) - type trailers = fields; - - /// Represents an HTTP Request. - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) type headers = fields; @@ -327,7 +263,6 @@ interface types { /// Represents an HTTP Request. @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit resource request { /// Construct a new `request` with a default `method` of `GET`, and /// `none` values for `path-with-query`, `scheme`, and `authority`. @@ -414,11 +349,7 @@ interface types { /// /// These timeouts are separate from any the user may use to bound an /// asynchronous call. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit resource request-options { /// Construct a default `request-options` value. constructor(); @@ -447,19 +378,11 @@ interface types { } /// This type corresponds to the HTTP standard Status Code. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - type status-code = u16; - - /// Represents an HTTP Response. - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) type status-code = u16; /// Represents an HTTP Response. @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit resource response { /// Construct a new `response`, with a default `status-code` of `200`. /// If a different `status-code` is needed, it must be set via the @@ -508,11 +431,7 @@ interface types { /// /// In `wasi:http/middleware` this interface is both exported and imported as /// the "downstream" and "upstream" directions of the middleware chain. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit interface handler { use types.{request, response, error-code}; @@ -531,11 +450,7 @@ interface handler { /// (including WIT itself) is unable to represent a component importing two /// instances of the same interface. A `client.send` import may be linked /// directly to a `handler.handle` export to bypass the network. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit interface client { use types.{request, response, error-code}; @@ -547,24 +462,6 @@ interface client { /// The `wasi:http/service` world captures a broad category of HTTP services /// including web applications, API servers, and proxies. It may be `include`d /// in more specific worlds such as `wasi:http/middleware`. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -world service { - import wasi:cli/types@0.3.0-rc-2026-02-09; - import wasi:cli/stdout@0.3.0-rc-2026-02-09; - import wasi:cli/stderr@0.3.0-rc-2026-02-09; - import wasi:cli/stdin@0.3.0-rc-2026-02-09; - import wasi:clocks/types@0.3.0-rc-2026-02-09; - import types; - import client; - import wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09; - import wasi:clocks/system-clock@0.3.0-rc-2026-02-09; - @unstable(feature = clocks-timezone) - import wasi:clocks/timezone@0.3.0-rc-2026-02-09; - import wasi:random/random@0.3.0-rc-2026-02-09; - import wasi:random/insecure@0.3.0-rc-2026-02-09; - import wasi:random/insecure-seed@0.3.0-rc-2026-02-09; -======== @since(version = 0.3.0-rc-2026-03-15) world service { import wasi:cli/types@0.3.0-rc-2026-03-15; @@ -581,7 +478,6 @@ world service { import wasi:random/random@0.3.0-rc-2026-03-15; import wasi:random/insecure@0.3.0-rc-2026-03-15; import wasi:random/insecure-seed@0.3.0-rc-2026-03-15; ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit export handler; } @@ -591,25 +487,6 @@ world service { /// Components may implement this world to allow them to participate in handler /// "chains" where a `request` flows through handlers on its way to some terminal /// `service` and corresponding `response` flows in the opposite direction. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -world middleware { - import wasi:clocks/types@0.3.0-rc-2026-02-09; - import types; - import handler; - import wasi:cli/types@0.3.0-rc-2026-02-09; - import wasi:cli/stdout@0.3.0-rc-2026-02-09; - import wasi:cli/stderr@0.3.0-rc-2026-02-09; - import wasi:cli/stdin@0.3.0-rc-2026-02-09; - import client; - import wasi:clocks/monotonic-clock@0.3.0-rc-2026-02-09; - import wasi:clocks/system-clock@0.3.0-rc-2026-02-09; - @unstable(feature = clocks-timezone) - import wasi:clocks/timezone@0.3.0-rc-2026-02-09; - import wasi:random/random@0.3.0-rc-2026-02-09; - import wasi:random/insecure@0.3.0-rc-2026-02-09; - import wasi:random/insecure-seed@0.3.0-rc-2026-02-09; -======== @since(version = 0.3.0-rc-2026-03-15) world middleware { import wasi:clocks/types@0.3.0-rc-2026-03-15; @@ -627,7 +504,6 @@ world middleware { import wasi:random/random@0.3.0-rc-2026-03-15; import wasi:random/insecure@0.3.0-rc-2026-03-15; import wasi:random/insecure-seed@0.3.0-rc-2026-03-15; ->>>>>>>> main:wasi/p3/wit/deps/wasi-http-0.3.0-rc-2026-03-15/package.wit export handler; } diff --git a/wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit b/wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit index a3ba367e1..026f44a10 100644 --- a/wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit +++ b/wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit @@ -1,18 +1,10 @@ -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit -package wasi:random@0.3.0-rc-2026-02-09; -======== package wasi:random@0.3.0-rc-2026-03-15; ->>>>>>>> main:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit /// The insecure-seed interface for seeding hash-map DoS resistance. /// /// It is intended to be portable at least between Unix-family platforms and /// Windows. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit interface insecure-seed { /// Return a 128-bit value that may contain a pseudo-random value. /// @@ -31,11 +23,7 @@ interface insecure-seed { /// This will likely be changed to a value import, to prevent it from being /// called multiple times and potentially used for purposes other than DoS /// protection. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit get-insecure-seed: func() -> tuple; } @@ -43,11 +31,7 @@ interface insecure-seed { /// /// It is intended to be portable at least between Unix-family platforms and /// Windows. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit interface insecure { /// Return up to `max-len` insecure pseudo-random bytes. /// @@ -57,10 +41,6 @@ interface insecure { /// There are no requirements on the values of the returned bytes, however /// implementations are encouraged to return evenly distributed values with /// a long period. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-insecure-random-bytes: func(len: u64) -> list; -======== /// /// Implementations MAY return fewer bytes than requested (a short read). /// Callers that require exactly `max-len` bytes MUST call this function in @@ -70,17 +50,12 @@ interface insecure { /// list without trapping. @since(version = 0.3.0-rc-2026-03-15) get-insecure-random-bytes: func(max-len: u64) -> list; ->>>>>>>> main:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit /// Return an insecure pseudo-random `u64` value. /// /// This function returns the same type of pseudo-random data as /// `get-insecure-random-bytes`, represented as a `u64`. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit get-insecure-random-u64: func() -> u64; } @@ -88,11 +63,7 @@ interface insecure { /// /// It is intended to be portable at least between Unix-family platforms and /// Windows. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit interface random { /// Return up to `max-len` cryptographically-secure random or pseudo-random /// bytes. @@ -114,31 +85,13 @@ interface random { /// This function must always return fresh data. Deterministic environments /// must omit this function, rather than implementing it with deterministic /// data. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-random-bytes: func(len: u64) -> list; -======== @since(version = 0.3.0-rc-2026-03-15) get-random-bytes: func(max-len: u64) -> list; ->>>>>>>> main:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit /// Return a cryptographically-secure random or pseudo-random `u64` value. /// /// This function returns the same type of data as `get-random-bytes`, /// represented as a `u64`. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-random-u64: func() -> u64; -} - -@since(version = 0.3.0-rc-2026-02-09) -world imports { - @since(version = 0.3.0-rc-2026-02-09) - import random; - @since(version = 0.3.0-rc-2026-02-09) - import insecure; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-random-u64: func() -> u64; } @@ -150,6 +103,5 @@ world imports { @since(version = 0.3.0-rc-2026-03-15) import insecure; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-random-0.3.0-rc-2026-03-15/package.wit import insecure-seed; } diff --git a/wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit b/wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit index 294d5dbb1..cde2e4d6e 100644 --- a/wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit +++ b/wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit @@ -1,18 +1,9 @@ -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit -package wasi:sockets@0.3.0-rc-2026-02-09; - -@since(version = 0.3.0-rc-2026-02-09) -interface types { - @since(version = 0.3.0-rc-2026-02-09) - use wasi:clocks/types@0.3.0-rc-2026-02-09.{duration}; -======== package wasi:sockets@0.3.0-rc-2026-03-15; @since(version = 0.3.0-rc-2026-03-15) interface types { @since(version = 0.3.0-rc-2026-03-15) use wasi:clocks/types@0.3.0-rc-2026-03-15.{duration}; ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit /// Error codes. /// @@ -25,15 +16,8 @@ interface types { /// - `out-of-memory` /// /// See each individual API for what the POSIX equivalents are. They sometimes differ per API. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - enum error-code { - /// Unknown error - unknown, -======== @since(version = 0.3.0-rc-2026-03-15) variant error-code { ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit /// Access denied. /// /// POSIX equivalent: EACCES, EPERM @@ -96,11 +80,7 @@ interface types { other(option), } -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit enum ip-address-family { /// Similar to `AF_INET` in POSIX. ipv4, @@ -108,15 +88,6 @@ interface types { ipv6, } -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - type ipv4-address = tuple; - - @since(version = 0.3.0-rc-2026-02-09) - type ipv6-address = tuple; - - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) type ipv4-address = tuple; @@ -124,17 +95,12 @@ interface types { type ipv6-address = tuple; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit variant ip-address { ipv4(ipv4-address), ipv6(ipv6-address), } -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit record ipv4-socket-address { /// sin_port port: u16, @@ -142,11 +108,7 @@ interface types { address: ipv4-address, } -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit record ipv6-socket-address { /// sin6_port port: u16, @@ -158,11 +120,7 @@ interface types { scope-id: u32, } -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit variant ip-socket-address { ipv4(ipv4-socket-address), ipv6(ipv6-socket-address), @@ -200,11 +158,7 @@ interface types { /// In addition to the general error codes documented on the /// `types::error-code` type, TCP socket methods may always return /// `error(invalid-state)` when in the `closed` state. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit resource tcp-socket { /// Create a new TCP socket. /// @@ -224,11 +178,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit create: static func(address-family: ip-address-family) -> result; /// Bind the socket to the provided IP address and port. /// @@ -263,11 +213,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit bind: func(local-address: ip-socket-address) -> result<_, error-code>; /// Connect to a remote endpoint. /// @@ -303,11 +249,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit connect: async func(remote-address: ip-socket-address) -> result<_, error-code>; /// Start listening and return a stream of new inbound connections. /// @@ -379,11 +321,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit listen: func() -> result, error-code>; /// Transmit data to peer. /// @@ -407,11 +345,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit send: func(data: stream) -> future>; /// Read data from peer. /// @@ -440,11 +374,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit receive: func() -> tuple, future>>; /// Get the bound local address. /// @@ -463,11 +393,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit get-local-address: func() -> result; /// Get the remote address. /// @@ -479,31 +405,19 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit get-remote-address: func() -> result; /// Whether the socket is in the `listening` state. /// /// Equivalent to the SO_ACCEPTCONN socket option. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit get-is-listening: func() -> bool; /// Whether this is a IPv4 or IPv6 socket. /// /// This is the value passed to the constructor. /// /// Equivalent to the SO_DOMAIN socket option. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit get-address-family: func() -> ip-address-family; /// Hints the desired listen queue size. Implementations are free to /// ignore this. @@ -516,11 +430,7 @@ interface types { /// - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen. /// - `invalid-argument`: (set) The provided value was 0. /// - `invalid-state`: (set) The socket is in the `connecting` or `connected` state. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit set-listen-backlog-size: func(value: u64) -> result<_, error-code>; /// Enables or disables keepalive. /// @@ -532,15 +442,9 @@ interface types { /// false, but only come into effect when `keep-alive-enabled` is true. /// /// Equivalent to the SO_KEEPALIVE socket option. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-keep-alive-enabled: func() -> result; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-keep-alive-enabled: func() -> result; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit set-keep-alive-enabled: func(value: bool) -> result<_, error-code>; /// Amount of time the connection has to be idle before TCP starts /// sending keepalive packets. @@ -554,15 +458,9 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-keep-alive-idle-time: func() -> result; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-keep-alive-idle-time: func() -> result; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>; /// The time between keepalive packets. /// @@ -575,15 +473,9 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-keep-alive-interval: func() -> result; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-keep-alive-interval: func() -> result; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit set-keep-alive-interval: func(value: duration) -> result<_, error-code>; /// The maximum amount of keepalive packets TCP should send before /// aborting the connection. @@ -597,15 +489,9 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-keep-alive-count: func() -> result; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-keep-alive-count: func() -> result; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit set-keep-alive-count: func(value: u32) -> result<_, error-code>; /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. /// @@ -613,15 +499,9 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The TTL value must be 1 or higher. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-hop-limit: func() -> result; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-hop-limit: func() -> result; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit set-hop-limit: func(value: u8) -> result<_, error-code>; /// Kernel buffer space reserved for sending/receiving on this socket. /// Implementations usually treat this as a cap the buffer can grow to, @@ -644,15 +524,6 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-receive-buffer-size: func() -> result; - @since(version = 0.3.0-rc-2026-02-09) - set-receive-buffer-size: func(value: u64) -> result<_, error-code>; - @since(version = 0.3.0-rc-2026-02-09) - get-send-buffer-size: func() -> result; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-receive-buffer-size: func() -> result; @since(version = 0.3.0-rc-2026-03-15) @@ -660,16 +531,11 @@ interface types { @since(version = 0.3.0-rc-2026-03-15) get-send-buffer-size: func() -> result; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit set-send-buffer-size: func(value: u64) -> result<_, error-code>; } /// A UDP socket handle. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit resource udp-socket { /// Create a new UDP socket. /// @@ -686,11 +552,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit create: static func(address-family: ip-address-family) -> result; /// Bind the socket to the provided IP address and port. /// @@ -711,11 +573,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit bind: func(local-address: ip-socket-address) -> result<_, error-code>; /// Associate this socket with a specific peer address. /// @@ -753,11 +611,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit connect: func(remote-address: ip-socket-address) -> result<_, error-code>; /// Dissociate this socket from its peer address. /// @@ -774,11 +628,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit disconnect: func() -> result<_, error-code>; /// Send a message on the socket to a particular peer. /// @@ -822,11 +672,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit send: async func(data: list, remote-address: option) -> result<_, error-code>; /// Receive a message on the socket. /// @@ -851,11 +697,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit receive: async func() -> result, ip-socket-address>, error-code>; /// Get the current bound address. /// @@ -874,11 +716,7 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit get-local-address: func() -> result; /// Get the address the socket is currently "connected" to. /// @@ -890,22 +728,14 @@ interface types { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit get-remote-address: func() -> result; /// Whether this is a IPv4 or IPv6 socket. /// /// This is the value passed to the constructor. /// /// Equivalent to the SO_DOMAIN socket option. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit get-address-family: func() -> ip-address-family; /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. /// @@ -913,15 +743,9 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The TTL value must be 1 or higher. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-unicast-hop-limit: func() -> result; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-unicast-hop-limit: func() -> result; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit set-unicast-hop-limit: func(value: u8) -> result<_, error-code>; /// Kernel buffer space reserved for sending/receiving on this socket. /// Implementations usually treat this as a cap the buffer can grow to, @@ -936,15 +760,6 @@ interface types { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - get-receive-buffer-size: func() -> result; - @since(version = 0.3.0-rc-2026-02-09) - set-receive-buffer-size: func(value: u64) -> result<_, error-code>; - @since(version = 0.3.0-rc-2026-02-09) - get-send-buffer-size: func() -> result; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) get-receive-buffer-size: func() -> result; @since(version = 0.3.0-rc-2026-03-15) @@ -952,23 +767,10 @@ interface types { @since(version = 0.3.0-rc-2026-03-15) get-send-buffer-size: func() -> result; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit set-send-buffer-size: func(value: u64) -> result<_, error-code>; } } -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit -@since(version = 0.3.0-rc-2026-02-09) -interface ip-name-lookup { - @since(version = 0.3.0-rc-2026-02-09) - use types.{ip-address}; - - /// Lookup error codes. - @since(version = 0.3.0-rc-2026-02-09) - enum error-code { - /// Unknown error - unknown, -======== @since(version = 0.3.0-rc-2026-03-15) interface ip-name-lookup { @since(version = 0.3.0-rc-2026-03-15) @@ -977,7 +779,6 @@ interface ip-name-lookup { /// Lookup error codes. @since(version = 0.3.0-rc-2026-03-15) variant error-code { ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit /// Access denied. /// /// POSIX equivalent: EACCES, EPERM @@ -1023,19 +824,6 @@ interface ip-name-lookup { /// - /// - /// - -<<<<<<<< HEAD:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-02-09/package.wit - @since(version = 0.3.0-rc-2026-02-09) - resolve-addresses: async func(name: string) -> result, error-code>; -} - -@since(version = 0.3.0-rc-2026-02-09) -world imports { - @since(version = 0.3.0-rc-2026-02-09) - import wasi:clocks/types@0.3.0-rc-2026-02-09; - @since(version = 0.3.0-rc-2026-02-09) - import types; - @since(version = 0.3.0-rc-2026-02-09) -======== @since(version = 0.3.0-rc-2026-03-15) resolve-addresses: async func(name: string) -> result, error-code>; } @@ -1047,6 +835,5 @@ world imports { @since(version = 0.3.0-rc-2026-03-15) import types; @since(version = 0.3.0-rc-2026-03-15) ->>>>>>>> main:wasi/p3/wit/deps/wasi-sockets-0.3.0-rc-2026-03-15/package.wit import ip-name-lookup; } From 4d2e463ee8be631548ac8e611b8c86e8f009a5e6 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Fri, 12 Jun 2026 15:40:14 +0100 Subject: [PATCH 37/43] Rename coop threads macro --- CMakeLists.txt | 1 - libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c | 2 +- libc-bottom-half/headers/public/wasi/version.h.in | 1 - libc-top-half/musl/include/alltypes.h.in | 2 +- libc-top-half/musl/include/pthread.h | 8 ++++---- libc-top-half/musl/include/semaphore.h | 2 +- libc-top-half/musl/include/unistd.h | 2 +- libc-top-half/musl/src/conf/sysconf.c | 6 +++--- libc-top-half/musl/src/env/__init_tls.c | 2 +- libc-top-half/musl/src/internal/lock.h | 2 +- libc-top-half/musl/src/internal/pthread_impl.h | 6 +++--- libc-top-half/musl/src/internal/stdio_impl.h | 2 +- libc-top-half/musl/src/malloc/oldmalloc/malloc.c | 2 +- libc-top-half/musl/src/stdio/__lockfile.c | 2 +- libc-top-half/musl/src/stdio/ftrylockfile.c | 4 ++-- libc-top-half/musl/src/stdio/getc.h | 4 ++-- libc-top-half/musl/src/stdio/putc.h | 4 ++-- .../musl/src/thread/common/pthread_rwlock_init.c | 2 +- 18 files changed, 26 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c42fead6..94f90a50a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,7 +143,6 @@ elseif(WASI STREQUAL "p2") set(__wasip2__ ON) elseif(WASI STREQUAL "p3") set(__wasip3__ ON) - set(__wasi_cooperative_threads__ ON) else() message(FATAL_ERROR "Unknown WASI version: ${WASI}") endif() diff --git a/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c b/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c index 4b1a5b6e3..c14017c75 100644 --- a/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c +++ b/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c @@ -7,7 +7,7 @@ #include int sched_yield(void) { -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ #ifdef __wasip3__ wasip3_thread_yield(); return 0; diff --git a/libc-bottom-half/headers/public/wasi/version.h.in b/libc-bottom-half/headers/public/wasi/version.h.in index 8da5d9991..2cca21efc 100644 --- a/libc-bottom-half/headers/public/wasi/version.h.in +++ b/libc-bottom-half/headers/public/wasi/version.h.in @@ -10,7 +10,6 @@ #cmakedefine __wasip1__ #cmakedefine __wasip2__ #cmakedefine __wasip3__ -#cmakedefine __wasi_cooperative_threads__ #cmakedefine __wasi_sdk_major__ @__wasi_sdk_major__@ #cmakedefine __wasi_sdk_version__ "@__wasi_sdk_version__@" diff --git a/libc-top-half/musl/include/alltypes.h.in b/libc-top-half/musl/include/alltypes.h.in index b133f3d23..c26adae59 100644 --- a/libc-top-half/musl/include/alltypes.h.in +++ b/libc-top-half/musl/include/alltypes.h.in @@ -107,7 +107,7 @@ 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; -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ struct __waitlist_node; TYPEDEF struct { int _m_type; int _m_lock; int _m_count; struct __waitlist_node *_m_waiters; } pthread_mutex_t; TYPEDEF struct { int _m_type; int _m_lock; int _m_count; struct __waitlist_node *_m_waiters; } mtx_t; diff --git a/libc-top-half/musl/include/pthread.h b/libc-top-half/musl/include/pthread.h index 5b1fc0ce2..cf76fb54f 100644 --- a/libc-top-half/musl/include/pthread.h +++ b/libc-top-half/musl/include/pthread.h @@ -55,7 +55,7 @@ extern "C" { #define PTHREAD_PROCESS_SHARED 1 -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ #define PTHREAD_MUTEX_INITIALIZER {0, 0, 0, 0} #define PTHREAD_RWLOCK_INITIALIZER {0, 0} #define PTHREAD_COND_INITIALIZER {0} @@ -116,11 +116,11 @@ int pthread_setcanceltype(int, int *); void pthread_testcancel(void); /* wasi-threads takes the approach of not declaring unsupported functions. For greater compatibility, we stub them for cooperative threading. */ -#ifdef __wasi_cooperative_threads__ /* WASI has no cancellation support. */ +#ifdef __wasi_libcall_thread_context__ /* WASI has no cancellation support. */ int pthread_cancel(pthread_t); #endif -#ifdef __wasi_cooperative_threads__ /* WASI has no CPU scheduling support. */ +#ifdef __wasi_libcall_thread_context__ /* 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 @@ -186,7 +186,7 @@ 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 __wasi_cooperative_threads__ /* WASI has no CPU scheduling support. */ +#ifdef __wasi_libcall_thread_context__ /* 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 diff --git a/libc-top-half/musl/include/semaphore.h b/libc-top-half/musl/include/semaphore.h index 09887a381..ebc6ca42e 100644 --- a/libc-top-half/musl/include/semaphore.h +++ b/libc-top-half/musl/include/semaphore.h @@ -14,7 +14,7 @@ extern "C" { #define SEM_FAILED ((sem_t *)0) -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ struct __waitlist_node; typedef struct { int __count; diff --git a/libc-top-half/musl/include/unistd.h b/libc-top-half/musl/include/unistd.h index c8c46fea1..bcddc3866 100644 --- a/libc-top-half/musl/include/unistd.h +++ b/libc-top-half/musl/include/unistd.h @@ -359,7 +359,7 @@ pid_t gettid(void); #define _POSIX_BARRIERS _POSIX_VERSION #define _POSIX_SPIN_LOCKS _POSIX_VERSION #define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ #define _POSIX_SEMAPHORES _POSIX_VERSION #elif defined(__wasilibc_unmodified_upstream) /* WASI has no POSIX async I/O, semaphores, or shared memory */ #define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION diff --git a/libc-top-half/musl/src/conf/sysconf.c b/libc-top-half/musl/src/conf/sysconf.c index 41f8b35f4..61955181d 100644 --- a/libc-top-half/musl/src/conf/sysconf.c +++ b/libc-top-half/musl/src/conf/sysconf.c @@ -21,7 +21,7 @@ #define JT_MQ_PRIO_MAX JT(3) #endif #define JT_PAGE_SIZE JT(4) -#ifdef __wasi_cooperative_threads__ // wasi-threads has no semaphores +#ifdef __wasi_libcall_thread_context__ // wasi-threads has no semaphores #define JT_SEM_VALUE_MAX JT(5) #endif #define JT_NPROCESSORS_CONF JT(6) @@ -88,7 +88,7 @@ long sysconf(int name) // Not supported on wasi. [_SC_RTSIG_MAX] = -1, #endif -#ifdef __wasi_cooperative_threads__ // wasi-threads has no semaphores +#ifdef __wasi_libcall_thread_context__ // wasi-threads has no semaphores [_SC_SEM_NSEMS_MAX] = SEM_NSEMS_MAX, [_SC_SEM_VALUE_MAX] = JT_SEM_VALUE_MAX, #else @@ -249,7 +249,7 @@ long sysconf(int name) #endif case JT_PAGE_SIZE & 255: return PAGE_SIZE; -#if defined(__wasilibc_unmodified_upstream) || defined(__wasi_cooperative_threads__) // wasi-threads has no semaphores +#if defined(__wasilibc_unmodified_upstream) || defined(__wasi_libcall_thread_context__) // wasi-threads has no semaphores case JT_SEM_VALUE_MAX & 255: return SEM_VALUE_MAX; #endif diff --git a/libc-top-half/musl/src/env/__init_tls.c b/libc-top-half/musl/src/env/__init_tls.c index 58308609f..05f38b077 100644 --- a/libc-top-half/musl/src/env/__init_tls.c +++ b/libc-top-half/musl/src/env/__init_tls.c @@ -109,7 +109,7 @@ int __init_tp(void *p) td->stack = bounds.base; td->stack_size = bounds.size; td->guard_size = 0; - #if defined(__wasi_cooperative_threads__) + #if defined(__wasi_libcall_thread_context__) td->detach_state = DT_JOINABLE; #ifdef __wasip3__ td->tid = wasip3_thread_index(); diff --git a/libc-top-half/musl/src/internal/lock.h b/libc-top-half/musl/src/internal/lock.h index 6f1aa8d36..c88fca8ab 100644 --- a/libc-top-half/musl/src/internal/lock.h +++ b/libc-top-half/musl/src/internal/lock.h @@ -11,7 +11,7 @@ // and thus can be no-ops in cooperative threading mode. -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ struct __waitlist_node; struct __coop_lock { int owner; // tid of owning thread, or 0 if unlocked diff --git a/libc-top-half/musl/src/internal/pthread_impl.h b/libc-top-half/musl/src/internal/pthread_impl.h index f0e615309..e3ba3f50b 100644 --- a/libc-top-half/musl/src/internal/pthread_impl.h +++ b/libc-top-half/musl/src/internal/pthread_impl.h @@ -68,7 +68,7 @@ struct pthread { DECLARE_WEAK_LOCK(killlock); char *dlerror_buf; void *stdio_locks; - #ifdef __wasi_cooperative_threads__ + #ifdef __wasi_libcall_thread_context__ struct __waitlist_node *joiner_waiters; #endif @@ -96,7 +96,7 @@ enum { #define _a_sched __u.__i[3*__SU+1] #define _a_policy __u.__i[3*__SU+2] #define _a_prio __u.__i[3*__SU+3] -#ifndef __wasi_cooperative_threads__ +#ifndef __wasi_libcall_thread_context__ #define _m_type __u.__i[0] #define _m_lock __u.__vi[1] #define _m_waiters __u.__vi[2] @@ -179,7 +179,7 @@ hidden int __libc_sigaction(int, const struct sigaction *, struct sigaction *); #endif hidden void __unmapself(void *, size_t); -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ struct __waitlist_node { uint32_t tid; struct __waitlist_node *next; diff --git a/libc-top-half/musl/src/internal/stdio_impl.h b/libc-top-half/musl/src/internal/stdio_impl.h index 64c476f16..05d265e2b 100644 --- a/libc-top-half/musl/src/internal/stdio_impl.h +++ b/libc-top-half/musl/src/internal/stdio_impl.h @@ -10,7 +10,7 @@ #include "lock.h" -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ #define FFINALLOCK(f) __lockfile((f)) #define FLOCK(f) int __need_unlock = __lockfile((f)) #define FUNLOCK(f) do { if (__need_unlock) __unlockfile((f)); } while (0) diff --git a/libc-top-half/musl/src/malloc/oldmalloc/malloc.c b/libc-top-half/musl/src/malloc/oldmalloc/malloc.c index f4caed87c..1b203f0fb 100644 --- a/libc-top-half/musl/src/malloc/oldmalloc/malloc.c +++ b/libc-top-half/musl/src/malloc/oldmalloc/malloc.c @@ -27,7 +27,7 @@ static struct { /* Synchronization tools */ -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ /* The implementation has no yield points, so locks can be no-ops. */ static inline void lock(volatile int *lk) { diff --git a/libc-top-half/musl/src/stdio/__lockfile.c b/libc-top-half/musl/src/stdio/__lockfile.c index 107d753c0..f8a69f8e5 100644 --- a/libc-top-half/musl/src/stdio/__lockfile.c +++ b/libc-top-half/musl/src/stdio/__lockfile.c @@ -1,7 +1,7 @@ #include "stdio_impl.h" #include "pthread_impl.h" -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ #include "lock.h" int __lockfile(FILE *f) { diff --git a/libc-top-half/musl/src/stdio/ftrylockfile.c b/libc-top-half/musl/src/stdio/ftrylockfile.c index 482cd9ee0..262c37b16 100644 --- a/libc-top-half/musl/src/stdio/ftrylockfile.c +++ b/libc-top-half/musl/src/stdio/ftrylockfile.c @@ -6,7 +6,7 @@ void __do_orphaned_stdio_locks() { FILE *f; for (f=__pthread_self()->stdio_locks; f; f=f->next_locked) { - #ifdef __wasi_cooperative_threads__ + #ifdef __wasi_libcall_thread_context__ f->lock.owner = 0; __waitlist_wake_all(&f->lock.waiters); #else @@ -33,7 +33,7 @@ void __register_locked_file(FILE *f, pthread_t self) self->stdio_locks = f; } -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ int ftrylockfile(FILE *f) { #ifdef __wasip3__ diff --git a/libc-top-half/musl/src/stdio/getc.h b/libc-top-half/musl/src/stdio/getc.h index 7502102dc..63ffb614d 100644 --- a/libc-top-half/musl/src/stdio/getc.h +++ b/libc-top-half/musl/src/stdio/getc.h @@ -7,7 +7,7 @@ __attribute__((__noinline__)) #endif static int locking_getc(FILE *f) { -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ __lockfile(f); int c = getc_unlocked(f); __unlockfile(f); @@ -24,7 +24,7 @@ static int locking_getc(FILE *f) static inline int do_getc(FILE *f) { -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ if (f->lock.owner == wasip3_thread_index()) return getc_unlocked(f); return locking_getc(f); diff --git a/libc-top-half/musl/src/stdio/putc.h b/libc-top-half/musl/src/stdio/putc.h index aae780ab3..1a9781bb3 100644 --- a/libc-top-half/musl/src/stdio/putc.h +++ b/libc-top-half/musl/src/stdio/putc.h @@ -7,7 +7,7 @@ __attribute__((__noinline__)) #endif static int locking_putc(int c, FILE *f) { -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ __lockfile(f); c = putc_unlocked(c, f); __unlockfile(f); @@ -24,7 +24,7 @@ static int locking_putc(int c, FILE *f) static inline int do_putc(int c, FILE *f) { -#ifdef __wasi_cooperative_threads__ +#ifdef __wasi_libcall_thread_context__ #ifdef __wasip3__ int tid = wasip3_thread_index(); #else diff --git a/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c b/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c index 0ae4c8efd..2729e3b64 100644 --- a/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c +++ b/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c @@ -3,7 +3,7 @@ int pthread_rwlock_init(pthread_rwlock_t *restrict rw, const pthread_rwlockattr_t *restrict a) { *rw = (pthread_rwlock_t){0}; - #ifndef __wasi_cooperative_threads__ + #ifndef __wasi_libcall_thread_context__ if (a) rw->_rw_shared = a->__attr[0]*128; #endif return 0; From d7961f8d8aeab36a220ed82995e2847e4b2e90f1 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Fri, 12 Jun 2026 15:51:37 +0100 Subject: [PATCH 38/43] Lock name fixes --- libc-bottom-half/sources/chdir.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libc-bottom-half/sources/chdir.c b/libc-bottom-half/sources/chdir.c index bac19ef52..6f88f2bc1 100644 --- a/libc-bottom-half/sources/chdir.c +++ b/libc-bottom-half/sources/chdir.c @@ -129,12 +129,12 @@ static const char *make_absolute(const char *path) { int __wasilibc_find_relpath_alloc(const char *path, const char **abs_prefix, char **relative_buf, size_t *relative_buf_len, int can_realloc) { - WEAK_LOCK(lock); + WEAK_LOCK(__wasilibc_cwd_lock); // First, make our path absolute taking the cwd into account. const char *abspath = make_absolute(path); if (abspath == NULL) { - WEAK_UNLOCK(lock); + WEAK_UNLOCK(__wasilibc_cwd_lock); errno = ENOMEM; return -1; } @@ -145,20 +145,20 @@ int __wasilibc_find_relpath_alloc(const char *path, const char **abs_prefix, const char *rel; int fd = __wasilibc_find_abspath(abspath, abs_prefix, &rel); if (fd == -1) { - WEAK_UNLOCK(lock); + WEAK_UNLOCK(__wasilibc_cwd_lock); return -1; } size_t rel_len = strlen(rel); if (*relative_buf_len < rel_len + 1) { if (!can_realloc) { - WEAK_UNLOCK(lock); + WEAK_UNLOCK(__wasilibc_cwd_lock); errno = ERANGE; return -1; } char *tmp = realloc(*relative_buf, rel_len + 1); if (tmp == NULL) { - WEAK_UNLOCK(lock); + WEAK_UNLOCK(__wasilibc_cwd_lock); errno = ENOMEM; return -1; } @@ -166,6 +166,6 @@ int __wasilibc_find_relpath_alloc(const char *path, const char **abs_prefix, *relative_buf_len = rel_len + 1; } strcpy(*relative_buf, rel); - WEAK_UNLOCK(lock); + WEAK_UNLOCK(__wasilibc_cwd_lock); return fd; } From 8fe99d7462c2877c30a05a10a73b17d2772482d3 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Fri, 12 Jun 2026 17:17:47 +0100 Subject: [PATCH 39/43] Fix macro name --- libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c | 2 +- libc-top-half/musl/include/alltypes.h.in | 2 +- libc-top-half/musl/include/pthread.h | 8 ++++---- libc-top-half/musl/include/semaphore.h | 2 +- libc-top-half/musl/include/unistd.h | 2 +- libc-top-half/musl/src/conf/sysconf.c | 6 +++--- libc-top-half/musl/src/env/__init_tls.c | 2 +- libc-top-half/musl/src/internal/lock.h | 2 +- libc-top-half/musl/src/internal/pthread_impl.h | 6 +++--- libc-top-half/musl/src/internal/stdio_impl.h | 2 +- libc-top-half/musl/src/malloc/oldmalloc/malloc.c | 2 +- libc-top-half/musl/src/stdio/__lockfile.c | 2 +- libc-top-half/musl/src/stdio/ftrylockfile.c | 4 ++-- libc-top-half/musl/src/stdio/getc.h | 4 ++-- libc-top-half/musl/src/stdio/putc.h | 4 ++-- .../musl/src/thread/common/pthread_rwlock_init.c | 2 +- 16 files changed, 26 insertions(+), 26 deletions(-) diff --git a/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c b/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c index c14017c75..92a7fc3f4 100644 --- a/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c +++ b/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c @@ -7,7 +7,7 @@ #include int sched_yield(void) { -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ #ifdef __wasip3__ wasip3_thread_yield(); return 0; diff --git a/libc-top-half/musl/include/alltypes.h.in b/libc-top-half/musl/include/alltypes.h.in index c26adae59..60203839e 100644 --- a/libc-top-half/musl/include/alltypes.h.in +++ b/libc-top-half/musl/include/alltypes.h.in @@ -107,7 +107,7 @@ 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; -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ struct __waitlist_node; TYPEDEF struct { int _m_type; int _m_lock; int _m_count; struct __waitlist_node *_m_waiters; } pthread_mutex_t; TYPEDEF struct { int _m_type; int _m_lock; int _m_count; struct __waitlist_node *_m_waiters; } mtx_t; diff --git a/libc-top-half/musl/include/pthread.h b/libc-top-half/musl/include/pthread.h index cf76fb54f..19b6563e0 100644 --- a/libc-top-half/musl/include/pthread.h +++ b/libc-top-half/musl/include/pthread.h @@ -55,7 +55,7 @@ extern "C" { #define PTHREAD_PROCESS_SHARED 1 -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ #define PTHREAD_MUTEX_INITIALIZER {0, 0, 0, 0} #define PTHREAD_RWLOCK_INITIALIZER {0, 0} #define PTHREAD_COND_INITIALIZER {0} @@ -116,11 +116,11 @@ int pthread_setcanceltype(int, int *); void pthread_testcancel(void); /* wasi-threads takes the approach of not declaring unsupported functions. For greater compatibility, we stub them for cooperative threading. */ -#ifdef __wasi_libcall_thread_context__ /* WASI has no cancellation support. */ +#ifdef __wasm_libcall_thread_context__ /* WASI has no cancellation support. */ int pthread_cancel(pthread_t); #endif -#ifdef __wasi_libcall_thread_context__ /* WASI has no CPU scheduling support. */ +#ifdef __wasm_libcall_thread_context__ /* 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 @@ -186,7 +186,7 @@ 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 __wasi_libcall_thread_context__ /* WASI has no CPU scheduling support. */ +#ifdef __wasm_libcall_thread_context__ /* 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 diff --git a/libc-top-half/musl/include/semaphore.h b/libc-top-half/musl/include/semaphore.h index ebc6ca42e..056fe9f5e 100644 --- a/libc-top-half/musl/include/semaphore.h +++ b/libc-top-half/musl/include/semaphore.h @@ -14,7 +14,7 @@ extern "C" { #define SEM_FAILED ((sem_t *)0) -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ struct __waitlist_node; typedef struct { int __count; diff --git a/libc-top-half/musl/include/unistd.h b/libc-top-half/musl/include/unistd.h index bcddc3866..b06f84957 100644 --- a/libc-top-half/musl/include/unistd.h +++ b/libc-top-half/musl/include/unistd.h @@ -359,7 +359,7 @@ pid_t gettid(void); #define _POSIX_BARRIERS _POSIX_VERSION #define _POSIX_SPIN_LOCKS _POSIX_VERSION #define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ #define _POSIX_SEMAPHORES _POSIX_VERSION #elif defined(__wasilibc_unmodified_upstream) /* WASI has no POSIX async I/O, semaphores, or shared memory */ #define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION diff --git a/libc-top-half/musl/src/conf/sysconf.c b/libc-top-half/musl/src/conf/sysconf.c index 61955181d..3ca8b7add 100644 --- a/libc-top-half/musl/src/conf/sysconf.c +++ b/libc-top-half/musl/src/conf/sysconf.c @@ -21,7 +21,7 @@ #define JT_MQ_PRIO_MAX JT(3) #endif #define JT_PAGE_SIZE JT(4) -#ifdef __wasi_libcall_thread_context__ // wasi-threads has no semaphores +#ifdef __wasm_libcall_thread_context__ // wasi-threads has no semaphores #define JT_SEM_VALUE_MAX JT(5) #endif #define JT_NPROCESSORS_CONF JT(6) @@ -88,7 +88,7 @@ long sysconf(int name) // Not supported on wasi. [_SC_RTSIG_MAX] = -1, #endif -#ifdef __wasi_libcall_thread_context__ // wasi-threads has no semaphores +#ifdef __wasm_libcall_thread_context__ // wasi-threads has no semaphores [_SC_SEM_NSEMS_MAX] = SEM_NSEMS_MAX, [_SC_SEM_VALUE_MAX] = JT_SEM_VALUE_MAX, #else @@ -249,7 +249,7 @@ long sysconf(int name) #endif case JT_PAGE_SIZE & 255: return PAGE_SIZE; -#if defined(__wasilibc_unmodified_upstream) || defined(__wasi_libcall_thread_context__) // wasi-threads has no semaphores +#if defined(__wasilibc_unmodified_upstream) || defined(__wasm_libcall_thread_context__) // wasi-threads has no semaphores case JT_SEM_VALUE_MAX & 255: return SEM_VALUE_MAX; #endif diff --git a/libc-top-half/musl/src/env/__init_tls.c b/libc-top-half/musl/src/env/__init_tls.c index 05f38b077..8dffd3263 100644 --- a/libc-top-half/musl/src/env/__init_tls.c +++ b/libc-top-half/musl/src/env/__init_tls.c @@ -109,7 +109,7 @@ int __init_tp(void *p) td->stack = bounds.base; td->stack_size = bounds.size; td->guard_size = 0; - #if defined(__wasi_libcall_thread_context__) + #if defined(__wasm_libcall_thread_context__) td->detach_state = DT_JOINABLE; #ifdef __wasip3__ td->tid = wasip3_thread_index(); diff --git a/libc-top-half/musl/src/internal/lock.h b/libc-top-half/musl/src/internal/lock.h index c88fca8ab..5bc84ede0 100644 --- a/libc-top-half/musl/src/internal/lock.h +++ b/libc-top-half/musl/src/internal/lock.h @@ -11,7 +11,7 @@ // and thus can be no-ops in cooperative threading mode. -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ struct __waitlist_node; struct __coop_lock { int owner; // tid of owning thread, or 0 if unlocked diff --git a/libc-top-half/musl/src/internal/pthread_impl.h b/libc-top-half/musl/src/internal/pthread_impl.h index e3ba3f50b..32489f608 100644 --- a/libc-top-half/musl/src/internal/pthread_impl.h +++ b/libc-top-half/musl/src/internal/pthread_impl.h @@ -68,7 +68,7 @@ struct pthread { DECLARE_WEAK_LOCK(killlock); char *dlerror_buf; void *stdio_locks; - #ifdef __wasi_libcall_thread_context__ + #ifdef __wasm_libcall_thread_context__ struct __waitlist_node *joiner_waiters; #endif @@ -96,7 +96,7 @@ enum { #define _a_sched __u.__i[3*__SU+1] #define _a_policy __u.__i[3*__SU+2] #define _a_prio __u.__i[3*__SU+3] -#ifndef __wasi_libcall_thread_context__ +#ifndef __wasm_libcall_thread_context__ #define _m_type __u.__i[0] #define _m_lock __u.__vi[1] #define _m_waiters __u.__vi[2] @@ -179,7 +179,7 @@ hidden int __libc_sigaction(int, const struct sigaction *, struct sigaction *); #endif hidden void __unmapself(void *, size_t); -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ struct __waitlist_node { uint32_t tid; struct __waitlist_node *next; diff --git a/libc-top-half/musl/src/internal/stdio_impl.h b/libc-top-half/musl/src/internal/stdio_impl.h index 05d265e2b..9c0f0f86a 100644 --- a/libc-top-half/musl/src/internal/stdio_impl.h +++ b/libc-top-half/musl/src/internal/stdio_impl.h @@ -10,7 +10,7 @@ #include "lock.h" -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ #define FFINALLOCK(f) __lockfile((f)) #define FLOCK(f) int __need_unlock = __lockfile((f)) #define FUNLOCK(f) do { if (__need_unlock) __unlockfile((f)); } while (0) diff --git a/libc-top-half/musl/src/malloc/oldmalloc/malloc.c b/libc-top-half/musl/src/malloc/oldmalloc/malloc.c index 1b203f0fb..3fe31f49b 100644 --- a/libc-top-half/musl/src/malloc/oldmalloc/malloc.c +++ b/libc-top-half/musl/src/malloc/oldmalloc/malloc.c @@ -27,7 +27,7 @@ static struct { /* Synchronization tools */ -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ /* The implementation has no yield points, so locks can be no-ops. */ static inline void lock(volatile int *lk) { diff --git a/libc-top-half/musl/src/stdio/__lockfile.c b/libc-top-half/musl/src/stdio/__lockfile.c index f8a69f8e5..8c20464d5 100644 --- a/libc-top-half/musl/src/stdio/__lockfile.c +++ b/libc-top-half/musl/src/stdio/__lockfile.c @@ -1,7 +1,7 @@ #include "stdio_impl.h" #include "pthread_impl.h" -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ #include "lock.h" int __lockfile(FILE *f) { diff --git a/libc-top-half/musl/src/stdio/ftrylockfile.c b/libc-top-half/musl/src/stdio/ftrylockfile.c index 262c37b16..2854b6c33 100644 --- a/libc-top-half/musl/src/stdio/ftrylockfile.c +++ b/libc-top-half/musl/src/stdio/ftrylockfile.c @@ -6,7 +6,7 @@ void __do_orphaned_stdio_locks() { FILE *f; for (f=__pthread_self()->stdio_locks; f; f=f->next_locked) { - #ifdef __wasi_libcall_thread_context__ + #ifdef __wasm_libcall_thread_context__ f->lock.owner = 0; __waitlist_wake_all(&f->lock.waiters); #else @@ -33,7 +33,7 @@ void __register_locked_file(FILE *f, pthread_t self) self->stdio_locks = f; } -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ int ftrylockfile(FILE *f) { #ifdef __wasip3__ diff --git a/libc-top-half/musl/src/stdio/getc.h b/libc-top-half/musl/src/stdio/getc.h index 63ffb614d..f97fe6333 100644 --- a/libc-top-half/musl/src/stdio/getc.h +++ b/libc-top-half/musl/src/stdio/getc.h @@ -7,7 +7,7 @@ __attribute__((__noinline__)) #endif static int locking_getc(FILE *f) { -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ __lockfile(f); int c = getc_unlocked(f); __unlockfile(f); @@ -24,7 +24,7 @@ static int locking_getc(FILE *f) static inline int do_getc(FILE *f) { -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ if (f->lock.owner == wasip3_thread_index()) return getc_unlocked(f); return locking_getc(f); diff --git a/libc-top-half/musl/src/stdio/putc.h b/libc-top-half/musl/src/stdio/putc.h index 1a9781bb3..e05efb09d 100644 --- a/libc-top-half/musl/src/stdio/putc.h +++ b/libc-top-half/musl/src/stdio/putc.h @@ -7,7 +7,7 @@ __attribute__((__noinline__)) #endif static int locking_putc(int c, FILE *f) { -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ __lockfile(f); c = putc_unlocked(c, f); __unlockfile(f); @@ -24,7 +24,7 @@ static int locking_putc(int c, FILE *f) static inline int do_putc(int c, FILE *f) { -#ifdef __wasi_libcall_thread_context__ +#ifdef __wasm_libcall_thread_context__ #ifdef __wasip3__ int tid = wasip3_thread_index(); #else diff --git a/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c b/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c index 2729e3b64..32961af59 100644 --- a/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c +++ b/libc-top-half/musl/src/thread/common/pthread_rwlock_init.c @@ -3,7 +3,7 @@ int pthread_rwlock_init(pthread_rwlock_t *restrict rw, const pthread_rwlockattr_t *restrict a) { *rw = (pthread_rwlock_t){0}; - #ifndef __wasi_libcall_thread_context__ + #ifndef __wasm_libcall_thread_context__ if (a) rw->_rw_shared = a->__attr[0]*128; #endif return 0; From 84383bb380795c4986a8a494210a042f5876de83 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 22 Jun 2026 09:25:22 +0100 Subject: [PATCH 40/43] Fix lock issue --- libc-top-half/musl/src/exit/at_quick_exit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libc-top-half/musl/src/exit/at_quick_exit.c b/libc-top-half/musl/src/exit/at_quick_exit.c index 25b329e40..f6b863036 100644 --- a/libc-top-half/musl/src/exit/at_quick_exit.c +++ b/libc-top-half/musl/src/exit/at_quick_exit.c @@ -12,21 +12,21 @@ DECLARE_STRONG_LOCK(lock, static); void __funcs_on_quick_exit() { void (*func)(void); - WEAK_LOCK(lock); + STRONG_LOCK(lock); while (count > 0) { func = funcs[--count]; - WEAK_UNLOCK(lock); + STRONG_UNLOCK(lock); func(); - WEAK_LOCK(lock); + STRONG_LOCK(lock); } } int at_quick_exit(void (*func)(void)) { int r = 0; - WEAK_LOCK(lock); + STRONG_LOCK(lock); if (count == 32) r = -1; else funcs[count++] = func; - WEAK_UNLOCK(lock); + STRONG_UNLOCK(lock); return r; } From 5d1f3288e0517d2b6d4b705bfcee3c282085a9a2 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 22 Jun 2026 09:26:54 +0100 Subject: [PATCH 41/43] Remove stale files --- .../musl/src/thread/common/tss_create copy.c | 10 ---------- .../musl/src/thread/common/tss_delete copy.c | 7 ------- libc-top-half/musl/src/thread/common/tss_set copy.c | 13 ------------- 3 files changed, 30 deletions(-) delete mode 100644 libc-top-half/musl/src/thread/common/tss_create copy.c delete mode 100644 libc-top-half/musl/src/thread/common/tss_delete copy.c delete mode 100644 libc-top-half/musl/src/thread/common/tss_set copy.c diff --git a/libc-top-half/musl/src/thread/common/tss_create copy.c b/libc-top-half/musl/src/thread/common/tss_create copy.c deleted file mode 100644 index 6d6ef96b4..000000000 --- a/libc-top-half/musl/src/thread/common/tss_create copy.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -int tss_create(tss_t *tss, tss_dtor_t dtor) -{ - /* Different error returns are possible. C glues them together into - * just failure notification. Can't be optimized to a tail call, - * unless thrd_error equals EAGAIN. */ - return __pthread_key_create(tss, dtor) ? thrd_error : thrd_success; -} diff --git a/libc-top-half/musl/src/thread/common/tss_delete copy.c b/libc-top-half/musl/src/thread/common/tss_delete copy.c deleted file mode 100644 index 6f51b07eb..000000000 --- a/libc-top-half/musl/src/thread/common/tss_delete copy.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -void tss_delete(tss_t key) -{ - __pthread_key_delete(key); -} diff --git a/libc-top-half/musl/src/thread/common/tss_set copy.c b/libc-top-half/musl/src/thread/common/tss_set copy.c deleted file mode 100644 index 70c4fb723..000000000 --- a/libc-top-half/musl/src/thread/common/tss_set copy.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "pthread_impl.h" -#include - -int tss_set(tss_t k, void *x) -{ - struct pthread *self = __pthread_self(); - /* Avoid unnecessary COW */ - if (self->tsd[k] != x) { - self->tsd[k] = x; - self->tsd_used = 1; - } - return thrd_success; -} From 3c017ffd0df69ee36fca088ec06b5639f566c2b5 Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 22 Jun 2026 13:54:46 +0100 Subject: [PATCH 42/43] Move thread index retrieval --- .../src/thread/coop-threads/__wasi_coop_thread_start.s | 6 +----- .../musl/src/thread/coop-threads/pthread_create.c | 7 ++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s b/libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s index 62c386129..90a46a92f 100644 --- a/libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s +++ b/libc-top-half/musl/src/thread/coop-threads/__wasi_coop_thread_start.s @@ -3,12 +3,9 @@ .export_name __wasi_coop_thread_start, __wasi_coop_thread_start .globaltype __init_stack_pointer, i32 - .functype __wasi_coop_thread_start_C (i32, i32) -> () + .functype __wasi_coop_thread_start_C (i32) -> () .functype __wasm_set_tls_base (i32) -> () .functype __wasm_set_stack_pointer (i32) -> () - .import_module __wasm_component_model_builtin_thread_index, "$root" - .import_name __wasm_component_model_builtin_thread_index, "[thread-index]" - .functype __wasm_component_model_builtin_thread_index () -> (i32) .hidden __wasi_coop_thread_start .globl __wasi_coop_thread_start @@ -26,7 +23,6 @@ __wasi_coop_thread_start: i32.load 4 # tls_base call __wasm_set_tls_base # Make the C function do the rest of work. - call __wasm_component_model_builtin_thread_index local.get 0 # start_arg call __wasi_coop_thread_start_C diff --git a/libc-top-half/musl/src/thread/coop-threads/pthread_create.c b/libc-top-half/musl/src/thread/coop-threads/pthread_create.c index c4456176b..bd75faeda 100644 --- a/libc-top-half/musl/src/thread/coop-threads/pthread_create.c +++ b/libc-top-half/musl/src/thread/coop-threads/pthread_create.c @@ -126,7 +126,12 @@ struct start_args { void __wasi_coop_thread_start(void *context); hidden void *__dummy_reference = __wasi_coop_thread_start; -hidden void __wasi_coop_thread_start_C(int tid, void *context) { +hidden void __wasi_coop_thread_start_C(void *context) { + #ifdef __wasip3__ + int tid = wasip3_thread_index(); + #else + #error "Unknown WASI version" + #endif struct start_args *args = context; __pthread_self()->tid = tid; __pthread_exit(args->start_func(args->start_arg)); From 112e66264d8b41da8498de539d79b20e30db1c1d Mon Sep 17 00:00:00 2001 From: Sy Brand Date: Mon, 22 Jun 2026 15:02:30 +0100 Subject: [PATCH 43/43] Move TLS allocation to C --- libc-bottom-half/sources/__wasm_init_task.s | 35 +++------------------ libc-top-half/musl/src/env/__init_tls.c | 8 +++++ 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/libc-bottom-half/sources/__wasm_init_task.s b/libc-bottom-half/sources/__wasm_init_task.s index 8b52ef0ae..83a63d097 100644 --- a/libc-bottom-half/sources/__wasm_init_task.s +++ b/libc-bottom-half/sources/__wasm_init_task.s @@ -13,41 +13,14 @@ .functype malloc (i32) -> (i32) .functype __copy_tls (i32) -> (i32) + .functype __allocate_tls () -> (i32) .globl __wasm_init_task .type __wasm_init_task,@function .globl __wasm_init_async_task .type __wasm_init_async_task,@function - .functype __wasi_init_tp() -> () - -# Helper function to allocate and align TLS -# Returns an aligned TLS pointer ready for __copy_tls -__allocate_aligned_tls: - .functype __allocate_aligned_tls () -> (i32) - - # Allocate size + align - 1 to ensure we have room for alignment - global.get __tls_size - global.get __tls_align - i32.add - i32.const 1 - i32.sub - call malloc - - # Align the pointer: (ptr + align - 1) & ~(align - 1) - global.get __tls_align - i32.const 1 - i32.sub - i32.add - - global.get __tls_align - i32.const 1 - i32.sub - i32.const -1 - i32.xor - i32.and - - end_function + .functype __wasi_init_tp() -> () __wasm_init_task: .functype __wasm_init_task () -> () @@ -59,7 +32,7 @@ __wasm_init_task: call __wasm_set_tls_base # Allocate a new TLS area - call __allocate_aligned_tls + call __allocate_tls call __copy_tls call __wasm_set_tls_base @@ -87,7 +60,7 @@ __wasm_init_async_task: call __wasm_set_stack_pointer # Allocate a new TLS area - call __allocate_aligned_tls + call __allocate_tls call __copy_tls call __wasm_set_tls_base diff --git a/libc-top-half/musl/src/env/__init_tls.c b/libc-top-half/musl/src/env/__init_tls.c index 8dffd3263..a03b4b7ca 100644 --- a/libc-top-half/musl/src/env/__init_tls.c +++ b/libc-top-half/musl/src/env/__init_tls.c @@ -292,3 +292,11 @@ static void static_init_tls(size_t *aux) weak_alias(static_init_tls, __init_tls); #endif + +#ifdef _REENTRANT +void* __allocate_tls() { + void* mem; + posix_memalign(&mem, __builtin_wasm_tls_align(), __builtin_wasm_tls_size()); + return mem; +} +#endif \ No newline at end of file