Better control of pthread keys used in bionic.

Change-Id: I1e1bc77c0e7879baead6c3417282ce549a1153b5
diff --git a/libc/dns/resolv/res_state.c b/libc/dns/resolv/res_state.c
index 7533d19..459f073 100644
--- a/libc/dns/resolv/res_state.c
+++ b/libc/dns/resolv/res_state.c
@@ -39,6 +39,8 @@
 #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
 #include <sys/_system_properties.h>
 
+#include "private/ThreadLocalBuffer.h"
+
 /* Set to 1 to enable debug traces */
 #define DEBUG 0
 
@@ -50,8 +52,6 @@
 #  define D(...)  do{}while(0)
 #endif
 
-static pthread_key_t   _res_key;
-
 typedef struct {
     int                  _h_errno;
     // TODO: Have one __res_state per network so we don't have to repopulate frequently.
@@ -105,12 +105,7 @@
     free(rt);
 }
 
-__attribute__((constructor))
-static void
-_res_init_key( void )
-{
-    pthread_key_create( &_res_key, _res_thread_free );
-}
+BIONIC_PTHREAD_KEY_WITH_CONSTRUCTOR(_res_key, _res_thread_free);
 
 static _res_thread*
 _res_thread_get(void)