diff options
-rw-r--r-- | libc/bionic/libc_init_common.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp index c22f5718e..2396c3678 100644 --- a/libc/bionic/libc_init_common.cpp +++ b/libc/bionic/libc_init_common.cpp @@ -46,6 +46,7 @@ #include "private/KernelArgumentBlock.h" #include "private/WriteProtected.h" #include "private/bionic_auxv.h" +#include "private/bionic_defs.h" #include "private/bionic_globals.h" #include "private/bionic_tls.h" #include "private/thread_private.h" @@ -107,6 +108,13 @@ static void arc4random_fork_handler() { _thread_arc4_lock(); } +__BIONIC_WEAK_FOR_NATIVE_BRIDGE +void __libc_add_main_thread() { + // Get the main thread from TLS and add it to the thread list. + pthread_internal_t* main_thread = __get_thread(); + __pthread_internal_add(main_thread); +} + void __libc_init_common(KernelArgumentBlock& args) { // Initialize various globals. environ = args.envp; @@ -118,9 +126,7 @@ void __libc_init_common(KernelArgumentBlock& args) { __check_max_thread_id(); #endif - // Get the main thread from TLS and add it to the thread list. - pthread_internal_t* main_thread = __get_thread(); - __pthread_internal_add(main_thread); + __libc_add_main_thread(); // Register atfork handlers to take and release the arc4random lock. pthread_atfork(arc4random_fork_handler, _thread_arc4_unlock, _thread_arc4_unlock); |