Changeset 65012bf in rtems


Ignore:
Timestamp:
Oct 6, 2017, 1:41:46 PM (22 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
af9115f3
Parents:
2256946
git-author:
Sebastian Huber <sebastian.huber@…> (10/06/17 13:41:46)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/09/17 06:30:07)
Message:

score: Change Timestamp_Control to sbintime_t

The timestamp are based on the uptime. There is no need for a 64-bit
seconds part. The signed 32-bit seconds part of the sbintime_t limits
the uptime to roughly 68 years.

Close #2740.

Location:
cpukit/score
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/timecounter.h

    r2256946 r65012bf  
    7070
    7171/**
     72 * @brief Returns the uptime in the sbintime_t format.
     73 *
     74 * @return Returns the uptime.
     75 */
     76sbintime_t _Timecounter_Sbinuptime( void );
     77
     78/**
    7279 * @brief Returns the uptime in the timespec format.
    7380 *
  • cpukit/score/include/rtems/score/timestamp.h

    r2256946 r65012bf  
    5353 *   Define the Timestamp control type.
    5454 */
    55 typedef struct bintime Timestamp_Control;
     55typedef sbintime_t Timestamp_Control;
    5656
    5757/**
     
    7676  _ts.tv_nsec = _nanoseconds;
    7777
    78   timespec2bintime( &_ts, _time );
     78  *_time = tstosbt(_ts);
    7979}
    8080
     
    9292)
    9393{
    94   _time->sec = 0;
    95   _time->frac = 0;
     94  *_time = 0;
    9695}
    9796
     
    113112)
    114113{
    115   if ( _lhs->sec < _rhs->sec )
    116     return true;
    117 
    118   if ( _lhs->sec > _rhs->sec )
    119     return false;
    120 
    121   return _lhs->frac < _rhs->frac;
     114  return *_lhs < *_rhs;
    122115}
    123116
     
    139132)
    140133{
    141   if ( _lhs->sec > _rhs->sec )
    142     return true;
    143 
    144   if ( _lhs->sec < _rhs->sec )
    145     return false;
    146 
    147   return _lhs->frac > _rhs->frac;
     134  return *_lhs > *_rhs;
    148135}
    149136
     
    165152)
    166153{
    167   return _lhs->sec == _rhs->sec && _lhs->frac == _rhs->frac;
     154  return *_lhs == *_rhs;
    168155}
    169156
     
    182169)
    183170{
    184   bintime_add( _time, _add );
     171  *_time += *_add;
    185172}
    186173
     
    204191)
    205192{
    206   _result->sec = _end->sec;
    207   _result->frac = _end->frac;
    208 
    209   bintime_sub( _result, _start );
     193  *_result = *_end - *_start;
    210194}
    211195
     
    233217  struct timespec _ts_right;
    234218
    235   bintime2timespec( _lhs, &_ts_left );
    236   bintime2timespec( _rhs, &_ts_right );
     219  _ts_left = sbttots( *_lhs );
     220  _ts_right = sbttots( *_rhs );
    237221
    238222  _Timespec_Divide(
     
    257241)
    258242{
    259   return _time->sec;
     243  return (*_time >> 32);
    260244}
    261245
     
    275259  struct timespec _ts;
    276260
    277   bintime2timespec( _time, &_ts );
     261  _ts = sbttots( *_time );
    278262
    279263  return (uint32_t) _ts.tv_nsec;
     
    295279  struct timespec _ts;
    296280
    297   bintime2timespec( _time, &_ts );
     281  _ts = sbttots( *_time );
    298282
    299283  return _Timespec_Get_as_nanoseconds( &_ts );
     
    313297)
    314298{
    315   bintime2timespec( _timestamp, _timespec );
     299  *_timespec = sbttots( *_timestamp );
    316300}
    317301
     
    327311)
    328312{
    329   bintime2timeval( _timestamp, _timeval );
     313  *_timeval = sbttotv( *_timestamp );
    330314}
    331315
  • cpukit/score/include/rtems/score/todimpl.h

    r2256946 r65012bf  
    202202)
    203203{
    204   _Timecounter_Binuptime( time );
     204  *time = _Timecounter_Sbinuptime();
    205205}
    206206
     
    217217)
    218218{
    219   _Timecounter_Binuptime( time );
    220   --time->sec;
     219  *time = _Timecounter_Sbinuptime() - SBT_1S;
    221220}
    222221
  • cpukit/score/src/kern_tc.c

    r2256946 r65012bf  
    6767#ifdef __rtems__
    6868#include <limits.h>
     69#include <string.h>
    6970#include <rtems.h>
    7071ISR_LOCK_DEFINE(, _Timecounter_Lock, "Timecounter")
     
    470471        } while (gen == 0 || gen != tc_getgen(th));
    471472}
     473#ifdef __rtems__
     474sbintime_t
     475_Timecounter_Sbinuptime(void)
     476{
     477        struct timehands *th;
     478        uint32_t gen;
     479        sbintime_t sbt;
     480
     481        do {
     482                th = timehands;
     483                gen = tc_getgen(th);
     484                sbt = bttosbt(th->th_offset);
     485                sbt += (th->th_scale * tc_delta(th)) >> 32;
     486        } while (gen == 0 || gen != tc_getgen(th));
     487
     488        return (sbt);
     489}
     490#endif /* __rtems__ */
    472491
    473492void
Note: See TracChangeset for help on using the changeset viewer.