summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-09 21:27:35 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-09 21:27:35 +0000
commite57cb3c9df68ebe3616f8276be8d6fe7e926b4f2 (patch)
tree42483f3fce61b821e9d617a8c633e7fdd53a0d19
parent2008-12-09 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-e57cb3c9df68ebe3616f8276be8d6fe7e926b4f2.tar.bz2
2008-12-09 Joel Sherrill <joel.sherrill@oarcorp.com>
* score/Makefile.am, score/preinstall.am, score/include/rtems/score/timespec.h, score/include/rtems/score/timestamp.h: Add 64-bit implementation of SuperCore Timestamps. Tested on PowerPC/psim and SPARC/sis. * 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/ts64greaterthan.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: New files.
-rw-r--r--cpukit/ChangeLog14
-rw-r--r--cpukit/score/Makefile.am15
-rw-r--r--cpukit/score/include/rtems/score/timespec.h50
-rw-r--r--cpukit/score/include/rtems/score/timestamp.h237
-rw-r--r--cpukit/score/include/rtems/score/timestamp64.h370
-rw-r--r--cpukit/score/preinstall.am4
-rw-r--r--cpukit/score/src/ts64addto.c34
-rw-r--r--cpukit/score/src/ts64divide.c54
-rw-r--r--cpukit/score/src/ts64dividebyinteger.c35
-rw-r--r--cpukit/score/src/ts64equalto.c34
-rw-r--r--cpukit/score/src/ts64getnanoseconds.c33
-rw-r--r--cpukit/score/src/ts64getseconds.c33
-rw-r--r--cpukit/score/src/ts64greaterthan.c34
-rw-r--r--cpukit/score/src/ts64lessthan.c34
-rw-r--r--cpukit/score/src/ts64set.c39
-rw-r--r--cpukit/score/src/ts64settozero.c33
-rw-r--r--cpukit/score/src/ts64subtract.c35
-rw-r--r--cpukit/score/src/ts64toticks.c39
-rw-r--r--cpukit/score/src/ts64totimespec.c35
19 files changed, 1101 insertions, 61 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 2a4e3ee967..2aef624ba7 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,17 @@
+2008-12-09 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * score/Makefile.am, score/preinstall.am,
+ score/include/rtems/score/timespec.h,
+ score/include/rtems/score/timestamp.h: Add 64-bit implementation of
+ SuperCore Timestamps. Tested on PowerPC/psim and SPARC/sis.
+ * 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/ts64greaterthan.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: New files.
+
2008-12-09 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libblock/src/bdbuf.c: Fix typo having crept in during
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index e2052efce4..82ebc5e20d 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -30,9 +30,10 @@ include_rtems_score_HEADERS = include/rtems/score/address.h \
include/rtems/score/sysstate.h include/rtems/score/thread.h \
include/rtems/score/threadq.h include/rtems/score/threadsync.h \
include/rtems/score/timespec.h include/rtems/score/timestamp.h \
- include/rtems/score/tod.h include/rtems/score/tqdata.h \
- include/rtems/score/userext.h include/rtems/score/watchdog.h \
- include/rtems/score/wkspace.h include/rtems/score/cpuopts.h
+ include/rtems/score/timestamp64.h include/rtems/score/tod.h \
+ include/rtems/score/tqdata.h include/rtems/score/userext.h \
+ include/rtems/score/watchdog.h include/rtems/score/wkspace.h \
+ include/rtems/score/cpuopts.h
if HAS_MP
# We only build multiprocessing related files if HAS_MP was defined
@@ -167,6 +168,14 @@ libscore_a_SOURCES += src/timespecaddto.c src/timespecfromticks.c \
src/timespecsubtract.c src/timespectoticks.c src/timespecdivide.c \
src/timespecdividebyinteger.c
+## TIMESTAMP_INT64_C_FILES
+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/ts64set.c src/ts64settozero.c src/ts64subtract.c \
+ src/ts64toticks.c src/ts64totimespec.c
+
## TOD_C_FILES
libscore_a_SOURCES += src/coretod.c src/coretodset.c src/coretodget.c \
src/coretodgetuptime.c src/coretodgetuptimetimespec.c src/coretodtickle.c
diff --git a/cpukit/score/include/rtems/score/timespec.h b/cpukit/score/include/rtems/score/timespec.h
index 42eb67a377..060df71f38 100644
--- a/cpukit/score/include/rtems/score/timespec.h
+++ b/cpukit/score/include/rtems/score/timespec.h
@@ -32,6 +32,56 @@ extern "C" {
#include <sys/types.h>
+/** @brief Set Timespec to Seconds Nanosecond
+ *
+ * This method sets the timespec to the specified seconds and nanoseconds
+ * value.
+ *
+ * @param[in] _time points to the timespec instance to validate.
+ * @param[in] _seconds is the seconds portion of the timespec
+ * @param[in] _nanoseconds is the nanoseconds portion of the timespec
+ */
+#define _Timespec_Set( _time, _seconds, _nanoseconds ) \
+ do { \
+ (_time)->tv_sec = (_seconds); \
+ (_time)->tv_nsec = (_nanoseconds); \
+ } while (0)
+
+/** @brief Zero Timespec
+ *
+ * This method sets the timespec to zero.
+ * value.
+ *
+ * @param[in] _time points to the timespec instance to zero.
+ */
+#define _Timespec_Set_to_zero( _time ) \
+ do { \
+ (_time)->tv_sec = 0; \
+ (_time)->tv_nsec = 0; \
+ } while (0)
+
+/** @brief Get Seconds Portion of Timespec
+ *
+ * This method returns the seconds portion of the specified timespec
+ *
+ * @param[in] _time points to the timespec
+ *
+ * @return The seconds portion of @a _time.
+ */
+#define _Timespec_Get_seconds( _time ) \
+ ((_time)->tv_sec)
+
+/** @brief Get Nanoseconds Portion of Timespec
+ *
+ * This method returns the nanoseconds portion of the specified timespec
+ *
+ * @param[in] _time points to the timespec
+ *
+ * @return The nanoseconds portion of @a _time.
+ */
+#define _Timespec_Get_nanoseconds( _time ) \
+ ((_time)->tv_nsec)
+
/** @brief Is Timespec Valid
*
* This method determines the validity of a timespec.
diff --git a/cpukit/score/include/rtems/score/timestamp.h b/cpukit/score/include/rtems/score/timestamp.h
index 0602c8d916..d039a195fb 100644
--- a/cpukit/score/include/rtems/score/timestamp.h
+++ b/cpukit/score/include/rtems/score/timestamp.h
@@ -44,15 +44,90 @@ extern "C" {
#include <rtems/score/timespec.h>
-#define RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC
+/*
+ * 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."
+#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)
+ #include <rtems/score/timestamp64.h>
+#endif
/**
* Define the Timestamp control type.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
typedef struct timespec Timestamp_Control;
#else
- #error "No Alternative implementations for SuperCore Timestamp."
+ typedef Timestamp64_Control Timestamp_Control;
#endif
/** @brief Set Timestamp to Seconds Nanosecond
@@ -64,12 +139,12 @@ extern "C" {
* @param[in] _seconds is the seconds portion of the timestamp
* @param[in] _nanoseconds is the nanoseconds portion of the timestamp
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_Set( _time, _seconds, _nanoseconds ) \
- do { \
- (_time)->tv_sec = (_seconds); \
- (_time)->tv_nsec = (_nanoseconds); \
- } while (0)
+ _Timespec_Set( _time, _seconds, _nanoseconds )
+#else
+ #define _Timestamp_Set( _time, _seconds, _nanoseconds ) \
+ _Timestamp64_Set( _time, _seconds, _nanoseconds )
#endif
/** @brief Zero Timestamp
@@ -79,71 +154,83 @@ extern "C" {
*
* @param[in] _time points to the timestamp instance to zero.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_Set_to_zero( _time ) \
- do { \
- (_time)->tv_sec = 0; \
- (_time)->tv_nsec = 0; \
- } while (0)
+ _Timespec_Set_to_zero( _time )
+#else
+ #define _Timestamp_Set_to_zero( _time ) \
+ _Timestamp64_Set_to_zero( _time )
#endif
/** @brief Is Timestamp Valid
*
* This method determines the validity of a timestamp.
*
- * @param[in] time is the timestamp instance to validate.
+ * @param[in] _time points to the timestamp instance to validate.
*
* @return This method returns true if @a time is valid and
* false otherwise.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_Is_valid( _time ) \
_Timespec_Is_valid( _time )
+#else
+ #define _Timestamp_Is_valid( _time ) \
+ _Timestamp64_Is_valid( _time )
#endif
/** @brief Timestamp Less Than Operator
*
* This method is the less than operator for timestamps.
*
- * @param[in] lhs is the left hand side timestamp
- * @param[in] rhs is the right hand side timestamp
+ * @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 less than the @a rhs and
+ * @return This method returns true if @a _lhs is less than the @a _rhs and
* false otherwise.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_Less_than( _lhs, _rhs ) \
_Timespec_Less_than( _lhs, _rhs )
+#else
+ #define _Timestamp_Less_than( _lhs, _rhs ) \
+ _Timestamp64_Less_than( _lhs, _rhs )
#endif
/** @brief Timestamp Greater Than Operator
*
* This method is the greater than operator for timestamps.
*
- * @param[in] lhs is the left hand side timestamp
- * @param[in] rhs is the right hand side timestamp
+ * @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
+ * @return This method returns true if @a _lhs is greater than the @a _rhs and
* false otherwise.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#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
/** @brief Timestamp equal to Operator
*
* This method is the is equal to than operator for timestamps.
*
- * @param[in] lhs is the left hand side timestamp
- * @param[in] rhs is the right hand side timestamp
+ * @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 equal to @a rhs and
+ * @return This method returns true if @a _lhs is equal to @a _rhs and
* false otherwise.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_Equal_to( _lhs, _rhs ) \
_Timespec_Equal_to( _lhs, _rhs )
+#else
+ #define _Timestamp_Equal_to( _lhs, _rhs ) \
+ _Timestamp64_Equal_to( _lhs, _rhs )
#endif
/** @brief Add to a Timestamp
@@ -151,12 +238,17 @@ extern "C" {
* 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
+ * @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
+ *
+ * @return This method returns the number of seconds @a time increased by.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_Add_to( _time, _add ) \
_Timespec_Add_to( _time, _add )
+#else
+ #define _Timestamp_Add_to( _time, _add ) \
+ _Timestamp64_Add_to( _time, _add )
#endif
/** @brief Add to a Timestamp (At Clock Tick)
@@ -170,14 +262,17 @@ extern "C" {
* operation is ONLY used as part of processing a clock tick,
* it is generally safe to assume that only one second changed.
*
- * @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
+ * @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
*
* @return This method returns the number of seconds @a time increased by.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_Add_to_at_tick( _time, _add ) \
_Timespec_Add_to( _time, _add )
+#else
+ #define _Timestamp_Add_to_at_tick( _time, _add ) \
+ _Timestamp64_Add_to_at_tick( _time, _add )
#endif
/** @brief Convert Timestamp to Number of Ticks
@@ -185,26 +280,32 @@ extern "C" {
* This routine convert the @a time timestamp to the corresponding number
* of clock ticks.
*
- * @param[in] time points to the time to be converted
+ * @param[in] _time points to the time to be converted
*
* @return This method returns the number of ticks computed.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_To_ticks( _time ) \
_Timespec_To_ticks( _time )
+#else
+ #define _Timestamp_To_ticks( _time ) \
+ _Timestamp64_To_ticks( _time )
#endif
/** @brief Convert Ticks to Timestamp
*
- * This routine converts the @a ticks value to the corresponding
- * timestamp format @a time.
+ * This routine converts the @a _ticks value to the corresponding
+ * timestamp format @a _time.
*
* @param[in] time points to the timestamp format time result
- * @param[in] ticks points to the the number of ticks to be filled in
+ * @param[in] ticks points to the number of ticks to be filled in
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_From_ticks( _ticks, _time ) \
_Timespec_From_ticks( _ticks, _time )
+#else
+ #define _Timestamp_From_ticks( _ticks, _time ) \
+ _Timestamp64_From_ticks( _ticks, _time )
#endif
/** @brief Subtract Two Timestamp
@@ -212,15 +313,19 @@ extern "C" {
* 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.
+ * @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.
*
- * @return This method fills in @a result.
+ * @return This method fills in @a _result.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_Subtract( _start, _end, _result ) \
_Timespec_Subtract( _start, _end, _result )
+#else
+ #define _Timestamp_Subtract( _start, _end, _result ) \
+ _Timestamp64_Subtract( _start, _end, _result )
#endif
/** @brief Divide Timestamp By Integer
@@ -229,15 +334,18 @@ extern "C" {
* use is to assist in benchmark calculations where you typically
* divide a duration by a number of iterations.
*
- * @param[in] time points to the total
- * @param[in] iterations is the number of iterations
- * @param[in] result points to the average time.
+ * @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.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_Divide_by_integer( _time, _iterations, _result ) \
_Timespec_Divide_by_integer(_time, _iterations, _result )
+#else
+ #define _Timestamp_Divide_by_integer( _time, _iterations, _result ) \
+ _Timestamp64_Divide_by_integer( _time, _iterations, _result )
#endif
/** @brief Divide Timestamp
@@ -245,16 +353,19 @@ extern "C" {
* 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 is the integer portion of the average
- * @param[in] fval_percentage is the thousandths of percentage
+ * @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.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_Divide( _lhs, _rhs, _ival_percentage, _fval_percentage ) \
_Timespec_Divide( _lhs, _rhs, _ival_percentage, _fval_percentage )
+#else
+ #define _Timestamp_Divide( _lhs, _rhs, _ival_percentage, _fval_percentage ) \
+ _Timestamp64_Divide( _lhs, _rhs, _ival_percentage, _fval_percentage )
#endif
/** @brief Get Seconds Portion of Timestamp
@@ -265,9 +376,12 @@ extern "C" {
*
* @return The seconds portion of @a _time.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
#define _Timestamp_Get_seconds( _time ) \
- ((_time)->tv_sec)
+ _Timespec_Get_seconds( _time )
+#else
+ #define _Timestamp_Get_seconds( _time ) \
+ _Timestamp64_Get_seconds( _time )
#endif
/** @brief Get Nanoseconds Portion of Timestamp
@@ -278,9 +392,12 @@ extern "C" {
*
* @return The nanoseconds portion of @a _time.
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_Get_nanoseconds( _time ) \
+ _Timespec_Get_nanoseconds( _time )
+#else
#define _Timestamp_Get_nanoseconds( _time ) \
- ((_time)->tv_nsec)
+ _Timestamp64_Get_nanoseconds( _time )
#endif
/** @brief Convert Timestamp to struct timespec
@@ -290,9 +407,13 @@ extern "C" {
* @param[in] _timestamp points to the timestamp
* @param[in] _timespec points to the timespec
*/
-#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ /* in this case we know they are the same type so use simple assignment */
#define _Timestamp_To_timespec( _timestamp, _timespec ) \
*(_timespec) = *(_timestamp)
+#else
+ #define _Timestamp_To_timespec( _timestamp, _timespec ) \
+ _Timestamp64_To_timespec( _timestamp, _timespec )
#endif
#ifdef __cplusplus
diff --git a/cpukit/score/include/rtems/score/timestamp64.h b/cpukit/score/include/rtems/score/timestamp64.h
new file mode 100644
index 0000000000..34b83c41cd
--- /dev/null
+++ b/cpukit/score/include/rtems/score/timestamp64.h
@@ -0,0 +1,370 @@
+/**
+ * @file rtems/score/timestamp64.h
+ *
+ * This include file contains helpers for manipulating
+ * 64-bit integer timestamps.
+ */
+
+/*
+ * 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$
+ */
+
+#ifndef _RTEMS_SCORE_TIMESTAMP64_H
+#define _RTEMS_SCORE_TIMESTAMP64_H
+
+/**
+ * @defgroup SuperCore Timestamp64
+ *
+ * This handler encapsulates functionality related to manipulating
+ * the 64 bit integer implementation of SuperCore Timestamps.
+ */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This .h file is not for general use. It is an alternative
+ * implementation of Timestamps and should only be used that way.
+ */
+#ifndef _RTEMS_SCORE_TIMESTAMP_H
+ #error "Should only be included by rtems/score/timestamp.h"
+#endif
+
+/*
+ * Verify something is defined.
+ */
+#if !defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64)
+ #error "SuperCore Timestamp64 implementation included but not defined."
+#endif
+
+/**
+ * Define the Timestamp control type.
+ */
+typedef int64_t Timestamp64_Control;
+
+/** @brief Set Timestamp to Seconds Nanosecond
+ *
+ * This method sets the timestamp to the specified seconds and 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
+ */
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+ #define _Timestamp64_Set( _time, _seconds, _nanoseconds ) \
+ do { \
+ *(_time) = ((int64_t)_seconds * 1000000000); \
+ *(_time) += (int64_t)(_nanoseconds); \
+ } while (0)
+#else
+ void _Timestamp64_Set(
+ Timestamp64_Control *_time,
+ long _seconds,
+ long _nanoseconds
+ );
+#endif
+
+/** @brief Zero Timestamp
+ *
+ * This method sets the timestamp to zero.
+ * value.
+ *
+ * @param[in] _time points to the timestamp instance to zero.
+ */
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+ #define _Timestamp64_Set_to_zero( _time ) \
+ *(_time) = 0
+#else
+ void _Timestamp64_Set_to_zero(
+ Timestamp64_Control *_time
+ );
+#endif
+
+/** @brief Is Timestamp Valid
+ *
+ * This method determines the validity of a timestamp.
+ *
+ * @param[in] _time points to the timestamp instance to validate.
+ *
+ * @return This method returns true if @a time is valid and
+ * false otherwise.
+ */
+#define _Timestamp64_Is_valid( _time ) \
+ (1)
+
+/** @brief Timestamp Less Than Operator
+ *
+ * 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
+ *
+ * @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)
+ #define _Timestamp64_Less_than( _lhs, _rhs ) \
+ (*(_lhs) < *(_rhs))
+#else
+ bool _Timestamp64_Less_than(
+ Timestamp64_Control *_lhs,
+ 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
+
+/** @brief Timestamp equal to Operator
+ *
+ * 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
+ *
+ * @return This method returns true if @a _lhs is equal to @a _rhs and
+ * false otherwise.
+ */
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+ #define _Timestamp64_Equal_to( _lhs, _rhs ) \
+ (*(_lhs) == *(_rhs))
+#else
+ bool _Timestamp64_Equal_to(
+ Timestamp64_Control *_lhs,
+ Timestamp64_Control *_rhs
+ );
+#endif
+
+/** @brief Add to a Timestamp
+ *
+ * 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
+ *
+ * @return This method returns the number of seconds @a time increased by.
+ */
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+ #define _Timestamp64_Add_to( _time, _add ) \
+ *(_time) += *(_add)
+#else
+ void _Timestamp64_Add_to(
+ Timestamp64_Control *_time,
+ Timestamp64_Control *_add
+ );
+#endif
+
+/** @brief Add to a Timestamp (At Clock Tick)
+ *
+ * This routine adds two timestamps. The second argument is added
+ * to the first.
+ *
+ * @node This routine places a special requirement on the addition
+ * operation. It must return the number of units that the
+ * seconds field changed as the result of the addition. Since this
+ * operation is ONLY used as part of processing a clock tick,
+ * it is generally safe to assume that only one second changed.
+ *
+ * @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
+ *
+ * @return This method returns the number of seconds @a time increased by.
+ */
+static inline uint32_t _Timestamp64_Add_to_at_tick(
+ Timestamp64_Control *_time,
+ Timestamp64_Control *_add
+)
+{
+ Timestamp64_Control start = *_time / 1000000000;
+ *_time += *_add;
+ if ( ((*_time) / 1000000000) != start ) {
+ return 1;
+ }
+ return 0;
+}
+
+/** @brief Convert Timestamp to Number of Ticks
+ *
+ * This routine convert the @a time timestamp to the corresponding number
+ * of clock ticks.
+ *
+ * @param[in] _time points to the time to be converted
+ *
+ * @return This method returns the number of ticks computed.
+ */
+uint32_t _Timestamp64_To_ticks(
+ const Timestamp64_Control *time
+);
+
+/** @brief Convert Ticks to Timestamp
+ *
+ * This routine converts the @a _ticks value to the corresponding
+ * 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
+ */
+void _Timestamp64_From_ticks(
+ uint32_t _ticks,
+ Timestamp64_Control *_time
+);
+
+/** @brief Subtract Two Timestamp
+ *
+ * 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.
+ *
+ * @return This method fills in @a _result.
+ */
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+ #define _Timestamp64_Subtract( _start, _end, _result ) \
+ do { \
+ *(_result) = *(_end) - *(_start); \
+ } while (0)
+#else
+ void _Timestamp64_Subtract(
+ Timestamp64_Control *_start,
+ Timestamp64_Control *_end,
+ Timestamp64_Control *_result
+ );
+#endif
+
+/** @brief Divide Timestamp By Integer
+ *
+ * This routine divides a timestamp by an integer value. The expected
+ * use is to assist in benchmark calculations where you typically
+ * divide a duration by a number of iterations.
+ *
+ * @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.
+ */
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+ #define _Timestamp64_Divide_by_integer( _time, _iterations, _result ) \
+ do { \
+ *(_result) = *(_time) / (_iterations); \
+ } while (0)
+#else
+ void _Timestamp64_Divide_by_integer(
+ Timestamp64_Control *_time,
+ uint32_t _iterations,
+ Timestamp64_Control *_result
+ );
+#endif
+
+/** @brief Divide 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
+ *
+ * @return This method fills in @a result.
+ */
+void _Timestamp64_Divide(
+ const Timestamp64_Control *_lhs,
+ const Timestamp64_Control *_rhs,
+ uint32_t *_ival_percentage,
+ uint32_t *_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
+ *
+ * @return The seconds portion of @a _time.
+ */
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+ #define _Timestamp64_Get_seconds( _time ) \
+ (*(_time) / 1000000000)
+#else
+ uint32_t _Timestamp64_Get_seconds(
+ Timestamp64_Control *_time
+ );
+#endif
+
+/** @brief Get Nanoseconds Portion of Timestamp
+ *
+ * This method returns the nanoseconds portion of the specified timestamp
+ *
+ * @param[in] _time points to the timestamp
+ *
+ * @return The nanoseconds portion of @a _time.
+ */
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+ #define _Timestamp64_Get_nanoseconds( _time ) \
+ (*(_time) % 1000000000)
+#else
+ uint32_t _Timestamp64_Get_nanoseconds(
+ Timestamp64_Control *_time
+ );
+#endif
+
+/** @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
+ */
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+ #define _Timestamp64_To_timespec( _timestamp, _timespec ) \
+ do { \
+ (_timespec)->tv_sec = *(_timestamp) / 1000000000; \
+ (_timespec)->tv_nsec = *(_timestamp) % 1000000000; \
+ } while (0)
+#else
+ void _Timestamp64_To_timespec(
+ Timestamp64_Control *_timestamp,
+ struct timespec *_timespec
+ );
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+#endif
+/* end of include file */
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index af521fd10c..c225515adb 100644
--- a/cpukit/score/preinstall.am
+++ b/cpukit/score/preinstall.am
@@ -143,6 +143,10 @@ $(PROJECT_INCLUDE)/rtems/score/timestamp.h: include/rtems/score/timestamp.h $(PR
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timestamp.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timestamp.h
+$(PROJECT_INCLUDE)/rtems/score/timestamp64.h: include/rtems/score/timestamp64.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timestamp64.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timestamp64.h
+
$(PROJECT_INCLUDE)/rtems/score/tod.h: include/rtems/score/tod.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/tod.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/tod.h
diff --git a/cpukit/score/src/ts64addto.c b/cpukit/score/src/ts64addto.c
new file mode 100644
index 0000000000..14439de0f3
--- /dev/null
+++ b/cpukit/score/src/ts64addto.c
@@ -0,0 +1,34 @@
+/**
+ * @file score/src/ts64addto.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)
+void _Timestamp64_Add_to(
+ Timestamp64_Control *_time,
+ Timestamp64_Control *_add
+)
+{
+ *_time += *_add;
+}
+#endif
diff --git a/cpukit/score/src/ts64divide.c b/cpukit/score/src/ts64divide.c
new file mode 100644
index 0000000000..a8a08c985d
--- /dev/null
+++ b/cpukit/score/src/ts64divide.c
@@ -0,0 +1,54 @@
+/**
+ * @file score/src/ts64divide.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 <stdio.h>
+
+#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)
+void _Timestamp64_Divide(
+ const Timestamp64_Control *_lhs,
+ const Timestamp64_Control *_rhs,
+ uint32_t *_ival_percentage,
+ uint32_t *_fval_percentage
+)
+{
+ Timestamp64_Control answer;
+
+ if ( *_rhs == 0 ) {
+ *_ival_percentage = 0;
+ *_fval_percentage = 0;
+ return;
+ }
+
+ /*
+ * This looks odd but gives the results the proper precision.
+ *
+ * TODO: Rounding on the last digit of the fval.
+ */
+
+ answer = (*_lhs * 100000) / *_rhs;
+
+ *_ival_percentage = answer / 1000;
+ *_fval_percentage = answer % 1000;
+}
+#endif
diff --git a/cpukit/score/src/ts64dividebyinteger.c b/cpukit/score/src/ts64dividebyinteger.c
new file mode 100644
index 0000000000..f815078322
--- /dev/null
+++ b/cpukit/score/src/ts64dividebyinteger.c
@@ -0,0 +1,35 @@
+/**
+ * @file score/src/ts64dividebyinteger.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)
+void _Timestamp64_Divide_by_integer(
+ Timestamp64_Control *_time,
+ uint32_t _iterations,
+ Timestamp64_Control *_result
+)
+{
+ *_result = *_time / _iterations;
+}
+#endif
diff --git a/cpukit/score/src/ts64equalto.c b/cpukit/score/src/ts64equalto.c
new file mode 100644
index 0000000000..d6c9eca998
--- /dev/null
+++ b/cpukit/score/src/ts64equalto.c
@@ -0,0 +1,34 @@
+/**
+ * @file score/src/ts64equalto.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_Equal_to(
+ Timestamp64_Control *_lhs,
+ Timestamp64_Control *_rhs
+)
+{
+ return (*(_lhs) == *(_rhs));
+}
+#endif
diff --git a/cpukit/score/src/ts64getnanoseconds.c b/cpukit/score/src/ts64getnanoseconds.c
new file mode 100644
index 0000000000..86ba1c1b75
--- /dev/null
+++ b/cpukit/score/src/ts64getnanoseconds.c
@@ -0,0 +1,33 @@
+/**
+ * @file score/src/ts64toticks.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)
+uint32_t _Timestamp64_Get_nanoseconds(
+ Timestamp64_Control *_time
+)
+{
+ return *(_time) % 1000000000;
+}
+#endif
diff --git a/cpukit/score/src/ts64getseconds.c b/cpukit/score/src/ts64getseconds.c
new file mode 100644
index 0000000000..f459ee07a5
--- /dev/null
+++ b/cpukit/score/src/ts64getseconds.c
@@ -0,0 +1,33 @@
+/**
+ * @file score/src/ts64getseconds.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)
+uint32_t _Timestamp64_Get_seconds(
+ Timestamp64_Control *_time
+)
+{
+ return *(_time) / 1000000000;
+}
+#endif
diff --git a/cpukit/score/src/ts64greaterthan.c b/cpukit/score/src/ts64greaterthan.c
new file mode 100644
index 0000000000..571adca4c1
--- /dev/null
+++ b/cpukit/score/src/ts64greaterthan.c
@@ -0,0 +1,34 @@
+/**
+ * @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
new file mode 100644
index 0000000000..1df5eb11f8
--- /dev/null
+++ b/cpukit/score/src/ts64lessthan.c
@@ -0,0 +1,34 @@
+/**
+ * @file score/src/ts64lessthan.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_Less_than(
+ Timestamp64_Control *_lhs,
+ Timestamp64_Control *_rhs
+)
+{
+ return (*(_lhs) < *(_rhs));
+}
+#endif
diff --git a/cpukit/score/src/ts64set.c b/cpukit/score/src/ts64set.c
new file mode 100644
index 0000000000..f4ed3c40e7
--- /dev/null
+++ b/cpukit/score/src/ts64set.c
@@ -0,0 +1,39 @@
+/**
+ * @file score/src/ts64set.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)
+void _Timestamp64_Set(
+ Timestamp64_Control *_time,
+ long _seconds,
+ long _nanoseconds
+)
+{
+ int64_t time;
+
+ time = (int64_t)_seconds * 1000000000;
+ time += (int64_t)_nanoseconds;
+ *_time = time;
+}
+#endif
diff --git a/cpukit/score/src/ts64settozero.c b/cpukit/score/src/ts64settozero.c
new file mode 100644
index 0000000000..f5cd78194d
--- /dev/null
+++ b/cpukit/score/src/ts64settozero.c
@@ -0,0 +1,33 @@
+/**
+ * @file score/src/ts64settozero.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)
+void _Timestamp64_Set_to_zero(
+ Timestamp64_Control *_time
+)
+{
+ *_time = 0;
+}
+#endif
diff --git a/cpukit/score/src/ts64subtract.c b/cpukit/score/src/ts64subtract.c
new file mode 100644
index 0000000000..be7445b2e6
--- /dev/null
+++ b/cpukit/score/src/ts64subtract.c
@@ -0,0 +1,35 @@
+/**
+ * @file score/src/ts64subtract.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)
+void _Timestamp64_Subtract(
+ Timestamp64_Control *_start,
+ Timestamp64_Control *_end,
+ Timestamp64_Control *_result
+)
+{
+ *_result = *_end - *_start;
+}
+#endif
diff --git a/cpukit/score/src/ts64toticks.c b/cpukit/score/src/ts64toticks.c
new file mode 100644
index 0000000000..5594387df8
--- /dev/null
+++ b/cpukit/score/src/ts64toticks.c
@@ -0,0 +1,39 @@
+/**
+ * @file score/src/ts64toticks.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>
+#include <rtems/score/tod.h>
+
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \
+ !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE)
+uint32_t _Timestamp64_To_ticks(
+ const Timestamp64_Control *time
+)
+{
+ uint32_t ticks;
+
+ ticks = *time / (_TOD_Microseconds_per_tick * 1000);
+ if ( ticks )
+ return ticks;
+ return 1;
+}
+#endif
diff --git a/cpukit/score/src/ts64totimespec.c b/cpukit/score/src/ts64totimespec.c
new file mode 100644
index 0000000000..92c2b690bc
--- /dev/null
+++ b/cpukit/score/src/ts64totimespec.c
@@ -0,0 +1,35 @@
+/**
+ * @file score/src/ts64totimespec.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)
+void _Timestamp64_To_timespec(
+ Timestamp64_Control *_timestamp,
+ struct timespec *_timespec
+)
+{
+ _timespec->tv_sec = *_timestamp / 1000000000;
+ _timespec->tv_nsec = *_timestamp % 1000000000;
+}
+#endif