Better control of pthread keys used in bionic.

Change-Id: I1e1bc77c0e7879baead6c3417282ce549a1153b5
diff --git a/libc/private/ThreadLocalBuffer.h b/libc/private/ThreadLocalBuffer.h
index e5bd28c..cc47317 100644
--- a/libc/private/ThreadLocalBuffer.h
+++ b/libc/private/ThreadLocalBuffer.h
@@ -38,15 +38,17 @@
 
 // We used to use pthread_once to initialize the keys, but life is more predictable
 // if we allocate them all up front when the C library starts up, via __constructor__.
+#define BIONIC_PTHREAD_KEY_WITH_CONSTRUCTOR(key_name, key_destructor) \
+  static pthread_key_t key_name; \
+  __attribute__((constructor)) static void __bionic_tls_ ## key_name ## _key_init() { \
+    pthread_key_create(&key_name, key_destructor); \
+  }
 
 #define GLOBAL_INIT_THREAD_LOCAL_BUFFER(name) \
-  static pthread_key_t __bionic_tls_ ## name ## _key; \
   static void __bionic_tls_ ## name ## _key_destroy(void* buffer) { \
     free(buffer); \
   } \
-  __attribute__((constructor)) static void __bionic_tls_ ## name ## _key_init() { \
-    pthread_key_create(&__bionic_tls_ ## name ## _key, __bionic_tls_ ## name ## _key_destroy); \
-  }
+  BIONIC_PTHREAD_KEY_WITH_CONSTRUCTOR(__bionic_tls_ ## name ## _key, __bionic_tls_ ## name ## _key_destroy)
 
 // Leaves "name_tls_buffer" and "name_tls_buffer_size" defined and initialized.
 #define LOCAL_INIT_THREAD_LOCAL_BUFFER(type, name, byte_count) \