-
Notifications
You must be signed in to change notification settings - Fork 7.4k
posix: Clean up various headers #16626
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
Conversation
42a480b
to
6dcacd0
Compare
Ok, so this started as just moving open() from unistd.h to fcntl.h, but as usual, led to chain of conflicts, which however this time were tracked down to completion. |
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.
If the goal is a cleanup, I think at least including kernel.h from a libc header ought to be addressed, as it does fall under that umbrella.
@mbolivar: I don't understand what you mean. Please review previous comments and history of title changes regarding the goal of this PR. And perhaps, post comments without hitting -1 button right away? |
I posted 3 comments; what are you talking about? |
Ok, sorry, I didn't get them in email, and didn't see at once here. |
I'm done with this PR. Dismissing my stale review. |
lib/libc/minimal/include/sys/stat.h
Outdated
extern "C" { | ||
#endif | ||
|
||
#include <kernel.h> |
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.
I'm with @mbolivar from the perspective of minimal libc headers should not be including kernel.h. However I'll say it shouldn't have been put into the Zephyr's POSIX material in the first place, so that ship has sailed and though removing the include should happen it's not in scope for this PR.
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.
Should not be including kernel.h here
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.
Should not be including kernel.h here
Again, I just moved the file around, and made minimal change to accompany that, if any. Let me try to remove that and see if it leads to cascade of unexpected CI breaks (which is very common so far with POSIX subsys stuff, and what I'm trying to fix - step by step).
I would like to see this merged soon since it's required as the basis of reworking #17003. |
@pabigot: Thanks for approval. |
@nashif can you re-visit your review? |
The remark was already included in the recent update.
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.
LGTM
(I know Anas is on holiday and double checked that his remark was included, so I dismissed it - hope that's OK) |
@mgielda, Thanks for review. Also, the PR is rebased against master, added a commit to fix issue mentioned in #17768 (comment) (cc: @PiotrZierhoffer). |
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.
A few minor comments, but otherwise looks good.
Newlib libc already provides sys/stat.h, so trying to have sys/stat.h on the level of POSIX subsys inevitable leads to include order and definition conflicts. Instead (as most of other sys/* includes) should come from the underlying libc. While moving, made unrelated change of removing #include <kernel.h>, to accommodate the change reviewers. Signed-off-by: Paul Sokolovsky <[email protected]>
POSIX subsys defines struct timespec in <time.h> (as POSIX public API requires), but newlib defines in in sys/_timespec.h, which inevitably leads to inclusion order and redifinition conflicts. Follow newlib way and define it in single place, sys/_timespec.h, which belongs to libc namespace. Thus, we move current definition to minimal libc, and will use either minlibc's or newlib's definition, instead of trying to redefine it. This is similar to the introduction of sys/_timeval.h done earlier. Signed-off-by: Paul Sokolovsky <[email protected]>
Unfortunately, Zephyr SDK 0.10.0 ships with outdated Newlib 2.0.0 (from 2015 or earlier) which lacks sys/_timespec.h header, requiring ugly workaround of defining struct timespec inline (the whole idea was to standardize on sys/_timespec.h header for different libc's). This is similar to earlier workaround for struct timeval definition introduced in a6aee9b. Zephyr SDK ticket for this issue is zephyrproject-rtos/sdk-ng#64, and it will ve possible to remove both workarounds when Xtensa toolchain will be upgraded to newlib version consistent with other architectures. Signed-off-by: Paul Sokolovsky <[email protected]>
That's the header which is supposed to define them, there was even FIXME on that in mqueue.h. Signed-off-by: Paul Sokolovsky <[email protected]>
Per POSIX, open() is defined in <fcntl.h>. fcntl.h in turn comes from the underlying libc, either newlib, or minimal libc. Signed-off-by: Paul Sokolovsky <[email protected]>
By the latest convention, libc's define struct timespec in sys/_timespec.h. This is consistent with Newlib and ensures about errors due to redefinitions. Signed-off-by: Paul Sokolovsky <[email protected]>
Should be addressed now. |
Ok, so this started as just moving open() from unistd.h to fcntl.h, but as usual, led to chain of conflicts, which however this time were tracked down to completion.
Per POSIX, open() is defined in <fcntl.h>. fcntl.h in turn comes from
the underlying libc, either newlib, or minimal libc.
Signed-off-by: Paul Sokolovsky [email protected]