This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/54129] emulated __thread variables and pthread_*specific data


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]