Skip to content

WIP: move time.h to common libc #94876

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
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented Aug 22, 2025

This is just a work in progress to see if the POSIX AEP PR will pass with additional changes to time.h

@cfriedt cfriedt force-pushed the add-zephyr-posix-aep-choice-v2 branch 2 times, most recently from 09fa0ed to 23a398f Compare August 22, 2025 16:38
cfriedt added 11 commits August 22, 2025 12:38
In order to reduce conflicts with limits defined in external C libraries,
move Zephyr's POSIX limits from posix_features.h to limits.h in the
common C library sources.

In order to give the implementation better control over where POSIX
limit definitions originate, use `#include_next <limits.h>` to pull in
the corresponding header of the C library, and provide a non-user
configurable option `CONFIG_TC_PROVIDES_POSIX_LIMIT_DEFS` that may be set
in order to ensure that the C library version of POSIX limits are used.

Note: this may mean that runtime invariant values are inconsistent with
parts that are actually in use within Zephyr, so applications are
encouraged to use `sysconf()` with external C libraries that implement
parts of the POSIX standard to query system configuration values at
runtime.

Signed-off-by: Chris Friedt <[email protected]>
Remove duplicate limits.h headers for multiple libc's and use a common one.

Signed-off-by: Chris Friedt <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Default POSIX_AEP_CHOICE to POSIX_AEP_CHOICE_ZEPHYR

Signed-off-by: Chris Friedt <[email protected]>
Add zephyr-keep-sorted-start and zephyr-keep-sorted-stop
comments.

Signed-off-by: Chris Friedt <[email protected]>
Introduce CONFIG_TC_PROVIDES_POSIX_TIME_DEFS which indicates whether the
libc-provided time.h includes definitions and declarations required for
POSIX comnformance.

Signed-off-by: Chris Friedt <[email protected]>
Use the realtime clock, since that is always guaranteed to be available
with _POSIX_TIMERS.

Signed-off-by: Chris Friedt <[email protected]>
Define _POSIX_TIMERS=200809L when so configured.

This change is required to ensure that Newlib provides the necessary POSIX
timer API definitions in toolchain headers.

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt cfriedt force-pushed the add-zephyr-posix-aep-choice-v2 branch from 23a398f to 612a0f9 Compare August 22, 2025 16:38
Copy link

Please retry analysis of this Pull-Request directly on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant