diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1996-07-02 18:13:59 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1996-07-02 18:13:59 +0000 |
commit | df8d1440d10dfa8b4a239afb1562c43dde588e98 (patch) | |
tree | 4d652104e37cae42fc5d509020223a3aa71d970e | |
parent | updated to reflect latest gnu tools versions (diff) | |
download | rtems-df8d1440d10dfa8b4a239afb1562c43dde588e98.tar.bz2 |
*** empty log message ***
-rw-r--r-- | c/src/exec/posix/src/time.c | 23 | ||||
-rw-r--r-- | cpukit/posix/src/time.c | 23 |
2 files changed, 44 insertions, 2 deletions
diff --git a/c/src/exec/posix/src/time.c b/c/src/exec/posix/src/time.c index 10808dd6b5..1af360c359 100644 --- a/c/src/exec/posix/src/time.c +++ b/c/src/exec/posix/src/time.c @@ -239,12 +239,33 @@ int nanosleep( { Watchdog_Interval ticks; - if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) + /* + * Return EAGAIN if the delay interval is negative. + * + * NOTE: This behavior is beyond the POSIX specification. + * FSU pthreads shares this behavior. + */ + + if ( rqtp->tv_sec < 0 || rqtp->tv_nsec < 0 ) + set_errno_and_return_minus_one( EAGAIN ); + + if ( rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) set_errno_and_return_minus_one( EINVAL ); /* XXX this is interruptible by a posix signal */ ticks = _POSIX_Timespec_to_interval( rqtp ); + + /* + * This behavior is also beyond the POSIX specification but is + * consistent with the RTEMS api and yields desirable behavior. + */ + + if ( !ticks ) { + _Thread_Yield_processor(); + _Thread_Dispatch(); + return 0; + } _Thread_Disable_dispatch(); _Thread_Set_state( diff --git a/cpukit/posix/src/time.c b/cpukit/posix/src/time.c index 10808dd6b5..1af360c359 100644 --- a/cpukit/posix/src/time.c +++ b/cpukit/posix/src/time.c @@ -239,12 +239,33 @@ int nanosleep( { Watchdog_Interval ticks; - if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) + /* + * Return EAGAIN if the delay interval is negative. + * + * NOTE: This behavior is beyond the POSIX specification. + * FSU pthreads shares this behavior. + */ + + if ( rqtp->tv_sec < 0 || rqtp->tv_nsec < 0 ) + set_errno_and_return_minus_one( EAGAIN ); + + if ( rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) set_errno_and_return_minus_one( EINVAL ); /* XXX this is interruptible by a posix signal */ ticks = _POSIX_Timespec_to_interval( rqtp ); + + /* + * This behavior is also beyond the POSIX specification but is + * consistent with the RTEMS api and yields desirable behavior. + */ + + if ( !ticks ) { + _Thread_Yield_processor(); + _Thread_Dispatch(); + return 0; + } _Thread_Disable_dispatch(); _Thread_Set_state( |