summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2011-09-28 14:42:12 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2011-09-28 14:42:12 +0000
commit3a42e6fd104c3544a677ffbbeda2fd59e1bbb100 (patch)
tree1fffb6c96058801bb8bdf1723a198d705e40fe91 /cpukit
parentHousekeeping. (diff)
downloadrtems-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')
-rw-r--r--cpukit/ChangeLog18
-rw-r--r--cpukit/score/Makefile.am4
-rw-r--r--cpukit/score/include/rtems/score/timespec.h6
-rw-r--r--cpukit/score/include/rtems/score/timestamp.h125
-rw-r--r--cpukit/score/include/rtems/score/timestamp64.h216
-rw-r--r--cpukit/score/src/timespecgreaterthan.c42
-rw-r--r--cpukit/score/src/ts64addto.c12
-rw-r--r--cpukit/score/src/ts64divide.c4
-rw-r--r--cpukit/score/src/ts64dividebyinteger.c14
-rw-r--r--cpukit/score/src/ts64equalto.c12
-rw-r--r--cpukit/score/src/ts64getnanoseconds.c10
-rw-r--r--cpukit/score/src/ts64getseconds.c10
-rw-r--r--cpukit/score/src/ts64greaterthan.c34
-rw-r--r--cpukit/score/src/ts64lessthan.c12
-rw-r--r--cpukit/score/src/ts64set.c12
-rw-r--r--cpukit/score/src/ts64settozero.c8
-rw-r--r--cpukit/score/src/ts64subtract.c14
-rw-r--r--cpukit/score/src/ts64toticks.c3
-rw-r--r--cpukit/score/src/ts64totimespec.c13
19 files changed, 223 insertions, 346 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 7cfe2a4f31..1d531d2e20 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,21 @@
+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.
+
2011-09-26 Petr Benes <benesp16@fel.cvut.cz>
PR 1923/testing
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 44a0df4c4f..24d71b722e 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -295,7 +295,7 @@ libscore_a_SOURCES += src/threadq.c src/threadqdequeue.c \
## TIMESPEC_C_FILES
libscore_a_SOURCES += src/timespecaddto.c src/timespecfromticks.c \
- src/timespecisvalid.c src/timespeclessthan.c src/timespecgreaterthan.c \
+ src/timespecisvalid.c src/timespeclessthan.c \
src/timespecsubtract.c src/timespectoticks.c src/timespecdivide.c \
src/timespecdividebyinteger.c
@@ -303,7 +303,7 @@ libscore_a_SOURCES += src/timespecaddto.c src/timespecfromticks.c \
libscore_a_SOURCES += src/ts64addto.c src/ts64dividebyinteger.c \
src/ts64divide.c src/ts64equalto.c \
src/ts64getnanoseconds.c src/ts64getseconds.c \
- src/ts64greaterthan.c src/ts64lessthan.c \
+ src/ts64lessthan.c \
src/ts64set.c src/ts64settozero.c src/ts64subtract.c \
src/ts64toticks.c src/ts64totimespec.c
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
diff --git a/cpukit/score/src/timespecgreaterthan.c b/cpukit/score/src/timespecgreaterthan.c
deleted file mode 100644
index b0e7870ac6..0000000000
--- a/cpukit/score/src/timespecgreaterthan.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * @file score/src/timespecgreaterthan.c
- */
-
-/*
- * COPYRIGHT (c) 1989-2007.
- * 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.com/license/LICENSE.
- *
- * $Id$
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/types.h>
-
-#include <rtems/system.h>
-#include <rtems/score/timespec.h>
-#include <rtems/score/tod.h>
-
-bool _Timespec_Greater_than(
- const struct timespec *lhs,
- const struct timespec *rhs
-)
-{
- if ( lhs->tv_sec > rhs->tv_sec )
- return true;
-
- if ( lhs->tv_sec < rhs->tv_sec )
- return false;
-
- /* ASSERT: lhs->tv_sec == rhs->tv_sec */
- if ( lhs->tv_nsec > rhs->tv_nsec )
- return true;
-
- return false;
-}
diff --git a/cpukit/score/src/ts64addto.c b/cpukit/score/src/ts64addto.c
index 14439de0f3..35ff8e3698 100644
--- a/cpukit/score/src/ts64addto.c
+++ b/cpukit/score/src/ts64addto.c
@@ -17,18 +17,14 @@
#include "config.h"
#endif
-#include <sys/types.h>
-
-#include <rtems/system.h>
#include <rtems/score/timestamp.h>
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE
void _Timestamp64_Add_to(
- Timestamp64_Control *_time,
- Timestamp64_Control *_add
+ Timestamp64_Control *_time,
+ const Timestamp64_Control *_add
)
{
- *_time += *_add;
+ _Timestamp64_implementation_Add_to( _time, _add );
}
#endif
diff --git a/cpukit/score/src/ts64divide.c b/cpukit/score/src/ts64divide.c
index 01e2661ac4..284a4f75a1 100644
--- a/cpukit/score/src/ts64divide.c
+++ b/cpukit/score/src/ts64divide.c
@@ -17,12 +17,10 @@
#include "config.h"
#endif
-#include <rtems/system.h>
-#include <sys/types.h>
#include <rtems/score/timestamp.h>
/* This method is never inlined. */
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE || CPU_TIMESTAMP_USE_INT64_INLINE == TRUE
void _Timestamp64_Divide(
const Timestamp64_Control *_lhs,
const Timestamp64_Control *_rhs,
diff --git a/cpukit/score/src/ts64dividebyinteger.c b/cpukit/score/src/ts64dividebyinteger.c
index f815078322..72a9d65f1d 100644
--- a/cpukit/score/src/ts64dividebyinteger.c
+++ b/cpukit/score/src/ts64dividebyinteger.c
@@ -17,19 +17,15 @@
#include "config.h"
#endif
-#include <sys/types.h>
-
-#include <rtems/system.h>
#include <rtems/score/timestamp.h>
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE
void _Timestamp64_Divide_by_integer(
- Timestamp64_Control *_time,
- uint32_t _iterations,
- Timestamp64_Control *_result
+ const Timestamp64_Control *_time,
+ uint32_t _iterations,
+ Timestamp64_Control *_result
)
{
- *_result = *_time / _iterations;
+ _Timestamp64_implementation_Divide_by_integer( _time, _iterations, _result );
}
#endif
diff --git a/cpukit/score/src/ts64equalto.c b/cpukit/score/src/ts64equalto.c
index d6c9eca998..5172d0b2ad 100644
--- a/cpukit/score/src/ts64equalto.c
+++ b/cpukit/score/src/ts64equalto.c
@@ -17,18 +17,14 @@
#include "config.h"
#endif
-#include <sys/types.h>
-
-#include <rtems/system.h>
#include <rtems/score/timestamp.h>
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE
bool _Timestamp64_Equal_to(
- Timestamp64_Control *_lhs,
- Timestamp64_Control *_rhs
+ const Timestamp64_Control *_lhs,
+ const Timestamp64_Control *_rhs
)
{
- return (*(_lhs) == *(_rhs));
+ _Timestamp64_implementation_Equal_to( _lhs, _rhs );
}
#endif
diff --git a/cpukit/score/src/ts64getnanoseconds.c b/cpukit/score/src/ts64getnanoseconds.c
index f9d57a9ab1..6ab9b47892 100644
--- a/cpukit/score/src/ts64getnanoseconds.c
+++ b/cpukit/score/src/ts64getnanoseconds.c
@@ -17,17 +17,13 @@
#include "config.h"
#endif
-#include <sys/types.h>
-
-#include <rtems/system.h>
#include <rtems/score/timestamp.h>
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE
uint32_t _Timestamp64_Get_nanoseconds(
- Timestamp64_Control *_time
+ const Timestamp64_Control *_time
)
{
- return *(_time) % 1000000000;
+ _Timestamp64_implementation_Get_nanoseconds( _time );
}
#endif
diff --git a/cpukit/score/src/ts64getseconds.c b/cpukit/score/src/ts64getseconds.c
index f459ee07a5..54db036bcc 100644
--- a/cpukit/score/src/ts64getseconds.c
+++ b/cpukit/score/src/ts64getseconds.c
@@ -17,17 +17,13 @@
#include "config.h"
#endif
-#include <sys/types.h>
-
-#include <rtems/system.h>
#include <rtems/score/timestamp.h>
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE
uint32_t _Timestamp64_Get_seconds(
- Timestamp64_Control *_time
+ const Timestamp64_Control *_time
)
{
- return *(_time) / 1000000000;
+ _Timestamp64_implementation_Get_seconds( _time );
}
#endif
diff --git a/cpukit/score/src/ts64greaterthan.c b/cpukit/score/src/ts64greaterthan.c
deleted file mode 100644
index 571adca4c1..0000000000
--- a/cpukit/score/src/ts64greaterthan.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * @file score/src/ts64greaterthan.c
-*/
-
-/*
- * COPYRIGHT (c) 1989-2008.
- * 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.com/license/LICENSE.
- *
- * $Id$
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/types.h>
-
-#include <rtems/system.h>
-#include <rtems/score/timestamp.h>
-
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
-bool _Timestamp64_Greater_than(
- Timestamp64_Control *_lhs,
- Timestamp64_Control *_rhs
-)
-{
- return (*(_lhs) > *(_rhs));
-}
-#endif
diff --git a/cpukit/score/src/ts64lessthan.c b/cpukit/score/src/ts64lessthan.c
index 1df5eb11f8..e0d6519c16 100644
--- a/cpukit/score/src/ts64lessthan.c
+++ b/cpukit/score/src/ts64lessthan.c
@@ -17,18 +17,14 @@
#include "config.h"
#endif
-#include <sys/types.h>
-
-#include <rtems/system.h>
#include <rtems/score/timestamp.h>
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE
bool _Timestamp64_Less_than(
- Timestamp64_Control *_lhs,
- Timestamp64_Control *_rhs
+ const Timestamp64_Control *_lhs,
+ const Timestamp64_Control *_rhs
)
{
- return (*(_lhs) < *(_rhs));
+ _Timestamp64_implementation_Less_than( _lhs, _rhs );
}
#endif
diff --git a/cpukit/score/src/ts64set.c b/cpukit/score/src/ts64set.c
index f4ed3c40e7..2a3aaca8fe 100644
--- a/cpukit/score/src/ts64set.c
+++ b/cpukit/score/src/ts64set.c
@@ -17,23 +17,15 @@
#include "config.h"
#endif
-#include <sys/types.h>
-
-#include <rtems/system.h>
#include <rtems/score/timestamp.h>
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE
void _Timestamp64_Set(
Timestamp64_Control *_time,
long _seconds,
long _nanoseconds
)
{
- int64_t time;
-
- time = (int64_t)_seconds * 1000000000;
- time += (int64_t)_nanoseconds;
- *_time = time;
+ _Timestamp64_implementation_Set( _time, _seconds, _nanoseconds );
}
#endif
diff --git a/cpukit/score/src/ts64settozero.c b/cpukit/score/src/ts64settozero.c
index f5cd78194d..b017e3e860 100644
--- a/cpukit/score/src/ts64settozero.c
+++ b/cpukit/score/src/ts64settozero.c
@@ -17,17 +17,13 @@
#include "config.h"
#endif
-#include <sys/types.h>
-
-#include <rtems/system.h>
#include <rtems/score/timestamp.h>
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE
void _Timestamp64_Set_to_zero(
Timestamp64_Control *_time
)
{
- *_time = 0;
+ _Timestamp64_implementation_Set_to_zero( _time );
}
#endif
diff --git a/cpukit/score/src/ts64subtract.c b/cpukit/score/src/ts64subtract.c
index be7445b2e6..a1ed20ed89 100644
--- a/cpukit/score/src/ts64subtract.c
+++ b/cpukit/score/src/ts64subtract.c
@@ -17,19 +17,15 @@
#include "config.h"
#endif
-#include <sys/types.h>
-
-#include <rtems/system.h>
#include <rtems/score/timestamp.h>
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE
void _Timestamp64_Subtract(
- Timestamp64_Control *_start,
- Timestamp64_Control *_end,
- Timestamp64_Control *_result
+ const Timestamp64_Control *_start,
+ const Timestamp64_Control *_end,
+ Timestamp64_Control *_result
)
{
- *_result = *_end - *_start;
+ _Timestamp64_implementation_Subtract( _start, _end, _result );
}
#endif
diff --git a/cpukit/score/src/ts64toticks.c b/cpukit/score/src/ts64toticks.c
index 273bcc15b4..f028f8892f 100644
--- a/cpukit/score/src/ts64toticks.c
+++ b/cpukit/score/src/ts64toticks.c
@@ -24,8 +24,7 @@
#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE
uint32_t _Timestamp64_To_ticks(
const Timestamp64_Control *time
)
diff --git a/cpukit/score/src/ts64totimespec.c b/cpukit/score/src/ts64totimespec.c
index 92c2b690bc..b93c1db55d 100644
--- a/cpukit/score/src/ts64totimespec.c
+++ b/cpukit/score/src/ts64totimespec.c
@@ -17,19 +17,14 @@
#include "config.h"
#endif
-#include <sys/types.h>
-
-#include <rtems/system.h>
#include <rtems/score/timestamp.h>
-#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
- !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+#if CPU_TIMESTAMP_USE_INT64 == TRUE
void _Timestamp64_To_timespec(
- Timestamp64_Control *_timestamp,
- struct timespec *_timespec
+ const Timestamp64_Control *_timestamp,
+ struct timespec *_timespec
)
{
- _timespec->tv_sec = *_timestamp / 1000000000;
- _timespec->tv_nsec = *_timestamp % 1000000000;
+ _Timestamp64_implementation_To_timespec( _timestamp, _timespec );
}
#endif