src/atrshmlogc.c
volatile const void* atrshmlog_get_thread_locals_adress(void)
{
  // are we before attach ? 
  if (atrshmlog_key_once == 0)
    {
      int ret = pthread_key_create(&atrshmlog_pthread_key, atrshmlog_destruct_specific);

      ++atrshmlog_key_once; 

      if (ret != 0)
	{

	  // sorry pal - but we are simply out of options.

	  // no more tries
	
	  return 0;
	}
    }
  
  void *my_tls = pthread_getspecific(atrshmlog_pthread_key);

  if (my_tls == NULL)
    {
      atrshmlog_g_tl_t * p = (atrshmlog_g_tl_t*)calloc(1, sizeof(atrshmlog_g_tl_t));

      if (p)
	{
	  p->atrshmlog_idnotok = -1;

	  int ret = pthread_setspecific(atrshmlog_pthread_key, (const void*)p);

	  if (ret == 0)
	    {
	      // ok. we have at least now a valid buffer.
	      return (volatile const void*)p;
	    }
	  else
	    {
	      free(p);

	      return 0;
	    }
	}
      else
	{
	  return 0;
	}
    }
  else
    {
      return (volatile const void*)my_tls;
    }
}
// this is now a new thing. we use internal the key from  - hopeful - attach.
// then we check for it and get our data ptr.
// if no ptr is there we malloc and deliver the thing
// to the caller.
// we need a destroy here, but this is for later ...
this is now a new thing. we use internal the key from  - hopeful - attach.
then we check for it and get our data ptr.
if no ptr is there we malloc and deliver the thing
to the caller.
we need a destroy here, but this is for later
this is now a new thing . we use internal the key from - hopeful - attach . then we check for it and get our data ptr . if no ptr is there we malloc and deliver the thing to the caller . we need a destroy here but this is for later
volatile const void* atrshmlog_get_thread_locals_adress(void)
{
  if (atrshmlog_key_once == 0)
    {
      int ret = pthread_key_create(&atrshmlog_pthread_key, atrshmlog_destruct_specific);
      ++atrshmlog_key_once; 
      if (ret != 0)
	{
	  return 0;
	}
    }
  void *my_tls = pthread_getspecific(atrshmlog_pthread_key);
  if (my_tls == NULL)
    {
      atrshmlog_g_tl_t * p = (atrshmlog_g_tl_t*)calloc(1, sizeof(atrshmlog_g_tl_t));
      if (p)
	{
	  p->atrshmlog_idnotok = -1;
	  int ret = pthread_setspecific(atrshmlog_pthread_key, (const void*)p);
	  if (ret == 0)
	    {
	      return (volatile const void*)p;
	    }
	  else
	    {
	      free(p);
	      return 0;
	    }
	}
      else
	{
	  return 0;
	}
    }
  else
    {
      return (volatile const void*)my_tls;
    }
}
volatile const void * atrshmlog_get_thread_locals_adress ( void ) { if ( atrshmlog_key_once == 0 ) { int ret = pthread_key_create ( & atrshmlog_pthread_key , atrshmlog_destruct_specific ) ; ++ atrshmlog_key_once ; if ( ret != 0 ) { return 0 ; } } void * my_tls = pthread_getspecific ( atrshmlog_pthread_key ) ; if ( my_tls == NULL ) { atrshmlog_g_tl_t * p = ( atrshmlog_g_tl_t * ) calloc ( 1 , sizeof ( atrshmlog_g_tl_t ) ) ; if ( p ) { p -> atrshmlog_idnotok = -1 ; int ret = pthread_setspecific ( atrshmlog_pthread_key , ( const void * ) p ) ; if ( ret == 0 ) { return ( volatile const void * ) p ; } else { free ( p ) ; return 0 ; } } else { return 0 ; } } else { return ( volatile const void * ) my_tls ; } }
this is now a new thing.
this is now a new thing .
// are we before attach ?  // sorry pal - but we are simply out of options. // no more tries // ok. we have at least now a valid buffer.