-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Open
Labels
RFCRequest For Comments: want input from the communityRequest For Comments: want input from the communityarea: Networkingarea: POSIXPOSIX API LibraryPOSIX API Library
Description
Problem Description
Our coding guidelines limit what C library functions Zephyr code may use:
https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#rule-a-5-c-standard-library-usage-restrictions-in-zephyr-codebase
Today the networking code is using some extensions beyond this. This either limits the C library which can be used to one which supports this extensions, or requires enabling the POSIX_API subsystem (which should not be required by core Zephyr code).
Proposed Change
One way forward/option would be that
- We locate all offending uses (for ex. after Networking subsystem should not (re)define C library types, macros or functions #97050 is solved, we (locally) build the networking subsystem ensuring we disable the POSIX subsystem and do not enable any of the feature test macros to enable extensions and see what breaks).
- We add to this RFC the list of all offenders, and once we have done that we decide how to proceed for each.
- Options may be to either:
a) Eliminate the use where it can be replaced simply enough with standard functionality
b) Accept that particular function use as an extra exception to ruleRule A.5: C, and provide it as an option from the common libc, which C libraries can enable if needed.
c) Accept that particular function use, which is used from the POSIX subsystem if not provided by the C library, but ensure it is a clearly separate component which then networking would enable thru kconfig (without enabling/pulling anything else).
d) ...
(Added 2025/10/31..) Known so far:
- https://github.com/zephyrproject-rtos/zephyr/blob/main/subsys/net/lib/http/http_server_core.c#L781
utilizesfnmatch()which is a POSIX.1-2008, andFNM_LEADING_DIRwhich is a further GNU extension on this. - Zephyr's not standard
getopt*: Zephyr's "getopt" should become a separate component #98568 - eventfd: Way forward: Fix uses in core net code by using underlaying zvfs_eventfd
- Includes of unistd.h: Seem unnecessary. => We remove
#include <unistd.h>lines from core net code. - Uses of flags from fcntl.h: We have ZVFS_ prefixed versions we can use
- Hostapp and WIFI_NM_WPA_SUPPLICANT using it. Most sensible way forward seems to be to accept it.
- Basic net samples like echo_client/server using posix interface instead of zephyr zsock_ interface
Dependencies
Networking, C library, POSIX_API/POSIX compatibility layer subsystem.
Additional info
This is related to but it is not the same than:
Metadata
Metadata
Labels
RFCRequest For Comments: want input from the communityRequest For Comments: want input from the communityarea: Networkingarea: POSIXPOSIX API LibraryPOSIX API Library
Type
Projects
Status
No status