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/nanosleep.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/nanosleep.c')
-rw-r--r-- | cpukit/posix/src/nanosleep.c | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/cpukit/posix/src/nanosleep.c b/cpukit/posix/src/nanosleep.c index 47f7cbad0e..bca61ad709 100644 --- a/cpukit/posix/src/nanosleep.c +++ b/cpukit/posix/src/nanosleep.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$ */ @@ -28,41 +35,25 @@ int nanosleep( ) { Watchdog_Interval ticks; - struct timespec *the_rqtp; - if ( !rqtp ) + if ( !_Timespec_Is_valid( rqtp ) ) rtems_set_errno_and_return_minus_one( EINVAL ); - the_rqtp = (struct timespec *)rqtp; - /* - * Return EAGAIN if the delay interval is negative. + * Return EINVAL if the delay interval is negative. * * NOTE: This behavior is beyond the POSIX specification. - * FSU pthreads shares this behavior. + * FSU and GNU/Linux pthreads shares this behavior. */ - - if ( the_rqtp->tv_sec < 0 ) - the_rqtp->tv_sec = 0; - - if ( /* the_rqtp->tv_sec < 0 || */ the_rqtp->tv_nsec < 0 ) - rtems_set_errno_and_return_minus_one( EAGAIN ); - - if ( the_rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) + if ( rqtp->tv_sec < 0 || rqtp->tv_nsec < 0 ) rtems_set_errno_and_return_minus_one( EINVAL ); - ticks = _POSIX_Timespec_to_interval( the_rqtp ); - - /* - * Bump the ticks by one so the delay is at least the number of - * ticks requested - */ - ticks++; + ticks = _Timespec_To_ticks( rqtp ); /* * A nanosleep for zero time is implemented as a yield. * This behavior is also beyond the POSIX specification but is - * consistent with the RTEMS api and yields desirable behavior. + * consistent with the RTEMS API and yields desirable behavior. */ if ( !ticks ) { @@ -99,7 +90,7 @@ int nanosleep( ticks -= _Thread_Executing->Timer.stop_time - _Thread_Executing->Timer.start_time; - _POSIX_Interval_to_timespec( ticks, rmtp ); + _Timespec_From_ticks( ticks, rmtp ); /* * If there is time remaining, then we were interrupted by a signal. |