Changeset ef23838 in rtems


Ignore:
Timestamp:
Dec 3, 2018, 12:10:21 PM (7 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
0a1f5df9
Parents:
9921ab6
git-author:
Sebastian Huber <sebastian.huber@…> (12/03/18 12:10:21)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/07/18 13:22:01)
Message:

score: Avoid sbintime_t in API headers

The sbintime_t is a non-POSIX type and not visible if strict standard
options are selected.

Move implementation details from <rtems/score/timestamp.h> to
<rtems/score/timestampimpl.h>.

Update #3598.

Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • cpukit/headers.am

    r9921ab6 ref23838  
    392392include_rtems_score_HEADERS += include/rtems/score/timespec.h
    393393include_rtems_score_HEADERS += include/rtems/score/timestamp.h
     394include_rtems_score_HEADERS += include/rtems/score/timestampimpl.h
    394395include_rtems_score_HEADERS += include/rtems/score/tls.h
    395396include_rtems_score_HEADERS += include/rtems/score/todimpl.h
  • cpukit/include/rtems/score/threadimpl.h

    r9921ab6 ref23838  
    3232#include <rtems/score/status.h>
    3333#include <rtems/score/sysstate.h>
     34#include <rtems/score/timestampimpl.h>
    3435#include <rtems/score/threadqimpl.h>
    3536#include <rtems/score/todimpl.h>
  • cpukit/include/rtems/score/timecounter.h

    r9921ab6 ref23838  
    7575 * @return Returns the uptime.
    7676 */
    77 sbintime_t _Timecounter_Sbinuptime( void );
     77int64_t _Timecounter_Sbinuptime( void );
    7878
    7979/**
  • cpukit/include/rtems/score/timestamp.h

    r9921ab6 ref23838  
    4141/**@{*/
    4242
    43 #include <sys/time.h>
    44 
    45 #include <rtems/score/basedefs.h>
    4643#include <rtems/score/timespec.h>
    4744
     
    5350 *   Define the Timestamp control type.
    5451 */
    55 typedef sbintime_t Timestamp_Control;
    56 
    57 /**
    58  *  @brief Set timestamp to specified seconds and nanoseconds.
    59  *
    60  *  This method sets the timestamp to the specified @a _seconds and @a _nanoseconds
    61  *  value.
    62  *
    63  *  @param[in] _time points to the timestamp instance to validate.
    64  *  @param[in] _seconds is the seconds portion of the timestamp
    65  *  @param[in] _nanoseconds is the nanoseconds portion of the timestamp
    66  */
    67 RTEMS_INLINE_ROUTINE void _Timestamp_Set(
    68   Timestamp_Control *_time,
    69   time_t             _seconds,
    70   long               _nanoseconds
    71 )
    72 {
    73   struct timespec _ts;
    74 
    75   _ts.tv_sec = _seconds;
    76   _ts.tv_nsec = _nanoseconds;
    77 
    78   *_time = tstosbt(_ts);
    79 }
    80 
    81 /**
    82  *  @brief Sets the timestamp to zero.
    83  *
    84  *  This method sets the timestamp to zero.
    85  *  value.
    86  *
    87  *  @param[in] _time points to the timestamp instance to zero.
    88  */
    89 
    90 RTEMS_INLINE_ROUTINE void _Timestamp_Set_to_zero(
    91   Timestamp_Control *_time
    92 )
    93 {
    94   *_time = 0;
    95 }
    96 
    97 /**
    98  *  @brief Less than operator for timestamps.
    99  *
    100  *  This method is the less than operator for timestamps.
    101  *
    102  *  @param[in] _lhs points to the left hand side timestamp
    103  *  @param[in] _rhs points to the right hand side timestamp
    104  *
    105  *  @retval This method returns true if @a _lhs is less than the @a _rhs and
    106  *          false otherwise.
    107  */
    108 
    109 RTEMS_INLINE_ROUTINE bool _Timestamp_Less_than(
    110   const Timestamp_Control *_lhs,
    111   const Timestamp_Control *_rhs
    112 )
    113 {
    114   return *_lhs < *_rhs;
    115 }
    116 
    117 /**
    118  *  @brief Greater than operator for timestamps.
    119  *
    120  *  This method is the greater than operator for timestamps.
    121  *
    122  *  @param[in] _lhs points to the left hand side timestamp
    123  *  @param[in] _rhs points to the right hand side timestamp
    124  *
    125  *  @retval This method returns true if @a _lhs is greater than the @a _rhs and
    126  *          false otherwise.
    127  */
    128 
    129 RTEMS_INLINE_ROUTINE bool _Timestamp_Greater_than(
    130   const Timestamp_Control *_lhs,
    131   const Timestamp_Control *_rhs
    132 )
    133 {
    134   return *_lhs > *_rhs;
    135 }
    136 
    137 /**
    138  *  @brief Equal to than operator for timestamps.
    139  *
    140  *  This method is the is equal to than operator for timestamps.
    141  *
    142  *  @param[in] _lhs points to the left hand side timestamp
    143  *  @param[in] _rhs points to the right hand side timestamp
    144  *
    145  *  @retval This method returns true if @a _lhs is equal to  @a _rhs and
    146  *          false otherwise.
    147  */
    148 
    149 RTEMS_INLINE_ROUTINE bool _Timestamp_Equal_to(
    150   const Timestamp_Control *_lhs,
    151   const Timestamp_Control *_rhs
    152 )
    153 {
    154   return *_lhs == *_rhs;
    155 }
    156 
    157 /**
    158  *  @brief Adds two timestamps.
    159  *
    160  *  This routine adds two timestamps.  The second argument is added
    161  *  to the first.
    162  *
    163  *  @param[in] _time points to the base time to be added to
    164  *  @param[in] _add points to the timestamp to add to the first argument
    165  */
    166 RTEMS_INLINE_ROUTINE void _Timestamp_Add_to(
    167   Timestamp_Control *_time,
    168   const Timestamp_Control *_add
    169 )
    170 {
    171   *_time += *_add;
    172 }
    173 
    174 /**
    175  *  @brief Subtracts two timestamps.
    176  *
    177  *  This routine subtracts two timestamps.  @a result is set to
    178  *  @a end - @a start.
    179  *
    180  *  @param[in] _start points to the starting time
    181  *  @param[in] _end points to the ending time
    182  *  @param[in] _result points to the difference between
    183  *             starting and ending time.
    184  *
    185  *  @retval This method fills in @a _result.
    186  */
    187 RTEMS_INLINE_ROUTINE void _Timestamp_Subtract(
    188   const Timestamp_Control *_start,
    189   const Timestamp_Control *_end,
    190   Timestamp_Control       *_result
    191 )
    192 {
    193   *_result = *_end - *_start;
    194 }
    195 
    196 /**
    197  *  @brief Divides a timestamp by another timestamp.
    198  *
    199  *  This routine divides a timestamp by another timestamp.  The
    200  *  intended use is for calculating percentages to three decimal points.
    201  *
    202  *  @param[in] _lhs points to the left hand number
    203  *  @param[in] _rhs points to the right hand number
    204  *  @param[in] _ival_percentage points to the integer portion of the average
    205  *  @param[in] _fval_percentage points to the thousandths of percentage
    206  *
    207  *  @retval This method fills in @a result.
    208  */
    209 RTEMS_INLINE_ROUTINE void _Timestamp_Divide(
    210   const Timestamp_Control *_lhs,
    211   const Timestamp_Control *_rhs,
    212   uint32_t                *_ival_percentage,
    213   uint32_t                *_fval_percentage
    214 )
    215 {
    216   struct timespec _ts_left;
    217   struct timespec _ts_right;
    218 
    219   _ts_left = sbttots( *_lhs );
    220   _ts_right = sbttots( *_rhs );
    221 
    222   _Timespec_Divide(
    223     &_ts_left,
    224     &_ts_right,
    225     _ival_percentage,
    226     _fval_percentage
    227   );
    228 }
    229 
    230 /**
    231  *  @brief Get seconds portion of timestamp.
    232  *
    233  *  This method returns the seconds portion of the specified timestamp
    234  *
    235  *  @param[in] _time points to the timestamp
    236  *
    237  *  @retval The seconds portion of @a _time.
    238  */
    239 RTEMS_INLINE_ROUTINE time_t _Timestamp_Get_seconds(
    240   const Timestamp_Control *_time
    241 )
    242 {
    243   return (*_time >> 32);
    244 }
    245 
    246 /**
    247  *  @brief Get nanoseconds portion of timestamp.
    248  *
    249  *  This method returns the nanoseconds portion of the specified timestamp
    250  *
    251  *  @param[in] _time points to the timestamp
    252  *
    253  *  @retval The nanoseconds portion of @a _time.
    254  */
    255 RTEMS_INLINE_ROUTINE uint32_t _Timestamp_Get_nanoseconds(
    256   const Timestamp_Control *_time
    257 )
    258 {
    259   struct timespec _ts;
    260 
    261   _ts = sbttots( *_time );
    262 
    263   return (uint32_t) _ts.tv_nsec;
    264 }
    265 
    266 /**
    267  *  @brief Get the timestamp as nanoseconds.
    268  *
    269  *  This method returns the timestamp as nanoseconds.
    270  *
    271  *  @param[in] _time points to the timestamp
    272  *
    273  *  @retval The time in nanoseconds.
    274  */
    275 RTEMS_INLINE_ROUTINE uint64_t _Timestamp_Get_as_nanoseconds(
    276   const Timestamp_Control *_time
    277 )
    278 {
    279   struct timespec _ts;
    280 
    281   _ts = sbttots( *_time );
    282 
    283   return _Timespec_Get_as_nanoseconds( &_ts );
    284 }
    285 
    286 /**
    287  *  @brief Convert timestamp to struct timespec.
    288  *
    289  *  This method returns the seconds portion of the specified @a _timestamp.
    290  *
    291  *  @param[in] _timestamp points to the timestamp
    292  *  @param[in] _timespec points to the timespec
    293  */
    294 RTEMS_INLINE_ROUTINE void _Timestamp_To_timespec(
    295   const Timestamp_Control *_timestamp,
    296   struct timespec         *_timespec
    297 )
    298 {
    299   *_timespec = sbttots( *_timestamp );
    300 }
    301 
    302 /**
    303  *  @brief Convert timestamp to struct timeval.
    304  *
    305  *  @param[in] _timestamp points to the timestamp
    306  *  @param[in] _timeval points to the timeval
    307  */
    308 RTEMS_INLINE_ROUTINE void _Timestamp_To_timeval(
    309   const Timestamp_Control *_timestamp,
    310   struct timeval          *_timeval
    311 )
    312 {
    313   *_timeval = sbttotv( *_timestamp );
    314 }
     52typedef int64_t Timestamp_Control;
    31553
    31654#ifdef __cplusplus
  • cpukit/include/rtems/score/watchdogimpl.h

    r9921ab6 ref23838  
    399399}
    400400
    401 RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_sbintime(
    402   sbintime_t sbt
    403 )
     401RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_sbintime( int64_t sbt )
    404402{
    405403  uint64_t ticks = ( sbt >> 32 ) << WATCHDOG_BITS_FOR_1E9_NANOSECONDS;
  • cpukit/rtems/src/clockgetuptimenanoseconds.c

    r9921ab6 ref23838  
    1919
    2020#include <rtems/rtems/clock.h>
     21#include <rtems/score/timestampimpl.h>
    2122#include <rtems/score/todimpl.h>
    2223
  • cpukit/rtems/src/clockgetuptimetimeval.c

    r9921ab6 ref23838  
    2525
    2626#include <rtems/rtems/clock.h>
     27#include <rtems/score/timestampimpl.h>
    2728#include <rtems/score/todimpl.h>
    2829
  • testsuites/psxtests/psx13/test.c

    r9921ab6 ref23838  
    3030#include <rtems.h>
    3131#include <rtems/libio.h>
     32#include <sys/time.h>
    3233#include <fcntl.h>
    3334#include <unistd.h>
  • testsuites/psxtmtests/psxtmcond08/init.c

    r9921ab6 ref23838  
    2525#endif
    2626
     27#include <sys/time.h>
    2728#include <stdio.h>
    2829#include <time.h>
Note: See TracChangeset for help on using the changeset viewer.