diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2006-10-30 22:21:23 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2006-10-30 22:21:23 +0000 |
commit | 0c2ec7f52c496e436f09d44dcb880bf4ea16ba86 (patch) | |
tree | a9b300a256bb640e1abfdc6dbbb6eac0a49c6a96 /cpukit/posix/src/semtimedwait.c | |
parent | 2006-10-30 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-0c2ec7f52c496e436f09d44dcb880bf4ea16ba86.tar.bz2 |
2006-10-30 Joel Sherrill <joel@OARcorp.com>
PR 841/rtems
* itron/inline/rtems/itron/semaphore.inl, itron/src/twai_sem.c,
posix/include/rtems/posix/semaphore.h,
posix/inline/rtems/posix/semaphore.inl,
posix/src/semaphorewaitsupp.c, posix/src/semtimedwait.c,
posix/src/semwait.c, rtems/src/semobtain.c,
rtems/src/semtranslatereturncode.c,
score/include/rtems/score/coresem.h, score/src/coresemseize.c: Make
sem_timedwait more conformant to Open Group specification.
Diffstat (limited to '')
-rw-r--r-- | cpukit/posix/src/semtimedwait.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/cpukit/posix/src/semtimedwait.c b/cpukit/posix/src/semtimedwait.c index 6acb704f7c..b0cb78deca 100644 --- a/cpukit/posix/src/semtimedwait.c +++ b/cpukit/posix/src/semtimedwait.c @@ -35,34 +35,37 @@ int sem_timedwait( /* * The abstime is a walltime. We turn it into an interval. */ - Watchdog_Interval ticks; - struct timespec current_time; - struct timespec difference; + Watchdog_Interval ticks = 0; + struct timespec current_time; + struct timespec difference; + Core_semaphore_Blocking_option blocking = CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT; /* * Error check the absolute time to timeout */ +#if 0 if ( /* abstime->tv_sec < 0 || */ abstime->tv_nsec ) /* tv_sec is unsigned */ - return EINVAL; - + blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE; + else +#endif if ( abstime->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) - return EINVAL; - - (void) clock_gettime( CLOCK_REALTIME, ¤t_time ); - - /* - * Make sure the abstime is in the future - */ - if ( abstime->tv_sec < current_time.tv_sec ) - return EINVAL; - if ( (abstime->tv_sec == current_time.tv_sec) && - (abstime->tv_nsec <= current_time.tv_nsec) ) - return EINVAL; - - _POSIX_Timespec_subtract( ¤t_time, abstime, &difference ); + blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE; + else { + (void) clock_gettime( CLOCK_REALTIME, ¤t_time ); + /* + * Make sure the abstime is in the future + */ + if ( abstime->tv_sec < current_time.tv_sec ) + blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE; + else if ( (abstime->tv_sec == current_time.tv_sec) && + (abstime->tv_nsec <= current_time.tv_nsec) ) + blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE; + else { + _POSIX_Timespec_subtract( ¤t_time, abstime, &difference ); + ticks = _POSIX_Timespec_to_interval( &difference ); + blocking = CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT; + } + } - ticks = _POSIX_Timespec_to_interval( &difference ); - - return _POSIX_Semaphore_Wait_support( sem, TRUE, ticks ); + return _POSIX_Semaphore_Wait_support( sem, blocking, ticks ); } - |