aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9
diff options
context:
space:
mode:
authorCaroline Tice <cmtice@google.com>2018-01-19 20:17:11 (GMT)
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-01-19 20:17:11 (GMT)
commit430f43829fa42b459ccbb53b44843c54c8ba4550 (patch)
treead64b0f67f8165c0e9c92540aba2f290c7659d48 /gcc-4.9
parentdeec799746e92ab0487eca489499ade08a2610bf (diff)
parent46936205f991de051a9555a03f856683475a2be5 (diff)
downloadtoolchain_gcc-430f43829fa42b459ccbb53b44843c54c8ba4550.zip
toolchain_gcc-430f43829fa42b459ccbb53b44843c54c8ba4550.tar.gz
toolchain_gcc-430f43829fa42b459ccbb53b44843c54c8ba4550.tar.bz2
Merge "[libgcc] Fix emutls.c to not leak pthread keys."
Diffstat (limited to 'gcc-4.9')
-rw-r--r--gcc-4.9/libgcc/emutls.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc-4.9/libgcc/emutls.c b/gcc-4.9/libgcc/emutls.c
index fd6d86e..77550e0 100644
--- a/gcc-4.9/libgcc/emutls.c
+++ b/gcc-4.9/libgcc/emutls.c
@@ -60,6 +60,7 @@ static __gthread_mutex_t emutls_mutex = __GTHREAD_MUTEX_INIT;
static __gthread_mutex_t emutls_mutex;
#endif
static __gthread_key_t emutls_key;
+static int emutls_key_created = 0;
static pointer emutls_size;
static void
@@ -86,9 +87,18 @@ emutls_init (void)
#endif
if (__gthread_key_create (&emutls_key, emutls_destroy) != 0)
abort ();
+ emutls_key_created = 1;
}
#endif
+__attribute__((destructor))
+static void
+unregister_emutls_key (void)
+{
+ if (emutls_key_created)
+ __gthread_key_delete (emutls_key);
+}
+
static void *
emutls_alloc (struct __emutls_object *obj)
{