Skip to content

Commit a1a7559

Browse files
authored
Use pthread_testcancel from musl (#16134)
1 parent c061567 commit a1a7559

File tree

6 files changed

+7
-28
lines changed

6 files changed

+7
-28
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "pthread_impl.h"
44
#include "syscall.h"
55

6-
#ifndef __EMSCRIPTEN__
76
hidden long __cancel(), __syscall_cp_asm(), __syscall_cp_c();
87

98
long __cancel()
@@ -15,6 +14,7 @@ long __cancel()
1514
return -ECANCELED;
1615
}
1716

17+
#ifndef __EMSCRIPTEN__
1818
long __syscall_cp_asm(volatile void *, syscall_arg_t,
1919
syscall_arg_t, syscall_arg_t, syscall_arg_t,
2020
syscall_arg_t, syscall_arg_t, syscall_arg_t);
@@ -67,6 +67,7 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx)
6767

6868
__syscall(SYS_tkill, self->tid, SIGCANCEL);
6969
}
70+
#endif
7071

7172
void __testcancel()
7273
{
@@ -75,6 +76,7 @@ void __testcancel()
7576
__cancel();
7677
}
7778

79+
#ifndef __EMSCRIPTEN__
7880
static void init_cancellation()
7981
{
8082
struct sigaction sa = {

system/lib/pthread/library_pthread.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636

3737
#include "threading_internal.h"
3838

39-
void __pthread_testcancel();
40-
4139
int emscripten_pthread_attr_gettransferredcanvases(const pthread_attr_t* a, const char** str) {
4240
*str = a->_a_transferredcanvases;
4341
return 0;

system/lib/pthread/library_pthread_stub.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ int pthread_cancel(pthread_t thread) {
206206
return 0;
207207
}
208208

209+
void pthread_testcancel() {}
210+
209211
_Noreturn void __pthread_exit(void* status) {
210212
exit(0);
211213
}

system/lib/pthread/pthread_testcancel.c

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/other/metadce/minimal_main_Oz_USE_PTHREADS_PROXY_TO_PTHREAD.funcs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $__pthread_setcancelstate
1010
$__set_thread_state
1111
$__stdio_write
1212
$__timedwait
13-
$__wake
13+
$__wake.2
1414
$__wasi_syscall_ret
1515
$__wasm_call_ctors
1616
$__wasm_init_memory
@@ -22,7 +22,7 @@ $_emscripten_thread_init
2222
$_main_thread
2323
$a_cas
2424
$a_dec
25-
$a_fetch_add
25+
$a_fetch_add.1
2626
$a_inc
2727
$a_swap
2828
$add

tools/system_libs.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,15 +827,12 @@ def get_files(self):
827827
'syscall_cp.c', 'tls.c',
828828
# TODO: Support this. See #12216.
829829
'pthread_setname_np.c',
830-
# TODO: Prefer to use the musl implementation.
831-
'pthread_testcancel.c',
832830
]
833831
libc_files += files_in_path(
834832
path='system/lib/pthread',
835833
filenames=[
836834
'library_pthread.c',
837835
'pthread_create.c',
838-
'pthread_testcancel.c',
839836
'emscripten_proxy_main.c',
840837
'emscripten_thread_init.c',
841838
'emscripten_thread_state.S',

0 commit comments

Comments
 (0)