Back to index

glibc  2.9
Functions | Variables
libc_pthread_init.c File Reference
#include <unistd.h>
#include <list.h>
#include <fork.h>
#include <dl-sysdep.h>
#include <tls.h>
#include <string.h>
#include <pthreadP.h>
#include <bits/libc-lock.h>
#include <sysdep.h>
#include <ldsodefs.h>

Go to the source code of this file.

Functions

int__libc_pthread_init (unsigned long int *ptr, void(*)(void) reclaim, const struct pthread_functions *functions)

Variables

int __libc_multiple_threads attribute_hidden

Function Documentation

int* __libc_pthread_init ( unsigned long int ptr,
void (*) (void)  reclaim,
const struct pthread_functions functions 
)

Definition at line 39 of file libc_pthread_init.c.

{
  /* 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;
    void *parr[1];
  } const *src;
  union ptrhack *dest;
# define NPTRS (sizeof (struct pthread_functions) / sizeof (void *))

  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
}

Here is the call graph for this function:


Variable Documentation

int __libc_multiple_threads attribute_hidden

Definition at line 25 of file init-first.c.