diff options
author | Frank Kühndel <frank.kuehndel@embedded-brains.de> | 2021-04-08 15:41:15 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-04-21 07:13:31 +0200 |
commit | 7bbbe4225c92b646faa14e5f5800ed2feba09899 (patch) | |
tree | ece4e7cd78885c29207ce0b2c50ea537af65bc86 /cpukit/include/rtems/score/todimpl.h | |
parent | bsps/arm: Set MSP in ARMv7-M start code (diff) | |
download | rtems-7bbbe4225c92b646faa14e5f5800ed2feba09899.tar.bz2 |
clock:_TOD_To_seconds(): Fix year 2514 overflow
This patch fixes issue #4338 by changing _TOD_Validate()
to only accept years till 2105. This requires another patch
to change the documentation of rtems_clock_set() and other
affected API functions (indicating the end date is 2105 not 2514).
I tried to support till year 2514 but it turned out that
this needs changing the Timer Manager too. That in turn
would mean to change _TOD_Seconds_since_epoch( void )
from 32 to 64 bit. Sebastian pointed out that a naive extension
leads to trouble with 32 bit processors. He deemed a safe
re-implementation too costly performance wise considering
that year 2106 is far away and current binaries using RTEMS
Classic API are unlikely to be in use by 2106.
The constant TOD_SECONDS_AT_2100_03_01_00_00 in
cpukit/rtems/src/clocktodtoseconds.c happens to be wrong by
1 hour. When setting the date 2100-Feb-28 23:59:59 and then
reading the date again you will find yourself in 2100-Feb-27.
Update #4338
Diffstat (limited to 'cpukit/include/rtems/score/todimpl.h')
-rw-r--r-- | cpukit/include/rtems/score/todimpl.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cpukit/include/rtems/score/todimpl.h b/cpukit/include/rtems/score/todimpl.h index 9805ec0dfd..316a56ec74 100644 --- a/cpukit/include/rtems/score/todimpl.h +++ b/cpukit/include/rtems/score/todimpl.h @@ -124,6 +124,22 @@ extern "C" { #define TOD_BASE_YEAR 1988 /** + * @brief Latest year to which a time of day can be initialized. + * + * The following constant defines the latest year to which an + * RTEMS time of day can be set using rtems_clock_set(). + * + * 32 bits can accept as latest point in time 2106-Feb-7 6:28:15 + * but to simplify the implementation, is was decided to only + * check that the year is not greater than the year of this constant. + * + * The internal realtime clock can run centuries longer but in + * contrast to the POSIX API, the RTEMS Classic API does not + * support this for efficiency reasons. + */ +#define TOD_LATEST_YEAR 2105 + +/** * @addtogroup RTEMSScoreTOD * * This handler encapsulates functionality used to manage time of day. |