Back to index

glibc  2.9
Defines | Functions
tst-rwlock1.c File Reference
#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 116 of file tst-rwlock1.c.


Function Documentation

static int do_test ( void  ) [static]

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

{
  pthread_rwlock_t r;

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

  if (pthread_rwlock_rdlock (&r) != 0)
    {
      puts ("1st rwlock_rdlock failed");
      return 1;
    }
  puts ("1st rwlock_rdlock succeeded");

  if (pthread_rwlock_rdlock (&r) != 0)
    {
      puts ("2nd rwlock_rdlock failed");
      return 1;
    }
  puts ("2nd rwlock_rdlock succeeded");

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

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

  if (pthread_rwlock_wrlock (&r) != 0)
    {
      puts ("1st rwlock_wrlock failed");
      return 1;
    }
  puts ("1st rwlock_wrlock succeeded");

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

  if (pthread_rwlock_wrlock (&r) != 0)
    {
      puts ("2nd rwlock_wrlock failed");
      return 1;
    }
  puts ("2nd rwlock_wrlock succeeded");

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

  if (pthread_rwlock_rdlock (&r) != 0)
    {
      puts ("3rd rwlock_rdlock failed");
      return 1;
    }
  puts ("3rd rwlock_rdlock succeeded");

  if (pthread_rwlock_unlock (&r) != 0)
    {
      puts ("5th rwlock_unlock failed");
      return 1;
    }
  puts ("5th 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: