From 412dbff629308745d967718fbd91e272c91b055c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 5 Apr 2007 21:17:27 +0000 Subject: 2007-04-05 Joel Sherrill * 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. --- cpukit/posix/src/semtimedwait.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'cpukit/posix/src/semtimedwait.c') diff --git a/cpukit/posix/src/semtimedwait.c b/cpukit/posix/src/semtimedwait.c index 662845ecd9..6b93b9232b 100644 --- a/cpukit/posix/src/semtimedwait.c +++ b/cpukit/posix/src/semtimedwait.c @@ -1,4 +1,11 @@ /* + * 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$ */ @@ -43,26 +50,18 @@ int sem_timedwait( /* * Error check the absolute time to timeout */ -#if 0 - if ( /* abstime->tv_sec < 0 || */ abstime->tv_nsec ) /* tv_sec is unsigned */ + if ( !_Timespec_Is_valid( abstime ) ) { blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE; - else -#endif - if ( abstime->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) { - blocking = CORE_SEMAPHORE_BAD_TIMEOUT; } else { - clock_gettime( CLOCK_REALTIME, ¤t_time ); + _TOD_Get( ¤t_time ); /* * Make sure the abstime is in the future */ - if ( abstime->tv_sec < current_time.tv_sec ) - blocking = CORE_SEMAPHORE_BAD_TIMEOUT; - else if ( (abstime->tv_sec == current_time.tv_sec) && - (abstime->tv_nsec <= current_time.tv_nsec) ) + if ( _Timespec_Less_than( abstime, ¤t_time ) ) { blocking = CORE_SEMAPHORE_BAD_TIMEOUT; - else { - _POSIX_Timespec_subtract( ¤t_time, abstime, &difference ); - ticks = _POSIX_Timespec_to_interval( &difference ); + } else { + _Timespec_Subtract( ¤t_time, abstime, &difference ); + ticks = _Timespec_To_ticks( &difference ); blocking = CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT; } } -- cgit v1.2.3