Inconsistency in time_t definition (Zephyr docs vs armstdc implementation) #94772
Unanswered
johnlange2
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all,
While reviewing the size and type of time_t in Zephyr, I noticed a potential inconsistency between the documentation and the actual implementation.
The documentation at https://docs.zephyrproject.org/latest/kernel/timeutil.html states:
“time_t is defined to be 64-bits both for historical reasons and to be robust enough to represent times in the future.”
From my review, time_t is indeed consistently defined as a 64-bit signed integer across Zephyr libraries except for armstdc, where it is defined as unsigned int. The relevant lines are here:
#if !defined(__time_t_defined)
#define __time_t_defined
typedef unsigned int time_t;
#endif
On 32-bit ARM platforms, this makes time_t a 32-bit unsigned integer. While this allows dates to be represented until Feb 7, 2106 (so not an immediate problem), it does not align with the documentation quoted above.
My concern is mainly the inconsistency:
Ideally, Zephyr should support a 64-bit time_t on all platforms, including 32-bit ARM. If that’s not readily possible, perhaps the documentation should be updated to clarify that time_t is 64-bit signed except when using armstdc, in which case it is 32-bit unsigned.
Best regards,
John
Beta Was this translation helpful? Give feedback.
All reactions