Skip to content

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented Oct 18, 2025

Deprecation of CONFIG_POSIX_API

Deprecate CONFIG_POSIX_API.

User may choose one of the pre-defined POSIX subprofiles, for simplicity.

Libraries should depend on CONFIG_POSIX_SYSTEM_INTERFACES as well as other POSIX Option Groups, as needed.

Custom Configurations

Of course, instead of, or in addition to, using a pre-defined POSIX subprofile, users can still fully customize their POSIX configuration via Kconfig.

Zephyr's POSIX Kconfig option names correspond 1:1 with official POSIX Option Group names. Simply add a CONFIG_ at the beginning of an Option Group to get the corresponding Kconfig option.

For more information on POSIX Subprofiling Option Groups, please see
https://pubs.opengroup.org/onlinepubs/9799919799/xrat/V4_subprofiles.html

Removal of zephyr/posix/ prefix for standard includes

The majority of the changes in this category (~156 files) are mechanical and are contained in the commit posix: remove zephyr/posix in header prefixes. They are approximately equivalent to running this command (with some adjustments).

FILE_LIST="$(grep "^#include.*zephyr/posix/" $(find * -name '*.c' -o -name '*.h') | awk '{split($0,a,":"); print a[1];}' | sort -u)"
sed -i -e 's|zephyr/posix/||g' $FILE_LIST

Originally from #97152, but included here for simplicity, these changes mean that we no longer need to have include/zephyr/posix in the library search path for C libraries that have (at least partially) conformant POSIX headers. In other words, we use the C library's POSIX headers.

  • Eliminates conflicts between Zephyr's POSIX headers and the libc headers
    • C library headers and types used as-is whenever possible
    • Still possible to "fix up" libc headers, as needed, via #include_next <foo.h>
    • It allows non-POSIX C libraries to also have POSIX support in Zephyr
  • Ensures that POSIX applications and libraries are actually portable at the source level and, in many cases, at the binary level
  • Paves the way for Zephyr's POSIX implementation to become a module

Originally added to mitigate C-library conflicts, the <zephyr/posix/...h> prefix on standard includes has been a thorn in our sides for several years. Since these changes remove the conflicts, opting to use C-library headers (if they exist), we no longer need to namespace those in Zephyr.

Depends on

Note

Compliance issues are false positives

Fixes #97949

@github-actions
Copy link

github-actions bot commented Oct 19, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hostap zephyrproject-rtos/hostap@3ec675b zephyrproject-rtos/hostap@ab7630c (main) zephyrproject-rtos/[email protected]

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-hostap DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Oct 19, 2025
@stephanosio stephanosio assigned cfriedt and unassigned stephanosio Oct 19, 2025
@cfriedt cfriedt force-pushed the deprecate-config-posix-api branch 2 times, most recently from b9dac21 to dc6abc8 Compare October 19, 2025 01:36
@cfriedt
Copy link
Member Author

cfriedt commented Oct 19, 2025

  • rebased

This change mitigates some code sonar issues (from SonarQube).

1. explicit 'U' after 0xffffffff

> A cast shall not remove any const or volatile qualification from the
> type of a pointer or reference c:S859

2. check return value from call to pthread_barrierattr_getpshared()

> Unused assignments should be removed c:S1854

Signed-off-by: Chris Friedt <[email protected]>
This mitigates a sonarqube warning

"Value stored to 'cvalue' is never read"

> Unused assignments should be removed c:S1854

https://sonarcloud.io/project/issues?pullRequest=97152&\
open=AZnAZi4C7BgzESPFIGwf&id=zephyrproject-rtos_zephyr

Signed-off-by: Chris Friedt <[email protected]>
This change mitigates a sonarqube warning about uninitialized variables.

"1st function call argument is an uninitialized value"

> Variables should be initialized before use c:S836

https://sonarcloud.io/project/issues?pullRequest=97152&\
open=AZnAZi0m7BgzESPFIGwe&id=zephyrproject-rtos_zephyr

Signed-off-by: Chris Friedt <[email protected]>
If C libraries provide conformant POSIX headers, then use the headers
provided by the C library.

Otherwise, C library maintainers may add `include/zephyr/posix` to their
standard search path.

Signed-off-by: Chris Friedt <[email protected]>
This change removes the requirement to have `<zephyr/posix/...>` prefixing
all standard POSIX includes in Zephyr.

The main reason that it was required was due to conflicts between C
library time.h, signal.h and the fact that Zephyr posix headers were being
somewhat ad-hoc mixed with libc posix headers.

Now, any (even partially) POSIX-conformant C libraries are expected to
provide their own types, constants, and headers, and Zephyr's
implementation uses those definitions.

If any definitions are missing, we define them on a per-libc basis. This
can also be done out-of-tree, which allows for implementors to take
advantage of the `CONFIG_TC_PROVIDES_POSIX..` options.

This is likely the last major commit required before we deprecate the
`CONFIG_POSIX_API` Kconfig option in favour of POSIX subprofiling \o/

Signed-off-by: Chris Friedt <[email protected]>
Additional workarounds for POSIX compatibility with the arcmwdt
toolchain.

This commit addresses issues described in the comment linked below.

https://github.com/zephyrproject-rtos/zephyr/pull/97152#\
issuecomment-3409956230

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt cfriedt force-pushed the deprecate-config-posix-api branch from e17271c to 88f9291 Compare October 23, 2025 17:27
@cfriedt
Copy link
Member Author

cfriedt commented Oct 23, 2025

Fixed, and rebased to avoid merge conflicts.

@cfriedt cfriedt requested review from nordicjm and ycsin October 23, 2025 17:29
@cfriedt
Copy link
Member Author

cfriedt commented Oct 23, 2025

@nordicjm - in case you are interested, the commit that resolves your issue is here.
88f9291 (#97855)

Please review and remove your nack. Thanks

@cfriedt cfriedt requested a review from jukkar October 23, 2025 17:31
jukkar
jukkar previously approved these changes Oct 23, 2025
@cfriedt cfriedt removed the TSC Topics that need TSC discussion label Oct 23, 2025
jhedberg
jhedberg previously approved these changes Oct 23, 2025
Include standard headers for POSIX types and functions instead of making
implicit declarations.

Signed-off-by: Chris Friedt <[email protected]>
Remove the duplicate Kconfig option `CONFIG_POSIX_SYSTEM_INTERFACES` in
`lib/posix/Kconfig.profile` that shadows the option in
`lib/posix/Kconfig`.

Signed-off-by: Chris Friedt <[email protected]>
Remove usage of CONFIG_POSIX_API.

Signed-off-by: Chris Friedt <[email protected]>
This change deprecates the Kconfig option `CONFIG_POSIX_API`.

It is slated for removal in Zephyr v4.5.0.

Signed-off-by: Chris Friedt <[email protected]>
Add release notes about the deprecation of CONFIG_POSIX_API.

User should instead use one of the pre-defined POSIX subprofiles

CONFIG_POSIX_AEP_CHOICE_BASE
CONFIG_POSIX_AEP_CHOICE_PSE51
CONFIG_POSIX_AEP_CHOICE_PSE52
CONFIG_POSIX_AEP_CHOICE_PSE53

and libraries should depend on CONFIG_POSIX_SYSTEM_INTERFACES as well as
other POSIX Option Groups, as needed.

For more information, please see

https://pubs.opengroup.org/onlinepubs/9799919799/xrat/V4_subprofiles.html

Signed-off-by: Chris Friedt <[email protected]>
The specification requires that unistd.h (or a file that is included via
unistd.h) declare version macros and feature test macros.

Feature test macros declarations are also removed from
`lib/posix/options/CMakeLists.txt`.

Closes zephyrproject-rtos#97949

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt cfriedt dismissed stale reviews from jhedberg and jukkar via 9fa199e October 23, 2025 20:20
@cfriedt cfriedt force-pushed the deprecate-config-posix-api branch from 88f9291 to 9fa199e Compare October 23, 2025 20:20
@cfriedt
Copy link
Member Author

cfriedt commented Oct 23, 2025

@github-actions github-actions bot removed the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Oct 23, 2025
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

posix: implementation conformance macros defined on command line instead of in unistd.h

8 participants