[PATCH] clock:_TOD_To_seconds(): Fix year 2514 overflow

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Apr 19 15:44:01 UTC 2021


On 13/04/2021 18:03, Sebastian Huber wrote:

> Hello,
>
> On 08/04/2021 15:41, Frank Kuehndel wrote:
>> +/**
>> + *  @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
>
> any objections to use this approach? If we want to support years after 
> 2105 in the Classic API, then we would need 64-bit values and 
> calculations in several places. I think an RTEMS system which operates 
> after 2105 is currently a bit unrealistic.
>
> If we limit the time frame to the year 2100 we could simplify 
> _TOD_Validate() a bit more since all years % 4 == 0 are leap years in 
> the range 1988 to 2100 (exclusive). 
If there are no objections, then I will check this in on Wednesday and 
send a documentation update.

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber at embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/



More information about the devel mailing list