summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cpukit/ChangeLog24
-rw-r--r--cpukit/libcsupport/src/__times.c21
-rw-r--r--cpukit/libmisc/cpuuse/cpuusagereport.c24
-rw-r--r--cpukit/libmisc/cpuuse/cpuusagereset.c6
-rw-r--r--cpukit/posix/src/clockgettime.c24
-rw-r--r--cpukit/posix/src/pthread.c1
-rw-r--r--cpukit/posix/src/timersettime.c6
-rw-r--r--cpukit/rtems/include/rtems/rtems/ratemon.h18
-rw-r--r--cpukit/rtems/src/clockgetsecondssinceepoch.c2
-rw-r--r--cpukit/rtems/src/clockgetuptime.c3
-rw-r--r--cpukit/rtems/src/ratemongetstatus.c12
-rw-r--r--cpukit/rtems/src/ratemonperiod.c35
-rw-r--r--cpukit/rtems/src/ratemonreportstatistics.c49
-rw-r--r--cpukit/rtems/src/taskwakewhen.c4
-rw-r--r--cpukit/rtems/src/timerfirewhen.c4
-rw-r--r--cpukit/rtems/src/timerserver.c4
-rw-r--r--cpukit/rtems/src/timerserverfirewhen.c4
-rw-r--r--cpukit/score/Makefile.am10
-rw-r--r--cpukit/score/include/rtems/score/thread.h6
-rw-r--r--cpukit/score/include/rtems/score/timestamp.h305
-rw-r--r--cpukit/score/include/rtems/score/tod.h20
-rw-r--r--cpukit/score/preinstall.am4
-rw-r--r--cpukit/score/src/coretod.c6
-rw-r--r--cpukit/score/src/coretodget.c23
-rw-r--r--cpukit/score/src/coretodgetuptime.c26
-rw-r--r--cpukit/score/src/coretodgetuptimetimespec.c44
-rw-r--r--cpukit/score/src/coretodset.c17
-rw-r--r--cpukit/score/src/coretodtickle.c15
-rw-r--r--cpukit/score/src/threaddispatch.c12
-rw-r--r--cpukit/score/src/threadinitialize.c3
30 files changed, 573 insertions, 159 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index 5d6c5eed12..daede54b8d 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,5 +1,29 @@
2008-12-08 Joel Sherrill <joel.sherrill@oarcorp.com>
+ * libcsupport/src/__times.c, libmisc/cpuuse/cpuusagereport.c,
+ libmisc/cpuuse/cpuusagereset.c, posix/src/clockgettime.c,
+ posix/src/pthread.c, posix/src/timersettime.c,
+ rtems/include/rtems/rtems/ratemon.h,
+ rtems/src/clockgetsecondssinceepoch.c, rtems/src/clockgetuptime.c,
+ rtems/src/ratemongetstatus.c, rtems/src/ratemonperiod.c,
+ rtems/src/ratemonreportstatistics.c, rtems/src/taskwakewhen.c,
+ rtems/src/timerfirewhen.c, rtems/src/timerserver.c,
+ rtems/src/timerserverfirewhen.c, score/Makefile.am,
+ score/preinstall.am, score/include/rtems/score/thread.h,
+ score/include/rtems/score/tod.h, score/src/coretod.c,
+ score/src/coretodget.c, score/src/coretodgetuptime.c,
+ score/src/coretodset.c, score/src/coretodtickle.c,
+ score/src/threaddispatch.c, score/src/threadinitialize.c: Add
+ SuperCore handler Timestamp to provide an opaque class for the
+ representation and manipulation of uptime, time of day, and the
+ difference between two timestamps. By using SuperCore Timestamp, it
+ is clear which methods and APIs really have to be struct timespec and
+ which can be in an optimized native format.
+ * score/include/rtems/score/timestamp.h,
+ score/src/coretodgetuptimetimespec.c: New files.
+
+2008-12-08 Joel Sherrill <joel.sherrill@oarcorp.com>
+
* libfs/src/nfsclient/src/nfs.c: Use
rtems_clock_get_seconds_since_epoch() from public API.
diff --git a/cpukit/libcsupport/src/__times.c b/cpukit/libcsupport/src/__times.c
index 086144dd77..8ddad3ad9f 100644
--- a/cpukit/libcsupport/src/__times.c
+++ b/cpukit/libcsupport/src/__times.c
@@ -1,7 +1,7 @@
/*
* times() - POSIX 1003.1b 4.5.2 - Get Process Times
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2008.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -23,7 +23,7 @@
#include <errno.h>
#include <assert.h>
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- #include <rtems/score/timespec.h>
+ #include <rtems/score/timestamp.h>
#endif
clock_t _times(
@@ -53,16 +53,17 @@ clock_t _times(
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
{
- struct timespec per_tick;
- uint32_t ticks;
- uint32_t fractional_ticks;
+ Timestamp_Control per_tick;
+ uint32_t ticks;
+ uint32_t fractional_ticks;
- per_tick.tv_sec =
- _TOD_Microseconds_per_tick / TOD_MILLISECONDS_PER_SECOND;
- per_tick.tv_nsec =
- (_TOD_Microseconds_per_tick % TOD_MILLISECONDS_PER_SECOND) / 1000;
+ _Timestamp_Set(
+ &per_tick,
+ _TOD_Microseconds_per_tick / TOD_MILLISECONDS_PER_SECOND,
+ (_TOD_Microseconds_per_tick % TOD_MILLISECONDS_PER_SECOND) / 1000
+ );
- _Timespec_Divide(
+ _Timestamp_Divide(
&_Thread_Executing->cpu_time_used,
&per_tick,
&ticks,
diff --git a/cpukit/libmisc/cpuuse/cpuusagereport.c b/cpukit/libmisc/cpuuse/cpuusagereport.c
index 144be50645..b0144948e4 100644
--- a/cpukit/libmisc/cpuuse/cpuusagereport.c
+++ b/cpukit/libmisc/cpuuse/cpuusagereport.c
@@ -28,11 +28,11 @@
#include <rtems/bspIo.h>
#if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
- #include <rtems/score/timespec.h>
+ #include <rtems/score/timestamp.h>
#endif
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- extern struct timespec CPU_usage_Uptime_at_last_reset;
+ extern Timestamp_Control CPU_usage_Uptime_at_last_reset;
#else
extern uint32_t CPU_usage_Ticks_at_last_reset;
#endif
@@ -54,7 +54,7 @@ void rtems_cpu_usage_report_with_plugin(
char name[13];
uint32_t ival, fval;
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- struct timespec uptime, total, ran;
+ Timestamp_Control uptime, total, ran;
#else
uint32_t total_units = 0;
#endif
@@ -69,7 +69,7 @@ void rtems_cpu_usage_report_with_plugin(
*/
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
_TOD_Get_uptime( &uptime );
- _Timespec_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total );
+ _Timestamp_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total );
#else
for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) {
if ( !_Objects_Information_table[ api_index ] )
@@ -123,13 +123,13 @@ void rtems_cpu_usage_report_with_plugin(
*/
ran = the_thread->cpu_time_used;
if ( _Thread_Executing->Object.id == the_thread->Object.id ) {
- struct timespec used;
- _Timespec_Subtract(
+ Timestamp_Control used;
+ _Timestamp_Subtract(
&_Thread_Time_of_last_context_switch, &uptime, &used
);
- _Timespec_Add_to( &ran, &used );
+ _Timestamp_Add_to( &ran, &used );
};
- _Timespec_Divide( &ran, &total, &ival, &fval );
+ _Timestamp_Divide( &ran, &total, &ival, &fval );
/*
* Print the information
@@ -137,7 +137,9 @@ void rtems_cpu_usage_report_with_plugin(
(*print)( context,
"%3" PRId32 ".%06" PRId32 " %3" PRId32 ".%03" PRId32 "\n",
- ran.tv_sec, ran.tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND,
+ _Timestamp_Get_seconds( &ran ),
+ _Timestamp_Get_nanoseconds( &ran ) /
+ TOD_NANOSECONDS_PER_MICROSECOND,
ival, fval
);
#else
@@ -159,8 +161,8 @@ void rtems_cpu_usage_report_with_plugin(
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
(*print)( context, "Time since last CPU Usage reset %" PRId32
".%06" PRId32 " seconds\n",
- total.tv_sec,
- total.tv_nsec / TOD_NANOSECONDS_PER_MICROSECOND
+ _Timestamp_Get_seconds( &total ),
+ _Timestamp_Get_nanoseconds( &total ) / TOD_NANOSECONDS_PER_MICROSECOND
);
#else
(*print)( context,
diff --git a/cpukit/libmisc/cpuuse/cpuusagereset.c b/cpukit/libmisc/cpuuse/cpuusagereset.c
index b6920702e1..233631dda2 100644
--- a/cpukit/libmisc/cpuuse/cpuusagereset.c
+++ b/cpukit/libmisc/cpuuse/cpuusagereset.c
@@ -16,6 +16,7 @@
#endif
#include <rtems.h>
+#include <rtems/score/timestamp.h>
#include <stdlib.h>
#include <ctype.h>
@@ -28,8 +29,7 @@ static void CPU_usage_Per_thread_handler(
)
{
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- the_thread->cpu_time_used.tv_sec = 0;
- the_thread->cpu_time_used.tv_nsec = 0;
+ _Timestamp_Set_to_zero( &the_thread->cpu_time_used );
#else
the_thread->cpu_time_used = 0;
#endif
@@ -40,7 +40,7 @@ static void CPU_usage_Per_thread_handler(
* External data that is shared by cpu usage code but not declared in .h files.
*/
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- extern struct timespec CPU_usage_Uptime_at_last_reset;
+ extern Timestamp_Control CPU_usage_Uptime_at_last_reset;
#else
extern uint32_t CPU_usage_Ticks_at_last_reset;
#endif
diff --git a/cpukit/posix/src/clockgettime.c b/cpukit/posix/src/clockgettime.c
index d94bd16f98..8182f8e70f 100644
--- a/cpukit/posix/src/clockgettime.c
+++ b/cpukit/posix/src/clockgettime.c
@@ -36,22 +36,30 @@ int clock_gettime(
if ( !tp )
rtems_set_errno_and_return_minus_one( EINVAL );
- if ( clock_id == CLOCK_REALTIME )
+ if ( clock_id == CLOCK_REALTIME ) {
_TOD_Get(tp);
+ return 0;
+ }
#ifdef CLOCK_MONOTONIC
- else if ( clock_id == CLOCK_MONOTONIC )
- _TOD_Get_uptime(tp);
+ if ( clock_id == CLOCK_MONOTONIC ) {
+ _TOD_Get_uptime_as_timespec( tp );
+ return 0;
+ }
#endif
+
#ifdef _POSIX_CPUTIME
- else if ( clock_id == CLOCK_PROCESS_CPUTIME )
- _TOD_Get_uptime(tp);
+ if ( clock_id == CLOCK_PROCESS_CPUTIME ) {
+ _TOD_Get_uptime_as_timespec( tp );
+ return 0;
+ }
#endif
+
#ifdef _POSIX_THREAD_CPUTIME
- else if ( clock_id == CLOCK_THREAD_CPUTIME )
+ if ( clock_id == CLOCK_THREAD_CPUTIME )
rtems_set_errno_and_return_minus_one( ENOSYS );
#endif
- else
- rtems_set_errno_and_return_minus_one( EINVAL );
+
+ rtems_set_errno_and_return_minus_one( EINVAL );
return 0;
}
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index 4a53d939be..d8aab727f2 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -31,6 +31,7 @@
#include <rtems/posix/config.h>
#include <rtems/posix/key.h>
#include <rtems/posix/time.h>
+#include <rtems/score/timespec.h>
/*PAGE
*
diff --git a/cpukit/posix/src/timersettime.c b/cpukit/posix/src/timersettime.c
index 6099ae0400..eb7738a5b9 100644
--- a/cpukit/posix/src/timersettime.c
+++ b/cpukit/posix/src/timersettime.c
@@ -59,10 +59,12 @@ int timer_settime(
/* Convert absolute to relative time */
if (flags == TIMER_ABSTIME) {
+ struct timespec now;
+ _TOD_Get( &now );
/* Check for seconds in the past */
- if ( _Timespec_Greater_than( &_TOD_Now, &normalize.it_value ) )
+ if ( _Timespec_Greater_than( &now, &normalize.it_value ) )
rtems_set_errno_and_return_minus_one( EINVAL );
- _Timespec_Subtract( &_TOD_Now, &normalize.it_value, &normalize.it_value );
+ _Timespec_Subtract( &now, &normalize.it_value, &normalize.it_value );
}
/* If the function reaches this point, then it will be necessary to do
diff --git a/cpukit/rtems/include/rtems/rtems/ratemon.h b/cpukit/rtems/include/rtems/rtems/ratemon.h
index 41eb68ed31..3c5d1b65dc 100644
--- a/cpukit/rtems/include/rtems/rtems/ratemon.h
+++ b/cpukit/rtems/include/rtems/rtems/ratemon.h
@@ -70,7 +70,9 @@ extern "C" {
* statistics.
*/
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS)
- typedef struct timespec rtems_rate_monotonic_period_time_t;
+ #include <rtems/score/timestamp.h>
+
+ typedef Timestamp_Control rtems_rate_monotonic_period_time_t;
#else
typedef uint32_t rtems_rate_monotonic_period_time_t;
#endif
@@ -382,8 +384,11 @@ void _Rate_monotonic_Timeout(
#define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
do { \
/* set the minimums to a large value */ \
- (_the_period)->Statistics.min_wall_time.tv_sec = 0x7fffffff; \
- (_the_period)->Statistics.min_wall_time.tv_nsec = 0x7fffffff; \
+ _Timestamp_Set( \
+ &(_the_period)->Statistics.min_wall_time, \
+ 0x7fffffff, \
+ 0x7fffffff \
+ ); \
} while (0)
#else
#define _Rate_monotonic_Reset_wall_time_statistics( _the_period )
@@ -398,8 +403,11 @@ void _Rate_monotonic_Timeout(
#define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
do { \
/* set the minimums to a large value */ \
- (_the_period)->Statistics.min_cpu_time.tv_sec = 0x7fffffff; \
- (_the_period)->Statistics.min_cpu_time.tv_nsec = 0x7fffffff; \
+ _Timestamp_Set( \
+ &(_the_period)->Statistics.min_cpu_time, \
+ 0x7fffffff, \
+ 0x7fffffff \
+ ); \
} while (0)
#else
#define _Rate_monotonic_Reset_cpu_use_statistics( _the_period )
diff --git a/cpukit/rtems/src/clockgetsecondssinceepoch.c b/cpukit/rtems/src/clockgetsecondssinceepoch.c
index 9c1badfe99..c8fcdc3183 100644
--- a/cpukit/rtems/src/clockgetsecondssinceepoch.c
+++ b/cpukit/rtems/src/clockgetsecondssinceepoch.c
@@ -33,6 +33,6 @@ rtems_status_code rtems_clock_get_seconds_since_epoch(
if ( !_TOD_Is_set )
return RTEMS_NOT_DEFINED;
- *the_interval = _TOD_Seconds_since_epoch;
+ *the_interval = _TOD_Seconds_since_epoch();
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/clockgetuptime.c b/cpukit/rtems/src/clockgetuptime.c
index 9fa88ef74b..9ac834c5f5 100644
--- a/cpukit/rtems/src/clockgetuptime.c
+++ b/cpukit/rtems/src/clockgetuptime.c
@@ -20,6 +20,7 @@
#include <rtems/rtems/clock.h>
#include <rtems/score/isr.h>
#include <rtems/score/thread.h>
+#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
@@ -45,6 +46,6 @@ rtems_status_code rtems_clock_get_uptime(
if ( !uptime )
return RTEMS_INVALID_ADDRESS;
- _TOD_Get_uptime( uptime );
+ _TOD_Get_uptime_as_timespec( uptime );
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/ratemongetstatus.c b/cpukit/rtems/src/ratemongetstatus.c
index ef47a032e5..59b39e2917 100644
--- a/cpukit/rtems/src/ratemongetstatus.c
+++ b/cpukit/rtems/src/ratemongetstatus.c
@@ -65,14 +65,12 @@ rtems_status_code rtems_rate_monotonic_get_status(
if ( status->state == RATE_MONOTONIC_INACTIVE ) {
#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
- status->since_last_period.tv_sec = 0;
- status->since_last_period.tv_nsec = 0;
+ _Timestamp_Set_to_zero( &status->since_last_period );
#else
status->since_last_period = 0;
#endif
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- status->executed_since_last_period.tv_sec = 0;
- status->executed_since_last_period.tv_nsec = 0;
+ _Timestamp_Set_to_zero( &status->executed_since_last_period );
#else
status->executed_since_last_period = 0;
#endif
@@ -83,12 +81,12 @@ rtems_status_code rtems_rate_monotonic_get_status(
*/
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
- struct timespec uptime;
+ Timestamp_Control uptime;
_TOD_Get_uptime( &uptime );
#endif
#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
- _Timespec_Subtract(
+ _Timestamp_Subtract(
&the_period->time_at_period,
&uptime,
&status->since_last_period
@@ -99,7 +97,7 @@ rtems_status_code rtems_rate_monotonic_get_status(
#endif
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- _Timespec_Subtract(
+ _Timestamp_Subtract(
&_Thread_Time_of_last_context_switch,
&uptime,
&status->executed_since_last_period
diff --git a/cpukit/rtems/src/ratemonperiod.c b/cpukit/rtems/src/ratemonperiod.c
index 26db51f43b..db3b179e98 100644
--- a/cpukit/rtems/src/ratemonperiod.c
+++ b/cpukit/rtems/src/ratemonperiod.c
@@ -22,11 +22,6 @@
#include <rtems/score/object.h>
#include <rtems/rtems/ratemon.h>
#include <rtems/score/thread.h>
-#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
- defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
- #include <rtems/score/timespec.h>
- extern struct timespec _Thread_Time_of_last_context_switch;
-#endif
void _Rate_monotonic_Update_statistics(
Rate_monotonic_Control *the_period
@@ -40,7 +35,7 @@ void _Rate_monotonic_Update_statistics(
#endif
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
- struct timespec uptime;
+ Timestamp_Control uptime;
/*
* Obtain the current time since boot
@@ -60,7 +55,7 @@ void _Rate_monotonic_Update_statistics(
#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
period_start = the_period->time_at_period;
- _Timespec_Subtract( &period_start, &uptime, &since_last_period );
+ _Timestamp_Subtract( &period_start, &uptime, &since_last_period );
the_period->time_at_period = uptime;
#else
since_last_period = _Watchdog_Ticks_since_boot - the_period->time_at_period;
@@ -75,17 +70,17 @@ void _Rate_monotonic_Update_statistics(
used = _Thread_Executing->cpu_time_used;
/* partial period, cpu usage info reset while executing. Throw away */
- if (_Timespec_Less_than( &used, &the_period->owner_executed_at_period))
+ if (_Timestamp_Less_than( &used, &the_period->owner_executed_at_period))
return;
/* How much time time since last context switch */
- _Timespec_Subtract(&_Thread_Time_of_last_context_switch, &uptime, &ran);
+ _Timestamp_Subtract(&_Thread_Time_of_last_context_switch, &uptime, &ran);
/* executed += ran */
- _Timespec_Add_to( &used, &ran );
+ _Timestamp_Add_to( &used, &ran );
/* executed = current cpu usage - value at start of period */
- _Timespec_Subtract(
+ _Timestamp_Subtract(
&the_period->owner_executed_at_period,
&used,
&executed
@@ -112,12 +107,12 @@ void _Rate_monotonic_Update_statistics(
*/
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- _Timespec_Add_to( &stats->total_cpu_time, &executed );
+ _Timestamp_Add_to( &stats->total_cpu_time, &executed );
- if ( _Timespec_Less_than( &executed, &stats->min_cpu_time ) )
+ if ( _Timestamp_Less_than( &executed, &stats->min_cpu_time ) )
stats->min_cpu_time = executed;
- if ( _Timespec_Greater_than( &executed, &stats->max_cpu_time ) )
+ if ( _Timestamp_Greater_than( &executed, &stats->max_cpu_time ) )
stats->max_cpu_time = executed;
#else
stats->total_cpu_time += executed;
@@ -142,12 +137,12 @@ void _Rate_monotonic_Update_statistics(
if ( since_last_period > stats->max_wall_time )
stats->max_wall_time = since_last_period;
#else
- _Timespec_Add_to( &stats->total_wall_time, &since_last_period );
+ _Timestamp_Add_to( &stats->total_wall_time, &since_last_period );
- if ( _Timespec_Less_than( &since_last_period, &stats->min_wall_time ) )
+ if ( _Timestamp_Less_than( &since_last_period, &stats->min_wall_time ) )
stats->min_wall_time = since_last_period;
- if ( _Timespec_Greater_than( &since_last_period, &stats->max_wall_time ) )
+ if ( _Timestamp_Greater_than( &since_last_period, &stats->max_wall_time ) )
stats->max_wall_time = since_last_period;
#endif
}
@@ -211,7 +206,7 @@ rtems_status_code rtems_rate_monotonic_period(
case RATE_MONOTONIC_INACTIVE: {
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
- struct timespec uptime;
+ Timestamp_Control uptime;
#endif
/*
@@ -244,7 +239,7 @@ rtems_status_code rtems_rate_monotonic_period(
_Thread_Executing->cpu_time_used;
/* How much time time since last context switch */
- _Timespec_Subtract(
+ _Timestamp_Subtract(
&_Thread_Time_of_last_context_switch,
&uptime,
&ran
@@ -254,7 +249,7 @@ rtems_status_code rtems_rate_monotonic_period(
*
* the_period->owner_executed_at_period += ran
*/
- _Timespec_Add_to( &the_period->owner_executed_at_period, &ran );
+ _Timestamp_Add_to( &the_period->owner_executed_at_period, &ran );
}
#else
the_period->owner_executed_at_period =
diff --git a/cpukit/rtems/src/ratemonreportstatistics.c b/cpukit/rtems/src/ratemonreportstatistics.c
index e8949f4b5e..02a0237faa 100644
--- a/cpukit/rtems/src/ratemonreportstatistics.c
+++ b/cpukit/rtems/src/ratemonreportstatistics.c
@@ -24,7 +24,7 @@
#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
- #include <rtems/score/timespec.h>
+ #include <rtems/score/timestamp.h>
/* We print to 1/10's of milliseconds */
#define NANOSECONDS_DIVIDER 1000
@@ -149,23 +149,22 @@ ididididid NNNN ccccc mmmmmm X
*/
{
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- struct timespec cpu_average;
+ Timestamp_Control cpu_average;
+ Timestamp_Control *min_cpu = &the_stats.min_cpu_time;
+ Timestamp_Control *max_cpu = &the_stats.max_cpu_time;
+ Timestamp_Control *total_cpu = &the_stats.total_cpu_time;
- _Timespec_Divide_by_integer(
- &the_stats.total_cpu_time,
- the_stats.count,
- &cpu_average
- );
+ _Timestamp_Divide_by_integer( total_cpu, the_stats.count, &cpu_average );
(*print)( context,
"%" PRId32 "." NANOSECONDS_FMT "/" /* min cpu time */
"%" PRId32 "." NANOSECONDS_FMT "/" /* max cpu time */
"%" PRId32 "." NANOSECONDS_FMT " ", /* avg cpu time */
- the_stats.min_cpu_time.tv_sec,
- the_stats.min_cpu_time.tv_nsec / NANOSECONDS_DIVIDER,
- the_stats.max_cpu_time.tv_sec,
- the_stats.max_cpu_time.tv_nsec / NANOSECONDS_DIVIDER,
- cpu_average.tv_sec,
- cpu_average.tv_nsec / NANOSECONDS_DIVIDER
+ _Timestamp_Get_seconds( min_cpu ),
+ _Timestamp_Get_nanoseconds( min_cpu ) / NANOSECONDS_DIVIDER,
+ _Timestamp_Get_seconds( max_cpu ),
+ _Timestamp_Get_nanoseconds( max_cpu ) / NANOSECONDS_DIVIDER,
+ _Timestamp_Get_seconds( &cpu_average ),
+ _Timestamp_Get_nanoseconds( &cpu_average ) / NANOSECONDS_DIVIDER
);
#else
uint32_t ival_cpu, fval_cpu;
@@ -186,22 +185,22 @@ ididididid NNNN ccccc mmmmmm X
*/
{
#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
- struct timespec wall_average;
- _Timespec_Divide_by_integer(
- &the_stats.total_wall_time,
- the_stats.count,
- &wall_average
- );
+ Timestamp_Control wall_average;
+ Timestamp_Control *min_wall = &the_stats.min_wall_time;
+ Timestamp_Control *max_wall = &the_stats.max_wall_time;
+ Timestamp_Control *total_wall = &the_stats.total_wall_time;
+
+ _Timestamp_Divide_by_integer(total_wall, the_stats.count, &wall_average);
(*print)( context,
"%" PRId32 "." NANOSECONDS_FMT "/" /* min wall time */
"%" PRId32 "." NANOSECONDS_FMT "/" /* max wall time */
"%" PRId32 "." NANOSECONDS_FMT "\n", /* avg wall time */
- the_stats.min_wall_time.tv_sec,
- the_stats.min_wall_time.tv_nsec / NANOSECONDS_DIVIDER,
- the_stats.max_wall_time.tv_sec,
- the_stats.max_wall_time.tv_nsec / NANOSECONDS_DIVIDER,
- wall_average.tv_sec,
- wall_average.tv_nsec / NANOSECONDS_DIVIDER
+ _Timestamp_Get_seconds( min_wall ),
+ _Timestamp_Get_nanoseconds( min_wall ) / NANOSECONDS_DIVIDER,
+ _Timestamp_Get_seconds( max_wall ),
+ _Timestamp_Get_nanoseconds( max_wall ) / NANOSECONDS_DIVIDER,
+ _Timestamp_Get_seconds( &wall_average ),
+ _Timestamp_Get_nanoseconds( &wall_average ) / NANOSECONDS_DIVIDER
);
#else
uint32_t ival_wall, fval_wall;
diff --git a/cpukit/rtems/src/taskwakewhen.c b/cpukit/rtems/src/taskwakewhen.c
index 96f7db2618..5496f55a73 100644
--- a/cpukit/rtems/src/taskwakewhen.c
+++ b/cpukit/rtems/src/taskwakewhen.c
@@ -67,7 +67,7 @@ rtems_status_code rtems_task_wake_when(
seconds = _TOD_To_seconds( time_buffer );
- if ( seconds <= _TOD_Seconds_since_epoch )
+ if ( seconds <= _TOD_Seconds_since_epoch() )
return RTEMS_INVALID_CLOCK;
_Thread_Disable_dispatch();
@@ -80,7 +80,7 @@ rtems_status_code rtems_task_wake_when(
);
_Watchdog_Insert_seconds(
&_Thread_Executing->Timer,
- seconds - _TOD_Seconds_since_epoch
+ seconds - _TOD_Seconds_since_epoch()
);
_Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL;
diff --git a/cpukit/rtems/src/timerfirewhen.c b/cpukit/rtems/src/timerfirewhen.c
index bf1ffd568e..84ed3f6520 100644
--- a/cpukit/rtems/src/timerfirewhen.c
+++ b/cpukit/rtems/src/timerfirewhen.c
@@ -63,7 +63,7 @@ rtems_status_code rtems_timer_fire_when(
return RTEMS_INVALID_ADDRESS;
seconds = _TOD_To_seconds( wall_time );
- if ( seconds <= _TOD_Seconds_since_epoch )
+ if ( seconds <= _TOD_Seconds_since_epoch() )
return RTEMS_INVALID_CLOCK;
the_timer = _Timer_Get( id, &location );
@@ -75,7 +75,7 @@ rtems_status_code rtems_timer_fire_when(
_Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
_Watchdog_Insert_seconds(
&the_timer->Ticker,
- seconds - _TOD_Seconds_since_epoch
+ seconds - _TOD_Seconds_since_epoch()
);
_Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL;
diff --git a/cpukit/rtems/src/timerserver.c b/cpukit/rtems/src/timerserver.c
index 9c4ea90b50..5f4b318e35 100644
--- a/cpukit/rtems/src/timerserver.c
+++ b/cpukit/rtems/src/timerserver.c
@@ -189,7 +189,7 @@ static void _Timer_Server_process_seconds_chain(
* of Day (TOD) has not been set backwards. If it has then
* we want to adjust the _Timer_Seconds_chain to indicate this.
*/
- snapshot = _TOD_Seconds_since_epoch;
+ snapshot = _TOD_Seconds_since_epoch();
if ( snapshot > _Timer_Server_seconds_last_time ) {
/*
* This path is for normal forward movement and cases where the
@@ -232,7 +232,7 @@ Thread _Timer_Server_body(
* the server was initiated.
*/
_Timer_Server_ticks_last_time = _Watchdog_Ticks_since_boot;
- _Timer_Server_seconds_last_time = _TOD_Seconds_since_epoch;
+ _Timer_Server_seconds_last_time = _TOD_Seconds_since_epoch();
/*
* Insert the timers that were inserted before we got to run.
diff --git a/cpukit/rtems/src/timerserverfirewhen.c b/cpukit/rtems/src/timerserverfirewhen.c
index a1f2caee6f..d8b503e274 100644
--- a/cpukit/rtems/src/timerserverfirewhen.c
+++ b/cpukit/rtems/src/timerserverfirewhen.c
@@ -67,7 +67,7 @@ rtems_status_code rtems_timer_server_fire_when(
return RTEMS_INVALID_CLOCK;
seconds = _TOD_To_seconds( wall_time );
- if ( seconds <= _TOD_Seconds_since_epoch )
+ if ( seconds <= _TOD_Seconds_since_epoch() )
return RTEMS_INVALID_CLOCK;
the_timer = _Timer_Get( id, &location );
@@ -77,7 +77,7 @@ rtems_status_code rtems_timer_server_fire_when(
(void) _Watchdog_Remove( &the_timer->Ticker );
the_timer->the_class = TIMER_TIME_OF_DAY_ON_TASK;
_Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
- the_timer->Ticker.initial = seconds - _TOD_Seconds_since_epoch;
+ the_timer->Ticker.initial = seconds - _TOD_Seconds_since_epoch();
/*
* _Timer_Server_schedule_operation != NULL because we checked that
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index ab38b23237..e2052efce4 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -29,10 +29,10 @@ include_rtems_score_HEADERS = include/rtems/score/address.h \
include/rtems/score/stack.h include/rtems/score/states.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/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/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
if HAS_MP
# We only build multiprocessing related files if HAS_MP was defined
@@ -169,7 +169,7 @@ libscore_a_SOURCES += src/timespecaddto.c src/timespecfromticks.c \
## TOD_C_FILES
libscore_a_SOURCES += src/coretod.c src/coretodset.c src/coretodget.c \
- src/coretodgetuptime.c src/coretodtickle.c
+ src/coretodgetuptime.c src/coretodgetuptimetimespec.c src/coretodtickle.c
## WATCHDOG_C_FILES
libscore_a_SOURCES += src/watchdog.c src/watchdogadjust.c \
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index fbfd971b23..ccdeb3df27 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -36,6 +36,8 @@ extern "C" {
* resolution.
*/
#ifndef __RTEMS_USE_TICKS_CPU_USAGE_STATISTICS__
+ #include <rtems/score/timestamp.h>
+
/**
* This macro enables the nanosecond accurate statistics
*
@@ -44,7 +46,7 @@ extern "C" {
*/
#define RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- typedef struct timespec rtems_thread_cpu_usage_t;
+ typedef Timestamp_Control rtems_thread_cpu_usage_t;
#else
typedef uint32_t rtems_thread_cpu_usage_t;
@@ -500,7 +502,7 @@ SCORE_EXTERN struct _reent **_Thread_libc_reent;
* system initialization and does not need to be known outside this
* file.
*/
- SCORE_EXTERN struct timespec _Thread_Time_of_last_context_switch;
+ SCORE_EXTERN Timestamp_Control _Thread_Time_of_last_context_switch;
#endif
/**
diff --git a/cpukit/score/include/rtems/score/timestamp.h b/cpukit/score/include/rtems/score/timestamp.h
new file mode 100644
index 0000000000..0602c8d916
--- /dev/null
+++ b/cpukit/score/include/rtems/score/timestamp.h
@@ -0,0 +1,305 @@
+/**
+ * @file rtems/score/timestamp.h
+ *
+ * This include file contains helpers for manipulating 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_TIMESTAMP_H
+#define _RTEMS_SCORE_TIMESTAMP_H
+
+/**
+ * @defgroup SuperCore Timestamp
+ *
+ * This handler encapsulates functionality related to manipulating
+ * SuperCore Timestamps. SuperCore Timestamps may be used to
+ * represent time of day, uptime, or intervals.
+ *
+ * The key attribute of the SuperCore Timestamp handler is that it
+ * is a completely opaque handler. There can be multiple implementations
+ * of the required functionality and with a recompile, RTEMS can use
+ * any implementation. It is intended to be a simple wrapper.
+ *
+ * This handler can be implemented as either struct timespec or
+ * unsigned64 bit numbers. The use of a wrapper class allows the
+ * the implementation of timestamps to change on a per architecture
+ * basis. This is an important option as the performance of this
+ * handler is critical.
+ */
+/**@{*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/score/timespec.h>
+
+#define RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC
+
+/**
+ * Define the Timestamp control type.
+ */
+#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ typedef struct timespec Timestamp_Control;
+#else
+ #error "No Alternative implementations for SuperCore Timestamp."
+#endif
+
+/** @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(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_Set( _time, _seconds, _nanoseconds ) \
+ do { \
+ (_time)->tv_sec = (_seconds); \
+ (_time)->tv_nsec = (_nanoseconds); \
+ } while (0)
+#endif
+
+/** @brief Zero Timestamp
+ *
+ * This method sets the timestamp to zero.
+ * value.
+ *
+ * @param[in] _time points to the timestamp instance to zero.
+ */
+#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_Set_to_zero( _time ) \
+ do { \
+ (_time)->tv_sec = 0; \
+ (_time)->tv_nsec = 0; \
+ } while (0)
+#endif
+
+/** @brief Is Timestamp Valid
+ *
+ * This method determines the validity of a timestamp.
+ *
+ * @param[in] time is 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)
+ #define _Timestamp_Is_valid( _time ) \
+ _Timespec_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
+ *
+ * @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)
+ #define _Timestamp_Less_than( _lhs, _rhs ) \
+ _Timespec_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
+ *
+ * @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)
+ #define _Timestamp_Greater_than( _lhs, _rhs ) \
+ _Timespec_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
+ *
+ * @return This method returns true if @a lhs is equal to @a rhs and
+ * false otherwise.
+ */
+#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_Equal_to( _lhs, _rhs ) \
+ _Timespec_Equal_to( _lhs, _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
+ */
+#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_Add_to( _time, _add ) \
+ _Timespec_Add_to( _time, _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.
+ */
+#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_Add_to_at_tick( _time, _add ) \
+ _Timespec_Add_to( _time, _add )
+#endif
+
+/** @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.
+ */
+#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_To_ticks( _time ) \
+ _Timespec_To_ticks( _time )
+#endif
+
+/** @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 the number of ticks to be filled in
+ */
+#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_From_ticks( _ticks, _time ) \
+ _Timespec_From_ticks( _ticks, _time )
+#endif
+
+/** @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(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_Subtract( _start, _end, _result ) \
+ _Timespec_Subtract( _start, _end, _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(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_Divide_by_integer( _time, _iterations, _result ) \
+ _Timespec_Divide_by_integer(_time, _iterations, _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 is the integer portion of the average
+ * @param[in] fval_percentage is the thousandths of percentage
+ *
+ * @return This method fills in @a result.
+ */
+#if defined(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_Divide( _lhs, _rhs, _ival_percentage, _fval_percentage ) \
+ _Timespec_Divide( _lhs, _rhs, _ival_percentage, _fval_percentage )
+#endif
+
+/** @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(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_Get_seconds( _time ) \
+ ((_time)->tv_sec)
+#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(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_Get_nanoseconds( _time ) \
+ ((_time)->tv_nsec)
+#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(RTEMS_SCORE_TIMESTAMP_IS_STRUCT_SPEC)
+ #define _Timestamp_To_timespec( _timestamp, _timespec ) \
+ *(_timespec) = *(_timestamp)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/**@}*/
+
+#endif
+/* end of include file */
diff --git a/cpukit/score/include/rtems/score/tod.h b/cpukit/score/include/rtems/score/tod.h
index 6038b686d5..44d4df862e 100644
--- a/cpukit/score/include/rtems/score/tod.h
+++ b/cpukit/score/include/rtems/score/tod.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-#include <rtems/score/object.h>
+#include <rtems/score/timestamp.h>
#include <time.h>
/** @defgroup ScoreTODConstants TOD Constants
@@ -134,18 +134,19 @@ SCORE_EXTERN bool _TOD_Is_set;
/** @brief Current Time of Day (Timespec)
* The following contains the current time of day.
*/
-SCORE_EXTERN struct timespec _TOD_Now;
+SCORE_EXTERN Timestamp_Control _TOD_Now;
/** @brief Current Time of Day (Timespec)
* The following contains the running uptime.
*/
-SCORE_EXTERN struct timespec _TOD_Uptime;
+SCORE_EXTERN Timestamp_Control _TOD_Uptime;
/** @brief Seconds Since RTEMS Epoch
* The following contains the number of seconds from 00:00:00
* January 1, TOD_BASE_YEAR until the current time of day.
*/
-#define _TOD_Seconds_since_epoch (_TOD_Now.tv_sec)
+#define _TOD_Seconds_since_epoch() \
+ _Timestamp_Get_seconds(&_TOD_Now)
/** @brief Microseconds per Clock Tick
*
@@ -189,6 +190,17 @@ void _TOD_Get(
* @param[in] time is a pointer to the uptime to be returned
*/
void _TOD_Get_uptime(
+ Timestamp_Control *time
+);
+
+/** @brief _TOD_Get_uptime_as_timespec
+ *
+ * This routine returns the system uptime with potential accuracy
+ * to the nanosecond.
+ *
+ * @param[in] time is a pointer to the uptime to be returned
+ */
+void _TOD_Get_uptime_as_timespec(
struct timespec *time
);
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index cb27e47d48..af521fd10c 100644
--- a/cpukit/score/preinstall.am
+++ b/cpukit/score/preinstall.am
@@ -139,6 +139,10 @@ $(PROJECT_INCLUDE)/rtems/score/timespec.h: include/rtems/score/timespec.h $(PROJ
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timespec.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timespec.h
+$(PROJECT_INCLUDE)/rtems/score/timestamp.h: include/rtems/score/timestamp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timestamp.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timestamp.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/coretod.c b/cpukit/score/src/coretod.c
index fbadaf673d..cf4ec8e334 100644
--- a/cpukit/score/src/coretod.c
+++ b/cpukit/score/src/coretod.c
@@ -41,12 +41,10 @@ void _TOD_Handler_initialization(
_TOD_Microseconds_per_tick = microseconds_per_tick;
/* POSIX format TOD (timespec) */
- _TOD_Now.tv_sec = TOD_SECONDS_1970_THROUGH_1988;
- _TOD_Now.tv_nsec = 0;
+ _Timestamp_Set( &_TOD_Now, TOD_SECONDS_1970_THROUGH_1988, 0 );
/* Uptime (timespec) */
- _TOD_Uptime.tv_sec = 0;
- _TOD_Uptime.tv_nsec = 0;
+ _Timestamp_Set_to_zero( &_TOD_Uptime );
/* TOD has not been set */
_TOD_Is_set = FALSE;
diff --git a/cpukit/score/src/coretodget.c b/cpukit/score/src/coretodget.c
index 1d48082f26..dff46a0748 100644
--- a/cpukit/score/src/coretodget.c
+++ b/cpukit/score/src/coretodget.c
@@ -18,6 +18,7 @@
#include <rtems/system.h>
#include <rtems/score/isr.h>
#include <rtems/score/timespec.h>
+#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
@@ -36,20 +37,22 @@ void _TOD_Get(
struct timespec *time
)
{
- ISR_Level level;
- struct timespec offset;
+ ISR_Level level;
+ Timestamp_Control offset;
+ Timestamp_Control now;
+ long nanoseconds;
- /* assume time checked by caller */
+ /* assume time checked for NULL by caller */
- offset.tv_sec = 0;
- offset.tv_nsec = 0;
-
- /* _TOD_Now is a proper POSIX time */
+ /* _TOD_Now is the native current time */
+ nanoseconds = 0;
_ISR_Disable( level );
- *time = _TOD_Now;
+ now = _TOD_Now;
if ( _Watchdog_Nanoseconds_since_tick_handler )
- offset.tv_nsec = (*_Watchdog_Nanoseconds_since_tick_handler)();
+ nanoseconds = (*_Watchdog_Nanoseconds_since_tick_handler)();
_ISR_Enable( level );
- _Timespec_Add_to( time, &offset );
+ _Timestamp_Set( &offset, 0, nanoseconds );
+ _Timestamp_Add_to( &now, &offset );
+ _Timestamp_To_timespec( &now, time );
}
diff --git a/cpukit/score/src/coretodgetuptime.c b/cpukit/score/src/coretodgetuptime.c
index 7155419f34..6d4e5dc72a 100644
--- a/cpukit/score/src/coretodgetuptime.c
+++ b/cpukit/score/src/coretodgetuptime.c
@@ -18,7 +18,7 @@
#include <rtems/system.h>
#include <rtems/score/isr.h>
-#include <rtems/score/timespec.h>
+#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
@@ -28,28 +28,30 @@
* This routine is used to obtain the system uptime
*
* Input parameters:
- * time - pointer to the time and date structure
+ * time - pointer to the timestamp structure
*
* Output parameters: NONE
*/
void _TOD_Get_uptime(
- struct timespec *uptime
+ Timestamp_Control *uptime
)
{
- ISR_Level level;
- struct timespec offset;
+ ISR_Level level;
+ Timestamp_Control offset;
+ Timestamp_Control up;
+ long nanoseconds;
- /* assume uptime checked by caller */
-
- offset.tv_sec = 0;
- offset.tv_nsec = 0;
+ /* assume time checked for NULL by caller */
+ /* _TOD_Uptime is in native timestamp format */
+ nanoseconds = 0;
_ISR_Disable( level );
- *uptime = _TOD_Uptime;
+ up= _TOD_Uptime;
if ( _Watchdog_Nanoseconds_since_tick_handler )
- offset.tv_nsec = (*_Watchdog_Nanoseconds_since_tick_handler)();
+ nanoseconds = (*_Watchdog_Nanoseconds_since_tick_handler)();
_ISR_Enable( level );
- _Timespec_Add_to( uptime, &offset );
+ _Timestamp_Set( &offset, 0, nanoseconds );
+ _Timestamp_Add_to( &up, &offset );
}
diff --git a/cpukit/score/src/coretodgetuptimetimespec.c b/cpukit/score/src/coretodgetuptimetimespec.c
new file mode 100644
index 0000000000..6d30a95d9c
--- /dev/null
+++ b/cpukit/score/src/coretodgetuptimetimespec.c
@@ -0,0 +1,44 @@
+/*
+ * Time of Day (TOD) Handler - get uptime
+ */
+
+/* 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 <rtems/system.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/timestamp.h>
+#include <rtems/score/tod.h>
+
+/*
+ * _TOD_Get_uptime_as_timespec
+ *
+ * This routine is used to obtain the system uptime
+ *
+ * Input parameters:
+ * time - pointer to the timestamp structure
+ *
+ * Output parameters: NONE
+ */
+
+void _TOD_Get_uptime_as_timespec(
+ struct timespec *uptime
+)
+{
+ Timestamp_Control uptime_ts;
+
+ /* assume time checked for NULL by caller */
+ _TOD_Get_uptime( &uptime_ts );
+ _Timestamp_To_timespec( &uptime_ts, uptime );
+}
diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c
index c34f571e30..fea26dd190 100644
--- a/cpukit/score/src/coretodset.c
+++ b/cpukit/score/src/coretodset.c
@@ -19,6 +19,7 @@
#include <rtems/system.h>
#include <rtems/score/object.h>
#include <rtems/score/thread.h>
+#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
@@ -39,19 +40,21 @@ void _TOD_Set(
const struct timespec *time
)
{
+ long seconds;
+
_Thread_Disable_dispatch();
_TOD_Deactivate();
- if ( time->tv_sec < _TOD_Seconds_since_epoch )
- _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD,
- _TOD_Seconds_since_epoch - time->tv_sec );
+ seconds = _TOD_Seconds_since_epoch();
+
+ if ( time->tv_sec < seconds )
+ _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds - time->tv_sec );
else
- _Watchdog_Adjust_seconds( WATCHDOG_FORWARD,
- time->tv_sec - _TOD_Seconds_since_epoch );
+ _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, time->tv_sec - seconds );
/* POSIX format TOD (timespec) */
- _TOD_Now = *time;
- _TOD_Is_set = TRUE;
+ _Timestamp_Set( &_TOD_Now, time->tv_sec, time->tv_nsec );
+ _TOD_Is_set = TRUE;
_TOD_Activate();
diff --git a/cpukit/score/src/coretodtickle.c b/cpukit/score/src/coretodtickle.c
index 1afef420a2..f4e5a4f69c 100644
--- a/cpukit/score/src/coretodtickle.c
+++ b/cpukit/score/src/coretodtickle.c
@@ -19,7 +19,7 @@
#include <rtems/system.h>
#include <rtems/score/object.h>
#include <rtems/score/thread.h>
-#include <rtems/score/timespec.h>
+#include <rtems/score/timestamp.h>
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
@@ -36,22 +36,21 @@
void _TOD_Tickle_ticks( void )
{
- struct timespec tick;
- uint32_t seconds;
+ Timestamp_Control tick;
+ uint32_t seconds;
- /* Convert the tick quantum to a timespec */
- tick.tv_nsec = _TOD_Microseconds_per_tick * 1000;
- tick.tv_sec = 0;
+ /* Convert the tick quantum to a timestamp */
+ _Timestamp_Set( &tick, 0, _TOD_Microseconds_per_tick * 1000 );
/* Update the counter of ticks since boot */
_Watchdog_Ticks_since_boot += 1;
/* Update the timespec format uptime */
- (void) _Timespec_Add_to( &_TOD_Uptime, &tick );
+ _Timestamp_Add_to( &_TOD_Uptime, &tick );
/* we do not care how much the uptime changed */
/* Update the timespec format TOD */
- seconds = _Timespec_Add_to( &_TOD_Now, &tick );
+ seconds = _Timestamp_Add_to_at_tick( &_TOD_Now, &tick );
while ( seconds ) {
_Watchdog_Tickle_seconds();
seconds--;
diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c
index 4911ab5342..45a4a45ebe 100644
--- a/cpukit/score/src/threaddispatch.c
+++ b/cpukit/score/src/threaddispatch.c
@@ -31,7 +31,7 @@
#include <rtems/score/wkspace.h>
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- #include <rtems/score/timespec.h>
+ #include <rtems/score/timestamp.h>
#endif
/*PAGE
@@ -103,10 +103,14 @@ void _Thread_Dispatch( void )
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
{
- struct timespec uptime, ran;
+ Timestamp_Control uptime, ran;
_TOD_Get_uptime( &uptime );
- _Timespec_Subtract(&_Thread_Time_of_last_context_switch, &uptime, &ran);
- _Timespec_Add_to( &executing->cpu_time_used, &ran );
+ _Timestamp_Subtract(
+ &_Thread_Time_of_last_context_switch,
+ &uptime,
+ &ran
+ );
+ _Timestamp_Add_to( &executing->cpu_time_used, &ran );
_Thread_Time_of_last_context_switch = uptime;
}
#else
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c
index 596fe365a0..b7e504ca4a 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -206,8 +206,7 @@ bool _Thread_Initialize(
*/
#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
- the_thread->cpu_time_used.tv_sec = 0;
- the_thread->cpu_time_used.tv_nsec = 0;
+ _Timestamp_Set_to_zero( &the_thread->cpu_time_used );
#else
the_thread->cpu_time_used = 0;
#endif