summaryrefslogtreecommitdiff
path: root/libc/private/bionic_elf_tls.h
diff options
context:
space:
mode:
authorJustin DeMartino <jjdemartino@google.com>2020-09-21 13:23:58 -0700
committerJustin DeMartino <jjdemartino@google.com>2020-09-21 13:23:58 -0700
commit7e4fe6a28b718ab97c08811566238af2893ca65b (patch)
tree5413a5ec890b5a1ac4fbbe4548b5014e41a2591b /libc/private/bionic_elf_tls.h
parentdcdcb3fa15004669823a3a118189d9d72ff30852 (diff)
parentab08b955a34423d53b28a6210e7530e67241af4a (diff)
Merge SP1A.200921.001
Change-Id: Id2ab019914bb555dadf52c46b8403c0d5fb3c20a
Diffstat (limited to 'libc/private/bionic_elf_tls.h')
-rw-r--r--libc/private/bionic_elf_tls.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/libc/private/bionic_elf_tls.h b/libc/private/bionic_elf_tls.h
index fa1af768e..e0ec7b51d 100644
--- a/libc/private/bionic_elf_tls.h
+++ b/libc/private/bionic_elf_tls.h
@@ -111,6 +111,18 @@ struct TlsModule {
void* soinfo_ptr = nullptr;
};
+// Signature of the callbacks that will be called after DTLS creation and
+// before DTLS destruction.
+typedef void (*dtls_listener_t)(void* dynamic_tls_begin, void* dynamic_tls_end);
+
+// Signature of the thread-exit callbacks.
+typedef void (*thread_exit_cb_t)(void);
+
+struct CallbackHolder {
+ thread_exit_cb_t cb;
+ CallbackHolder* prev;
+};
+
// Table of the ELF TLS modules. Either the dynamic linker or the static
// initialization code prepares this table, and it's then used during thread
// creation and for dynamic TLS lookups.
@@ -128,7 +140,20 @@ struct TlsModules {
// Pointer to a block of TlsModule objects. The first module has ID 1 and
// is stored at index 0 in this table.
size_t module_count = 0;
+ size_t static_module_count = 0;
TlsModule* module_table = nullptr;
+
+ // Callback to be invoked after a dynamic TLS allocation.
+ dtls_listener_t on_creation_cb = nullptr;
+
+ // Callback to be invoked before a dynamic TLS deallocation.
+ dtls_listener_t on_destruction_cb = nullptr;
+
+ // The first thread-exit callback; inlined to avoid allocation.
+ thread_exit_cb_t first_thread_exit_callback = nullptr;
+
+ // The additional callbacks, if any.
+ CallbackHolder* thread_exit_callback_tail_node = nullptr;
};
void __init_static_tls(void* static_tls);
@@ -175,3 +200,4 @@ extern "C" void* TLS_GET_ADDR(const TlsIndex* ti) TLS_GET_ADDR_CCONV;
struct bionic_tcb;
void __free_dynamic_tls(bionic_tcb* tcb);
+void __notify_thread_exit_callbacks();