int __init_thread(pthread_internal_t* thread, bool add_to_thread_list) { int error = 0; // Set the scheduling policy/priority of the thread. if (thread->attr.sched_policy != SCHED_NORMAL) { sched_param param; param.sched_priority = thread->attr.sched_priority; if (sched_setscheduler(thread->tid, thread->attr.sched_policy, ¶m) == -1) { #if __LP64__ // For backwards compatibility reasons, we only report failures on 64-bit devices. error = errno; #endif __libc_format_log(ANDROID_LOG_WARN, "libc", "pthread_create sched_setscheduler call failed: %s", strerror(errno)); } } thread->cleanup_stack = NULL; if (add_to_thread_list) { _pthread_internal_add(thread); } return error; }
__LIBC_ABI_PRIVATE__ int _init_thread(pthread_internal_t* thread, bool add_to_thread_list) { int error = 0; // Set the scheduling policy/priority of the thread. if (thread->attr.sched_policy != SCHED_NORMAL) { struct sched_param param; param.sched_priority = thread->attr.sched_priority; if (sched_setscheduler(thread->tid, thread->attr.sched_policy, ¶m) == -1) { // For backwards compatibility reasons, we just warn about failures here. // error = errno; const char* msg = "pthread_create sched_setscheduler call failed: %s\n"; __libc_format_log(ANDROID_LOG_WARN, "libc", msg, strerror(errno)); } } pthread_cond_init(&thread->join_cond, NULL); thread->join_count = 0; thread->cleanup_stack = NULL; if (add_to_thread_list) { _pthread_internal_add(thread); } return error; }
void __libc_init_common(KernelArgumentBlock& args) { // Initialize various globals. environ = args.envp; errno = 0; __libc_auxv = args.auxv; __progname = args.argv[0] ? args.argv[0] : "<unknown>"; __abort_message_ptr = args.abort_message_ptr; // AT_RANDOM is a pointer to 16 bytes of randomness on the stack. __stack_chk_guard = *reinterpret_cast<uintptr_t*>(getauxval(AT_RANDOM)); // 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); __system_properties_init(); // Requires 'environ'. }
void __libc_init_common(uintptr_t* elf_data) { int argc = *elf_data; char** argv = (char**) (elf_data + 1); char** envp = argv + argc + 1; // Get the main thread from TLS and add it to the thread list. pthread_internal_t* main_thread = __get_thread(); main_thread->allocated_on_heap = false; _pthread_internal_add(main_thread); // Set various globals. errno = 0; __progname = argv[0] ? argv[0] : "<unknown>"; environ = envp; __system_properties_init(); // Requires 'environ'. }