Changeset 412dbff6 in rtems


Ignore:
Timestamp:
Apr 5, 2007, 9:17:27 PM (13 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
75ef2d5
Parents:
8ff5e59d
Message:

2007-04-05 Joel Sherrill <joel@…>

  • 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.
Location:
cpukit
Files:
6 added
2 deleted
30 edited
1 moved

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r8ff5e59d r412dbff6  
     12007-04-05      Joel Sherrill <joel@OARcorp.com>
     2
     3        * posix/Makefile.am, posix/include/rtems/posix/time.h,
     4        posix/src/adjtime.c, posix/src/alarm.c, posix/src/clockgetres.c,
     5        posix/src/condtimedwait.c, posix/src/mqueuetimedreceive.c,
     6        posix/src/mqueuetimedsend.c, posix/src/mutextimedlock.c,
     7        posix/src/nanosleep.c, posix/src/posixtimespecabsolutetimeout.c,
     8        posix/src/pthread.c, posix/src/pthreadcreate.c,
     9        posix/src/pthreadsetschedparam.c, posix/src/ptimer1.c,
     10        posix/src/sched.c, posix/src/semtimedwait.c,
     11        posix/src/sigtimedwait.c, posix/src/ualarm.c,
     12        rtems/src/clocktodtoseconds.c, score/Makefile.am,
     13        score/preinstall.am, score/include/rtems/score/tod.h,
     14        score/inline/rtems/score/tod.inl, score/src/coretod.c,
     15        score/src/coretodget.c, score/src/coretodgetuptime.c,
     16        score/src/coretodset.c, score/src/coretodtickle.c: Provide timespec
     17        manipulation routines in the SuperCore. Use them everywhere possible.
     18        This lead to significant cleanup in the API routines and eliminated
     19        some of the same code from the POSIX API. At this point, the
     20        SuperCore keeps time in POSIX timespec format properly from 1970. You
     21        just cannot set it before 1988 in keeping with RTEMS traditional
     22        behavior.
     23        * score/include/rtems/score/timespec.h, score/src/timespecaddto.c,
     24        score/src/timespecfromticks.c, score/src/timespecisvalid.c,
     25        score/src/timespeclessthan.c, score/src/timespecsubtract.c,
     26        score/src/timespectoticks.c: New files.
     27        * posix/src/posixintervaltotimespec.c,
     28        posix/src/posixtimespecsubtract.c,
     29        posix/src/posixtimespectointerval.c: Removed.
     30
    1312007-04-04      Joel Sherrill <joel@OARcorp.com>
    232
  • cpukit/posix/Makefile.am

    r8ff5e59d r412dbff6  
    145145
    146146## TIME_C_FILES
    147 libposix_a_SOURCES += src/adjtime.c src/posixtimespecsubtract.c \
    148     src/posixtimespectointerval.c src/posixintervaltotimespec.c \
     147libposix_a_SOURCES += src/adjtime.c \
    149148    src/posixtimespecabsolutetimeout.c src/clockgetcpuclockid.c \
    150149    src/clockgetenableattr.c src/clockgetres.c src/clockgettime.c \
  • cpukit/posix/include/rtems/posix/time.h

    r8ff5e59d r412dbff6  
    44
    55/*
     6 *  COPYRIGHT (c) 1989-2007.
     7 *  On-Line Applications Research Corporation (OAR).
    68 *
     9 *  The license and distribution terms for this file may be
     10 *  found in the file LICENSE in this distribution or at
     11 *  http://www.rtems.com/license/LICENSE.
    712 *
    813 *  $Id$
     
    1217#define _RTEMS_POSIX_TIME_H
    1318
    14 #include <rtems/score/tod.h>
    15 
    16 /*
    17  *  Seconds from January 1, 1970 to January 1, 1988.  Used to account for
    18  *  differences between POSIX API and RTEMS core.
    19  *
    20  *  XXX probably able to be removed once core switches completely to timespec
    21  *  XXX for current TOD.
    22  */
    23 #define POSIX_TIME_SECONDS_1970_THROUGH_1988 TOD_SECONDS_1970_THROUGH_1988
    24 
    25 /*
    26  *  _POSIX_Timespec_subtract
    27  */
    28 
    29 void _POSIX_Timespec_subtract(
    30   const struct timespec *the_start,
    31   const struct timespec *end,
    32   struct timespec *result
    33 );
    34 
    35 /*
    36  *  _POSIX_Timespec_to_interval
    37  */
    38 
    39 Watchdog_Interval _POSIX_Timespec_to_interval(
    40   const struct timespec *time
    41 );
    42 
    43 /*
    44  *  _POSIX_Interval_to_timespec
    45  */
    46 
    47 void _POSIX_Interval_to_timespec(
    48   Watchdog_Interval  ticks,
    49   struct timespec   *time
    50 );
     19#include <rtems/score/timespec.h>
    5120
    5221/*
  • cpukit/posix/src/adjtime.c

    r8ff5e59d r412dbff6  
    11/*
    2  *  adjustime() function - required by NTP
     2 *  adjime() function - required by NTP
    33 *
    44 *  I am unaware of the history behind the definition of this service
    55 *  and don't know if its behavior is covered by any standard. --joel
     6 */
     7
     8/*
     9 *  COPYRIGHT (c) 1989-2007.
     10 *  On-Line Applications Research Corporation (OAR).
     11 *
     12 *  The license and distribution terms for this file may be
     13 *  found in the file LICENSE in this distribution or at
     14 *  http://www.rtems.com/license/LICENSE.
    615 *
    716 *  $Id$
     
    3342    return -1;
    3443
    35   __adjustment = (delta->tv_sec * TOD_MICROSECONDS_PER_SECOND) + delta->tv_usec;
     44  /* convert delta to microseconds */
     45  __adjustment  = (delta->tv_sec * TOD_MICROSECONDS_PER_SECOND);
     46  __adjustment += delta->tv_usec;
     47
    3648  /* too small to account for */
    3749  if ( __adjustment < _TOD_Microseconds_per_tick )
    3850    return 0;
    3951
    40   clock_gettime( CLOCK_REALTIME, &ts );
     52  /* Grab the current TOD */
     53  _TOD_Get( &ts );
    4154
    42   ts.tv_sec  += (__adjustment / TOD_MICROSECONDS_PER_SECOND);
    43   ts.tv_nsec += (__adjustment % TOD_MICROSECONDS_PER_SECOND) *
    44                        TOD_NANOSECONDS_PER_MICROSECOND;
     55  ts.tv_sec  += delta->tv_sec;
     56  ts.tv_nsec += delta->tv_usec * TOD_NANOSECONDS_PER_MICROSECOND;
    4557
    4658  /* if adjustment is too much positive */
     
    5668  }
    5769
    58   clock_settime( CLOCK_REALTIME, &ts );
     70  _TOD_Set( &ts );
    5971  return 0;
    6072}
  • cpukit/posix/src/alarm.c

    r8ff5e59d r412dbff6  
    11/*
    22 *  3.4.1 Schedule Alarm, P1003.1b-1993, p. 79
    3  *
    4  *  COPYRIGHT (c) 1989-1999.
     3 */
     4
     5/*  COPYRIGHT (c) 1989-2007.
    56 *  On-Line Applications Research Corporation (OAR).
    67 *
     
    1718
    1819#include <pthread.h>
    19 /* #include <errno.h> */
    2020
    2121#include <rtems/system.h>
     
    7070         */
    7171
    72         remaining = the_timer->initial;
    73         remaining -= (the_timer->stop_time - the_timer->start_time);
    74        
    75         /* remaining is now in ticks */
    76         remaining *= _TOD_Microseconds_per_tick;
    77         remaining /= TOD_MICROSECONDS_PER_SECOND;
     72        remaining = the_timer->initial -
     73         ((the_timer->stop_time - the_timer->start_time) /
     74           TOD_TICKS_PER_SECOND);
    7875        break;
    7976    }
  • cpukit/posix/src/clockgetres.c

    r8ff5e59d r412dbff6  
    11/*
     2 *  $Id$
     3 */
     4
     5/*
     6 *  COPYRIGHT (c) 1989-2007.
     7 *  On-Line Applications Research Corporation (OAR).
     8 *
     9 *  The license and distribution terms for this file may be
     10 *  found in the file LICENSE in this distribution or at
     11 *  http://www.rtems.com/license/LICENSE.
     12 *
    213 *  $Id$
    314 */
     
    4354        res->tv_sec = _TOD_Microseconds_per_tick / 1000000;
    4455        res->tv_nsec = _TOD_Microseconds_per_tick * 1000;
    45         /* _POSIX_Interval_to_timespec( _TOD_Microseconds_per_tick, res );  */
     56        /* _TOD_From_ticks( _TOD_Microseconds_per_tick, res );  */
    4657      }
    4758      break;
  • cpukit/posix/src/condtimedwait.c

    r8ff5e59d r412dbff6  
    11/*
     2 *  $Id$
     3 */
     4
     5/*
     6 *  COPYRIGHT (c) 1989-2007.
     7 *  On-Line Applications Research Corporation (OAR).
     8 *
     9 *  The license and distribution terms for this file may be
     10 *  found in the file LICENSE in this distribution or at
     11 *  http://www.rtems.com/license/LICENSE.
     12 *
    213 *  $Id$
    314 */
     
    3445  boolean           already_timedout = FALSE;
    3546
    36   if ( !abstime )
     47  if ( !_Timespec_Is_valid(abstime) )
    3748    return EINVAL;
    3849
     
    4152   */
    4253
    43   (void) clock_gettime( CLOCK_REALTIME, &current_time );
     54  _TOD_Get( &current_time );
    4455
    45   /* XXX probably some error checking should go here */
    46 
    47   _POSIX_Timespec_subtract( &current_time, abstime, &difference );
    48 
    49   if ( ( difference.tv_sec < 0 ) || ( ( difference.tv_sec == 0 ) &&
    50        ( difference.tv_nsec < 0 ) ) )
     56  /*
     57   * Make sure the timeout is in the future
     58   */
     59  if ( _Timespec_Less_than( abstime, &current_time ) ) {
    5160    already_timedout = TRUE;
    52 
    53   timeout = _POSIX_Timespec_to_interval( &difference );
     61    difference.tv_sec  = 0;
     62    difference.tv_nsec = 0;
     63    timeout = 0;
     64  } else {
     65    _Timespec_Subtract( &current_time, abstime, &difference );
     66    timeout = _Timespec_To_ticks( &difference );
     67  }
    5468
    5569  return _POSIX_Condition_variables_Wait_support(
  • cpukit/posix/src/mqueuetimedreceive.c

    r8ff5e59d r412dbff6  
    1111 *         This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
    1212 *         time.
     13 */
     14
     15/*
     16 *  COPYRIGHT (c) 1989-2007.
     17 *  On-Line Applications Research Corporation (OAR).
     18 *
     19 *  The license and distribution terms for this file may be
     20 *  found in the file LICENSE in this distribution or at
     21 *  http://www.rtems.com/license/LICENSE.
    1322 *
    1423 *  $Id$
     
    5362    msg_len,
    5463    msg_prio,
    55     _POSIX_Timespec_to_interval( timeout )
     64    _Timespec_To_ticks( timeout )
    5665  );
    5766}
  • cpukit/posix/src/mqueuetimedsend.c

    r8ff5e59d r412dbff6  
    1111 *         This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
    1212 *         time.
     13 */
     14
     15/*
     16 *  COPYRIGHT (c) 1989-2007.
     17 *  On-Line Applications Research Corporation (OAR).
     18 *
     19 *  The license and distribution terms for this file may be
     20 *  found in the file LICENSE in this distribution or at
     21 *  http://www.rtems.com/license/LICENSE.
    1322 *
    1423 *  $Id$
     
    5362    msg_len,
    5463    msg_prio,
    55     _POSIX_Timespec_to_interval( timeout )
     64    _Timespec_To_ticks( timeout )
    5665  );
    5766}
  • cpukit/posix/src/mutextimedlock.c

    r8ff5e59d r412dbff6  
    11/*
     2 *  Mutex Timed Lock
     3 */
     4
     5/*
     6 *  COPYRIGHT (c) 1989-2007.
     7 *  On-Line Applications Research Corporation (OAR).
     8 *
     9 *  The license and distribution terms for this file may be
     10 *  found in the file LICENSE in this distribution or at
     11 *  http://www.rtems.com/license/LICENSE.
     12 *
    213 *  $Id$
    314 */
     
    3243)
    3344{
     45  /* XXX does timeout need to be based on CLOCK_REALTIME and be TOD? */
    3446  return _POSIX_Mutex_Lock_support(
    3547    mutex,
    3648    TRUE,
    37     _POSIX_Timespec_to_interval( timeout )
     49    _Timespec_To_ticks( timeout )
    3850  );
    3951}
  • cpukit/posix/src/nanosleep.c

    r8ff5e59d r412dbff6  
    11/*
     2 *  COPYRIGHT (c) 1989-2007.
     3 *  On-Line Applications Research Corporation (OAR).
     4 *
     5 *  The license and distribution terms for this file may be
     6 *  found in the file LICENSE in this distribution or at
     7 *  http://www.rtems.com/license/LICENSE.
     8 *
    29 *  $Id$
    310 */
     
    2936{
    3037  Watchdog_Interval  ticks;
    31   struct timespec   *the_rqtp;
    3238
    33   if ( !rqtp )
     39  if ( !_Timespec_Is_valid( rqtp ) )
    3440    rtems_set_errno_and_return_minus_one( EINVAL );
    3541
    36   the_rqtp = (struct timespec *)rqtp;
    37 
    3842  /*
    39    *  Return EAGAIN if the delay interval is negative.
     43   *  Return EINVAL if the delay interval is negative.
    4044   *
    4145   *  NOTE:  This behavior is beyond the POSIX specification.
    42    *         FSU pthreads shares this behavior.
     46   *         FSU and GNU/Linux pthreads shares this behavior.
    4347   */
    44 
    45   if ( the_rqtp->tv_sec < 0 )
    46     the_rqtp->tv_sec = 0;
    47 
    48   if ( /* the_rqtp->tv_sec < 0 || */ the_rqtp->tv_nsec < 0 )
    49     rtems_set_errno_and_return_minus_one( EAGAIN );
    50 
    51   if ( the_rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND )
     48  if ( rqtp->tv_sec < 0 || rqtp->tv_nsec < 0 )
    5249    rtems_set_errno_and_return_minus_one( EINVAL );
    5350
    54   ticks = _POSIX_Timespec_to_interval( the_rqtp );
    55 
    56   /*
    57    * Bump the ticks by one so the delay is at least the number of
    58    * ticks requested
    59    */
    60   ticks++;
     51  ticks = _Timespec_To_ticks( rqtp );
    6152
    6253  /*
    6354   *  A nanosleep for zero time is implemented as a yield.
    6455   *  This behavior is also beyond the POSIX specification but is
    65    *  consistent with the RTEMS api and yields desirable behavior.
     56   *  consistent with the RTEMS API and yields desirable behavior.
    6657   */
    6758
     
    10091      _Thread_Executing->Timer.stop_time - _Thread_Executing->Timer.start_time;
    10192
    102     _POSIX_Interval_to_timespec( ticks, rmtp );
     93    _Timespec_From_ticks( ticks, rmtp );
    10394
    10495    /*
  • cpukit/posix/src/posixtimespecabsolutetimeout.c

    r8ff5e59d r412dbff6  
    11/*
    22 *  Convert abstime timeout to ticks
     3 */
     4
     5/*
     6 *  COPYRIGHT (c) 1989-2007.
     7 *  On-Line Applications Research Corporation (OAR).
     8 *
     9 *  The license and distribution terms for this file may be
     10 *  found in the file LICENSE in this distribution or at
     11 *  http://www.rtems.com/license/LICENSE.
    312 *
    413 *  $Id$
     
    3140)
    3241{
    33   struct timespec   current_time;
    34   struct timespec   difference;
     42  struct timespec current_time;
     43  struct timespec difference;
    3544
    36   if ( !abstime )
     45  if ( !_Timespec_Is_valid(abstime) )
    3746    return EINVAL;
    3847
    39   /*
    40    *  Error check the absolute time to timeout
    41    */
    42 #if 0
    43    /* they are unsigned so this is impossible */
    44   if ( abstime->tv_sec < 0 || abstime->tv_nsec < 0 )
    45     return EINVAL;
    46 #endif
    47 
    48   if ( abstime->tv_nsec >= TOD_NANOSECONDS_PER_SECOND )
    49     return EINVAL;
    50  
    51   (void) clock_gettime( CLOCK_REALTIME, &current_time );
     48  _TOD_Get( &current_time );
    5249
    5350  /*
    5451   *  Make sure the abstime is in the future
    5552   */
    56   if ( abstime->tv_sec < current_time.tv_sec )
     53  if ( _Timespec_Less_than( abstime, &current_time ) )
    5754    return EINVAL;
    5855
    59   if ( (abstime->tv_sec == current_time.tv_sec) &&
    60        (abstime->tv_nsec <= current_time.tv_nsec) )
    61     return EINVAL;
     56  _Timespec_Subtract( &current_time, abstime, &difference );
    6257
    63   _POSIX_Timespec_subtract( &current_time, abstime, &difference );
    64 
    65   *ticks_out = _POSIX_Timespec_to_interval( &difference );
     58  *ticks_out = _Timespec_To_ticks( &difference );
    6659
    6760  return 0;
  • cpukit/posix/src/pthread.c

    r8ff5e59d r412dbff6  
    11/*
     2 *  COPYRIGHT (c) 1989-2007.
     3 *  On-Line Applications Research Corporation (OAR).
     4 *
     5 *  The license and distribution terms for this file may be
     6 *  found in the file LICENSE in this distribution or at
     7 *  http://www.rtems.com/license/LICENSE.
     8 *
    29 *  $Id$
    310 */
     
    7178  api = the_thread->API_Extensions[ THREAD_API_POSIX ];
    7279
    73   ticks = _POSIX_Timespec_to_interval( &api->schedparam.ss_initial_budget );
     80  ticks = _Timespec_To_ticks( &api->schedparam.ss_initial_budget );
    7481
    7582  if ( !ticks )
     
    8592    _Thread_Change_priority( the_thread, new_priority, TRUE );
    8693
    87   ticks = _POSIX_Timespec_to_interval( &api->schedparam.ss_replenish_period );
     94  ticks = _Timespec_To_ticks( &api->schedparam.ss_replenish_period );
    8895
    8996  if ( !ticks )
  • cpukit/posix/src/pthreadcreate.c

    r8ff5e59d r412dbff6  
    11/*
    22 *  16.1.2 Thread Creation, P1003.1c/Draft 10, p. 144
    3  *
    4  *  COPYRIGHT (c) 1989-1999.
     3 */
     4
     5/*  COPYRIGHT (c) 1989-2007.
    56 *  On-Line Applications Research Corporation (OAR).
    67 *
     
    127128      budget_callout = _POSIX_Threads_Sporadic_budget_callout;
    128129
    129       if ( _POSIX_Timespec_to_interval( &schedparam.ss_replenish_period ) <
    130            _POSIX_Timespec_to_interval( &schedparam.ss_initial_budget ) )
     130      if ( _Timespec_To_ticks( &schedparam.ss_replenish_period ) <
     131           _Timespec_To_ticks( &schedparam.ss_initial_budget ) )
    131132        return EINVAL;
    132133
     
    231232    _Watchdog_Insert_ticks(
    232233      &api->Sporadic_timer,
    233       _POSIX_Timespec_to_interval( &api->schedparam.ss_replenish_period )
     234      _Timespec_To_ticks( &api->schedparam.ss_replenish_period )
    234235    );
    235236  }
  • cpukit/posix/src/pthreadsetschedparam.c

    r8ff5e59d r412dbff6  
    22 *  13.5.2 Dynamic Thread Scheduling Parameters Access,
    33 *         P1003.1c/Draft 10, p. 124
    4  *
    5  *  COPYRIGHT (c) 1989-1999.
     4 */
     5
     6/*  COPYRIGHT (c) 1989-2007.
    67 *  On-Line Applications Research Corporation (OAR).
    78 *
     
    6768      budget_callout = _POSIX_Threads_Sporadic_budget_callout;
    6869
    69       if ( _POSIX_Timespec_to_interval( &param->ss_replenish_period ) <
    70            _POSIX_Timespec_to_interval( &param->ss_initial_budget ) )
     70      if ( _Timespec_To_ticks( &param->ss_replenish_period ) <
     71           _Timespec_To_ticks( &param->ss_initial_budget ) )
    7172        return EINVAL;
    7273
  • cpukit/posix/src/ptimer1.c

    r8ff5e59d r412dbff6  
    11/*
    2  *  ptimer.c,v 1.1 1996/06/03 16:29:58 joel Exp
     2 *  COPYRIGHT (c) 1989-2007.
     3 *  On-Line Applications Research Corporation (OAR).
     4 *
     5 *  The license and distribution terms for this file may be
     6 *  found in the file LICENSE in this distribution or at
     7 *  http://www.rtems.com/license/LICENSE.
     8 *
     9 *  $Id$
    310 */
    411
     
    345352         case POSIX_TIMER_RELATIVE:
    346353           /* First, convert from seconds and nanoseconds to ticks */
    347            ptimer->ticks = _POSIX_Timespec_to_interval( &value->it_value );
     354           ptimer->ticks = _Timespec_To_ticks( &value->it_value );
    348355
    349356           activated = _Watchdog_Insert_ticks_helper(
     
    423430      /* Calculates the time left before the timer finishes */
    424431
    425       _POSIX_Timespec_subtract(
    426         &ptimer->timer_data.it_value, &current_time, &value->it_value);
    427 
    428       value->it_interval.tv_sec  = ptimer->timer_data.it_interval.tv_sec;
    429       value->it_interval.tv_nsec = ptimer->timer_data.it_interval.tv_nsec;
     432      _Timespec_Subtract(
     433        &ptimer->timer_data.it_value,
     434        &current_time,
     435        &value->it_value
     436      );
     437
     438      value->it_interval  = ptimer->timer_data.it_interval;
    430439
    431440      _Thread_Enable_dispatch();
  • cpukit/posix/src/sched.c

    r8ff5e59d r412dbff6  
    11/*
     2 *  COPYRIGHT (c) 1989-2007.
     3 *  On-Line Applications Research Corporation (OAR).
     4 *
     5 *  The license and distribution terms for this file may be
     6 *  found in the file LICENSE in this distribution or at
     7 *  http://www.rtems.com/license/LICENSE.
     8 *
    29 *  $Id$
    310 */
     
    127134)
    128135{
    129   /* XXX do we need to support different time quantums per thread */
    130 
    131136  /*
    132137   *  Only supported for the "calling process" (i.e. this node).
     
    139144    rtems_set_errno_and_return_minus_one( EINVAL );
    140145
    141   _POSIX_Interval_to_timespec( _Thread_Ticks_per_timeslice, interval );
     146  _Timespec_From_ticks( _Thread_Ticks_per_timeslice, interval );
    142147  return 0;
    143148}
  • cpukit/posix/src/semtimedwait.c

    r8ff5e59d r412dbff6  
    11/*
     2 *  COPYRIGHT (c) 1989-2007.
     3 *  On-Line Applications Research Corporation (OAR).
     4 *
     5 *  The license and distribution terms for this file may be
     6 *  found in the file LICENSE in this distribution or at
     7 *  http://www.rtems.com/license/LICENSE.
     8 *
    29 *  $Id$
    310 */
     
    4451   *  Error check the absolute time to timeout
    4552   */
    46 #if 0
    47   if ( /* abstime->tv_sec < 0 || */ abstime->tv_nsec ) /* tv_sec is unsigned */
     53  if ( !_Timespec_Is_valid( abstime ) ) {
    4854    blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE;
    49   else
    50 #endif
    51   if ( abstime->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) {
    52     blocking = CORE_SEMAPHORE_BAD_TIMEOUT;
    5355  } else {
    54     clock_gettime( CLOCK_REALTIME, &current_time );
     56    _TOD_Get( &current_time );
    5557    /*
    5658     *  Make sure the abstime is in the future
    5759     */
    58     if ( abstime->tv_sec < current_time.tv_sec )
     60    if ( _Timespec_Less_than( abstime, &current_time ) ) {
    5961      blocking = CORE_SEMAPHORE_BAD_TIMEOUT;
    60     else if ( (abstime->tv_sec == current_time.tv_sec) &&
    61          (abstime->tv_nsec <= current_time.tv_nsec) )
    62       blocking = CORE_SEMAPHORE_BAD_TIMEOUT;
    63     else {
    64       _POSIX_Timespec_subtract( &current_time, abstime, &difference );
    65       ticks = _POSIX_Timespec_to_interval( &difference );
     62    } else {
     63      _Timespec_Subtract( &current_time, abstime, &difference );
     64      ticks = _Timespec_To_ticks( &difference );
    6665      blocking = CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT;
    6766    }
  • cpukit/posix/src/sigtimedwait.c

    r8ff5e59d r412dbff6  
    22 *  3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
    33 *
    4  *  COPYRIGHT (c) 1989-1999.
     4 *  COPYRIGHT (c) 1989-2007.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
     
    6969  if ( timeout ) {
    7070
    71     if ( timeout->tv_nsec < 0 ||
    72          timeout->tv_nsec >= TOD_NANOSECONDS_PER_SECOND) {
     71    if ( !_Timespec_Is_valid( timeout ) ) {
    7372      rtems_set_errno_and_return_minus_one( EINVAL );
    7473    }
    7574
    76     interval = _POSIX_Timespec_to_interval( timeout );
     75    interval = _Timespec_To_ticks( timeout );
    7776  }
    7877
     
    9796    /* XXX real info later */
    9897    the_info->si_signo = _POSIX_signals_Get_highest( api->signals_pending );
    99     _POSIX_signals_Clear_signals( api, the_info->si_signo, the_info, FALSE, FALSE );
     98    _POSIX_signals_Clear_signals(
     99      api,
     100      the_info->si_signo,
     101      the_info,
     102      FALSE,
     103      FALSE
     104    );
    100105    _ISR_Enable( level );
    101106
  • cpukit/posix/src/ualarm.c

    r8ff5e59d r412dbff6  
    11/*
    2  *  XXX 3.4.1 Schedule Alarm, P1003.1b-1993, p. 79
     2 *  3.4.1 Schedule Alarm, P1003.1b-1993, p. 79
    33 *
    4  *  COPYRIGHT (c) 1989-2003.
     4 *  COPYRIGHT (c) 1989-2007.
    55 *  On-Line Applications Research Corporation (OAR).
    66 *
     
    7676        ticks = the_timer->initial;
    7777        ticks -= (the_timer->stop_time - the_timer->start_time);
    78        
    7978        /* remaining is now in ticks */
    80         ticks *= _TOD_Microseconds_per_tick;
    81         ticks /= TOD_MICROSECONDS_PER_SECOND;
    8279
    83         _POSIX_Interval_to_timespec( ticks, &tp );
     80        _Timespec_From_ticks( ticks, &tp );
    8481        remaining  = tp.tv_sec * TOD_MICROSECONDS_PER_SECOND;
    8582        remaining += tp.tv_nsec / 1000;
     
    9087  tp.tv_sec = useconds / TOD_MICROSECONDS_PER_SECOND;
    9188  tp.tv_nsec = (useconds % TOD_MICROSECONDS_PER_SECOND) * 1000;
    92   ticks = _POSIX_Timespec_to_interval( &tp );
    93   _Watchdog_Insert_ticks( the_timer, ticks );
     89  _Watchdog_Insert_ticks( the_timer, _Timespec_To_ticks( &tp ) );
    9490
    9591  return remaining;
  • cpukit/rtems/src/clocktodtoseconds.c

    r8ff5e59d r412dbff6  
    11/*
    22 *  Time of Day (TOD) Handler - Classic TOD to Seconds
    3  *
    43 *
    54 *  COPYRIGHT (c) 1989-2007.
     
    8180  time += the_tod->second;
    8281
     82  time += TOD_SECONDS_1970_THROUGH_1988;
     83
    8384  return( time );
    8485}
  • cpukit/score/Makefile.am

    r8ff5e59d r412dbff6  
    2929    include/rtems/score/stack.h include/rtems/score/states.h \
    3030    include/rtems/score/sysstate.h include/rtems/score/thread.h \
    31     include/rtems/score/threadq.h include/rtems/score/tod.h \
    32     include/rtems/score/tqdata.h include/rtems/score/userext.h \
    33     include/rtems/score/watchdog.h include/rtems/score/wkspace.h \
    34     include/rtems/score/cpuopts.h
     31    include/rtems/score/threadq.h include/rtems/score/timespec.h \
     32    include/rtems/score/tod.h include/rtems/score/tqdata.h \
     33    include/rtems/score/userext.h include/rtems/score/watchdog.h \
     34    include/rtems/score/wkspace.h include/rtems/score/cpuopts.h
    3535
    3636if HAS_MP
     
    141141
    142142## TIMESPEC_C_FILES
    143 ## libscore_a_SOURCES +=
     143libscore_a_SOURCES += src/timespecaddto.c src/timespecfromticks.c \
     144    src/timespecisvalid.c src/timespeclessthan.c src/timespecsubtract.c \
     145    src/timespectoticks.c
    144146
    145147## TOD_C_FILES
  • cpukit/score/include/rtems/score/tod.h

    r8ff5e59d r412dbff6  
    138138 *  January 1, TOD_BASE_YEAR until the current time of day.
    139139 */
    140 SCORE_EXTERN Watchdog_Interval _TOD_Seconds_since_epoch;
     140#define _TOD_Seconds_since_epoch (_TOD_Now.tv_sec)
    141141
    142142/** @brief Microseconds per Clock Tick
     
    218218    (TOD_MILLISECONDS_TO_MICROSECONDS(_ms) / _TOD_Microseconds_per_tick)
    219219
     220
     221/** @brief How many ticks in a second?
     222 *
     223 *  This macro returns the number of ticks in a second.
     224 *
     225 *  @note If the clock tick value does not multiply evenly into a second
     226 *        then this number of ticks will be slightly shorter than a second.
     227 */
     228#define TOD_TICKS_PER_SECOND \
     229  (TOD_MICROSECONDS_PER_SECOND / _TOD_Microseconds_per_tick)
     230
    220231#ifndef __RTEMS_APPLICATION__
    221232#include <rtems/score/tod.inl>
  • cpukit/score/inline/rtems/score/tod.inl

    r8ff5e59d r412dbff6  
    2626 *  @{
    2727 */
    28 
    29 /**
    30  *
    31  *  This routines adds two timespecs.  The second argument is added
    32  *  to the first.
    33  */
    34 
    35 RTEMS_INLINE_ROUTINE uint32_t _TOD_Add_timespec(
    36   struct timespec *time,
    37   struct timespec *add
    38 )
    39 {
    40   uint32_t seconds = 0;
    41 
    42  
    43   /* Add the basics */
    44   time->tv_sec += add->tv_sec;
    45   time->tv_nsec += add->tv_nsec;
    46 
    47   /* Now adjust it so nanoseconds is in range */
    48   while ( time->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) {
    49     time->tv_nsec -= TOD_NANOSECONDS_PER_SECOND;
    50     time->tv_sec++;
    51     seconds++;
    52   }
    53 
    54   return seconds;
    55 }
    5628
    5729/**
  • cpukit/score/preinstall.am

    r8ff5e59d r412dbff6  
    127127        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/threadq.h
    128128PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/threadq.h
     129
     130$(PROJECT_INCLUDE)/rtems/score/timespec.h: include/rtems/score/timespec.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     131        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timespec.h
     132PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timespec.h
    129133
    130134$(PROJECT_INCLUDE)/rtems/score/tod.h: include/rtems/score/tod.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
  • cpukit/score/src/coretod.c

    r8ff5e59d r412dbff6  
    11/*
    22 *  Time of Day (TOD) Handler
    3  *
    4  *
    5  *  COPYRIGHT (c) 1989-1999.
     3 */
     4
     5/*  COPYRIGHT (c) 1989-2007.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    4949  _TOD_Uptime.tv_nsec = 0;
    5050
    51   /* Seconds since RTEMS Epoch (1988) */
    52   _TOD_Seconds_since_epoch = 0;
    53 
    5451  /* TOD has not been set */
    5552  _TOD_Is_set = FALSE;
  • cpukit/score/src/coretodget.c

    r8ff5e59d r412dbff6  
    1818#include <rtems/system.h>
    1919#include <rtems/score/isr.h>
     20#include <rtems/score/timespec.h>
    2021#include <rtems/score/tod.h>
    2122
     
    5051  _ISR_Enable( level );
    5152
    52   _TOD_Add_timespec( time, &offset );
     53  _Timespec_Add_to( time, &offset );
    5354}
  • cpukit/score/src/coretodgetuptime.c

    r8ff5e59d r412dbff6  
    11/*
    22 *  Time of Day (TOD) Handler - get uptime
    3  *
    4  *  COPYRIGHT (c) 1989-2007.
     3 */
     4
     5/*  COPYRIGHT (c) 1989-2007.
    56 *  On-Line Applications Research Corporation (OAR).
    67 *
     
    1819#include <rtems/system.h>
    1920#include <rtems/score/isr.h>
     21#include <rtems/score/timespec.h>
    2022#include <rtems/score/tod.h>
    2123
     
    4951  _ISR_Enable( level );
    5052
    51   _TOD_Add_timespec( uptime, &offset );
     53  _Timespec_Add_to( uptime, &offset );
    5254}
  • cpukit/score/src/coretodset.c

    r8ff5e59d r412dbff6  
    11/*
    2  *  Time of Day (TOD) Handler
    3  *
    4  *
    5  *  COPYRIGHT (c) 1989-1999.
     2 *  Time of Day (TOD) Handler -- Set Time
     3 */
     4
     5/*  COPYRIGHT (c) 1989-2007.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    5050       time->tv_sec - _TOD_Seconds_since_epoch );
    5151
    52   _TOD_Seconds_since_epoch = time->tv_sec;
     52  /* POSIX format TOD (timespec) */
     53  _TOD_Now                 = *time;
    5354  _TOD_Is_set              = TRUE;
    54 
    55   /* POSIX format TOD (timespec) */
    56   _TOD_Now         = *time;
    57   _TOD_Now.tv_sec += TOD_SECONDS_1970_THROUGH_1988;
    5855
    5956  _TOD_Activate( 0 );
  • cpukit/score/src/coretodtickle.c

    r8ff5e59d r412dbff6  
    1 
    21/*
    32 *  Time of Day (TOD) Handler -- Tickle Ticks
    4  *
    5  *  COPYRIGHT (c) 1989-2007.
     3 */
     4
     5/*  COPYRIGHT (c) 1989-2007.
    66 *  On-Line Applications Research Corporation (OAR).
    77 *
     
    2020#include <rtems/score/object.h>
    2121#include <rtems/score/thread.h>
     22#include <rtems/score/timespec.h>
    2223#include <rtems/score/tod.h>
    2324#include <rtems/score/watchdog.h>
     
    4748
    4849  /* Update the timespec format uptime */
    49   (void) _TOD_Add_timespec( &_TOD_Uptime, &tick );
     50  (void) _Timespec_Add_to( &_TOD_Uptime, &tick );
    5051  /* we do not care how much the uptime changed */
    5152
    5253  /* Update the timespec format TOD */
    53   seconds = _TOD_Add_timespec( &_TOD_Now, &tick );
     54  seconds = _Timespec_Add_to( &_TOD_Now, &tick );
    5455  while ( seconds ) {
    5556    _Watchdog_Tickle_seconds();
  • cpukit/score/src/timespecfromticks.c

    r8ff5e59d r412dbff6  
    11/*
     2 *  COPYRIGHT (c) 1989-2007.
     3 *  On-Line Applications Research Corporation (OAR).
     4 *
     5 *  The license and distribution terms for this file may be
     6 *  found in the file LICENSE in this distribution or at
     7 *  http://www.rtems.com/license/LICENSE.
     8 *
    29 *  $Id$
    310 */
     
    815
    916#include <time.h>
    10 #include <errno.h>
    1117
    1218#include <rtems/system.h>
    13 #include <rtems/score/isr.h>
    14 #include <rtems/score/thread.h>
     19#include <rtems/score/timespec.h>
    1520#include <rtems/score/tod.h>
    1621
    17 #include <rtems/seterr.h>
    18 #include <rtems/posix/time.h>
    19 
    20 /*PAGE
    21  *
    22  *  _POSIX_Interval_to_timespec
    23  */
    24 
    25 void _POSIX_Interval_to_timespec(
    26   Watchdog_Interval  ticks,
    27   struct timespec   *time
     22void _Timespec_From_ticks(
     23  uint32_t         ticks,
     24  struct timespec *time
    2825)
    2926{
Note: See TracChangeset for help on using the changeset viewer.