This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/54129] emulated __thread variables and pthread_*specific data
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 30 Jul 2012 20:50:21 +0000
- Subject: [Bug middle-end/54129] emulated __thread variables and pthread_*specific data
- Auto-submitted: auto-generated
- References: <bug-54129-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54129
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-07-30 20:50:21 UTC ---
>Where is the code in the destructor for the __thread variables?
in libgcc/emutls.c .
The code is:
static void
emutls_destroy (void *ptr)
{
struct __emutls_array *arr = ptr;
pointer size = arr->size;
pointer i;
for (i = 0; i < size; ++i)
{
if (arr->data[i])
free (arr->data[i][-1]);
}
free (ptr);
}
static void
emutls_init (void)
{
#ifndef __GTHREAD_MUTEX_INIT
__GTHREAD_MUTEX_INIT_FUNCTION (&emutls_mutex);
#endif
if (__gthread_key_create (&emutls_key, emutls_destroy) != 0)
abort ();
}
--- CUT ----
So it does is free the current thread memory.
__gthread_key_create is a simple wrapper around pthread_key_create.