forked from Imagelibrary/rtems
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.
This commit is contained in:
@@ -391,6 +391,7 @@ include_rtems_score_HEADERS += include/rtems/score/timecounter.h
|
|||||||
include_rtems_score_HEADERS += include/rtems/score/timecounterimpl.h
|
include_rtems_score_HEADERS += include/rtems/score/timecounterimpl.h
|
||||||
include_rtems_score_HEADERS += include/rtems/score/timespec.h
|
include_rtems_score_HEADERS += include/rtems/score/timespec.h
|
||||||
include_rtems_score_HEADERS += include/rtems/score/timestamp.h
|
include_rtems_score_HEADERS += include/rtems/score/timestamp.h
|
||||||
|
include_rtems_score_HEADERS += include/rtems/score/timestampimpl.h
|
||||||
include_rtems_score_HEADERS += include/rtems/score/tls.h
|
include_rtems_score_HEADERS += include/rtems/score/tls.h
|
||||||
include_rtems_score_HEADERS += include/rtems/score/todimpl.h
|
include_rtems_score_HEADERS += include/rtems/score/todimpl.h
|
||||||
include_rtems_score_HEADERS += include/rtems/score/userext.h
|
include_rtems_score_HEADERS += include/rtems/score/userext.h
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <rtems/score/statesimpl.h>
|
#include <rtems/score/statesimpl.h>
|
||||||
#include <rtems/score/status.h>
|
#include <rtems/score/status.h>
|
||||||
#include <rtems/score/sysstate.h>
|
#include <rtems/score/sysstate.h>
|
||||||
|
#include <rtems/score/timestampimpl.h>
|
||||||
#include <rtems/score/threadqimpl.h>
|
#include <rtems/score/threadqimpl.h>
|
||||||
#include <rtems/score/todimpl.h>
|
#include <rtems/score/todimpl.h>
|
||||||
#include <rtems/score/freechain.h>
|
#include <rtems/score/freechain.h>
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ void _Timecounter_Binuptime( struct bintime *bt );
|
|||||||
*
|
*
|
||||||
* @return Returns the uptime.
|
* @return Returns the uptime.
|
||||||
*/
|
*/
|
||||||
sbintime_t _Timecounter_Sbinuptime( void );
|
int64_t _Timecounter_Sbinuptime( void );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the uptime in the timespec format.
|
* @brief Returns the uptime in the timespec format.
|
||||||
|
|||||||
@@ -40,9 +40,6 @@
|
|||||||
*/
|
*/
|
||||||
/**@{*/
|
/**@{*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <rtems/score/basedefs.h>
|
|
||||||
#include <rtems/score/timespec.h>
|
#include <rtems/score/timespec.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -52,266 +49,7 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
* Define the Timestamp control type.
|
* Define the Timestamp control type.
|
||||||
*/
|
*/
|
||||||
typedef sbintime_t Timestamp_Control;
|
typedef int64_t Timestamp_Control;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set timestamp to specified seconds and nanoseconds.
|
|
||||||
*
|
|
||||||
* This method sets the timestamp to the specified @a _seconds and @a _nanoseconds
|
|
||||||
* value.
|
|
||||||
*
|
|
||||||
* @param[in] _time points to the timestamp instance to validate.
|
|
||||||
* @param[in] _seconds is the seconds portion of the timestamp
|
|
||||||
* @param[in] _nanoseconds is the nanoseconds portion of the timestamp
|
|
||||||
*/
|
|
||||||
RTEMS_INLINE_ROUTINE void _Timestamp_Set(
|
|
||||||
Timestamp_Control *_time,
|
|
||||||
time_t _seconds,
|
|
||||||
long _nanoseconds
|
|
||||||
)
|
|
||||||
{
|
|
||||||
struct timespec _ts;
|
|
||||||
|
|
||||||
_ts.tv_sec = _seconds;
|
|
||||||
_ts.tv_nsec = _nanoseconds;
|
|
||||||
|
|
||||||
*_time = tstosbt(_ts);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets the timestamp to zero.
|
|
||||||
*
|
|
||||||
* This method sets the timestamp to zero.
|
|
||||||
* value.
|
|
||||||
*
|
|
||||||
* @param[in] _time points to the timestamp instance to zero.
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE void _Timestamp_Set_to_zero(
|
|
||||||
Timestamp_Control *_time
|
|
||||||
)
|
|
||||||
{
|
|
||||||
*_time = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Less than operator for timestamps.
|
|
||||||
*
|
|
||||||
* This method is the less than operator for timestamps.
|
|
||||||
*
|
|
||||||
* @param[in] _lhs points to the left hand side timestamp
|
|
||||||
* @param[in] _rhs points to the right hand side timestamp
|
|
||||||
*
|
|
||||||
* @retval This method returns true if @a _lhs is less than the @a _rhs and
|
|
||||||
* false otherwise.
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE bool _Timestamp_Less_than(
|
|
||||||
const Timestamp_Control *_lhs,
|
|
||||||
const Timestamp_Control *_rhs
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return *_lhs < *_rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Greater than operator for timestamps.
|
|
||||||
*
|
|
||||||
* This method is the greater than operator for timestamps.
|
|
||||||
*
|
|
||||||
* @param[in] _lhs points to the left hand side timestamp
|
|
||||||
* @param[in] _rhs points to the right hand side timestamp
|
|
||||||
*
|
|
||||||
* @retval This method returns true if @a _lhs is greater than the @a _rhs and
|
|
||||||
* false otherwise.
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE bool _Timestamp_Greater_than(
|
|
||||||
const Timestamp_Control *_lhs,
|
|
||||||
const Timestamp_Control *_rhs
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return *_lhs > *_rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Equal to than operator for timestamps.
|
|
||||||
*
|
|
||||||
* This method is the is equal to than operator for timestamps.
|
|
||||||
*
|
|
||||||
* @param[in] _lhs points to the left hand side timestamp
|
|
||||||
* @param[in] _rhs points to the right hand side timestamp
|
|
||||||
*
|
|
||||||
* @retval This method returns true if @a _lhs is equal to @a _rhs and
|
|
||||||
* false otherwise.
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE bool _Timestamp_Equal_to(
|
|
||||||
const Timestamp_Control *_lhs,
|
|
||||||
const Timestamp_Control *_rhs
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return *_lhs == *_rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Adds two timestamps.
|
|
||||||
*
|
|
||||||
* This routine adds two timestamps. The second argument is added
|
|
||||||
* to the first.
|
|
||||||
*
|
|
||||||
* @param[in] _time points to the base time to be added to
|
|
||||||
* @param[in] _add points to the timestamp to add to the first argument
|
|
||||||
*/
|
|
||||||
RTEMS_INLINE_ROUTINE void _Timestamp_Add_to(
|
|
||||||
Timestamp_Control *_time,
|
|
||||||
const Timestamp_Control *_add
|
|
||||||
)
|
|
||||||
{
|
|
||||||
*_time += *_add;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Subtracts two timestamps.
|
|
||||||
*
|
|
||||||
* This routine subtracts two timestamps. @a result is set to
|
|
||||||
* @a end - @a start.
|
|
||||||
*
|
|
||||||
* @param[in] _start points to the starting time
|
|
||||||
* @param[in] _end points to the ending time
|
|
||||||
* @param[in] _result points to the difference between
|
|
||||||
* starting and ending time.
|
|
||||||
*
|
|
||||||
* @retval This method fills in @a _result.
|
|
||||||
*/
|
|
||||||
RTEMS_INLINE_ROUTINE void _Timestamp_Subtract(
|
|
||||||
const Timestamp_Control *_start,
|
|
||||||
const Timestamp_Control *_end,
|
|
||||||
Timestamp_Control *_result
|
|
||||||
)
|
|
||||||
{
|
|
||||||
*_result = *_end - *_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Divides a timestamp by another timestamp.
|
|
||||||
*
|
|
||||||
* This routine divides a timestamp by another timestamp. The
|
|
||||||
* intended use is for calculating percentages to three decimal points.
|
|
||||||
*
|
|
||||||
* @param[in] _lhs points to the left hand number
|
|
||||||
* @param[in] _rhs points to the right hand number
|
|
||||||
* @param[in] _ival_percentage points to the integer portion of the average
|
|
||||||
* @param[in] _fval_percentage points to the thousandths of percentage
|
|
||||||
*
|
|
||||||
* @retval This method fills in @a result.
|
|
||||||
*/
|
|
||||||
RTEMS_INLINE_ROUTINE void _Timestamp_Divide(
|
|
||||||
const Timestamp_Control *_lhs,
|
|
||||||
const Timestamp_Control *_rhs,
|
|
||||||
uint32_t *_ival_percentage,
|
|
||||||
uint32_t *_fval_percentage
|
|
||||||
)
|
|
||||||
{
|
|
||||||
struct timespec _ts_left;
|
|
||||||
struct timespec _ts_right;
|
|
||||||
|
|
||||||
_ts_left = sbttots( *_lhs );
|
|
||||||
_ts_right = sbttots( *_rhs );
|
|
||||||
|
|
||||||
_Timespec_Divide(
|
|
||||||
&_ts_left,
|
|
||||||
&_ts_right,
|
|
||||||
_ival_percentage,
|
|
||||||
_fval_percentage
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get seconds portion of timestamp.
|
|
||||||
*
|
|
||||||
* This method returns the seconds portion of the specified timestamp
|
|
||||||
*
|
|
||||||
* @param[in] _time points to the timestamp
|
|
||||||
*
|
|
||||||
* @retval The seconds portion of @a _time.
|
|
||||||
*/
|
|
||||||
RTEMS_INLINE_ROUTINE time_t _Timestamp_Get_seconds(
|
|
||||||
const Timestamp_Control *_time
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return (*_time >> 32);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get nanoseconds portion of timestamp.
|
|
||||||
*
|
|
||||||
* This method returns the nanoseconds portion of the specified timestamp
|
|
||||||
*
|
|
||||||
* @param[in] _time points to the timestamp
|
|
||||||
*
|
|
||||||
* @retval The nanoseconds portion of @a _time.
|
|
||||||
*/
|
|
||||||
RTEMS_INLINE_ROUTINE uint32_t _Timestamp_Get_nanoseconds(
|
|
||||||
const Timestamp_Control *_time
|
|
||||||
)
|
|
||||||
{
|
|
||||||
struct timespec _ts;
|
|
||||||
|
|
||||||
_ts = sbttots( *_time );
|
|
||||||
|
|
||||||
return (uint32_t) _ts.tv_nsec;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the timestamp as nanoseconds.
|
|
||||||
*
|
|
||||||
* This method returns the timestamp as nanoseconds.
|
|
||||||
*
|
|
||||||
* @param[in] _time points to the timestamp
|
|
||||||
*
|
|
||||||
* @retval The time in nanoseconds.
|
|
||||||
*/
|
|
||||||
RTEMS_INLINE_ROUTINE uint64_t _Timestamp_Get_as_nanoseconds(
|
|
||||||
const Timestamp_Control *_time
|
|
||||||
)
|
|
||||||
{
|
|
||||||
struct timespec _ts;
|
|
||||||
|
|
||||||
_ts = sbttots( *_time );
|
|
||||||
|
|
||||||
return _Timespec_Get_as_nanoseconds( &_ts );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Convert timestamp to struct timespec.
|
|
||||||
*
|
|
||||||
* This method returns the seconds portion of the specified @a _timestamp.
|
|
||||||
*
|
|
||||||
* @param[in] _timestamp points to the timestamp
|
|
||||||
* @param[in] _timespec points to the timespec
|
|
||||||
*/
|
|
||||||
RTEMS_INLINE_ROUTINE void _Timestamp_To_timespec(
|
|
||||||
const Timestamp_Control *_timestamp,
|
|
||||||
struct timespec *_timespec
|
|
||||||
)
|
|
||||||
{
|
|
||||||
*_timespec = sbttots( *_timestamp );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Convert timestamp to struct timeval.
|
|
||||||
*
|
|
||||||
* @param[in] _timestamp points to the timestamp
|
|
||||||
* @param[in] _timeval points to the timeval
|
|
||||||
*/
|
|
||||||
RTEMS_INLINE_ROUTINE void _Timestamp_To_timeval(
|
|
||||||
const Timestamp_Control *_timestamp,
|
|
||||||
struct timeval *_timeval
|
|
||||||
)
|
|
||||||
{
|
|
||||||
*_timeval = sbttotv( *_timestamp );
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
302
cpukit/include/rtems/score/timestampimpl.h
Normal file
302
cpukit/include/rtems/score/timestampimpl.h
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
/**
|
||||||
|
* @file rtems/score/timestamp.h
|
||||||
|
*
|
||||||
|
* @brief Helpers for Manipulating Timestamps
|
||||||
|
*
|
||||||
|
* This include file contains helpers for manipulating timestamps.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* COPYRIGHT (c) 1989-2009.
|
||||||
|
* On-Line Applications Research Corporation (OAR).
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.org/license/LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _RTEMS_SCORE_TIMESTAMPIMPL_H
|
||||||
|
#define _RTEMS_SCORE_TIMESTAMPIMPL_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup SuperCoreTimeStamp
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rtems/score/timestamp.h>
|
||||||
|
#include <rtems/score/basedefs.h>
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set timestamp to specified seconds and nanoseconds.
|
||||||
|
*
|
||||||
|
* This method sets the timestamp to the specified @a _seconds and @a _nanoseconds
|
||||||
|
* value.
|
||||||
|
*
|
||||||
|
* @param[in] _time points to the timestamp instance to validate.
|
||||||
|
* @param[in] _seconds is the seconds portion of the timestamp
|
||||||
|
* @param[in] _nanoseconds is the nanoseconds portion of the timestamp
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE void _Timestamp_Set(
|
||||||
|
Timestamp_Control *_time,
|
||||||
|
time_t _seconds,
|
||||||
|
long _nanoseconds
|
||||||
|
)
|
||||||
|
{
|
||||||
|
struct timespec _ts;
|
||||||
|
|
||||||
|
_ts.tv_sec = _seconds;
|
||||||
|
_ts.tv_nsec = _nanoseconds;
|
||||||
|
|
||||||
|
*_time = tstosbt(_ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the timestamp to zero.
|
||||||
|
*
|
||||||
|
* This method sets the timestamp to zero.
|
||||||
|
* value.
|
||||||
|
*
|
||||||
|
* @param[in] _time points to the timestamp instance to zero.
|
||||||
|
*/
|
||||||
|
|
||||||
|
RTEMS_INLINE_ROUTINE void _Timestamp_Set_to_zero(
|
||||||
|
Timestamp_Control *_time
|
||||||
|
)
|
||||||
|
{
|
||||||
|
*_time = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Less than operator for timestamps.
|
||||||
|
*
|
||||||
|
* This method is the less than operator for timestamps.
|
||||||
|
*
|
||||||
|
* @param[in] _lhs points to the left hand side timestamp
|
||||||
|
* @param[in] _rhs points to the right hand side timestamp
|
||||||
|
*
|
||||||
|
* @retval This method returns true if @a _lhs is less than the @a _rhs and
|
||||||
|
* false otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
|
RTEMS_INLINE_ROUTINE bool _Timestamp_Less_than(
|
||||||
|
const Timestamp_Control *_lhs,
|
||||||
|
const Timestamp_Control *_rhs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return *_lhs < *_rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Greater than operator for timestamps.
|
||||||
|
*
|
||||||
|
* This method is the greater than operator for timestamps.
|
||||||
|
*
|
||||||
|
* @param[in] _lhs points to the left hand side timestamp
|
||||||
|
* @param[in] _rhs points to the right hand side timestamp
|
||||||
|
*
|
||||||
|
* @retval This method returns true if @a _lhs is greater than the @a _rhs and
|
||||||
|
* false otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
|
RTEMS_INLINE_ROUTINE bool _Timestamp_Greater_than(
|
||||||
|
const Timestamp_Control *_lhs,
|
||||||
|
const Timestamp_Control *_rhs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return *_lhs > *_rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Equal to than operator for timestamps.
|
||||||
|
*
|
||||||
|
* This method is the is equal to than operator for timestamps.
|
||||||
|
*
|
||||||
|
* @param[in] _lhs points to the left hand side timestamp
|
||||||
|
* @param[in] _rhs points to the right hand side timestamp
|
||||||
|
*
|
||||||
|
* @retval This method returns true if @a _lhs is equal to @a _rhs and
|
||||||
|
* false otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
|
RTEMS_INLINE_ROUTINE bool _Timestamp_Equal_to(
|
||||||
|
const Timestamp_Control *_lhs,
|
||||||
|
const Timestamp_Control *_rhs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return *_lhs == *_rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Adds two timestamps.
|
||||||
|
*
|
||||||
|
* This routine adds two timestamps. The second argument is added
|
||||||
|
* to the first.
|
||||||
|
*
|
||||||
|
* @param[in] _time points to the base time to be added to
|
||||||
|
* @param[in] _add points to the timestamp to add to the first argument
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE void _Timestamp_Add_to(
|
||||||
|
Timestamp_Control *_time,
|
||||||
|
const Timestamp_Control *_add
|
||||||
|
)
|
||||||
|
{
|
||||||
|
*_time += *_add;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Subtracts two timestamps.
|
||||||
|
*
|
||||||
|
* This routine subtracts two timestamps. @a result is set to
|
||||||
|
* @a end - @a start.
|
||||||
|
*
|
||||||
|
* @param[in] _start points to the starting time
|
||||||
|
* @param[in] _end points to the ending time
|
||||||
|
* @param[in] _result points to the difference between
|
||||||
|
* starting and ending time.
|
||||||
|
*
|
||||||
|
* @retval This method fills in @a _result.
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE void _Timestamp_Subtract(
|
||||||
|
const Timestamp_Control *_start,
|
||||||
|
const Timestamp_Control *_end,
|
||||||
|
Timestamp_Control *_result
|
||||||
|
)
|
||||||
|
{
|
||||||
|
*_result = *_end - *_start;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Divides a timestamp by another timestamp.
|
||||||
|
*
|
||||||
|
* This routine divides a timestamp by another timestamp. The
|
||||||
|
* intended use is for calculating percentages to three decimal points.
|
||||||
|
*
|
||||||
|
* @param[in] _lhs points to the left hand number
|
||||||
|
* @param[in] _rhs points to the right hand number
|
||||||
|
* @param[in] _ival_percentage points to the integer portion of the average
|
||||||
|
* @param[in] _fval_percentage points to the thousandths of percentage
|
||||||
|
*
|
||||||
|
* @retval This method fills in @a result.
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE void _Timestamp_Divide(
|
||||||
|
const Timestamp_Control *_lhs,
|
||||||
|
const Timestamp_Control *_rhs,
|
||||||
|
uint32_t *_ival_percentage,
|
||||||
|
uint32_t *_fval_percentage
|
||||||
|
)
|
||||||
|
{
|
||||||
|
struct timespec _ts_left;
|
||||||
|
struct timespec _ts_right;
|
||||||
|
|
||||||
|
_ts_left = sbttots( *_lhs );
|
||||||
|
_ts_right = sbttots( *_rhs );
|
||||||
|
|
||||||
|
_Timespec_Divide(
|
||||||
|
&_ts_left,
|
||||||
|
&_ts_right,
|
||||||
|
_ival_percentage,
|
||||||
|
_fval_percentage
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get seconds portion of timestamp.
|
||||||
|
*
|
||||||
|
* This method returns the seconds portion of the specified timestamp
|
||||||
|
*
|
||||||
|
* @param[in] _time points to the timestamp
|
||||||
|
*
|
||||||
|
* @retval The seconds portion of @a _time.
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE time_t _Timestamp_Get_seconds(
|
||||||
|
const Timestamp_Control *_time
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return (*_time >> 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get nanoseconds portion of timestamp.
|
||||||
|
*
|
||||||
|
* This method returns the nanoseconds portion of the specified timestamp
|
||||||
|
*
|
||||||
|
* @param[in] _time points to the timestamp
|
||||||
|
*
|
||||||
|
* @retval The nanoseconds portion of @a _time.
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE uint32_t _Timestamp_Get_nanoseconds(
|
||||||
|
const Timestamp_Control *_time
|
||||||
|
)
|
||||||
|
{
|
||||||
|
struct timespec _ts;
|
||||||
|
|
||||||
|
_ts = sbttots( *_time );
|
||||||
|
|
||||||
|
return (uint32_t) _ts.tv_nsec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the timestamp as nanoseconds.
|
||||||
|
*
|
||||||
|
* This method returns the timestamp as nanoseconds.
|
||||||
|
*
|
||||||
|
* @param[in] _time points to the timestamp
|
||||||
|
*
|
||||||
|
* @retval The time in nanoseconds.
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE uint64_t _Timestamp_Get_as_nanoseconds(
|
||||||
|
const Timestamp_Control *_time
|
||||||
|
)
|
||||||
|
{
|
||||||
|
struct timespec _ts;
|
||||||
|
|
||||||
|
_ts = sbttots( *_time );
|
||||||
|
|
||||||
|
return _Timespec_Get_as_nanoseconds( &_ts );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Convert timestamp to struct timespec.
|
||||||
|
*
|
||||||
|
* This method returns the seconds portion of the specified @a _timestamp.
|
||||||
|
*
|
||||||
|
* @param[in] _timestamp points to the timestamp
|
||||||
|
* @param[in] _timespec points to the timespec
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE void _Timestamp_To_timespec(
|
||||||
|
const Timestamp_Control *_timestamp,
|
||||||
|
struct timespec *_timespec
|
||||||
|
)
|
||||||
|
{
|
||||||
|
*_timespec = sbttots( *_timestamp );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Convert timestamp to struct timeval.
|
||||||
|
*
|
||||||
|
* @param[in] _timestamp points to the timestamp
|
||||||
|
* @param[in] _timeval points to the timeval
|
||||||
|
*/
|
||||||
|
RTEMS_INLINE_ROUTINE void _Timestamp_To_timeval(
|
||||||
|
const Timestamp_Control *_timestamp,
|
||||||
|
struct timeval *_timeval
|
||||||
|
)
|
||||||
|
{
|
||||||
|
*_timeval = sbttotv( *_timestamp );
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**@}*/
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/* end of include file */
|
||||||
@@ -398,9 +398,7 @@ RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_timespec(
|
|||||||
return ticks;
|
return ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_sbintime(
|
RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_sbintime( int64_t sbt )
|
||||||
sbintime_t sbt
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
uint64_t ticks = ( sbt >> 32 ) << WATCHDOG_BITS_FOR_1E9_NANOSECONDS;
|
uint64_t ticks = ( sbt >> 32 ) << WATCHDOG_BITS_FOR_1E9_NANOSECONDS;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/rtems/clock.h>
|
#include <rtems/rtems/clock.h>
|
||||||
|
#include <rtems/score/timestampimpl.h>
|
||||||
#include <rtems/score/todimpl.h>
|
#include <rtems/score/todimpl.h>
|
||||||
|
|
||||||
uint64_t rtems_clock_get_uptime_nanoseconds( void )
|
uint64_t rtems_clock_get_uptime_nanoseconds( void )
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rtems/rtems/clock.h>
|
#include <rtems/rtems/clock.h>
|
||||||
|
#include <rtems/score/timestampimpl.h>
|
||||||
#include <rtems/score/todimpl.h>
|
#include <rtems/score/todimpl.h>
|
||||||
|
|
||||||
void rtems_clock_get_uptime_timeval( struct timeval *uptime )
|
void rtems_clock_get_uptime_timeval( struct timeval *uptime )
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/libio.h>
|
#include <rtems/libio.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user