diff options
author | Yabin Cui <yabinc@google.com> | 2015-03-05 18:26:43 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-03-05 18:26:44 +0000 |
commit | c3307dc43b2526c4031837738b139d22831c5d09 (patch) | |
tree | 483094a914357a55a76dcea7f94bf167aa155f1b /libc/private | |
parent | 5d400204589ceb781fa11864c2e8f3001e5dc96f (diff) | |
parent | 4a2891d8c8f09a64ea9e1479518b0cc969bd5969 (diff) | |
download | bionic-c3307dc43b2526c4031837738b139d22831c5d09.zip bionic-c3307dc43b2526c4031837738b139d22831c5d09.tar.gz bionic-c3307dc43b2526c4031837738b139d22831c5d09.tar.bz2 |
Merge "Better control of pthread keys used in bionic."
Diffstat (limited to 'libc/private')
-rw-r--r-- | libc/private/ThreadLocalBuffer.h | 10 | ||||
-rw-r--r-- | libc/private/bionic_tls.h | 4 |
2 files changed, 8 insertions, 6 deletions
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) \ diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h index 04f5fd2..724f896 100644 --- a/libc/private/bionic_tls.h +++ b/libc/private/bionic_tls.h @@ -78,7 +78,7 @@ enum { * Following are current pthread keys used internally by libc: * basename libc (GLOBAL_INIT_THREAD_LOCAL_BUFFER) * dirname libc (GLOBAL_INIT_THREAD_LOCAL_BUFFER) - * uselocale libc + * uselocale libc (BIONIC_PTHREAD_KEY_WITH_CONSTRUCTOR) * getmntent_mntent libc (GLOBAL_INIT_THREAD_LOCAL_BUFFER) * getmntent_strings libc (GLOBAL_INIT_THREAD_LOCAL_BUFFER) * ptsname libc (GLOBAL_INIT_THREAD_LOCAL_BUFFER) @@ -87,7 +87,7 @@ enum { * strsignal libc (GLOBAL_INIT_THREAD_LOCAL_BUFFER) * passwd libc (GLOBAL_INIT_THREAD_LOCAL_BUFFER) * group libc (GLOBAL_INIT_THREAD_LOCAL_BUFFER) - * _res_key libc + * _res_key libc (BIONIC_PTHREAD_KEY_WITH_CONSTRUCTOR) */ #define LIBC_PTHREAD_KEY_RESERVED_COUNT 12 |