Skip to content
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

Merged
merged 2 commits into from
Sep 4, 2020

Conversation

pabigot
Copy link
Collaborator

@pabigot pabigot commented Sep 1, 2020

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.)

@github-actions github-actions bot added area: API Changes to public APIs area: Samples Samples labels Sep 1, 2020
@pabigot pabigot changed the title dry run potential fix for posix time include/posix: incorporate toolchain-provided time.h header Sep 1, 2020
@jenmwms jenmwms mentioned this pull request Sep 1, 2020
2 tasks
@pabigot pabigot marked this pull request as ready for review September 1, 2020 22:11
@jhirsi
Copy link
Contributor

jhirsi commented Sep 2, 2020

Thanks @pabigot! #24730 is a blocker for me currently when porting a posix based app on top of zephyr posix api. But not with this, confirming that this would solve compilation issues that I faced and would unblock me to concentrate to the actual beef.
Hopefully this could be merged!

@@ -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
Copy link
Contributor

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);
Copy link
Contributor

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."

Copy link
Collaborator Author

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.

@pfalcon
Copy link
Contributor

pfalcon commented Sep 2, 2020

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.)

@pabigot
Copy link
Collaborator Author

pabigot commented Sep 2, 2020

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]>
@carlescufi carlescufi merged commit 1d02670 into zephyrproject-rtos:master Sep 4, 2020
@pabigot pabigot deleted the nordic/20200901b branch September 5, 2020 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

C standard library <time.h> functions and structures not available when using POSIX API
4 participants