Skip to content
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
28 changes: 0 additions & 28 deletions src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ var LibraryPThread = {
},
// Maps pthread_t to pthread info objects
pthreads: {},
threadExitHandlers: [], // An array of C functions to run when this thread exits.

#if PTHREADS_PROFILING
createProfilerBlock: function(pthreadPtr) {
Expand Down Expand Up @@ -985,39 +984,12 @@ var LibraryPThread = {
return 0;
},

__pthread_exit_run_handlers__deps: ['exit'],
__pthread_exit_run_handlers: function(status) {
// Called from pthread_exit, either when called explicitly called
// by programmer, or implicitly when leaving the thread main function.
//
// Note: in theory we would like to return any offscreen canvases back to
// the main thread, but if we ever fetched a rendering context for them that
// would not be valid, so we don't try.

#if PTHREADS_DEBUG
var tb = _pthread_self();
assert(tb);
err('Pthread 0x' + tb.toString(16) + ' exited.');
#endif

while (PThread.threadExitHandlers.length > 0) {
PThread.threadExitHandlers.pop()();
}
},

__pthread_detached_exit: function() {
// Called at the end of pthread_exit (which occurs also when leaving the
// thread main function) if an only if the thread is in a detached state.
postMessage({ 'cmd': 'detachedExit' });
},

__cxa_thread_atexit__sig: 'vii',
__cxa_thread_atexit: function(routine, arg) {
PThread.threadExitHandlers.push(function() { {{{ makeDynCall('vi', 'routine') }}}(arg) });
},
__cxa_thread_atexit_impl: '__cxa_thread_atexit',


// Returns 0 on success, or one of the values -ETIMEDOUT, -EWOULDBLOCK or -EINVAL on error.
emscripten_futex_wait__deps: ['emscripten_main_thread_process_queued_calls'],
emscripten_futex_wait: function(addr, val, timeout) {
Expand Down
7 changes: 6 additions & 1 deletion system/lib/libcxxabi/src/cxa_thread_atexit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,14 @@ extern "C" {
#ifdef HAVE___CXA_THREAD_ATEXIT_IMPL
return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
#else
#ifndef __EMSCRIPTEN__
// Emscripten doesn't fully support weak undefined symbols yet
// https://github.com/emscripten-core/emscripten/issues/12819
if (__cxa_thread_atexit_impl) {
return __cxa_thread_atexit_impl(dtor, obj, dso_symbol);
} else {
} else
#endif
{
// Initialize the dtors std::__libcpp_tls_key (uses __cxa_guard_*() for
// one-time initialization and __cxa_atexit() for destruction)
static DtorsManager manager;
Expand Down
5 changes: 0 additions & 5 deletions system/lib/pthread/pthread_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

extern int __pthread_create_js(struct pthread *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
extern void _emscripten_thread_init(int, int, int);
extern void __pthread_exit_run_handlers();
extern void __pthread_detached_exit();
extern void* _emscripten_tls_base();
extern int8_t __dso_handle;
Expand Down Expand Up @@ -125,10 +124,6 @@ void _emscripten_thread_exit(void* result) {
// Run any handlers registered with pthread_cleanup_push
__run_cleanup_handlers();

// Run any JS thread exit handlers (for C++ programs this includes any
// functions registered with __cxa_thread_atexit).
__pthread_exit_run_handlers();

// Call into the musl function that runs destructors of all thread-specific data.
__pthread_tsd_run_dtors();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ L
M
N
O
P
u
v
w
x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ a.q
a.r
a.s
a.t
a.u
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ q
r
s
t
u
1 change: 1 addition & 0 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@ def get_files(self):
'cxa_guard.cpp',
'cxa_handlers.cpp',
'cxa_virtual.cpp',
'cxa_thread_atexit.cpp',
'fallback_malloc.cpp',
'stdlib_new_delete.cpp',
'stdlib_exception.cpp',
Expand Down