Back to index

glibc  2.9
Defines | Functions
tst-rwlock3.c File Reference
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define TEST_FUNCTION   do_test ()

Functions

static int do_test (void)

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 92 of file tst-rwlock3.c.


Function Documentation

static int do_test ( void  ) [static]

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

{
  pthread_rwlock_t r;
  int e;

  if (pthread_rwlock_init (&r, NULL) != 0)
    {
      puts ("rwlock_init failed");
      return 1;
    }
  puts ("rwlock_init succeeded");

  if (pthread_rwlock_trywrlock (&r) != 0)
    {
      puts ("rwlock_trywrlock on unlocked rwlock failed");
      return 1;
    }
  puts ("rwlock_trywrlock on unlocked rwlock succeeded");

  e = pthread_rwlock_rdlock (&r);
  if (e == 0)
    {
      puts ("rwlock_rdlock on rwlock with writer succeeded");
      return 1;
    }
  if (e != EDEADLK)
    {
      puts ("rwlock_rdlock on rwlock with writer failed != EDEADLK");
      return 1;
    }
  puts ("rwlock_rdlock on rwlock with writer failed with EDEADLK");

  e = pthread_rwlock_wrlock (&r);
  if (e == 0)
    {
      puts ("rwlock_wrlock on rwlock with writer succeeded");
      return 1;
    }
  if (e != EDEADLK)
    {
      puts ("rwlock_wrlock on rwlock with writer failed != EDEADLK");
      return 1;
    }
  puts ("rwlock_wrlock on rwlock with writer failed with EDEADLK");

  if (pthread_rwlock_unlock (&r) != 0)
    {
      puts ("rwlock_unlock failed");
      return 1;
    }
  puts ("rwlock_unlock succeeded");

  if (pthread_rwlock_destroy (&r) != 0)
    {
      puts ("rwlock_destroy failed");
      return 1;
    }
  puts ("rwlock_destroy succeeded");

  return 0;
}

Here is the call graph for this function: