Switch pthread_create over to __bionic_clone.

Bug: 8206355
Bug: 11693195
Change-Id: I04aadbc36c87e1b7e33324b9a930a1e441fbfed6
diff --git a/libc/bionic/__thread_entry.cpp b/libc/bionic/__thread_entry.cpp
index 8300a64..3505f8b 100644
--- a/libc/bionic/__thread_entry.cpp
+++ b/libc/bionic/__thread_entry.cpp
@@ -32,26 +32,28 @@
 
 #include "private/bionic_tls.h"
 
-// This trampoline is called from the assembly _pthread_clone function.
-// Our 'tls' and __pthread_clone's 'child_stack' are one and the same, just growing in
-// opposite directions.
-extern "C" void __thread_entry(void* (*func)(void*), void* arg, void** tls) {
+// This trampoline is called from the assembly __bionic_clone function.
+int __thread_entry(void* arg) {
+  pthread_internal_t* thread = reinterpret_cast<pthread_internal_t*>(arg);
+
   // Wait for our creating thread to release us. This lets it have time to
   // notify gdb about this thread before we start doing anything.
   // This also provides the memory barrier needed to ensure that all memory
   // accesses previously made by the creating thread are visible to us.
-  pthread_mutex_t* start_mutex = (pthread_mutex_t*) &tls[TLS_SLOT_SELF];
+  pthread_mutex_t* start_mutex = (pthread_mutex_t*) &thread->tls[TLS_SLOT_START_MUTEX];
   pthread_mutex_lock(start_mutex);
   pthread_mutex_destroy(start_mutex);
 
-  pthread_internal_t* thread = (pthread_internal_t*) tls[TLS_SLOT_THREAD_ID];
-  thread->tls = tls;
   __init_tls(thread);
 
+  __init_alternate_signal_stack(thread);
+
   if ((thread->internal_flags & PTHREAD_INTERNAL_FLAG_THREAD_INIT_FAILED) != 0) {
     pthread_exit(NULL);
   }
 
-  void* result = func(arg);
+  void* result = thread->start_routine(thread->start_routine_arg);
   pthread_exit(result);
+
+  return 0;
 }