-
Notifications
You must be signed in to change notification settings - Fork 7.4k
posix: c_lib_ext: complete the POSIX_C_LIB_EXT Option Group #90449
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
Draft
cfriedt
wants to merge
21
commits into
zephyrproject-rtos:main
Choose a base branch
from
cfriedt:implement-c-lib-ext
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+872
−322
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
Additional entries for the sys_clock API, comprised of: * sys_clock_gettime() * sys_clock_settime() * sys_clock_nanosleep() along with the constants * SYS_CLOCK_REALTIME * SYS_CLOCK_MONOTONIC * SYS_TIMER_ABSTIME The primary motivation for this API is so that libc and other libraries have a familiar-enough API to reach to when POSIX is not available, since POSIX is optional in Zephyr. By adding this API to lib/os, we also eliminate dependency cycles between libc and posix, as lib/os is a mutual dependency. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add bullets to release notes for sys_clock_gettime(), sys_clock_settime(), and sys_clock_nanosleep(). These changes were significant, as they make timekeeping dependencies more independent between libc and posix, and remove several unnecessary dependencies on posix for ISO C library routines. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Remove POSIX clock_gettime() from the common libc time implementation, since POSIX should not be a dependency for ISO C. Instead, use the newly added lib/os sys_clock API. Specifically, sys_clock_gettime(). Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Use the implementation of time() from the common libc, since there it no longer pulls in POSIX. Use is implied for minimal, newlib, and picolibc, and selected for IAR. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Reduce the dependency on POSIX by taking advantage of the newly added sys_clock_nanosleep(). Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The C standard does not guarantee that `thrd_success` is equal to zero, so ensure that the test takes that into account. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The specification does not say that the first struct timespec passed to thrd_sleep() may be NULL. Preserving the testpoint so that a possible future testsuite can be run that expects faults to occur when undefined behaviour is used. Faults are one possible solution to handling undefined behaviour, but it would be good to come to a concensus about how that should be handled in Zephyr for standard function calls belonging to ISO C or POSIX. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Use `timespec_from_timeout(K_MSEC(msec), &ts)` instead of leaning on lazily-crafted timespecs with invalid tv_nsec fields. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Presumably the time testsuite was separate from the c library set of testsuites because it had a depedency on POSIX. Since that dependency no longer exists, colocate the time testsuite with the other c library testsuites. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Use the newly added sys_clock API in lib/os for * clock_gettime() * clock_settime() * clock_nanosleep() and nanosleep() * gettimeofday() Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The ISO C function time() should not depend on POSIX and this was corrected recently via the common libc time() implementation. Remove this dependency from the network subsystem where it has been unduly needed for some time. Similarly, XSI_SINGLE_PROCESS was a dependency for time() via picolibc, because the time() implementation in picolibc relies on the POSIX gettimeofday() call. However, since Zephyr's common libc time() implementation no longer depends on that, it can be removed as a dependency in the network subsystem as well. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Remove POSIX_TIMERS and XSI_SINGLE_PROCESS dependencies from the aws cloud sample and the lwm2m client sample, as they are no longer required. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The eventfd configuration does not need to be so deeply nested within POSIX since it does not depend on POSIX completely. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Separate the POSIX implementation into two categories: - Extensions to ISO C - System Interfaces The first category include standalone functions that generally do not require OS support or depend on any other features within the POSIX specification. The Option Groups that comprise this category include - POSIX_C_LIB_EXT: e.g. strnlen(), fnmatch() - POSIX_C_LANG_SUPPORT_R: e.g. gmtime_r(), strtok_r() The second category includes the majority of other POSIX Option Groups that do require OS support. The latter group may also be categorized generally as being NATIVE_LIBC_INCOMPATIBLE, although that might eventually become more granular. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add a custom Zephyr POSIX subprofile specifically for enabling the default features that Zephyr requires as per the coding guidelines. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Default POSIX_AEP_CHOICE to POSIX_AEP_CHOICE_ZEPHYR Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add zephyr-keep-sorted-start and zephyr-keep-sorted-stop comments. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Use the logging Kconfig template to facilitate a configurable log level for getopt() and friends. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The getsubopt() function is required as part of the POSIX_C_LIB_EXT option group. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
02a72f0
to
dc3882e
Compare
Add tests for getsubopt(). Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add the string handling functions stpcpy(), stpncpy(), strcasecmp(), strncasecmp(), strdup(), strndup(), and strnlen(). Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
dc3882e
to
9993eb9
Compare
|
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.
Complete the POSIX_C_LIB_EXT Option Group with the addition of getsubopt(), stpcpy(), stpncpy(), strcasecmp(), strdup(), strfmon(), strncasecmp(), strndup(), strnlen()