-
Notifications
You must be signed in to change notification settings - Fork 8.4k
posix: implement xsi_single_process and posix_clock_selection #89068
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
Merged
nashif
merged 9 commits into
zephyrproject-rtos:main
from
cfriedt:issue/88556/posix-gettimeofday-is-not-a-part-of-posix-timers-but-xsi-single-process
May 14, 2025
Merged
posix: implement xsi_single_process and posix_clock_selection #89068
nashif
merged 9 commits into
zephyrproject-rtos:main
from
cfriedt:issue/88556/posix-gettimeofday-is-not-a-part-of-posix-timers-but-xsi-single-process
May 14, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
247ce21 to
d41e9e4
Compare
ff4b6b4 to
0fa03fe
Compare
84db803 to
4144abe
Compare
7f7d093 to
3f894b8
Compare
cfriedt
commented
May 3, 2025
ycsin
reviewed
May 4, 2025
To facilitate adding putenv in a separate compilation unit, make z_getenv(), z_getenv_r(), z_setenv(), and z_unsetenv() convenience functions. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Move most implementations to env-common.c in preparation for adding putenv.c . We also take this as an opportunity to switch from using k_spinlock to sys_sem. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
To facilitate moving gettimeofday() and clock_nanosleep() to separate compilation units, make z_clock_nanosleep(), z_clock_gettime(), and z_clock_settime() convenience functions. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Move most implementations to clock_common.c in preparation for moving gettimeofday() and clock_nanosleep() to different compilation units. We also take this as an opportunity to switch from using k_spinlock to sys_sem. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
gettimeofday() was already implemented, but incorrectly lumped into POSIX_TIMERS. putenv() is really just a wrapper around setenv(). The only one left to implement was gethostid() which was relatively trivial. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add tests for the XSI_SINGLE_PROCESS Option Group. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Mark the XSI_SINGLE_PROCESS Option Group as supported. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Implement the POSIX_CLOCK_SELECTION Option Group. This was mostly already done, but compiled / linked in the wrong places. E.g. pthread_condattr_getclock() and pthread_condattr_setclock() were in pthread.c and part of POSIX_THREADS_BASE. clock_nanosleep() was in clock.c and part of POSIX_TIMERS. This change builds them as part of clock_selection.c with CONFIG_POSIX_CLOCK_SELECTION. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add a testsuite for the POSIX_CLOCK_SELECTION Option Group which consists of clock_nanosleep(), pthread_condattr_getclock(), and pthread_condattr_setclock(). Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
3f894b8 to
b8c8acb
Compare
ycsin
approved these changes
May 5, 2025
Member
ycsin
left a comment
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, thanks @cfriedt
peter-mitsis
approved these changes
May 5, 2025
Member
Author
cfriedt
pushed a commit
to cfriedt/zephyr
that referenced
this pull request
May 14, 2025
https://github.com/zephyrproject-rtos/zephyr/actions/runs/\ 15014534061/job/42189411225 We were seeing a linker error of the form ``` picolibc/x86_64-zephyr-elf/lib/32/libc.a(libc_time_time.c.o): \ in function `time': time.c:(.text.time+0x11): undefined reference to `gettimeofday' ``` Update the dependency from CONFIG_POSIX_TIMERS to CONFIG_XSI_SINGLE_PROCESS for gettimeofday(). Note: this is really only a workaround. The proper solution would be to have libc functions not depend on POSIX functions. Specifically, here https://github.com/zephyrproject-rtos/picolibc/blob/\ 51a8b32857e75345c37652a80b5cda98b28d69e5/newlib/libc/time/\ time.c#L54 and here https://github.com/zephyrproject-rtos/zephyr/blob/\ 3a4e128/lib/libc/common/\ source/time/time.c#L17 Also mentioned in zephyrproject-rtos#89068 Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
cfriedt
pushed a commit
to cfriedt/zephyr
that referenced
this pull request
May 15, 2025
https://github.com/zephyrproject-rtos/zephyr/actions/runs/\ 15014534061/job/42189411225 We were seeing a linker error of the form ``` picolibc/x86_64-zephyr-elf/lib/32/libc.a(libc_time_time.c.o): \ in function `time': time.c:(.text.time+0x11): undefined reference to `gettimeofday' ``` Update the dependency from CONFIG_POSIX_TIMERS to CONFIG_XSI_SINGLE_PROCESS for gettimeofday(). Note: this is really only a workaround. The proper solution would be to have libc functions not depend on POSIX functions. Specifically, here https://github.com/zephyrproject-rtos/picolibc/blob/\ 51a8b32857e75345c37652a80b5cda98b28d69e5/newlib/libc/time/\ time.c#L54 and here https://github.com/zephyrproject-rtos/zephyr/blob/\ 3a4e128/lib/libc/common/\ source/time/time.c#L17 Also mentioned in zephyrproject-rtos#89068 Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
kartben
pushed a commit
that referenced
this pull request
May 15, 2025
https://github.com/zephyrproject-rtos/zephyr/actions/runs/\ 15014534061/job/42189411225 We were seeing a linker error of the form ``` picolibc/x86_64-zephyr-elf/lib/32/libc.a(libc_time_time.c.o): \ in function `time': time.c:(.text.time+0x11): undefined reference to `gettimeofday' ``` Update the dependency from CONFIG_POSIX_TIMERS to CONFIG_XSI_SINGLE_PROCESS for gettimeofday(). Note: this is really only a workaround. The proper solution would be to have libc functions not depend on POSIX functions. Specifically, here https://github.com/zephyrproject-rtos/picolibc/blob/\ 51a8b32857e75345c37652a80b5cda98b28d69e5/newlib/libc/time/\ time.c#L54 and here https://github.com/zephyrproject-rtos/zephyr/blob/\ 3a4e128/lib/libc/common/\ source/time/time.c#L17 Also mentioned in #89068 Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
jlbwoods
pushed a commit
to jlbwoods/zephyr
that referenced
this pull request
May 15, 2025
https://github.com/zephyrproject-rtos/zephyr/actions/runs/\ 15014534061/job/42189411225 We were seeing a linker error of the form ``` picolibc/x86_64-zephyr-elf/lib/32/libc.a(libc_time_time.c.o): \ in function `time': time.c:(.text.time+0x11): undefined reference to `gettimeofday' ``` Update the dependency from CONFIG_POSIX_TIMERS to CONFIG_XSI_SINGLE_PROCESS for gettimeofday(). Note: this is really only a workaround. The proper solution would be to have libc functions not depend on POSIX functions. Specifically, here https://github.com/zephyrproject-rtos/picolibc/blob/\ 51a8b32857e75345c37652a80b5cda98b28d69e5/newlib/libc/time/\ time.c#L54 and here https://github.com/zephyrproject-rtos/zephyr/blob/\ 3a4e128/lib/libc/common/\ source/time/time.c#L17 Also mentioned in zephyrproject-rtos#89068 Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
z_getenv()..z_setenv()convenience functionsenv-common.cz_clock_gettime()..convenience functions.clock_common.cxsi_single_processoption groupxsi_single_processoption groupxsi_single_processoption groupposix_clock_selectionoption groupposix_clock_selectiontestsuiteNotable Changes
gettimeofday()is moved to theXSI_SINGLE_PROCESSOption Group (which is according to spec)POSIX_SINGLE_PROCESSandPOSIX_TIMERSfromXSI_SINGLE_PROCESSXSI_SINGLE_PROCESSandPOSIX_SINGLE_PROCESSmoved to env-common.cXSI_SINGLE_PROCESS,POSIX_TIMERS, andPOSIX_CLOCK_SELECTIONmoved toclock-common.cNotable Observations
z_functions will get replaced at a later date when we have resolution of Drop z_ prefix as identifier for internal/private functions and revert back to _ #58007tests/lib/timeshould really be a part oftests/lib/c_libsince it tests thetime()C89 functionCONFIG_POSIX_TIMERSandCONFIG_XSI_SINGLE_PROCESStime()usesclock_gettime(), which is maybe fine if the assumption is that one is using POSIX or running on top of a POSIX OS anyway, but that's definitely not the case in Zephyr.z_clock_gettime()and similar functions in this PR could easily become a core part of Zephyr (i.e. promoted tok_clock_gettime()etc)asctime_r(),ctime_r(),gmtime_r(),localtime_r()should all probably be moved to POSIX_C_LANG_SUPPORT_R since they are not part of ISO C until C23, which is not yet proposed in RFC: C11 (or C17) requirement #30105CONFIG_STD_C23Should be merged after #89063, #89107