aboutsummaryrefslogtreecommitdiffstats
path: root/libc/private/ThreadLocalBuffer.h
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-02-12 06:06:22 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-02-12 06:06:22 +0000
commit6f94de3ca49e4ea147b1c59e5818fa175846518f (patch)
tree9a2c45004114f53c4cf1f9468a58fe54c58320fa /libc/private/ThreadLocalBuffer.h
parent2a1bb4e64677b9abbc17173c79768ed494565047 (diff)
downloadandroid_bionic-6f94de3ca49e4ea147b1c59e5818fa175846518f.tar.gz
android_bionic-6f94de3ca49e4ea147b1c59e5818fa175846518f.tar.bz2
android_bionic-6f94de3ca49e4ea147b1c59e5818fa175846518f.zip
Revert "More pthreads cleanup."
This reverts commit 2a1bb4e64677b9abbc17173c79768ed494565047 Change-Id: Ia443d0748015c8e9fc3121e40e68258616767b51
Diffstat (limited to 'libc/private/ThreadLocalBuffer.h')
-rw-r--r--libc/private/ThreadLocalBuffer.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/libc/private/ThreadLocalBuffer.h b/libc/private/ThreadLocalBuffer.h
index 703acd67a..1c5e3f48a 100644
--- a/libc/private/ThreadLocalBuffer.h
+++ b/libc/private/ThreadLocalBuffer.h
@@ -37,17 +37,18 @@
// TODO: move __cxa_guard_acquire and __cxa_guard_release into libc.
#define GLOBAL_INIT_THREAD_LOCAL_BUFFER(name) \
+ static pthread_once_t __bionic_tls_ ## name ## _once; \
static pthread_key_t __bionic_tls_ ## name ## _key; \
static void __bionic_tls_ ## name ## _key_destroy(void* buffer) { \
free(buffer); \
} \
- /* Run automatically when libc.so is opened by the dynamic linker. */ \
- __attribute__((constructor)) static void __bionic_tls_ ## name ## _key_init() { \
+ static void __bionic_tls_ ## name ## _key_init() { \
pthread_key_create(&__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) \
+ pthread_once(&__bionic_tls_ ## name ## _once, __bionic_tls_ ## name ## _key_init); \
type name ## _tls_buffer = \
reinterpret_cast<type>(pthread_getspecific(__bionic_tls_ ## name ## _key)); \
if (name ## _tls_buffer == NULL) { \