Changeset 84b6c050 in rtems


Ignore:
Timestamp:
09/01/05 14:44:04 (19 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
a98ea87
Parents:
04ae040
Message:

2005-09-01 Joel Sherrill <joel@…>

PR 796/rtems

  • posix/src/semtimedwait.c: sem_timedwait is supposed to use absolute time for timeout specification. This patch is a modified version of the one suggested by Peter Dufault.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r04ae040 r84b6c050  
     12005-09-01      Joel Sherrill <joel@OARcorp.com>
     2
     3        PR 796/rtems
     4        * posix/src/semtimedwait.c: sem_timedwait is supposed to use absolute
     5        time for timeout specification. This patch is a modified version of
     6        the one suggested by Peter Dufault.
     7
    182005-09-01      Nuno Costa <nuno-costa@iol.pt>
    29
  • cpukit/posix/src/semtimedwait.c

    r04ae040 r84b6c050  
    3030int sem_timedwait(
    3131  sem_t                 *sem,
    32   const struct timespec *timeout
     32  const struct timespec *abstime
    3333)
    3434{
    35   return _POSIX_Semaphore_Wait_support(
    36     sem,
    37     TRUE,
    38     _POSIX_Timespec_to_interval( timeout )
    39   );
     35  /*
     36   *  The abstime is a walltime.  We turn it into an interval.
     37   */
     38  Watchdog_Interval ticks;
     39  struct timespec   current_time;
     40  struct timespec   difference;
     41
     42  /*
     43   *  Error check the absolute time to timeout
     44   */
     45  if ( /* abstime->tv_sec < 0 || */ abstime->tv_nsec ) /* tv_sec is unsigned */
     46    return EINVAL;
     47
     48  if ( abstime->tv_nsec >= TOD_NANOSECONDS_PER_SECOND )
     49    return EINVAL;
     50 
     51  (void) clock_gettime( CLOCK_REALTIME, &current_time );
     52
     53  /*
     54   *  Make sure the abstime is in the future
     55   */
     56  if ( abstime->tv_sec < current_time.tv_sec )
     57    return EINVAL;
     58  if ( (abstime->tv_sec == current_time.tv_sec) &&
     59       (abstime->tv_nsec <= current_time.tv_nsec) )
     60    return EINVAL;
     61
     62  _POSIX_Timespec_subtract( &current_time, abstime, &difference );
     63
     64  ticks = _POSIX_Timespec_to_interval( &difference );
     65
     66  return _POSIX_Semaphore_Wait_support( sem, TRUE, ticks );
    4067}
     68
Note: See TracChangeset for help on using the changeset viewer.