-
Notifications
You must be signed in to change notification settings - Fork 7.4k
lib: posix: remove posix/time.h #49887
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
6f08b1c
to
42718ce
Compare
ad1dcd2
to
5c43b9f
Compare
Likely need to rework this with configuration bits for pico libc. Related: picolibc/picolibc#305 |
#endif | ||
|
||
#ifdef CONFIG_POSIX_CLOCK | ||
__syscall int zephyr_clock_gettime(clockid_t clock_id, struct timespec *ts); |
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 you want to elide the libc wrapper, you should be able to define clock_gettime directly as a 'gnu_inline' function (where supported, which means gcc or clang). That might be a nice optimization.
extern __inline int __attribute ((gnu_inline, always_inline)) clock_gettime(clock_id_t clock_id, struct timespec *ts)
{
return zephyr_clock_gettime(clock_id, ts);
}
that would allow the C library 'time.h' header to continue to declare clock_gettime as a regular function but all uses will be inlined to direct calls to the zephyr syscall version.
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.
Oh wow - that is quite a useful optimization. I worry though that there may be portability concerns.
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.
This is looking pretty good. I think as a transition, you should add the necessary _POSIX definitions before the libc headers are included; that way newlib and picolibc will provide declarations for all of the necessary functions.
I guess it could be done in an additional header that gets included with |
d55333b
to
1cf4671
Compare
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.
In general, I think this should be accompanied by zephyrproject-rtos/sdk-ng#350, such that, for newlib and picolibc (included as part of the toolchains), when building arch-*-zephyr
targets, the proper Zephyr-specific definitions are provided.
22e286d
to
7078823
Compare
|
The `<time.h>` header typically belongs to the C libary. There is no reason for the posix subsystem to partially provide it. Removing `posix/time.h` also mitigates the need for the `#include_next` workaround. Signed-off-by: Christopher Friedt <[email protected]>
7078823
to
91ae602
Compare
@@ -5,8 +5,11 @@ | |||
*/ | |||
|
|||
#include <errno.h> | |||
#include <signal.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 a bit concerned about this inconsistence - in Zephyr, this should technically be <zephyr/posix/signal.h>
but iirc that breaks a couple of tests (if not here, then in another place where <signal.h>
is used. IIRC, timer.c
).
@stephanosio - I would like to try and get this upstreamed sooner rather than later since it blocks my other longstanding PR that allows us to opt out of the It would be good to sync up w.r.t. zephyrproject-rtos/sdk-ng#350 though. When do you think it will be ready? Is it possible this could go in first? |
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.
Having a problem using clock_gettime()
with Zephyr 3.2 and found this PR.
Reading this and picolibc/picolibc#305 together but still not sure how this transition suppose to work. Zephyr has system call wrappers but we are moving them to picolibc? Is #49887 (comment) the answer?
What is the point of moving thin wrappers to picolibc or the libcs we support for that matter? Just like Glibc? Or am I missing the whole point? Really appreciate if someone enlighten me.
Thanks.
} | ||
#endif | ||
|
||
#include <syscalls/time_calls.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.
Where can I find this file? Is it syscalls/time.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.
it's generated dynamically by the build system.
See https://docs.zephyrproject.org/latest/kernel/usermode/syscalls.html
BTW, this is what I got with the two patches
|
Hi @yashi - yeah, this PR is still in draft because it's part of a bigger effort to improve libc header consistency. We're aiming to go for newlib-compatible for the most part. This is on hold until some more work is done on zephyrproject-rtos/sdk-ng#350 |
This can be fixed by making sure the |
The
<time.h>
header typically belongs to the C libary. There is no reason for the posix subsystem to partially provide it.Removing
posix/time.h
also mitigates the need for the#include_next
workaround.Compliance failure is a false positive.