Repository navigation
include/time.h: Typedef time_t to uint64_t when CONFIG_SYSTEM_TIME64 is true - #7975
xiaoxiang781216 wants to merge 1 commit into
Conversation
…is true Signed-off-by: Xiang Xiao <[email protected]>
|
@yamt here is the change which map time_4 to uint64_t instead int64_t |
|
libcxx report the following warning with this patch: So, we have to keep the convention used by other OS. |
isn't it a problem for !CONFIG_SYSTEM_TIME64 case? |
|
No, it's problem when CONFIG_SYSTEM_TIME64 is enabled and time_t is map to uint64_t. So, if you don't have a good reason, it's better to map time_t to int64_t like other OS. |
|
|
If so, why not change 32bit time_t to int32_t like other OS? |
because int32_t wraps too soon. |
It exists in many places (the above warning is just a demo). I am afraid that not only libcxx but also many other libraries suffer the same issue.
But it doesn't have any warning before we define time_t to uint64_t
int32_t can represent time correctly until 2038. The reliable fix is promoted time_t to int64_t like other OS. Typedef time_t to uint32_t mayn't work as your expectation (2106) since many software only test with signed integer(https://en.wikipedia.org/wiki/Year_2038_problem). So, if you want to keep the consistence, I will prefer to map time_t to int32_t insteading map time_t to uint64_t. |
it seems like the only failure on the ci.
see #7979
i suspect broken software is broken anyway, even with 64-bit time_t.
i feel 2038 is too soon. but it's something the project can decide, i guess. |
I guess 64bit signed/unsigned comparison is handled differently from 32bit signed/unsigned comparison by compiler. Since even -Wsign-compare isn't enabled, compiler still warn 64bit signed/unsigned comparison, but not for 32bit. |
my understanding is it's more about C vs C++. |
Summary
See the discussion here: #7115
Impact
time_t mapping
Testing
Pass CI