Skip to content

Commit 21c0823

Browse files
committed
Revert hoisting of self changes
1 parent c0b7882 commit 21c0823

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

system/lib/libc/musl/src/thread/__timedwait.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ int __timedwait_cp(volatile int *addr, int val,
5858
}
5959

6060
#ifdef __EMSCRIPTEN__
61-
pthread_t self = __pthread_self();
6261
double msecsToSleep = top ? (top->tv_sec * 1000 + top->tv_nsec / 1000000.0) : INFINITY;
6362
const int is_runtime_thread = emscripten_is_main_runtime_thread();
6463

@@ -68,10 +67,12 @@ int __timedwait_cp(volatile int *addr, int val,
6867
// cp suffix in the function name means "cancellation point", so this wait can be cancelled
6968
// by the users unless current threads cancellability is set to PTHREAD_CANCEL_DISABLE
7069
// which may be either done by the user of __timedwait() function.
71-
if (is_runtime_thread || self->canceldisable != PTHREAD_CANCEL_DISABLE || self->cancelasync) {
70+
if (is_runtime_thread ||
71+
pthread_self()->canceldisable != PTHREAD_CANCEL_DISABLE ||
72+
pthread_self()->cancelasync == PTHREAD_CANCEL_ASYNCHRONOUS) {
7273
double sleepUntilTime = emscripten_get_now() + msecsToSleep;
7374
do {
74-
if (self->cancel) {
75+
if (pthread_self()->cancel) {
7576
// Emscripten-specific return value: The wait was canceled by user calling
7677
// pthread_cancel() for this thread, and the caller needs to cooperatively
7778
// cancel execution.

system/lib/libc/musl/src/thread/__wait.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@ void __wait(volatile int *addr, volatile int *waiters, int val, int priv)
1515
}
1616
if (waiters) a_inc(waiters);
1717
#ifdef __EMSCRIPTEN__
18-
pthread_t self = __pthread_self();
1918
const int is_runtime_thread = emscripten_is_main_runtime_thread();
2019

2120
// Main runtime thread may need to run proxied calls, so sleep in very small slices to be responsive.
2221
const double maxMsecsToSleep = is_runtime_thread ? 1 : 100;
2322

2423
while (*addr==val) {
25-
if (is_runtime_thread || self->cancelasync) {
24+
if (is_runtime_thread || pthread_self()->cancelasync == PTHREAD_CANCEL_ASYNCHRONOUS) {
2625
int e;
2726
do {
28-
if (self->cancel) {
27+
if (pthread_self()->cancel) {
2928
if (waiters) a_dec(waiters);
3029
return;
3130
}

0 commit comments

Comments
 (0)