diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-04-05 21:17:27 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-04-05 21:17:27 +0000 |
commit | 412dbff629308745d967718fbd91e272c91b055c (patch) | |
tree | 7fb92204e9ab59173a92e8950d633cc4b39e16ac /cpukit/posix/src/condtimedwait.c | |
parent | 2007-04-05 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-412dbff629308745d967718fbd91e272c91b055c.tar.bz2 |
2007-04-05 Joel Sherrill <joel@OARcorp.com>
* posix/Makefile.am, posix/include/rtems/posix/time.h,
posix/src/adjtime.c, posix/src/alarm.c, posix/src/clockgetres.c,
posix/src/condtimedwait.c, posix/src/mqueuetimedreceive.c,
posix/src/mqueuetimedsend.c, posix/src/mutextimedlock.c,
posix/src/nanosleep.c, posix/src/posixtimespecabsolutetimeout.c,
posix/src/pthread.c, posix/src/pthreadcreate.c,
posix/src/pthreadsetschedparam.c, posix/src/ptimer1.c,
posix/src/sched.c, posix/src/semtimedwait.c,
posix/src/sigtimedwait.c, posix/src/ualarm.c,
rtems/src/clocktodtoseconds.c, score/Makefile.am,
score/preinstall.am, score/include/rtems/score/tod.h,
score/inline/rtems/score/tod.inl, score/src/coretod.c,
score/src/coretodget.c, score/src/coretodgetuptime.c,
score/src/coretodset.c, score/src/coretodtickle.c: Provide timespec
manipulation routines in the SuperCore. Use them everywhere possible.
This lead to significant cleanup in the API routines and eliminated
some of the same code from the POSIX API. At this point, the
SuperCore keeps time in POSIX timespec format properly from 1970. You
just cannot set it before 1988 in keeping with RTEMS traditional
behavior.
* score/include/rtems/score/timespec.h, score/src/timespecaddto.c,
score/src/timespecfromticks.c, score/src/timespecisvalid.c,
score/src/timespeclessthan.c, score/src/timespecsubtract.c,
score/src/timespectoticks.c: New files.
* posix/src/posixintervaltotimespec.c,
posix/src/posixtimespecsubtract.c,
posix/src/posixtimespectointerval.c: Removed.
Diffstat (limited to 'cpukit/posix/src/condtimedwait.c')
-rw-r--r-- | cpukit/posix/src/condtimedwait.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/cpukit/posix/src/condtimedwait.c b/cpukit/posix/src/condtimedwait.c index 32ce1d4a05..717851a8c8 100644 --- a/cpukit/posix/src/condtimedwait.c +++ b/cpukit/posix/src/condtimedwait.c @@ -2,6 +2,17 @@ * $Id$ */ +/* + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + #if HAVE_CONFIG_H #include "config.h" #endif @@ -33,24 +44,27 @@ int pthread_cond_timedwait( struct timespec difference; boolean already_timedout = FALSE; - if ( !abstime ) + if ( !_Timespec_Is_valid(abstime) ) return EINVAL; /* * The abstime is a walltime. We turn it into an interval. */ - (void) clock_gettime( CLOCK_REALTIME, ¤t_time ); + _TOD_Get( ¤t_time ); - /* XXX probably some error checking should go here */ - - _POSIX_Timespec_subtract( ¤t_time, abstime, &difference ); - - if ( ( difference.tv_sec < 0 ) || ( ( difference.tv_sec == 0 ) && - ( difference.tv_nsec < 0 ) ) ) + /* + * Make sure the timeout is in the future + */ + if ( _Timespec_Less_than( abstime, ¤t_time ) ) { already_timedout = TRUE; - - timeout = _POSIX_Timespec_to_interval( &difference ); + difference.tv_sec = 0; + difference.tv_nsec = 0; + timeout = 0; + } else { + _Timespec_Subtract( ¤t_time, abstime, &difference ); + timeout = _Timespec_To_ticks( &difference ); + } return _POSIX_Condition_variables_Wait_support( cond, |