Back to index

glibc  2.9
Defines | Functions | Variables
tst-cond19.c File Reference
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.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)

Variables

static pthread_cond_t cond = PTHREAD_COND_INITIALIZER
static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER

Define Documentation

#define TEST_FUNCTION   do_test ()

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


Function Documentation

static int do_test ( void  ) [static]

Definition at line 32 of file tst-cond19.c.

{
  int result = 0;
  struct timespec ts;

  if (clock_gettime (CLOCK_REALTIME, &ts) != 0)
    {
      puts ("clock_gettime failed");
      return 1;
    }

  ts.tv_nsec = -1;

  int e = pthread_cond_timedwait (&cond, &mut, &ts);
  if (e == 0)
    {
      puts ("first cond_timedwait did not fail");
      result = 1;
    }
  else if (e != EINVAL)
    {
      puts ("first cond_timedwait did not return EINVAL");
      result = 1;
    }

  ts.tv_nsec = 2000000000;

  e = pthread_cond_timedwait (&cond, &mut, &ts);
  if (e == 0)
    {
      puts ("second cond_timedwait did not fail");
      result = 1;
    }
  else if (e != EINVAL)
    {
      puts ("second cond_timedwait did not return EINVAL");
      result = 1;
    }

  return result;
}

Here is the call graph for this function:


Variable Documentation

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

Definition at line 28 of file tst-cond19.c.