Skip to content

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented Apr 12, 2025

  • eventfd: bring config to top-level of posix dir, since it is not posix
  • posix: separate option groups into c library ext and system interfaces
  • posix: c_lib_ext: apply clang-format to getopt sources
  • posix: profiles: add custom Zephyr POSIX subprofile
  • posix: profiles: make POSIX_AEP_CHOICE_ZEPHYR the default
  • posix: options: add keep-sorted-start and -stop

Fixes #75843

Should only be merged after

Note

The sources used when CONFIG_POSIX_C_LANG_SUPPORT_R=y and CONFIG_POSIX_C_LIB_EXT=y can still be
overridden with CONFIG_TC_PROVIDES_POSIX_C_LANG_SUPPORT_R=y an CONFIG_TC_PROVIDES_POSIX_C_LIB_EXT=y (which must be used with select <option> in Kconfig), as they are primarily meant for toolchain maintainers.

A comparison when building samples/hello_world for native_sim.

Before:

wc -l build-main/zephyr/.config
   1295 build-main/zephyr/.config

After:

wc -l build-branch/zephyr/.config
   1220 build-branch/zephyr/.config
diff -Nua build-{main,branch}/zephyr/.config
--- build-main/zephyr/.config   2025-05-24 11:33:53.697011215 -0400
+++ build-branch/zephyr/.config 2025-05-24 11:34:27.140913656 -0400
@@ -900,98 +900,23 @@
 #
 # POSIX API Support
 #
-
-#
-# POSIX Options
-#
 # CONFIG_POSIX_API is not set
-CONFIG_POSIX_AEP_CHOICE_NONE=y
-# CONFIG_POSIX_AEP_CHOICE_BASE is not set
-# CONFIG_POSIX_AEP_CHOICE_PSE51 is not set
-# CONFIG_POSIX_AEP_CHOICE_PSE52 is not set
-# CONFIG_POSIX_AEP_CHOICE_PSE53 is not set
-# CONFIG_POSIX_ASYNCHRONOUS_IO is not set
-# CONFIG_POSIX_BARRIERS is not set
-# CONFIG_POSIX_C_LANG_SUPPORT_R is not set
-# CONFIG_POSIX_C_LIB_EXT is not set
-
-#
-# POSIX device I/O
-#
-# CONFIG_POSIX_DEVICE_IO is not set
-CONFIG_POSIX_OPEN_MAX=4
-# end of POSIX device I/O
-
-# CONFIG_POSIX_FD_MGMT is not set
-# CONFIG_POSIX_FILE_SYSTEM_R is not set
-# CONFIG_POSIX_FILE_SYSTEM is not set
-
-#
-# POSIX memory
-#
-CONFIG_POSIX_PAGE_SIZE=0x40
-# CONFIG_POSIX_SHARED_MEMORY_OBJECTS is not set
-# CONFIG_POSIX_MAPPED_FILES is not set
-# CONFIG_POSIX_MEMORY_PROTECTION is not set
-# end of POSIX memory
-
-# CONFIG_POSIX_MESSAGE_PASSING is not set
-# CONFIG_POSIX_SINGLE_PROCESS is not set
-# CONFIG_POSIX_MULTI_PROCESS is not set
-# CONFIG_POSIX_THREADS is not set
-# CONFIG_POSIX_READER_WRITER_LOCKS is not set
-
-#
-# POSIX scheduler options
-#
-# CONFIG_POSIX_PRIORITY_SCHEDULING is not set
-# end of POSIX scheduler options
-
-# CONFIG_POSIX_SEMAPHORES is not set
-
-#
-# POSIX signals
-#
-# CONFIG_POSIX_REALTIME_SIGNALS is not set
-# CONFIG_POSIX_SIGNALS is not set
-# end of POSIX signals
-
-# CONFIG_POSIX_SPIN_LOCKS is not set
-
-#
-# POSIX synchronized I/O
-#
-# CONFIG_POSIX_FSYNC is not set
-# CONFIG_POSIX_SYNCHRONIZED_IO is not set
-# end of POSIX synchronized I/O
-
-# CONFIG_POSIX_TIMERS is not set
-
-#
-# X/Open system interfaces
-#
-# CONFIG_XSI_REALTIME is not set
-# CONFIG_XSI_SINGLE_PROCESS is not set
-# CONFIG_XOPEN_STREAMS is not set
-# CONFIG_XSI_SYSTEM_LOGGING is not set
-# CONFIG_XSI_THREADS_EXT is not set
-# end of X/Open system interfaces
-
-#
-# Miscellaneous POSIX-related options
-#
-# CONFIG_EVENTFD is not set
-# end of Miscellaneous POSIX-related options
-
+# CONFIG_POSIX_AEP_CHOICE_NONE is not set
+CONFIG_POSIX_AEP_CHOICE_ZEPHYR=y
 CONFIG_TC_PROVIDES_POSIX_C_LANG_SUPPORT_R=y
-# end of POSIX Options
 
 #
-# POSIX Shell Utilities
+# POSIX C Library Extensions
 #
-# end of POSIX Shell Utilities
+CONFIG_POSIX_C_LANG_SUPPORT_R=y
+CONFIG_POSIX_C_LIB_EXT=y
+# CONFIG_GETOPT_LONG is not set
+# end of POSIX C Library Extensions
+
+# CONFIG_POSIX_SYSTEM_INTERFACES is not set
 # end of POSIX API Support
 
+# CONFIG_EVENTFD is not set
 # CONFIG_OPENAMP_RSC_TABLE is not set
 # CONFIG_SMF is not set
 CONFIG_LIBGCC_RTLIB=y

@cfriedt cfriedt force-pushed the add-zephyr-posix-aep-choice branch from 0d193e5 to f68b0fb Compare April 12, 2025 12:31
@cfriedt cfriedt requested review from nashif, JordanYates and ycsin April 12, 2025 12:37
@cfriedt cfriedt added the area: POSIX POSIX API Library label Apr 12, 2025
@cfriedt
Copy link
Member Author

cfriedt commented Apr 12, 2025

Probably one or two follow-up PRs can be made to ensure that the POSIX_C_LIB_EXT Option Group is complete. I think there are some string manipulation functions missing (not ISO C).

Currently, all of the implementation of POSIX_C_LANG_SUPPORT_R is done in libc/common, which ... doesn't matter too much, but that could be corrected later if necessary.

@cfriedt
Copy link
Member Author

cfriedt commented Apr 14, 2025

Shell utilities should probably also be gated by the new Kconfig.

Copy link
Member

@jukkar jukkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Chris, this helps to understand what is going on with the POSIX options.

@cfriedt cfriedt force-pushed the add-zephyr-posix-aep-choice branch 5 times, most recently from db9804b to 2ca347b Compare April 25, 2025 03:31
@cfriedt cfriedt force-pushed the add-zephyr-posix-aep-choice branch 2 times, most recently from aeb78be to 7ac5797 Compare April 29, 2025 01:15
@cfriedt
Copy link
Member Author

cfriedt commented May 14, 2025

I'll give this a rebase shorty

@cfriedt cfriedt force-pushed the add-zephyr-posix-aep-choice branch 3 times, most recently from 04b8fa8 to df478b2 Compare May 18, 2025 03:52
@cfriedt
Copy link
Member Author

cfriedt commented Aug 31, 2025

  • rebased and split out a few additional PRs

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]>
The getopt sources were not formatted according to our codying style
conventions, so apply formatting rules as a separate commit.

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]>
@cfriedt cfriedt force-pushed the add-zephyr-posix-aep-choice branch from 6fb04ad to 0756a62 Compare October 3, 2025 19:15
Copy link

sonarqubecloud bot commented Oct 3, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Base OS Base OS Library (lib/os) area: C Library C Standard Library area: LWM2M area: Networking area: POSIX POSIX API Library area: Process area: Samples Samples area: Utilities Release Notes To be mentioned in the release notes
Projects
Status: 4.3
Development

Successfully merging this pull request may close these issues.

POSIX kconfigs show up although POSIX APIs is not being used
4 participants