Back to index

glibc  2.9
Defines | Functions | Variables
tst-tsd2.c File Reference
#include <pthread.h>
#include <stdio.h>
#include <string.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 int result

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 96 of file tst-tsd2.c.


Function Documentation

static void destr ( void *  arg) [static]

Definition at line 29 of file tst-tsd2.c.

{
  if (arg != (void *) -2l)
    result = 2;
  else
    result = 0;
}

Here is the caller graph for this function:

static int do_test ( void  ) [static]

Definition at line 53 of file tst-tsd2.c.

{
  pthread_key_t key;
  pthread_t th;
  int err;

  err = pthread_key_create (&key, destr);
  if (err != 0)
    {
      printf ("key_create failed: %s\n", strerror (err));
      return 1;
    }

  result = 1;

  err = pthread_create (&th, NULL, tf, (void *) (long int) key);
  if (err != 0)
    {
      printf ("create failed: %s\n", strerror (err));
      return 1;
    }

  /* Wait for the thread to terminate.  */
  err = pthread_join (th, NULL);
  if (err != 0)
    {
      printf ("join failed: %s\n", strerror (err));
      return 1;
    }

  if (result == 1)
    puts ("destructor not called");
  else if (result == 2)
    puts ("destructor got passed a wrong value");
  else if (result == 3)
    puts ("setspecific in child failed");
  else if (result != 0)
    puts ("result != 0");

  return result;
}

Here is the call graph for this function:

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

Definition at line 39 of file tst-tsd2.c.

{
  pthread_key_t key = (pthread_key_t) (long int) arg;
  int err;

  err = pthread_setspecific (key, (void *) -2l);
  if (err != 0)
    result = 3;

  return NULL;
}

Here is the call graph for this function:


Variable Documentation

int result [static]

Definition at line 25 of file tst-tsd2.c.