summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-11 17:27:20 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-12 21:25:37 +0200
commit523867de9d274d2bdc29ce649d764b42a9167c0e (patch)
tree88d38e4054d3c24eaa9bbd5327faed8bffe406f8 /cpukit/rtems
parent6136918ddf3fa5cbe04082d9a1c06e1b4f738221 (diff)
downloadrtems-523867de9d274d2bdc29ce649d764b42a9167c0e.tar.bz2
rtems: Constify rtems_task_wake_when()
Add a parameter to _TOD_Validate() to disable the validation of the ticks member. There are two reasons for this change. Firstly, in rtems_task_wake_when() was a double check for time_buffer == NULL (one in rtems_task_wake_when() and one in _TOD_Validate()). Secondly, the ticks member is ignored by rtems_task_wake_when(). This was done with a write of zero to the ticks member and thus a modification of the user-provided structure. Now the structure is no longer modified. Using a mask parameter is quite efficient. You just have to load an immediate value and there are no additional branches in _TOD_Validate(). Close #4406.
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/src/clockset.c2
-rw-r--r--cpukit/rtems/src/clocktodvalidate.c5
-rw-r--r--cpukit/rtems/src/taskwakewhen.c8
-rw-r--r--cpukit/rtems/src/timercreate.c2
4 files changed, 7 insertions, 10 deletions
diff --git a/cpukit/rtems/src/clockset.c b/cpukit/rtems/src/clockset.c
index df163531a7..07384290b8 100644
--- a/cpukit/rtems/src/clockset.c
+++ b/cpukit/rtems/src/clockset.c
@@ -34,7 +34,7 @@ rtems_status_code rtems_clock_set(
struct timespec tod_as_timespec;
ISR_lock_Context lock_context;
- status = _TOD_Validate( tod );
+ status = _TOD_Validate( tod, TOD_ENABLE_TICKS_VALIDATION );
if ( status != RTEMS_SUCCESSFUL ) {
return status;
diff --git a/cpukit/rtems/src/clocktodvalidate.c b/cpukit/rtems/src/clocktodvalidate.c
index 95c8e77c37..41a1167287 100644
--- a/cpukit/rtems/src/clocktodvalidate.c
+++ b/cpukit/rtems/src/clocktodvalidate.c
@@ -36,7 +36,8 @@ const uint32_t _TOD_Days_per_month[ 2 ][ 13 ] = {
};
rtems_status_code _TOD_Validate(
- const rtems_time_of_day *the_tod
+ const rtems_time_of_day *the_tod,
+ uint32_t ticks_mask
)
{
uint32_t days_in_month;
@@ -48,7 +49,7 @@ rtems_status_code _TOD_Validate(
ticks_per_second = rtems_clock_get_ticks_per_second();
- if ((the_tod->ticks >= ticks_per_second) ||
+ if ( ( ( the_tod->ticks & ticks_mask ) >= ticks_per_second ) ||
(the_tod->second >= TOD_SECONDS_PER_MINUTE) ||
(the_tod->minute >= TOD_MINUTES_PER_HOUR) ||
(the_tod->hour >= TOD_HOURS_PER_DAY) ||
diff --git a/cpukit/rtems/src/taskwakewhen.c b/cpukit/rtems/src/taskwakewhen.c
index a25204ad01..4dfa6dfef2 100644
--- a/cpukit/rtems/src/taskwakewhen.c
+++ b/cpukit/rtems/src/taskwakewhen.c
@@ -27,7 +27,7 @@
#include <rtems/score/watchdogimpl.h>
rtems_status_code rtems_task_wake_when(
- rtems_time_of_day *time_buffer
+ const rtems_time_of_day *time_buffer
)
{
uint32_t seconds;
@@ -38,11 +38,7 @@ rtems_status_code rtems_task_wake_when(
if ( !_TOD_Is_set() )
return RTEMS_NOT_DEFINED;
- if ( !time_buffer )
- return RTEMS_INVALID_ADDRESS;
-
- time_buffer->ticks = 0;
- status = _TOD_Validate( time_buffer );
+ status = _TOD_Validate( time_buffer, TOD_DISABLE_TICKS_VALIDATION );
if ( status != RTEMS_SUCCESSFUL ) {
return status;
diff --git a/cpukit/rtems/src/timercreate.c b/cpukit/rtems/src/timercreate.c
index bd9421c440..59fa353b22 100644
--- a/cpukit/rtems/src/timercreate.c
+++ b/cpukit/rtems/src/timercreate.c
@@ -141,7 +141,7 @@ rtems_status_code _Timer_Fire_when(
if ( !routine )
return RTEMS_INVALID_ADDRESS;
- status = _TOD_Validate( wall_time );
+ status = _TOD_Validate( wall_time, TOD_ENABLE_TICKS_VALIDATION );
if ( status != RTEMS_SUCCESSFUL ) {
return status;