diff options
author | Evgeny Eltsin <eaeltsin@google.com> | 2018-04-19 18:39:48 +0200 |
---|---|---|
committer | Evgeny Eltsin <eaeltsin@google.com> | 2018-04-19 18:39:48 +0200 |
commit | 4c9504aa6cb4dad5142056d5e46bcb8409fd476d (patch) | |
tree | 7a31bb065ef29aa42c26db458684ef42359b4638 | |
parent | 9302cf252687b8705570b794a901959efc0c26af (diff) | |
download | bionic-4c9504aa6cb4dad5142056d5e46bcb8409fd476d.tar.gz |
Add __libc_add_main_thread and mark it weak
This complements __libc_init_main_thread in setting up main thread
under native bridge.
Test: run_tests
Bug: 77877742
Change-Id: I53efab66f285a1b9f0ab36d44386fa1e2621e4ba
-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); |