Back to index

glibc  2.9
Defines | Functions | Variables
tst-tsd4.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 destr (void *arg)
static void * tf (void *arg)
static int do_test (void)

Variables

static pthread_key_t key
static int rounds

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 102 of file tst-tsd4.c.


Function Documentation

static void destr ( void *  arg) [static]

Definition at line 34 of file tst-tsd4.c.

{
  ++rounds;

  if (pthread_setspecific (key, (void *) 1l) != 0)
    {
      puts ("destr: 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 63 of file tst-tsd4.c.

{
  /* Allocate two keys, both with destructors.  */
  if (pthread_key_create (&key, destr) != 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 (rounds < PTHREAD_DESTRUCTOR_ITERATIONS)
    {
      printf ("rounds == %d, PTHREAD_DESTRUCTOR_ITERATIONS = %d\n",
             rounds, PTHREAD_DESTRUCTOR_ITERATIONS);
      return 1;
    }

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

  return 0;
}

Here is the call graph for this function:

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

Definition at line 47 of file tst-tsd4.c.

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

  return NULL;
}

Here is the call graph for this function:


Variable Documentation

pthread_key_t key [static]

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

int rounds [static]

Definition at line 30 of file tst-tsd4.c.