Changeset 2256946 in rtems


Ignore:
Timestamp:
Oct 6, 2017, 1:30:47 PM (23 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
65012bf
Parents:
c0623a99
git-author:
Sebastian Huber <sebastian.huber@…> (10/06/17 13:30:47)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/09/17 06:30:03)
Message:

score: Use struct timespec for TOD

Use the timestamps only for uptime based values. Use struct timespec
for the absolute time values (TOD).

Update #2740.

Location:
cpukit
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/clockgettime.c

    rc0623a99 r2256946  
    3838
    3939  if ( clock_id == CLOCK_REALTIME ) {
    40     _TOD_Get_as_timespec(tp);
     40    _TOD_Get(tp);
    4141    return 0;
    4242  }
  • cpukit/posix/src/clocksettime.c

    rc0623a99 r2256946  
    3737
    3838  if ( clock_id == CLOCK_REALTIME ) {
     39    ISR_lock_Context lock_context;
     40
    3941    if ( tp->tv_sec < TOD_SECONDS_1970_THROUGH_1988 )
    4042      rtems_set_errno_and_return_minus_one( EINVAL );
    4143
    42     _TOD_Set_with_timespec( tp );
     44    _TOD_Lock();
     45    _TOD_Acquire( &lock_context );
     46    _TOD_Set( tp, &lock_context );
     47    _TOD_Unlock();
    4348  }
    4449#ifdef _POSIX_CPUTIME
  • cpukit/posix/src/timersettime.c

    rc0623a99 r2256946  
    4040
    4141  /* Store the time when the timer was started again */
    42   _TOD_Get_as_timespec( &ptimer->time );
     42  _TOD_Get( &ptimer->time );
    4343
    4444  _Watchdog_Insert(
     
    133133  if (flags == TIMER_ABSTIME) {
    134134    struct timespec now;
    135     _TOD_Get_as_timespec( &now );
     135    _TOD_Get( &now );
    136136    /* Check for seconds in the past */
    137137    if ( _Timespec_Greater_than( &now, &normalize.it_value ) )
  • cpukit/rtems/src/clockset.c

    rc0623a99 r2256946  
    3131
    3232  if ( _TOD_Validate( tod ) ) {
    33     Timestamp_Control tod_as_timestamp;
    34     uint32_t          seconds;
    35     uint32_t          nanoseconds;
    36     ISR_lock_Context  lock_context;
     33    struct timespec  tod_as_timespec;
     34    ISR_lock_Context lock_context;
    3735
    38     seconds = _TOD_To_seconds( tod );
    39     nanoseconds = tod->ticks
     36    tod_as_timespec.tv_sec = _TOD_To_seconds( tod );
     37    tod_as_timespec.tv_nsec = tod->ticks
    4038      * rtems_configuration_get_nanoseconds_per_tick();
    41     _Timestamp_Set( &tod_as_timestamp, seconds, nanoseconds );
    4239
    4340    _TOD_Lock();
    4441    _TOD_Acquire( &lock_context );
    45     _TOD_Set( &tod_as_timestamp, &lock_context );
     42    _TOD_Set( &tod_as_timespec, &lock_context );
    4643    _TOD_Unlock();
    4744
  • cpukit/score/include/rtems/score/todimpl.h

    rc0623a99 r2256946  
    165165 * The caller must be the owner of the TOD lock.
    166166 *
    167  * @param tod_as_timestamp The new time of day in timestamp format representing
     167 * @param tod The new time of day in timespec format representing
    168168 *   the time since UNIX Epoch.
    169169 * @param lock_context The ISR lock context used for the corresponding
     
    172172 */
    173173void _TOD_Set(
    174   const Timestamp_Control *tod_as_timestamp,
    175   ISR_lock_Context        *lock_context
     174  const struct timespec *tod,
     175  ISR_lock_Context      *lock_context
    176176);
    177177
    178178/**
    179  * @brief Sets the time of day with timespec format.
    180  *
    181  * @param tod_as_timespec The new time of day in timespec format.
    182  *
    183  * @see _TOD_Set().
    184  */
    185 static inline void _TOD_Set_with_timespec(
    186   const struct timespec *tod_as_timespec
    187 )
    188 {
    189   Timestamp_Control tod_as_timestamp;
    190   ISR_lock_Context  lock_context;
    191 
    192   _Timestamp_Set(
    193     &tod_as_timestamp,
    194     tod_as_timespec->tv_sec,
    195     tod_as_timespec->tv_nsec
    196   );
    197 
    198   _TOD_Lock();
    199   _TOD_Acquire( &lock_context );
    200   _TOD_Set( &tod_as_timestamp, &lock_context );
    201   _TOD_Unlock();
    202 }
    203 
    204 /**
    205  *  @brief Gets the current time in the bintime format.
    206  *
    207  *  @param[out] time is the value gathered by the bintime request
     179 *  @brief Gets the current time in the timespec format.
     180 *
     181 *  @param[out] time is the value gathered by the request
    208182 */
    209183static inline void _TOD_Get(
    210   Timestamp_Control *time
    211 )
    212 {
    213   _Timecounter_Bintime(time);
    214 }
    215 
    216 /**
    217  *  @brief Gets the current time in the timespec format.
    218  *
    219  *  @param[out] time is the value gathered by the nanotime request
    220  */
    221 static inline void _TOD_Get_as_timespec(
    222   struct timespec *time
    223 )
    224 {
    225   _Timecounter_Nanotime(time);
     184  struct timespec *tod
     185)
     186{
     187  _Timecounter_Nanotime( tod );
    226188}
    227189
     
    325287 */
    326288void _TOD_Adjust(
    327   const Timestamp_Control *delta
     289  const struct timespec *delta
    328290);
    329291
  • cpukit/score/src/coretodabsolutetimeout.c

    rc0623a99 r2256946  
    4848   */
    4949  if ( clock == CLOCK_REALTIME ) {
    50     _TOD_Get_as_timespec( &current_time );
     50    _TOD_Get( &current_time );
    5151  } else {
    5252    _Assert( clock == CLOCK_MONOTONIC );
  • cpukit/score/src/coretodadjust.c

    rc0623a99 r2256946  
    2222
    2323void _TOD_Adjust(
    24   const Timestamp_Control *delta
     24  const struct timespec *delta
    2525)
    2626{
    27   Timestamp_Control tod;
    28   ISR_lock_Context  lock_context;
     27  ISR_lock_Context lock_context;
     28  struct timespec  tod;
    2929
    3030  /*
     
    3939  _TOD_Acquire( &lock_context );
    4040  _TOD_Get( &tod );
    41   _Timestamp_Add_to( &tod, delta );
     41  _Timespec_Add_to( &tod, delta );
    4242  _TOD_Set( &tod, &lock_context );
    4343  _TOD_Unlock();
  • cpukit/score/src/coretodset.c

    rc0623a99 r2256946  
    2424
    2525void _TOD_Set(
    26   const Timestamp_Control *tod_as_timestamp,
    27   ISR_lock_Context        *lock_context
     26  const struct timespec *tod,
     27  ISR_lock_Context      *lock_context
    2828)
    2929{
    30   struct timespec tod_as_timespec;
     30  struct bintime  tod_as_bintime;
    3131  uint64_t        tod_as_ticks;
    3232  uint32_t        cpu_count;
     
    3535  _Assert( _API_Mutex_Is_owner( _Once_Mutex ) );
    3636
    37   _Timecounter_Set_clock( tod_as_timestamp, lock_context );
     37  timespec2bintime( tod, &tod_as_bintime );
     38  _Timecounter_Set_clock( &tod_as_bintime, lock_context );
    3839
    39   _Timestamp_To_timespec( tod_as_timestamp, &tod_as_timespec );
    40   tod_as_ticks = _Watchdog_Ticks_from_timespec( &tod_as_timespec );
     40  tod_as_ticks = _Watchdog_Ticks_from_timespec( tod );
    4141  cpu_count = _SMP_Get_processor_count();
    4242
Note: See TracChangeset for help on using the changeset viewer.