Repository navigation
Conversation
which part of posix? |
clock_settime(clockid_t clock_id, FAR const struct timespec *tp) if use a |
can you give me pointers to the relevant parts of the posix? |
|
isn't it linux-specific documentation? do you mean you interpreted the following part to mean tv_sec should be signed? |
yse,i use |
yamt
left a comment
There was a problem hiding this comment.
as far as i know, unsigned time_t is allowed by posix.
this change requires more explanation than "follow posix".
ISO-C allow signed or unsigned time_t, but POSIX require the signed integer: |
|
This will break several architectures that do not support 64-bit long long types. This includes all of the ZiLOG architectures. This logic all needs to conditioned on CONFIG_HAVE_LONG_LONG. |
the page says:
iirc the more recent versions of posix require it to be an integer.
i tend to agree, while i have a vague concern about using 64-bit types for small devices. |
int64_t tyoedef is guarded by CONFIG_SYSTEM_TIME64, so it is not real issue. |
Here the integer ahould mean signed, since other place use unsigned integer in the same page.
time_t is still int32_t if CONFIG_SYSTEM_TIME64 isnot defined. |
no. the page actually uses three kinds.
if we need 32 bit version, it should be unsigned, as int32_t will wrap too soon. |
You are right.
Yes, int32_t will wrap at 2038(https://en.wikipedia.org/wiki/Year_2038_problem). |
Most recent version here: I fail to see how rest of page using unsigned integer could be relevant, as the technical term "integer type" has a precisely defined meaning in ISO 9899:1999 (C99 standard, incorporated to Open Group spec by reference) section 6.2.5, clause 17: "The type char, the signed and unsigned integer types, and the enumerated types are collectively called integer types. The integer and real floating types are collectively called real types." I haven't looked inside this commit, but the claim that this is needed to "follow POSIX" in commit message's summary line is incorrect. |
It is an issue because CONFIG_SYSTEM_TIME64 value is not effected by CONFIG_HAVE_LONG_LONG; the first is defined by the configuration, the second by compiler.h. nuttx/clock.h "fixes" any inconsistency. However, nuttx/clock.h that is not included by sys/types.h. |
ca59692 to
86b7305
Compare
Move the CONFIG_HAVE_LONG_LONG check to sys/types.h |
Ok, change to uint32_t/uint64_t |
Negative time is never used in NuttX. Negative time could arise in applications as a consequence of arithmetic operations, but that would be a non-portable behavior of the application because POSIX permits unsigned time_t. For portability, applications should always cast to an appropriate time before performing signed operations. With unsigned time_t, the range is doubled. Instead of 2038 (1970 + 68) then it should overflow at (1970 + 2*68) = 2,206. Prior to that date, the upper 32-bits of a 64-bit time_t will always be zero. So a 64-bit is totally wasteful until then. The effect is no just limited to time_t parameters, but to the size of all structures that include a time_t field. |
Summary
time_t:add unsigned integer define time_t
Impact
Testing
dailytest