Fix the pthread_setname_np test.

Fix the pthread_setname_np test to take into account that emulator kernels are
so old that they don't support setting the name of other threads.

The CLONE_DETACHED thread is obsolete since 2.5 kernels.

Rename kernel_id to tid.

Fix the signature of __pthread_clone.

Clean up the clone and pthread_setname_np implementations slightly.

Change-Id: I16c2ff8845b67530544bbda9aa6618058603066d
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index 266d6fa..6038056 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -73,14 +73,15 @@
   unsigned stack_size = 128 * 1024;
   unsigned stack_bottom = stack_top - stack_size;
 
+  static void* tls[BIONIC_TLS_SLOTS];
   static pthread_internal_t thread;
+  thread.tid = gettid();
+  thread.tls = tls;
   pthread_attr_init(&thread.attr);
   pthread_attr_setstack(&thread.attr, (void*) stack_bottom, stack_size);
-  _init_thread(&thread, gettid(), false);
-
-  static void* tls_area[BIONIC_TLS_SLOTS];
-  __init_tls(tls_area, &thread);
-  tls_area[TLS_SLOT_BIONIC_PREINIT] = &args;
+  _init_thread(&thread, false);
+  __init_tls(&thread);
+  tls[TLS_SLOT_BIONIC_PREINIT] = &args;
 }
 
 void __libc_init_common(KernelArgumentBlock& args) {