Back to index

glibc  2.9
Functions | Variables
pthread_once.c File Reference
#include "pthreadP.h"
#include <lowlevellock.h>

Go to the source code of this file.


int __pthread_once (pthread_once_t *once_control, void(*)(void) init_routine)


static int once_lock = LLL_LOCK_INITIALIZER

Function Documentation

int __pthread_once ( pthread_once_t once_control,
void (*) (void)  init_routine 

Definition at line 29 of file pthread_once.c.

  /* XXX Depending on whether the LOCK_IN_ONCE_T is defined use a
     global lock variable or one which is part of the pthread_once_t
     object.  */
  if (*once_control == PTHREAD_ONCE_INIT)
      lll_lock (once_lock, LLL_PRIVATE);

      /* XXX This implementation is not complete.  It doesn't take
        cancelation and fork into account.  */
      if (*once_control == PTHREAD_ONCE_INIT)
         init_routine ();

         *once_control = !PTHREAD_ONCE_INIT;

      lll_unlock (once_lock, LLL_PRIVATE);

  return 0;

Variable Documentation

Definition at line 25 of file pthread_once.c.