Skip to content

Commit c9eb28c

Browse files
authored
Simplify musl's __wait. NFC (#26848)
The `__wait` operation is supposed to keep blocking regardless of the return code of the underlying futex. In particular it should keep looping/waiting even on inturrupts (i.e. `-EINTR`).
1 parent 0e63157 commit c9eb28c

4 files changed

Lines changed: 15 additions & 20 deletions

File tree

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@ void __wait(volatile int *addr, volatile int *waiters, int val, int priv)
1414
else return;
1515
}
1616
if (waiters) a_inc(waiters);
17+
while (*addr==val) {
1718
#ifdef __EMSCRIPTEN__
18-
// loop here to handle spurious wakeups from the underlying
19-
// emscripten_futex_wait.
20-
int ret = 0;
21-
while (*addr==val && ret == 0) {
22-
ret = emscripten_futex_wait((void*)addr, val, INFINITY);
23-
}
19+
emscripten_futex_wait((void*)addr, val, INFINITY);
2420
#else
25-
while (*addr==val) {
2621
__syscall(SYS_futex, addr, FUTEX_WAIT|priv, val, 0) != -ENOSYS
2722
|| __syscall(SYS_futex, addr, FUTEX_WAIT, val, 0);
28-
}
2923
#endif
24+
}
3025
if (waiters) a_dec(waiters);
3126
}

test/codesize/test_codesize_minimal_pthreads.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.out.js": 7323,
33
"a.out.js.gz": 3573,
4-
"a.out.nodebug.wasm": 19051,
5-
"a.out.nodebug.wasm.gz": 8796,
6-
"total": 26374,
7-
"total_gz": 12369,
4+
"a.out.nodebug.wasm": 19047,
5+
"a.out.nodebug.wasm.gz": 8794,
6+
"total": 26370,
7+
"total_gz": 12367,
88
"sent": [
99
"a (memory)",
1010
"b (exit)",

test/codesize/test_codesize_minimal_pthreads_memgrowth.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.out.js": 7726,
33
"a.out.js.gz": 3779,
4-
"a.out.nodebug.wasm": 19052,
5-
"a.out.nodebug.wasm.gz": 8797,
6-
"total": 26778,
7-
"total_gz": 12576,
4+
"a.out.nodebug.wasm": 19048,
5+
"a.out.nodebug.wasm.gz": 8796,
6+
"total": 26774,
7+
"total_gz": 12575,
88
"sent": [
99
"a (memory)",
1010
"b (exit)",

test/codesize/test_minimal_runtime_code_size_hello_wasm_worker.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"a.html.gz": 355,
44
"a.js": 952,
55
"a.js.gz": 601,
6-
"a.wasm": 2702,
7-
"a.wasm.gz": 1511,
8-
"total": 4169,
9-
"total_gz": 2467
6+
"a.wasm": 2661,
7+
"a.wasm.gz": 1479,
8+
"total": 4128,
9+
"total_gz": 2435
1010
}

0 commit comments

Comments
 (0)