-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
lib: libc: common: provide a common clock() implementation #57800
lib: libc: common: provide a common clock() implementation #57800
Conversation
1e957e5
to
8163da8
Compare
4cf381d
to
5362f66
Compare
884aa45
to
9e367cf
Compare
We'll see how this does in CI. @evgeniy-paltsev - I can add something here for ARC if you like as well. |
dfa3101
to
f24ec69
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.
Note that newlib and picolibc use unsigned long
for _CLOCK_T_
.
f24ec69
to
03d7858
Compare
Note: in the future it may be possible for |
03d7858
to
c0bb3cf
Compare
Coding guidelines check is currently failing due to this patch defining |
Doing a minor respin. I might as well add the POSIX bits as well, it's so simple to implement. Until we have |
c0c3b78
to
d72469e
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.
This is looking good; there's an unresolved comment in test_clock about getting a reasonable delay like you used in test_times. And, of course, the compliance checker has 'some issues'. Seems like it's almost ready ?
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.
Some comments..
tests/lib/c_lib/src/main.c
Outdated
clock_t now; | ||
|
||
then = clock(); | ||
k_sleep(K_TICKS(1)); |
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.
Yep - I'll change that shortly.
d72469e
to
201957c
Compare
Note: this is back in draft, so no need to review yet. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
949f69b
to
1afcb03
Compare
The `clock()` function was originally part of ISO C89, and it is also a POSIX extension of the C standard. Both newlib and picolibc have implementations of `clock()` that reference the POSIX `times()` function. However, POSIX is optional in Zephyr while C is non-optional. Due to this, the newlib and picolibc implementations cause a layering violation. Provide a simple implementation here that is independent of POSIX to avoid the layering violation. Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Add a test for the ISO C `clock()` function, which has been present since C89. Signed-off-by: Christopher Friedt <cfriedt@meta.com>
1afcb03
to
52d7a66
Compare
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
The
clock()
function was originally part of ISO C89 and it is also a POSIX extension of the C standard.Both newlib and picolibc have implementations of
clock()
that reference the POSIXtimes()
function. However, POSIX is optional in Zephyr while C is non-optional. Due to this, the newlib and picolibc implementations inadvertantly cause a layering violation that would otherwise not exist on full POSIX operating systems like Linux or BSD.Provide a simple implementation here that is independent of POSIX.
Fixes #51978
Compliance issue is a false positive