-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include/posix: incorporate toolchain-provided time.h header #27939
include/posix: incorporate toolchain-provided time.h header #27939
Conversation
27c61de
to
a69fefc
Compare
include/posix/time.h
Outdated
@@ -101,4 +106,9 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); | |||
#include <syscalls/time.h> | |||
#endif /* CONFIG_ARCH_POSIX */ | |||
|
|||
#else /* ZEPHYR_INCLUDE_POSIX_TIME_H_ */ | |||
/* Read the standard header when <posix/time.h> finds itself on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What "standard header"? If you mean "toolchain-provided header", as the commit message says, please say it so here too.
@@ -16,15 +16,19 @@ int main(void) | |||
|
|||
while (1) { | |||
int res = gettimeofday(&tv, NULL); | |||
time_t now = time(NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the sample is called "samples/posix/gettimeofday", and initially was intended to showcase gettimeofday (and not less than that, system time auto-init via SNTP). If you add more function calls there, please at least add comment like "Also exercise a few other functions at the same time."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the example description to note that localtime is printed as well.
I indeed wasn't able to look into that issue myself - started with first issues in backlog for POSIX subsys (syscalls for fd primitives), and never got out of that swamp. My only question (beyond a couple of code comment requests) is - how this was tested? (Any more or less big 3rd-party software build with it or whatever.) |
a69fefc
to
c2397ce
Compare
Review comments addressed. It's been compile-tested via sanitycheck, and externally tested by @jhirsi. |
Some of what's supposed to be in <time.h> was lost because this header attempts to define everything using more primitive include files. Instead incorporate the contents from the toolchain-provided header. Any gaps should be picked up by the legacy content present in this file, which should not conflict with the toolchain header. Signed-off-by: Peter Bigot <[email protected]>
Use time(), localtime_r(), and asctime() to confirm that the declarations required for these (newlib) libc functions are made available in CONFIG_POSIX context. Signed-off-by: Peter Bigot <[email protected]>
c2397ce
to
50ae411
Compare
Some of what's supposed to be in <time.h> was lost because this header attempts to define everything using more primitive include files. Instead incorporate the contents from the toolchain-provided header. Any gaps should be picked up by the legacy content present in this file, which should not conflict with the toolchain header.
An updated test confirms the problematic API is now available to Zephyr.
Closes #24730.
(This solution, which addresses a blocking problem for a Nordic-based project, has been discussed in #24730 (comment). The potential follow-up cleanup is not being addressed here.)