Merge "Add __libc_add_main_thread and mark it weak"

This commit is contained in:
Treehugger Robot 2018-04-22 17:27:34 +00:00 committed by Gerrit Code Review
commit 67b5979930
1 changed files with 9 additions and 3 deletions

View File

@ -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);