Example #1
0
internal_function
__libc_pthread_init (unsigned long int *ptr, void (*reclaim) (void),
		     const struct pthread_functions *functions)
{
  /* Remember the pointer to the generation counter in libpthread.  */
  __fork_generation_pointer = ptr;

  /* Called by a child after fork.  */
  __register_atfork (NULL, NULL, reclaim, NULL);

#ifdef SHARED
  /* Copy the function pointers into an array in libc.  This enables
     access with just one memory reference but moreso, it prevents
     hijacking the function pointers with just one pointer change.  We
     "encrypt" the function pointers since we cannot write-protect the
     array easily enough.  */
  union ptrhack
  {
    struct pthread_functions pf;
# define NPTRS (sizeof (struct pthread_functions) / sizeof (void *))
    void *parr[NPTRS];
  } __attribute__ ((may_alias)) const *src;
  union ptrhack *dest;

  src = (const void *) functions;
  dest = (void *) &__libc_pthread_functions;

  for (size_t cnt = 0; cnt < NPTRS; ++cnt)
    {
      void *p = src->parr[cnt];
      PTR_MANGLE (p);
      dest->parr[cnt] = p;
    }
  __libc_pthread_functions_init = 1;
#endif

#ifndef TLS_MULTIPLE_THREADS_IN_TCB
  return &__libc_multiple_threads;
#endif
}
Example #2
0
int
pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
{
	return __register_atfork(prepare, parent, child);
}
Example #3
0
static int __app_register_atfork (void (*prepare) (void), void (*parent) (void), void (*child) (void))
{
  return __register_atfork (prepare, parent, child,
			    &__dso_handle == NULL ? NULL : __dso_handle);
}