[PATCH 2/3] score: New structure TOD_Control
Joel Sherrill
joel.sherrill at OARcorp.com
Wed Jun 13 11:52:14 UTC 2012
_Timestamp_Get_seconds_since_epoch() returns an address. Is this correct based on its usage? Is it used?
Coretodtickle.c has a comment above each of the lines you changed that says it is in timespec format. I am not sure that is right.
Neither of these is new to this change but was near it. I am on my phone reviewing and wanted to make sure these got a look.
--joel
"sebastian.huber at embedded-brains.de " <sebastian.huber at embedded-brains.de> wrote:
>From: Sebastian Huber <sebastian.huber at embedded-brains.de>
>
>Group the global TOD variables (_TOD_Now, _TOD_Uptime, and _TOD_Is_set)
>in a structure to reduce address loads in _TOD_Tickle_ticks().
>---
> cpukit/rtems/src/clockgetsecondssinceepoch.c | 2 +-
> cpukit/rtems/src/clockgettod.c | 2 +-
> cpukit/rtems/src/clockgettodtimeval.c | 2 +-
> cpukit/rtems/src/taskwakewhen.c | 2 +-
> cpukit/rtems/src/timerfirewhen.c | 2 +-
> cpukit/rtems/src/timerserverfirewhen.c | 2 +-
> cpukit/score/include/rtems/score/tod.h | 39 ++++++++++++++------------
> cpukit/score/src/coretod.c | 6 ++--
> cpukit/score/src/coretodget.c | 4 +-
> cpukit/score/src/coretodgetuptime.c | 4 +-
> cpukit/score/src/coretodset.c | 4 +-
> cpukit/score/src/coretodtickle.c | 4 +-
> testsuites/sptests/spsize/size.c | 4 +-
> 13 files changed, 40 insertions(+), 37 deletions(-)
>
>diff --git a/cpukit/rtems/src/clockgetsecondssinceepoch.c b/cpukit/rtems/src/clockgetsecondssinceepoch.c
>index 040a407..91ca553 100644
>--- a/cpukit/rtems/src/clockgetsecondssinceepoch.c
>+++ b/cpukit/rtems/src/clockgetsecondssinceepoch.c
>@@ -28,7 +28,7 @@ rtems_status_code rtems_clock_get_seconds_since_epoch(
> if ( !the_interval )
> return RTEMS_INVALID_ADDRESS;
>
>- if ( !_TOD_Is_set )
>+ if ( !_TOD.is_set )
> return RTEMS_NOT_DEFINED;
>
> *the_interval = _TOD_Seconds_since_epoch();
>diff --git a/cpukit/rtems/src/clockgettod.c b/cpukit/rtems/src/clockgettod.c
>index b94d0dc..dd68ec5 100644
>--- a/cpukit/rtems/src/clockgettod.c
>+++ b/cpukit/rtems/src/clockgettod.c
>@@ -33,7 +33,7 @@ rtems_status_code rtems_clock_get_tod(
> if ( !time_buffer )
> return RTEMS_INVALID_ADDRESS;
>
>- if ( !_TOD_Is_set )
>+ if ( !_TOD.is_set )
> return RTEMS_NOT_DEFINED;
>
> /* Obtain the current time */
>diff --git a/cpukit/rtems/src/clockgettodtimeval.c b/cpukit/rtems/src/clockgettodtimeval.c
>index 66eab0b..a3fb49d 100644
>--- a/cpukit/rtems/src/clockgettodtimeval.c
>+++ b/cpukit/rtems/src/clockgettodtimeval.c
>@@ -28,7 +28,7 @@ rtems_status_code rtems_clock_get_tod_timeval(
> if ( !time )
> return RTEMS_INVALID_ADDRESS;
>
>- if ( !_TOD_Is_set )
>+ if ( !_TOD.is_set )
> return RTEMS_NOT_DEFINED;
>
> _TOD_Get_timeval( time );
>diff --git a/cpukit/rtems/src/taskwakewhen.c b/cpukit/rtems/src/taskwakewhen.c
>index 8043db5..d181848 100644
>--- a/cpukit/rtems/src/taskwakewhen.c
>+++ b/cpukit/rtems/src/taskwakewhen.c
>@@ -51,7 +51,7 @@ rtems_status_code rtems_task_wake_when(
> {
> Watchdog_Interval seconds;
>
>- if ( !_TOD_Is_set )
>+ if ( !_TOD.is_set )
> return RTEMS_NOT_DEFINED;
>
> if ( !time_buffer )
>diff --git a/cpukit/rtems/src/timerfirewhen.c b/cpukit/rtems/src/timerfirewhen.c
>index b3e1231..df24e2a 100644
>--- a/cpukit/rtems/src/timerfirewhen.c
>+++ b/cpukit/rtems/src/timerfirewhen.c
>@@ -50,7 +50,7 @@ rtems_status_code rtems_timer_fire_when(
> Objects_Locations location;
> rtems_interval seconds;
>
>- if ( !_TOD_Is_set )
>+ if ( !_TOD.is_set )
> return RTEMS_NOT_DEFINED;
>
> if ( !_TOD_Validate( wall_time ) )
>diff --git a/cpukit/rtems/src/timerserverfirewhen.c b/cpukit/rtems/src/timerserverfirewhen.c
>index 2a1172d..5f029a0 100644
>--- a/cpukit/rtems/src/timerserverfirewhen.c
>+++ b/cpukit/rtems/src/timerserverfirewhen.c
>@@ -55,7 +55,7 @@ rtems_status_code rtems_timer_server_fire_when(
> if ( !timer_server )
> return RTEMS_INCORRECT_STATE;
>
>- if ( !_TOD_Is_set )
>+ if ( !_TOD.is_set )
> return RTEMS_NOT_DEFINED;
>
> if ( !routine )
>diff --git a/cpukit/score/include/rtems/score/tod.h b/cpukit/score/include/rtems/score/tod.h
>index e9a2e84..06cc900 100644
>--- a/cpukit/score/include/rtems/score/tod.h
>+++ b/cpukit/score/include/rtems/score/tod.h
>@@ -123,26 +123,29 @@ extern "C" {
> /**@{*/
>
> /**
>- * @brief Is the Time Of Day Set
>- *
>- * This is true if the application has set the current
>- * time of day, and false otherwise.
>- */
>-SCORE_EXTERN bool _TOD_Is_set;
>-
>-/**
>- * @brief Current Time of Day (Timespec)
>- *
>- * The following contains the current time of day.
>- */
>-SCORE_EXTERN Timestamp_Control _TOD_Now;
>-
>-/**
>- * @brief Current Time of Day (Timespec)
>- *
>- * The following contains the running uptime.
>- */
>-SCORE_EXTERN Timestamp_Control _TOD_Uptime;
>+ * @brief TOD control.
>+ */
>+typedef struct {
>+ /**
>+ * @brief Current time of day value.
>+ */
>+ Timestamp_Control now;
>+
>+ /**
>+ * @brief System uptime.
>+ */
>+ Timestamp_Control uptime;
>+
>+ /**
>+ * @brief Indicates if the time of day is set.
>+ *
>+ * This is true if the application has set the current
>+ * time of day, and false otherwise.
>+ */
>+ bool is_set;
>+} TOD_Control;
>+
>+SCORE_EXTERN TOD_Control _TOD;
>
> /**
> * @brief Seconds Since RTEMS Epoch
>@@ -151,7 +154,7 @@ SCORE_EXTERN Timestamp_Control _TOD_Uptime;
> * January 1, TOD_BASE_YEAR until the current time of day.
> */
> #define _TOD_Seconds_since_epoch() \
>- _Timestamp_Get_seconds(&_TOD_Now)
>+ _Timestamp_Get_seconds(&_TOD.now)
>
> /**
> * @brief _TOD_Handler_initialization
>diff --git a/cpukit/score/src/coretod.c b/cpukit/score/src/coretod.c
>index 30efa76..1784a89 100644
>--- a/cpukit/score/src/coretod.c
>+++ b/cpukit/score/src/coretod.c
>@@ -33,12 +33,12 @@
> void _TOD_Handler_initialization(void)
> {
> /* POSIX format TOD (timespec) */
>- _Timestamp_Set( &_TOD_Now, TOD_SECONDS_1970_THROUGH_1988, 0 );
>+ _Timestamp_Set( &_TOD.now, TOD_SECONDS_1970_THROUGH_1988, 0 );
>
> /* Uptime (timespec) */
>- _Timestamp_Set_to_zero( &_TOD_Uptime );
>+ _Timestamp_Set_to_zero( &_TOD.uptime );
>
> /* TOD has not been set */
>- _TOD_Is_set = false;
>+ _TOD.is_set = false;
> _TOD_Activate();
> }
>diff --git a/cpukit/score/src/coretodget.c b/cpukit/score/src/coretodget.c
>index 3e73a8d..94517e5 100644
>--- a/cpukit/score/src/coretodget.c
>+++ b/cpukit/score/src/coretodget.c
>@@ -31,9 +31,9 @@ void _TOD_Get_as_timestamp(
>
> /* assume time checked for NULL by caller */
>
>- /* _TOD_Now is the native current time */
>+ /* _TOD.now is the native current time */
> _ISR_Disable( level );
>- now = _TOD_Now;
>+ now = _TOD.now;
> nanoseconds = (*_Watchdog_Nanoseconds_since_tick_handler)();
> _ISR_Enable( level );
>
>diff --git a/cpukit/score/src/coretodgetuptime.c b/cpukit/score/src/coretodgetuptime.c
>index 4542529..c3c05ae 100644
>--- a/cpukit/score/src/coretodgetuptime.c
>+++ b/cpukit/score/src/coretodgetuptime.c
>@@ -42,9 +42,9 @@ void _TOD_Get_uptime(
>
> /* assume time checked for NULL by caller */
>
>- /* _TOD_Uptime is in native timestamp format */
>+ /* _TOD.uptime is in native timestamp format */
> _ISR_Disable( level );
>- up = _TOD_Uptime;
>+ up = _TOD.uptime;
> nanoseconds = (*_Watchdog_Nanoseconds_since_tick_handler)();
> _ISR_Enable( level );
>
>diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c
>index e1b86a3..9708ef9 100644
>--- a/cpukit/score/src/coretodset.c
>+++ b/cpukit/score/src/coretodset.c
>@@ -38,8 +38,8 @@ void _TOD_Set_with_timestamp(
> else
> _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now );
>
>- _TOD_Now = *tod;
>- _TOD_Is_set = true;
>+ _TOD.now = *tod;
>+ _TOD.is_set = true;
>
> _TOD_Activate();
> _Thread_Enable_dispatch();
>diff --git a/cpukit/score/src/coretodtickle.c b/cpukit/score/src/coretodtickle.c
>index 25ab6f3..fbf67fd 100644
>--- a/cpukit/score/src/coretodtickle.c
>+++ b/cpukit/score/src/coretodtickle.c
>@@ -44,11 +44,11 @@ void _TOD_Tickle_ticks( void )
> _Watchdog_Ticks_since_boot += 1;
>
> /* Update the timespec format uptime */
>- _Timestamp_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 = _Timestamp_Add_to_at_tick( &_TOD_Now, &tick );
>+ seconds = _Timestamp_Add_to_at_tick( &_TOD.now, &tick );
> while ( seconds ) {
> _Watchdog_Tickle_seconds();
> seconds--;
>diff --git a/testsuites/sptests/spsize/size.c b/testsuites/sptests/spsize/size.c
>index cc37288..529cdd3 100644
>--- a/testsuites/sptests/spsize/size.c
>+++ b/testsuites/sptests/spsize/size.c
>@@ -406,8 +406,8 @@ uninitialized =
>
> /*timer.h*/ (sizeof _Timer_Information) +
>
>-/*tod.h*/ (sizeof _TOD_Now) +
>- (sizeof _TOD_Uptime) +
>+/*tod.h*/ (sizeof _TOD.now) +
>+ (sizeof _TOD.uptime) +
>
> /*tqdata.h*/ 0 +
>
>--
>1.6.4.2
>
>_______________________________________________
>rtems-devel mailing list
>rtems-devel at rtems.org
>http://www.rtems.org/mailman/listinfo/rtems-devel
More information about the devel
mailing list