Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a stub pthreads library for THREAD_MODEL=single #518

Merged
merged 13 commits into from
Oct 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Enable pthread_self
This is needed in order to *correctly* implement things such as
cancellation handlers being invoked on pthread_exit
ArcaneNibble committed Oct 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d0feebaf6df543684495270269c58d779785bd8d
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -307,6 +307,7 @@ LIBC_TOP_HALF_MUSL_SOURCES += \
thread/pthread_rwlockattr_destroy.c \
thread/pthread_rwlockattr_init.c \
thread/pthread_rwlockattr_setpshared.c \
thread/pthread_self.c \
thread/pthread_spin_destroy.c \
thread/pthread_spin_init.c \
)
@@ -357,7 +358,6 @@ LIBC_TOP_HALF_MUSL_SOURCES += \
thread/pthread_setcancelstate.c \
thread/pthread_setcanceltype.c \
thread/pthread_setspecific.c \
thread/pthread_self.c \
thread/pthread_spin_lock.c \
thread/pthread_spin_trylock.c \
thread/pthread_spin_unlock.c \
3 changes: 3 additions & 0 deletions expected/wasm32-wasip1/defined-symbols.txt
Original file line number Diff line number Diff line change
@@ -347,6 +347,7 @@ __wasilibc_nocwd_symlinkat
__wasilibc_nocwd_utimensat
__wasilibc_open_nomode
__wasilibc_populate_preopens
__wasilibc_pthread_self
__wasilibc_register_preopened_fd
__wasilibc_rename_newat
__wasilibc_rename_oldat
@@ -999,6 +1000,7 @@ pthread_rwlockattr_destroy
pthread_rwlockattr_getpshared
pthread_rwlockattr_init
pthread_rwlockattr_setpshared
pthread_self
pthread_spin_destroy
pthread_spin_init
pthread_spin_lock
@@ -1185,6 +1187,7 @@ tfind
tgamma
tgammaf
tgammal
thrd_current
thrd_sleep
time
timegm
3 changes: 3 additions & 0 deletions expected/wasm32-wasip2/defined-symbols.txt
Original file line number Diff line number Diff line change
@@ -363,6 +363,7 @@ __wasilibc_nocwd_symlinkat
__wasilibc_nocwd_utimensat
__wasilibc_open_nomode
__wasilibc_populate_preopens
__wasilibc_pthread_self
__wasilibc_register_preopened_fd
__wasilibc_rename_newat
__wasilibc_rename_oldat
@@ -1132,6 +1133,7 @@ pthread_rwlockattr_destroy
pthread_rwlockattr_getpshared
pthread_rwlockattr_init
pthread_rwlockattr_setpshared
pthread_self
pthread_spin_destroy
pthread_spin_init
pthread_spin_lock
@@ -1418,6 +1420,7 @@ tfind
tgamma
tgammaf
tgammal
thrd_current
thrd_sleep
time
timegm
3 changes: 1 addition & 2 deletions libc-top-half/musl/src/thread/pthread_self.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "pthread_impl.h"
#include <threads.h>

#if !defined(__wasilibc_unmodified_upstream) && defined(__wasm__) && \
defined(_REENTRANT)
#if !defined(__wasilibc_unmodified_upstream) && defined(__wasm__)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading things right, you're keeping the convention of conditionally compiling the threads stuff (stub or otherwise) behind _REENTRANT. Why remove it here? Or, conversely, why add it in the previous file (pthread_impl.h)? One of these seems inconsistent unless I'm missing something.

_Thread_local struct pthread __wasilibc_pthread_self;
#endif