source: rtems/cpukit/posix/src/condtimedwait.c @ 1e3940d

4.104.115
Last change on this file since 1e3940d was 1e3940d, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/09 at 23:10:02

2009-05-03 Joel Sherrill <joel.sherrill@…>

  • posix/src/condtimedwait.c, posix/src/mutextimedlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/semopen.c: Silence warnings.
  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  $Id$
3 */
4
5/*
6 *  COPYRIGHT (c) 1989-2008.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <pthread.h>
21#include <errno.h>
22
23#include <rtems/system.h>
24#include <rtems/score/object.h>
25#include <rtems/score/states.h>
26#include <rtems/score/watchdog.h>
27#include <rtems/posix/cond.h>
28#include <rtems/posix/time.h>
29#include <rtems/posix/mutex.h>
30
31/*PAGE
32 *
33 *  11.4.4 Waiting on a Condition, P1003.1c/Draft 10, p. 105
34 */
35
36int pthread_cond_timedwait(
37  pthread_cond_t        *cond,
38  pthread_mutex_t       *mutex,
39  const struct timespec *abstime
40)
41{
42  Watchdog_Interval ticks;
43  bool              already_timedout;
44
45  /*
46   *  POSIX requires that blocking calls with timeouts that take
47   *  an absolute timeout must ignore issues with the absolute
48   *  time provided if the operation would otherwise succeed.
49   *  So we check the abstime provided, and hold on to whether it
50   *  is valid or not.  If it isn't correct and in the future,
51   *  then we do a polling operation and convert the UNSATISFIED
52   *  status into the appropriate error.
53   */
54  switch ( _POSIX_Absolute_timeout_to_ticks(abstime, &ticks) ) {
55    case POSIX_ABSOLUTE_TIMEOUT_INVALID:
56      return EINVAL;
57    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_PAST:
58    case POSIX_ABSOLUTE_TIMEOUT_IS_NOW:
59      already_timedout = true;
60      break;
61    case POSIX_ABSOLUTE_TIMEOUT_IS_IN_FUTURE:
62    default:  /* only to silence warnings */
63      already_timedout = false;
64      break;
65  }
66
67  return _POSIX_Condition_variables_Wait_support(
68    cond,
69    mutex,
70    ticks,
71    already_timedout
72  );
73}
Note: See TracBrowser for help on using the repository browser.