OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [condtimedwait.c] - Blame information for rev 532

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  $Id: condtimedwait.c,v 1.2 2001-09-27 11:59:17 chris Exp $
3
 */
4
 
5
#include <pthread.h>
6
#include <errno.h>
7
 
8
#include <rtems/system.h>
9
#include <rtems/score/object.h>
10
#include <rtems/score/states.h>
11
#include <rtems/score/watchdog.h>
12
#include <rtems/posix/cond.h>
13
#include <rtems/posix/time.h>
14
#include <rtems/posix/mutex.h>
15
 
16
/*PAGE
17
 *
18
 *  11.4.4 Waiting on a Condition, P1003.1c/Draft 10, p. 105
19
 */
20
 
21
int pthread_cond_timedwait(
22
  pthread_cond_t        *cond,
23
  pthread_mutex_t       *mutex,
24
  const struct timespec *abstime
25
)
26
{
27
  Watchdog_Interval timeout;
28
  struct timespec   current_time;
29
  struct timespec   difference;
30
  boolean           already_timedout = FALSE;
31
 
32
  if ( !abstime )
33
    return EINVAL;
34
 
35
  /*
36
   *  The abstime is a walltime.  We turn it into an interval.
37
   */
38
 
39
  (void) clock_gettime( CLOCK_REALTIME, &current_time );
40
 
41
  /* XXX probably some error checking should go here */
42
 
43
  _POSIX_Timespec_subtract( &current_time, abstime, &difference );
44
 
45
  if ( ( difference.tv_sec < 0 ) || ( ( difference.tv_sec == 0 ) &&
46
       ( difference.tv_nsec < 0 ) ) )
47
    already_timedout = TRUE;
48
 
49
  timeout = _POSIX_Timespec_to_interval( &difference );
50
 
51
  return _POSIX_Condition_variables_Wait_support(
52
    cond,
53
    mutex,
54
    timeout,
55
    already_timedout
56
  );
57
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.