[RTEMS Project] #2624: Fix the year 2038 problem

RTEMS trac trac at rtems.org
Mon Mar 7 06:39:24 UTC 2016


#2624: Fix the year 2038 problem
-----------------------------+------------------
 Reporter:  sebastian.huber  |      Owner:
     Type:  defect           |     Status:  new
 Priority:  normal           |  Milestone:  4.12
Component:  General          |    Version:  4.10
 Severity:  normal           |   Keywords:
-----------------------------+------------------
 RTEMS uses currently a signed 32-bit integer for time_t on Newlib. Thus,
 it is affected by the year 2038 problem. There are only 22 years left and
 this time span is within the realistic time frame of some RTEMS
 applications that are developed now.

 The time_t should be changed to int64_t in Newlib. To make sure that all
 integer operations are carried out properly I suggest to temporarily do
 this

 {{{#include <sys/_stdint.h>

 typedef struct {
   __int64_t _val;
 } time_t;

 static inline time_t _time_add(time_t a, time_t b)
 {
   time_t r = { a._val + b._val };
   return r;
 }

 static inline time_t _time_sub(time_t a, time_t b)
 {
   time_t r = { a._val - b._val };
   return r;
 }

 static inline time_t _time_mul(time_t a, time_t b)
 {
   time_t r = { a._val * b._val };
   return r;
 }

 static inline time_t _time_div(time_t a, time_t b)
 {
   time_t r = { a._val / b._val };
   return r;
 }
 }}}

 Make sure that RTEMS and Newlib build with this. Add test cases to
 highlight the time_t integer limits.

--
Ticket URL: <http://devel.rtems.org/ticket/2624>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list