Back to index

glibc  2.9
Defines | Functions | Variables
tst-tsd3.c File Reference
#include <limits.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define TEST_FUNCTION   do_test ()

Functions

static void destr1 (void *arg)
static void destr2 (void *arg)
static void * tf (void *arg)
static int do_test (void)

Variables

static pthread_key_t key1
static pthread_key_t key2
static int left

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 128 of file tst-tsd3.c.


Function Documentation

static void destr1 ( void *  arg) [static]

Definition at line 35 of file tst-tsd3.c.

{
  if (--left > 0)
    {
      puts ("set key2");

      if (pthread_setspecific (key2, (void *) 1l) != 0)
       {
         puts ("destr1: setspecific failed");
         exit (1);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void destr2 ( void *  arg) [static]

Definition at line 51 of file tst-tsd3.c.

{
  if (--left > 0)
    {
      puts ("set key1");

      if (pthread_setspecific (key1, (void *) 1l) != 0)
       {
         puts ("destr2: setspecific failed");
         exit (1);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int do_test ( void  ) [static]

Definition at line 84 of file tst-tsd3.c.

{
  /* Allocate two keys, both with destructors.  */
  if (pthread_key_create (&key1, destr1) != 0
      || pthread_key_create (&key2, destr2) != 0)
    {
      puts ("key_create failed");
      return 1;
    }

  pthread_t th;
  if (pthread_create (&th, NULL, tf, NULL) != 0)
    {
      puts ("create failed");
      return 1;
    }

  if (pthread_join (th, NULL) != 0)
    {
      puts ("join failed");
      return 1;
    }

  if (left != 0)
    {
      printf ("left == %d\n", left);
      return 1;
    }

  if (pthread_getspecific (key1) != NULL)
    {
      puts ("key1 data != NULL");
      return 1;
    }
  if (pthread_getspecific (key2) != NULL)
    {
      puts ("key2 data != NULL");
      return 1;
    }

  return 0;
}

Here is the call graph for this function:

static void* tf ( void *  arg) [static]

Definition at line 67 of file tst-tsd3.c.

{
  /* Let the destructors work.  */
  left = 7;

  if (pthread_setspecific (key1, (void *) 1l) != 0
      || pthread_setspecific (key2, (void *) 1l) != 0)
    {
      puts ("tf: setspecific failed");
      exit (1);
    }

  return NULL;
}

Here is the call graph for this function:


Variable Documentation

pthread_key_t key1 [static]

Definition at line 27 of file tst-tsd3.c.

pthread_key_t key2 [static]

Definition at line 28 of file tst-tsd3.c.

int left [static]

Definition at line 31 of file tst-tsd3.c.