Skip to content

Use pthread_testcancel from musl #16134

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

Merged
merged 2 commits into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion system/lib/libc/musl/src/thread/pthread_cancel.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "pthread_impl.h"
#include "syscall.h"

#ifndef __EMSCRIPTEN__
hidden long __cancel(), __syscall_cp_asm(), __syscall_cp_c();

long __cancel()
Expand All @@ -15,6 +14,7 @@ long __cancel()
return -ECANCELED;
}

#ifndef __EMSCRIPTEN__
long __syscall_cp_asm(volatile void *, syscall_arg_t,
syscall_arg_t, syscall_arg_t, syscall_arg_t,
syscall_arg_t, syscall_arg_t, syscall_arg_t);
Expand Down Expand Up @@ -67,6 +67,7 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx)

__syscall(SYS_tkill, self->tid, SIGCANCEL);
}
#endif

void __testcancel()
{
Expand All @@ -75,6 +76,7 @@ void __testcancel()
__cancel();
}

#ifndef __EMSCRIPTEN__
static void init_cancellation()
{
struct sigaction sa = {
Expand Down
2 changes: 0 additions & 2 deletions system/lib/pthread/library_pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

#include "threading_internal.h"

void __pthread_testcancel();

int emscripten_pthread_attr_gettransferredcanvases(const pthread_attr_t* a, const char** str) {
*str = a->_a_transferredcanvases;
return 0;
Expand Down
2 changes: 2 additions & 0 deletions system/lib/pthread/library_pthread_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ int pthread_cancel(pthread_t thread) {
return 0;
}

void pthread_testcancel() {}

_Noreturn void __pthread_exit(void* status) {
exit(0);
}
Expand Down
20 changes: 0 additions & 20 deletions system/lib/pthread/pthread_testcancel.c

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $__pthread_setcancelstate
$__set_thread_state
$__stdio_write
$__timedwait
$__wake
$__wake.2
$__wasi_syscall_ret
$__wasm_call_ctors
$__wasm_init_memory
Expand All @@ -22,7 +22,7 @@ $_emscripten_thread_init
$_main_thread
$a_cas
$a_dec
$a_fetch_add
$a_fetch_add.1
$a_inc
$a_swap
$add
Expand Down
3 changes: 0 additions & 3 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,15 +827,12 @@ def get_files(self):
'syscall_cp.c', 'tls.c',
# TODO: Support this. See #12216.
'pthread_setname_np.c',
# TODO: Prefer to use the musl implementation.
'pthread_testcancel.c',
]
libc_files += files_in_path(
path='system/lib/pthread',
filenames=[
'library_pthread.c',
'pthread_create.c',
'pthread_testcancel.c',
'emscripten_proxy_main.c',
'emscripten_thread_init.c',
'emscripten_thread_state.S',
Expand Down