[PATCH] D52251: [builtins] Add __emutls_unregister_key function

Yi Kong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 19 18:05:53 PDT 2018


This revision was automatically updated to reflect the committed changes.
kongyi marked an inline comment as done.
Closed by commit rCRT342608: [builtins] Add __emutls_unregister_key function (authored by kongyi, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D52251

Files:
  lib/builtins/emutls.c


Index: lib/builtins/emutls.c
===================================================================
--- lib/builtins/emutls.c
+++ lib/builtins/emutls.c
@@ -42,6 +42,7 @@
 
 static pthread_mutex_t emutls_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_key_t emutls_pthread_key;
+static bool emutls_key_created = false;
 
 typedef unsigned int gcc_word __attribute__((mode(word)));
 typedef unsigned int gcc_pointer __attribute__((mode(pointer)));
@@ -109,6 +110,7 @@
 static __inline void emutls_init(void) {
     if (pthread_key_create(&emutls_pthread_key, emutls_key_destructor) != 0)
         abort();
+    emutls_key_created = true;
 }
 
 static __inline void emutls_init_once(void) {
@@ -390,3 +392,14 @@
         array->data[index] = emutls_allocate_object(control);
     return array->data[index];
 }
+
+#ifdef __BIONIC__
+/* Called by Bionic on dlclose to delete the emutls pthread key. */
+__attribute__((visibility("hidden")))
+void __emutls_unregister_key(void) {
+    if (emutls_key_created) {
+        pthread_key_delete(emutls_pthread_key);
+        emutls_key_created = false;
+    }
+}
+#endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52251.166208.patch
Type: text/x-patch
Size: 1109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180920/6258c2e8/attachment.bin>


More information about the llvm-commits mailing list