Back to index

glibc  2.9
Defines | Functions
tst-mutex1.c File Reference
#include <pthread.h>
#include <stdio.h>
#include <errno.h>
#include "../test-skeleton.c"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ATTR   NULL
#define TEST_FUNCTION   do_test ()

Functions

static int do_test (void)

Define Documentation

#define ATTR   NULL

Definition at line 26 of file tst-mutex1.c.

#define TEST_FUNCTION   do_test ()

Definition at line 75 of file tst-mutex1.c.


Function Documentation

static int do_test ( void  ) [static]

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

{
  pthread_mutex_t m;

  int e = pthread_mutex_init (&m, ATTR);
  if (ATTR != NULL && e == ENOTSUP)
    {
      puts ("cannot support selected type of mutexes");
      return 0;
    }
  else if (e != 0)
    {
      puts ("mutex_init failed");
      return 1;
    }

  if (ATTR != NULL && pthread_mutexattr_destroy (ATTR) != 0)
    {
      puts ("mutexattr_destroy failed");
      return 1;
    }

  if (pthread_mutex_lock (&m) != 0)
    {
      puts ("mutex_lock failed");
      return 1;
    }

  if (pthread_mutex_unlock (&m) != 0)
    {
      puts ("mutex_unlock failed");
      return 1;
    }

  if (pthread_mutex_destroy (&m) != 0)
    {
      puts ("mutex_destroy failed");
      return 1;
    }

  return 0;
}

Here is the call graph for this function: