diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-09-28 14:42:12 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2011-09-28 14:42:12 +0000 |
commit | 3a42e6fd104c3544a677ffbbeda2fd59e1bbb100 (patch) | |
tree | 1fffb6c96058801bb8bdf1723a198d705e40fe91 /cpukit/score/include | |
parent | Housekeeping. (diff) | |
download | rtems-3a42e6fd104c3544a677ffbbeda2fd59e1bbb100.tar.bz2 |
2011-09-28 Sebastian Huber <sebastian.huber@embedded-brains.de>
PR 1914/cpukit
* score/src/timespecgreaterthan.c, score/src/ts64greaterthan.c:
Removed files.
* score/Makefile.am: Reflect changes above.
* score/include/rtems/score/timespec.h,
score/include/rtems/score/timestamp.h,
score/include/rtems/score/timestamp64.h, score/src/ts64addto.c,
score/src/ts64divide.c, score/src/ts64dividebyinteger.c,
score/src/ts64equalto.c, score/src/ts64getnanoseconds.c,
score/src/ts64getseconds.c, score/src/ts64lessthan.c,
score/src/ts64set.c, score/src/ts64settozero.c,
score/src/ts64subtract.c, score/src/ts64toticks.c,
score/src/ts64totimespec.c: Use CPU_TIMESTAMP_USE_STRUCT_TIMESPEC,
CPU_TIMESTAMP_USE_INT64, and CPU_TIMESTAMP_USE_INT64_INLINE. Removed
copy and paste.
Diffstat (limited to 'cpukit/score/include')
-rw-r--r-- | cpukit/score/include/rtems/score/timespec.h | 6 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/timestamp.h | 125 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/timestamp64.h | 216 |
3 files changed, 165 insertions, 182 deletions
diff --git a/cpukit/score/include/rtems/score/timespec.h b/cpukit/score/include/rtems/score/timespec.h index 10c76d3247..ed0a9d89c5 100644 --- a/cpukit/score/include/rtems/score/timespec.h +++ b/cpukit/score/include/rtems/score/timespec.h @@ -131,10 +131,8 @@ bool _Timespec_Less_than( * @return This method returns true if @a lhs is greater than the @a rhs and * false otherwise. */ -bool _Timespec_Greater_than( - const struct timespec *lhs, - const struct timespec *rhs -); +#define _Timespec_Greater_than( _lhs, _rhs ) \ + _Timespec_Less_than( _rhs, _lhs ) /** * @brief Timespec equal to Operator diff --git a/cpukit/score/include/rtems/score/timestamp.h b/cpukit/score/include/rtems/score/timestamp.h index 7575006e78..6160744040 100644 --- a/cpukit/score/include/rtems/score/timestamp.h +++ b/cpukit/score/include/rtems/score/timestamp.h @@ -40,93 +40,33 @@ */ /**@{*/ +#include <rtems/score/cpu.h> #include <rtems/score/timespec.h> #ifdef __cplusplus extern "C" { #endif -/* - * NOTE: Eventually each port should select what it should use!!! - * - * These control which implementation of SuperCore Timestamp is used. - * - * if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) - * struct timespec is used - * else if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) - * int64_t is used - * - * When int64_t is used, then - * if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) - * the methods are inlined - * else - * the methods are NOT inlined - * - * Performance of int64_t versus struct timespec - * ============================================= - * - * On PowerPC/psim, inlined int64_t saves ~50 instructions on each - * _Thread_Dispatch operation which results in a context switch. - * This works out to be about 10% faster dispatches and 7.5% faster - * blocking semaphore obtains. The following numbers are in instructions - * and from tm02 and tm26. - * - * timespec int64 inlined int64 - * dispatch: 446 446 400 - * blocking sem obtain: 627 626 581 - * - * On SPARC/sis, inlined int64_t shows the same percentage gains. - * The following numbers are in microseconds and from tm02 and tm26. - * - * timespec int64 inlined int64 - * dispatch: 59 61 53 - * blocking sem obtain: 98 100 92 - * - * Inlining appears to have a tendency to increase the size of - * some executables. - * Not inlining reduces the execution improvement but does not seem to - * be an improvement on the PowerPC and SPARC. The struct timespec - * and the executables with int64 not inlined are about the same size. - * - * Once there has some analysis of which algorithm and configuration - * is best suited to each target, these defines should be moved to - * the appropriate score/cpu cpu.h file. In the meantime, it is - * appropriate to select an implementation here using CPU macros. - */ - -#define CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC -/* -#define CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64 -#define CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE -*/ - -/* - * Verify something is defined. - */ -#if !defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) && \ - !defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) - #error "No SuperCore Timestamp implementation selected." +#if ! ( ( CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE \ + && CPU_TIMESTAMP_USE_INT64 == FALSE \ + && CPU_TIMESTAMP_USE_INT64_INLINE == FALSE ) \ + || ( CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == FALSE \ + && CPU_TIMESTAMP_USE_INT64 == TRUE \ + && CPU_TIMESTAMP_USE_INT64_INLINE == FALSE ) \ + || ( CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == FALSE \ + && CPU_TIMESTAMP_USE_INT64 == FALSE \ + && CPU_TIMESTAMP_USE_INT64_INLINE == TRUE ) ) + #error "Invalid SuperCore Timestamp implementations selection." #endif -/* - * Verify that more than one is not defined. - */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) && \ - defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) - #error "Too many SuperCore Timestamp implementations selected." -#endif - -/** - * Include any implementation specific header files - */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) +#if CPU_TIMESTAMP_USE_INT64 == TRUE || CPU_TIMESTAMP_USE_INT64_INLINE == TRUE #include <rtems/score/timestamp64.h> #endif /** * Define the Timestamp control type. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE typedef struct timespec Timestamp_Control; #else typedef Timestamp64_Control Timestamp_Control; @@ -142,7 +82,7 @@ extern "C" { * @param[in] _seconds is the seconds portion of the timestamp * @param[in] _nanoseconds is the nanoseconds portion of the timestamp */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Set( _time, _seconds, _nanoseconds ) \ _Timespec_Set( _time, _seconds, _nanoseconds ) #else @@ -158,7 +98,7 @@ extern "C" { * * @param[in] _time points to the timestamp instance to zero. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Set_to_zero( _time ) \ _Timespec_Set_to_zero( _time ) #else @@ -176,7 +116,7 @@ extern "C" { * @return This method returns true if @a time is valid and * false otherwise. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Is_valid( _time ) \ _Timespec_Is_valid( _time ) #else @@ -195,7 +135,7 @@ extern "C" { * @return This method returns true if @a _lhs is less than the @a _rhs and * false otherwise. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Less_than( _lhs, _rhs ) \ _Timespec_Less_than( _lhs, _rhs ) #else @@ -214,13 +154,8 @@ extern "C" { * @return This method returns true if @a _lhs is greater than the @a _rhs and * false otherwise. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) - #define _Timestamp_Greater_than( _lhs, _rhs ) \ - _Timespec_Greater_than( _lhs, _rhs ) -#else - #define _Timestamp_Greater_than( _lhs, _rhs ) \ - _Timestamp64_Greater_than( _lhs, _rhs ) -#endif +#define _Timestamp_Greater_than( _lhs, _rhs ) \ + _Timestamp_Less_than( _rhs, _lhs ) /** * @brief Timestamp equal to Operator @@ -233,7 +168,7 @@ extern "C" { * @return This method returns true if @a _lhs is equal to @a _rhs and * false otherwise. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Equal_to( _lhs, _rhs ) \ _Timespec_Equal_to( _lhs, _rhs ) #else @@ -252,7 +187,7 @@ extern "C" { * * @return This method returns the number of seconds @a time increased by. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Add_to( _time, _add ) \ _Timespec_Add_to( _time, _add ) #else @@ -277,7 +212,7 @@ extern "C" { * * @return This method returns the number of seconds @a time increased by. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Add_to_at_tick( _time, _add ) \ _Timespec_Add_to( _time, _add ) #else @@ -295,7 +230,7 @@ extern "C" { * * @return This method returns the number of ticks computed. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_To_ticks( _time ) \ _Timespec_To_ticks( _time ) #else @@ -312,7 +247,7 @@ extern "C" { * @param[in] _time points to the timestamp format time result * @param[in] _ticks points to the number of ticks to be filled in */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_From_ticks( _ticks, _time ) \ _Timespec_From_ticks( _ticks, _time ) #else @@ -333,7 +268,7 @@ extern "C" { * * @return This method fills in @a _result. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Subtract( _start, _end, _result ) \ _Timespec_Subtract( _start, _end, _result ) #else @@ -354,7 +289,7 @@ extern "C" { * * @return This method fills in @a result. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Divide_by_integer( _time, _iterations, _result ) \ _Timespec_Divide_by_integer(_time, _iterations, _result ) #else @@ -375,7 +310,7 @@ extern "C" { * * @return This method fills in @a result. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Divide( _lhs, _rhs, _ival_percentage, _fval_percentage ) \ _Timespec_Divide( _lhs, _rhs, _ival_percentage, _fval_percentage ) #else @@ -392,7 +327,7 @@ extern "C" { * * @return The seconds portion of @a _time. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Get_seconds( _time ) \ _Timespec_Get_seconds( _time ) #else @@ -409,7 +344,7 @@ extern "C" { * * @return The nanoseconds portion of @a _time. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE #define _Timestamp_Get_nanoseconds( _time ) \ _Timespec_Get_nanoseconds( _time ) #else @@ -425,7 +360,7 @@ extern "C" { * @param[in] _timestamp points to the timestamp * @param[in] _timespec points to the timespec */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC) +#if CPU_TIMESTAMP_USE_STRUCT_TIMESPEC == TRUE /* in this case we know they are the same type so use simple assignment */ #define _Timestamp_To_timespec( _timestamp, _timespec ) \ *(_timespec) = *(_timestamp) diff --git a/cpukit/score/include/rtems/score/timestamp64.h b/cpukit/score/include/rtems/score/timestamp64.h index 69ace0a71e..2bc408528b 100644 --- a/cpukit/score/include/rtems/score/timestamp64.h +++ b/cpukit/score/include/rtems/score/timestamp64.h @@ -44,7 +44,7 @@ extern "C" { /* * Verify something is defined. */ -#if !defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) +#if CPU_TIMESTAMP_USE_INT64 != TRUE && CPU_TIMESTAMP_USE_INT64_INLINE != TRUE #error "SuperCore Timestamp64 implementation included but not defined." #endif @@ -53,6 +53,18 @@ extern "C" { */ typedef int64_t Timestamp64_Control; +static inline void _Timestamp64_implementation_Set( + Timestamp64_Control *_time, + long _seconds, + long _nanoseconds +) +{ + Timestamp64_Control _seconds64 = _seconds; + Timestamp64_Control _nanoseconds64 = _nanoseconds; + + *_time = _seconds64 * 1000000000L + _nanoseconds64; +} + /** * @brief Set Timestamp to Seconds Nanosecond * @@ -63,12 +75,9 @@ typedef int64_t Timestamp64_Control; * @param[in] _seconds is the seconds portion of the timestamp * @param[in] _nanoseconds is the nanoseconds portion of the timestamp */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE #define _Timestamp64_Set( _time, _seconds, _nanoseconds ) \ - do { \ - *(_time) = ((int64_t)_seconds * 1000000000); \ - *(_time) += (int64_t)(_nanoseconds); \ - } while (0) + _Timestamp64_implementation_Set( _time, _seconds, _nanoseconds ) #else void _Timestamp64_Set( Timestamp64_Control *_time, @@ -77,6 +86,13 @@ typedef int64_t Timestamp64_Control; ); #endif +static inline void _Timestamp64_implementation_Set_to_zero( + Timestamp64_Control *_time +) +{ + *_time = 0; +} + /** * @brief Zero Timestamp * @@ -85,9 +101,9 @@ typedef int64_t Timestamp64_Control; * * @param[in] _time points to the timestamp instance to zero. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE #define _Timestamp64_Set_to_zero( _time ) \ - *(_time) = 0 + _Timestamp64_implementation_Set_to_zero( _time ) #else void _Timestamp64_Set_to_zero( Timestamp64_Control *_time @@ -105,7 +121,15 @@ typedef int64_t Timestamp64_Control; * false otherwise. */ #define _Timestamp64_Is_valid( _time ) \ - (1) + (1) + +static inline bool _Timestamp64_implementation_Less_than( + const Timestamp64_Control *_lhs, + const Timestamp64_Control *_rhs +) +{ + return *_lhs < *_rhs; +} /** * @brief Timestamp Less Than Operator @@ -118,36 +142,26 @@ typedef int64_t Timestamp64_Control; * @return This method returns true if @a _lhs is less than the @a _rhs and * false otherwise. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE #define _Timestamp64_Less_than( _lhs, _rhs ) \ - (*(_lhs) < *(_rhs)) + _Timestamp64_implementation_Less_than( _lhs, _rhs ) #else bool _Timestamp64_Less_than( - Timestamp64_Control *_lhs, - Timestamp64_Control *_rhs + const Timestamp64_Control *_lhs, + const Timestamp64_Control *_rhs ); #endif -/** - * @brief Timestamp Greater Than Operator - * - * 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 - * - * @return This method returns true if @a _lhs is greater than the @a _rhs and - * false otherwise. - */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) - #define _Timestamp64_Greater_than( _lhs, _rhs ) \ - (*(_lhs) > *(_rhs)) -#else - bool _Timestamp64_Greater_than( - Timestamp64_Control *_lhs, - Timestamp64_Control *_rhs - ); -#endif +static inline bool _Timestamp64_implementation_Equal_to( + const Timestamp64_Control *_lhs, + const Timestamp64_Control *_rhs +) +{ + return *_lhs == *_rhs; +} + +#define _Timestamp64_Greater_than( _lhs, _rhs ) \ + _Timestamp64_Less_than( _rhs, _lhs ) /** * @brief Timestamp equal to Operator @@ -160,16 +174,24 @@ typedef int64_t Timestamp64_Control; * @return This method returns true if @a _lhs is equal to @a _rhs and * false otherwise. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE #define _Timestamp64_Equal_to( _lhs, _rhs ) \ - (*(_lhs) == *(_rhs)) + _Timestamp64_implementation_Equal_to( _lhs, _rhs ) #else bool _Timestamp64_Equal_to( - Timestamp64_Control *_lhs, - Timestamp64_Control *_rhs + const Timestamp64_Control *_lhs, + const Timestamp64_Control *_rhs ); #endif +static inline void _Timestamp64_implementation_Add_to( + Timestamp64_Control *_time, + const Timestamp64_Control *_add +) +{ + *_time += *_add; +} + /** * @brief Add to a Timestamp * @@ -181,13 +203,13 @@ typedef int64_t Timestamp64_Control; * * @return This method returns the number of seconds @a time increased by. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE #define _Timestamp64_Add_to( _time, _add ) \ - *(_time) += *(_add) + _Timestamp64_implementation_Add_to( _time, _add ) #else void _Timestamp64_Add_to( - Timestamp64_Control *_time, - Timestamp64_Control *_add + Timestamp64_Control *_time, + const Timestamp64_Control *_add ); #endif @@ -210,12 +232,12 @@ typedef int64_t Timestamp64_Control; */ static inline uint32_t _Timestamp64_Add_to_at_tick( Timestamp64_Control *_time, - Timestamp64_Control *_add + const Timestamp64_Control *_add ) { - Timestamp64_Control start = *_time / 1000000000; + Timestamp64_Control _start = *_time / 1000000000L; *_time += *_add; - if ( ((*_time) / 1000000000) != start ) { + if ( ((*_time) / 1000000000L) != _start ) { return 1; } return 0; @@ -242,13 +264,22 @@ uint32_t _Timestamp64_To_ticks( * timestamp format @a _time. * * @param[in] _time points to the timestamp format time result - * @param[in] _ticks points to the number of ticks to be filled in + * @param[out] _ticks points to the number of ticks to be filled in */ void _Timestamp64_From_ticks( uint32_t _ticks, Timestamp64_Control *_time ); +static inline void _Timestamp64_implementation_Subtract( + const Timestamp64_Control *_start, + const Timestamp64_Control *_end, + Timestamp64_Control *_result +) +{ + *_result = *_end - *_start; +} + /** * @brief Subtract Two Timestamp * @@ -257,24 +288,29 @@ void _Timestamp64_From_ticks( * * @param[in] _start points to the starting time * @param[in] _end points to the ending time - * @param[in] _result points to the difference between + * @param[out] _result points to the difference between * starting and ending time. - * - * @return This method fills in @a _result. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE #define _Timestamp64_Subtract( _start, _end, _result ) \ - do { \ - *(_result) = *(_end) - *(_start); \ - } while (0) + _Timestamp64_implementation_Subtract( _start, _end, _result ) #else void _Timestamp64_Subtract( - Timestamp64_Control *_start, - Timestamp64_Control *_end, - Timestamp64_Control *_result + const Timestamp64_Control *_start, + const Timestamp64_Control *_end, + Timestamp64_Control *_result ); #endif +static inline void _Timestamp64_implementation_Divide_by_integer( + const Timestamp64_Control *_time, + uint32_t _iterations, + Timestamp64_Control *_result +) +{ + *_result = *_time / _iterations; +} + /** * @brief Divide Timestamp By Integer * @@ -284,20 +320,16 @@ void _Timestamp64_From_ticks( * * @param[in] _time points to the total * @param[in] _iterations is the number of iterations - * @param[in] _result points to the average time. - * - * @return This method fills in @a result. + * @param[out] _result points to the average time. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE #define _Timestamp64_Divide_by_integer( _time, _iterations, _result ) \ - do { \ - *(_result) = *(_time) / (_iterations); \ - } while (0) + _Timestamp64_implementation_Divide_by_integer( _time, _iterations, _result ) #else void _Timestamp64_Divide_by_integer( - Timestamp64_Control *_time, - uint32_t _iterations, - Timestamp64_Control *_result + const Timestamp64_Control *_time, + uint32_t _iterations, + Timestamp64_Control *_result ); #endif @@ -309,10 +341,8 @@ void _Timestamp64_From_ticks( * * @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 - * - * @return This method fills in @a result. + * @param[out] _ival_percentage points to the integer portion of the average + * @param[out] _fval_percentage points to the thousandths of percentage */ void _Timestamp64_Divide( const Timestamp64_Control *_lhs, @@ -321,6 +351,13 @@ void _Timestamp64_Divide( uint32_t *_fval_percentage ); +static inline uint32_t _Timestamp64_implementation_Get_seconds( + const Timestamp64_Control *_time +) +{ + return (uint32_t) (*_time / 1000000000L); +} + /** * @brief Get Seconds Portion of Timestamp * @@ -330,15 +367,22 @@ void _Timestamp64_Divide( * * @return The seconds portion of @a _time. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE #define _Timestamp64_Get_seconds( _time ) \ - (*(_time) / 1000000000) + _Timestamp64_implementation_Get_seconds( _time ) #else uint32_t _Timestamp64_Get_seconds( - Timestamp64_Control *_time + const Timestamp64_Control *_time ); #endif +static inline uint32_t _Timestamp64_implementation_Get_nanoseconds( + const Timestamp64_Control *_time +) +{ + return (uint32_t) (*_time % 1000000000L); +} + /** * @brief Get Nanoseconds Portion of Timestamp * @@ -348,33 +392,39 @@ void _Timestamp64_Divide( * * @return The nanoseconds portion of @a _time. */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE #define _Timestamp64_Get_nanoseconds( _time ) \ - (*(_time) % 1000000000) + _Timestamp64_implementation_Get_nanoseconds( _time ) #else uint32_t _Timestamp64_Get_nanoseconds( - Timestamp64_Control *_time + const Timestamp64_Control *_time ); #endif +static inline void _Timestamp64_implementation_To_timespec( + const Timestamp64_Control *_timestamp, + struct timespec *_timespec +) +{ + _timespec->tv_sec = *_timestamp / 1000000000L; + _timespec->tv_nsec = *_timestamp % 1000000000L; +} + /** * @brief Convert Timestamp to struct timespec * * This method returns the seconds portion of the specified timestamp * * @param[in] _timestamp points to the timestamp - * @param[in] _timespec points to the timespec + * @param[out] _timespec points to the timespec */ -#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +#if CPU_TIMESTAMP_USE_INT64_INLINE == TRUE #define _Timestamp64_To_timespec( _timestamp, _timespec ) \ - do { \ - (_timespec)->tv_sec = *(_timestamp) / 1000000000; \ - (_timespec)->tv_nsec = *(_timestamp) % 1000000000; \ - } while (0) + _Timestamp64_implementation_To_timespec( _timestamp, _timespec ) #else void _Timestamp64_To_timespec( - Timestamp64_Control *_timestamp, - struct timespec *_timespec + const Timestamp64_Control *_timestamp, + struct timespec *_timespec ); #endif |