Skip to content

Commit

Permalink
Rename a few internal function for consistency. NFC (#21787)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Apr 19, 2024
1 parent d9aed28 commit 1ca2f31
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/library_pthread.js
Expand Up @@ -551,14 +551,14 @@ var LibraryPThread = {
worker.pthread_ptr = 0;
},

__emscripten_thread_cleanup: (thread) => {
_emscripten_thread_cleanup: (thread) => {
// Called when a thread needs to be cleaned up so it can be reused.
// A thread is considered reusable when it either returns from its
// entry point, calls pthread_exit, or acts upon a cancellation.
// Detached threads are responsible for calling this themselves,
// otherwise pthread_join is responsible for calling this.
#if PTHREADS_DEBUG
dbg(`__emscripten_thread_cleanup: ${ptrToString(thread)}`)
dbg(`_emscripten_thread_cleanup: ${ptrToString(thread)}`)
#endif
if (!ENVIRONMENT_IS_PTHREAD) cleanupThread(thread);
else postMessage({ 'cmd': 'cleanupThread', 'thread': thread });
Expand Down Expand Up @@ -702,7 +702,7 @@ var LibraryPThread = {
#endif
navigator['hardwareConcurrency'],

__emscripten_init_main_thread_js: (tb) => {
_emscripten_init_main_thread_js: (tb) => {
// Pass the thread address to the native code where they stored in wasm
// globals which act as a form of TLS. Global constructors trying
// to access this value will read the wrong value, but that is UB anyway.
Expand Down
4 changes: 2 additions & 2 deletions src/library_sigs.js
Expand Up @@ -225,8 +225,6 @@ sigs = {
__cxa_rethrow_primary_exception__sig: 'vp',
__cxa_throw__sig: 'vppp',
__cxa_uncaught_exceptions__sig: 'i',
__emscripten_init_main_thread_js__sig: 'vp',
__emscripten_thread_cleanup__sig: 'vp',
__handle_stack_overflow__sig: 'vp',
__pthread_create_js__sig: 'ipppp',
__pthread_kill_js__sig: 'ipi',
Expand Down Expand Up @@ -324,6 +322,7 @@ sigs = {
_emscripten_fs_load_embedded_files__sig: 'vp',
_emscripten_get_now_is_monotonic__sig: 'i',
_emscripten_get_progname__sig: 'vpi',
_emscripten_init_main_thread_js__sig: 'vp',
_emscripten_lookup_name__sig: 'ip',
_emscripten_memcpy_js__sig: 'vppp',
_emscripten_notify_mailbox_postmessage__sig: 'vppp',
Expand All @@ -333,6 +332,7 @@ sigs = {
_emscripten_runtime_keepalive_clear__sig: 'v',
_emscripten_set_offscreencanvas_size__sig: 'ipii',
_emscripten_system__sig: 'ip',
_emscripten_thread_cleanup__sig: 'vp',
_emscripten_thread_exit_joinable__sig: 'vp',
_emscripten_thread_mailbox_await__sig: 'vp',
_emscripten_thread_set_strongref__sig: 'vp',
Expand Down
4 changes: 2 additions & 2 deletions src/library_wasm_worker.js
Expand Up @@ -73,7 +73,7 @@ addToLibrary({
'$_wasmWorkerDelayedMessageQueue',
'$_wasmWorkerRunPostMessage',
'$_wasmWorkerAppendToQueue',
'emscripten_wasm_worker_initialize',
'_emscripten_wasm_worker_initialize',
#if PTHREADS
'__set_thread_state',
#endif
Expand All @@ -96,7 +96,7 @@ addToLibrary({
___set_stack_limits(m['sb'] + m['sz'], m['sb']);
#endif
// Run the C side Worker initialization for stack and TLS.
_emscripten_wasm_worker_initialize(m['sb'], m['sz']);
__emscripten_wasm_worker_initialize(m['sb'], m['sz']);
#if PTHREADS
// Record that this Wasm Worker supports synchronous blocking in emscripten_futex_wake().
___set_thread_state(/*thread_ptr=*/0, /*is_main_thread=*/0, /*is_runtime_thread=*/0, /*supports_wait=*/0);
Expand Down
6 changes: 3 additions & 3 deletions system/lib/compiler-rt/stack_limits.S
Expand Up @@ -85,9 +85,9 @@ emscripten_stack_get_free:
#ifdef __EMSCRIPTEN_WASM_WORKERS__
# TODO: Relocate the following to its own file wasm_worker.S, but need to figure out how to reference
# __stack_base and __stack_end globals from a separate file as externs in order for that to work.
.globl emscripten_wasm_worker_initialize
emscripten_wasm_worker_initialize:
.functype emscripten_wasm_worker_initialize (PTR /*stackLowestAddress*/, i32 /*stackSize*/) -> ()
.globl _emscripten_wasm_worker_initialize
_emscripten_wasm_worker_initialize:
.functype _emscripten_wasm_worker_initialize (PTR /*stackLowestAddress*/, i32 /*stackSize*/) -> ()

// __stack_end = stackLowestAddress + (__builtin_wasm_tls_size() + 15) & -16;
local.get 0
Expand Down
2 changes: 1 addition & 1 deletion system/lib/libc/musl/src/thread/pthread_join.c
Expand Up @@ -45,7 +45,7 @@ static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec
if (res) *res = t->result;
#ifdef __EMSCRIPTEN__
// Thread was exited during this call, be sure to clean it up.
if (state == DT_EXITED) __emscripten_thread_cleanup(t);
if (state == DT_EXITED) _emscripten_thread_cleanup(t);
#else // XXX Emscripten map_base unused
if (t->map_base) __munmap(t->map_base, t->map_size);
#endif
Expand Down
4 changes: 2 additions & 2 deletions system/lib/pthread/library_pthread.c
Expand Up @@ -137,8 +137,8 @@ weak_alias(dummy_tsd, __pthread_tsd_main);

// See system/lib/README.md for static constructor ordering.
__attribute__((constructor(48)))
void __emscripten_init_main_thread(void) {
__emscripten_init_main_thread_js(&__main_pthread);
void _emscripten_init_main_thread(void) {
_emscripten_init_main_thread_js(&__main_pthread);

// The pthread struct has a field that points to itself - this is used as
// a magic ID to detect whether the pthread_t structure is 'alive'.
Expand Down
2 changes: 1 addition & 1 deletion system/lib/pthread/pthread_create.c
Expand Up @@ -335,7 +335,7 @@ void _emscripten_thread_exit(void* result) {
int state = a_cas(&self->detach_state, DT_JOINABLE, DT_EXITING);

if (state == DT_DETACHED) {
__emscripten_thread_cleanup(self);
_emscripten_thread_cleanup(self);
} else {
// Mark the thread as no longer running, so it can be joined.
// Once we publish this, any threads that are waiting to join with us can
Expand Down
4 changes: 2 additions & 2 deletions system/lib/pthread/threading_internal.h
Expand Up @@ -43,9 +43,9 @@ typedef struct thread_profiler_block {
// the current time.
void _emscripten_yield(double now);

void __emscripten_init_main_thread_js(void* tb);
void _emscripten_init_main_thread_js(void* tb);
void _emscripten_thread_profiler_enable();
void __emscripten_thread_cleanup(pthread_t thread);
void _emscripten_thread_cleanup(pthread_t thread);

hidden void* _emscripten_tls_init(void);
hidden void _emscripten_tls_free(void);
Expand Down
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_pthreads.gzsize
@@ -1 +1 @@
5254
5253
2 changes: 1 addition & 1 deletion tools/emscripten.py
Expand Up @@ -1042,11 +1042,11 @@ def create_pointer_conversion_wrappers(metadata):
'_emscripten_thread_free_data': '_p',
'_emscripten_dlsync_self_async': '_p',
'_emscripten_proxy_dlsync_async': '_pp',
'_emscripten_wasm_worker_initialize': '_p_',
'_wasmfs_rmdir': '_p',
'_wasmfs_unlink': '_p',
'_wasmfs_mkdir': '_p_',
'_wasmfs_open': '_p__',
'emscripten_wasm_worker_initialize': '_p_',
'asyncify_start_rewind': '_p',
'asyncify_start_unwind': '_p',
'__get_exception_message': '_ppp',
Expand Down

0 comments on commit 1ca2f31

Please sign in to comment.