Skip to content

Commit b2d5065

Browse files
committed
posix: separate option groups into c library ext and system interfaces
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]>
1 parent 012ffd3 commit b2d5065

File tree

18 files changed

+68
-43
lines changed

18 files changed

+68
-43
lines changed

lib/posix/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
add_subdirectory(options)
43
add_subdirectory_ifdef(CONFIG_EVENTFD eventfd)
4+
add_subdirectory_ifdef(CONFIG_POSIX_C_LANG_SUPPORT_R c_lang_support_r)
5+
add_subdirectory_ifdef(CONFIG_POSIX_C_LIB_EXT c_lib_ext)
56
add_subdirectory_ifdef(CONFIG_POSIX_SHELL shell)
7+
add_subdirectory_ifdef(CONFIG_POSIX_SYSTEM_INTERFACES options)

lib/posix/Kconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,43 @@
11
# Copyright (c) 2024 Meta
2+
# Copyright (c) 2025 Tenstorrent AI ULC
23
#
34
# SPDX-License-Identifier: Apache-2.0
45

56
menu "POSIX API Support"
67

8+
# POSIX Subprofile Definitions
9+
rsource "Kconfig.profile"
10+
11+
# Toolchain hooks for external implementations
12+
rsource "Kconfig.toolchain"
13+
14+
# POSIX C Library Extensions
15+
# This menu is for POSIX Option Groups that do not require OS support.
16+
menu "POSIX C Library Extensions"
17+
rsource "c_lang_support_r/Kconfig"
18+
rsource "c_lib_ext/Kconfig"
19+
endmenu
20+
21+
# POSIX System Interfaces
22+
menuconfig POSIX_SYSTEM_INTERFACES
23+
bool "POSIX System Interfaces"
24+
depends on !NATIVE_APPLICATION
25+
select NATIVE_LIBC_INCOMPATIBLE
26+
help
27+
Select 'y' here to support POSIX System Interfaces within Zephyr.
28+
29+
Options in this menu are organized by POSIX subprofiling Option Group.
30+
31+
For more information, see
32+
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
33+
34+
35+
if POSIX_SYSTEM_INTERFACES
736
rsource "options/Kconfig"
37+
38+
# POSIX Shell utilities
839
rsource "shell/Kconfig"
40+
endif
941

1042
endmenu
1143

lib/posix/options/Kconfig.profile renamed to lib/posix/Kconfig.profile

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
config POSIX_API
6-
bool "POSIX APIs"
7-
depends on !NATIVE_APPLICATION
8-
select NATIVE_LIBC_INCOMPATIBLE
6+
bool "POSIX API (legacy)"
7+
select POSIX_SYSTEM_INTERFACES
98
select POSIX_BASE_DEFINITIONS # clock_gettime(), pthread_create(), sem_get(), etc
109
select POSIX_AEP_REALTIME_MINIMAL # CLOCK_MONOTONIC, pthread_attr_setstack(), etc
1110
select POSIX_NETWORKING if NETWORKING # inet_ntoa(), socket(), etc
@@ -31,14 +30,13 @@ choice POSIX_AEP_CHOICE
3130
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
3231

3332
config POSIX_AEP_CHOICE_NONE
34-
bool "No pre-defined POSIX subprofile"
33+
bool "No POSIX subprofile"
3534
help
36-
No pre-defined POSIX profile is selected.
35+
No POSIX subprofile is selected.
3736

3837
config POSIX_AEP_CHOICE_BASE
39-
bool "Base definitions (system interfaces)"
40-
depends on !NATIVE_APPLICATION
41-
select NATIVE_LIBC_INCOMPATIBLE
38+
bool "Minimal POSIX System Profile"
39+
depends on POSIX_SYSTEM_INTERFACES
4240
select POSIX_BASE_DEFINITIONS
4341
help
4442
Only enable the base definitions required for all POSIX systems.
@@ -48,8 +46,7 @@ config POSIX_AEP_CHOICE_BASE
4846

4947
config POSIX_AEP_CHOICE_PSE51
5048
bool "Minimal Realtime System Profile (PSE51)"
51-
depends on !NATIVE_APPLICATION
52-
select NATIVE_LIBC_INCOMPATIBLE
49+
depends on POSIX_SYSTEM_INTERFACES
5350
select POSIX_BASE_DEFINITIONS
5451
select POSIX_AEP_REALTIME_MINIMAL
5552
help
@@ -62,8 +59,7 @@ config POSIX_AEP_CHOICE_PSE51
6259

6360
config POSIX_AEP_CHOICE_PSE52
6461
bool "Realtime Controller System Profile (PSE52)"
65-
depends on !NATIVE_APPLICATION
66-
select NATIVE_LIBC_INCOMPATIBLE
62+
depends on POSIX_SYSTEM_INTERFACES
6763
select POSIX_BASE_DEFINITIONS
6864
select POSIX_AEP_REALTIME_MINIMAL
6965
select POSIX_AEP_REALTIME_CONTROLLER
@@ -77,8 +73,7 @@ config POSIX_AEP_CHOICE_PSE52
7773

7874
config POSIX_AEP_CHOICE_PSE53
7975
bool "Dedicated Realtime System Profile (PSE53)"
80-
depends on !NATIVE_APPLICATION
81-
select NATIVE_LIBC_INCOMPATIBLE
76+
depends on POSIX_SYSTEM_INTERFACES
8277
select POSIX_BASE_DEFINITIONS
8378
select POSIX_AEP_REALTIME_MINIMAL
8479
select POSIX_AEP_REALTIME_CONTROLLER
@@ -95,7 +90,9 @@ config POSIX_AEP_CHOICE_PSE53
9590

9691
endchoice # POSIX_AEP_CHOICE
9792

98-
# Base Definitions (System Interfaces)
93+
if POSIX_SYSTEM_INTERFACES
94+
95+
# Mandatory POSIX System Interfaces (base profile)
9996
config POSIX_BASE_DEFINITIONS
10097
bool
10198
select POSIX_ASYNCHRONOUS_IO
@@ -183,3 +180,5 @@ config POSIX_AEP_REALTIME_DEDICATED
183180

184181
For more information, please see
185182
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
183+
184+
endif # POSIX_SYSTEM_INTERFACE
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# intentionally empty
File renamed without changes.

lib/posix/c_lib_ext/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
zephyr_include_directories(getopt)
4+
5+
if (CONFIG_TC_PROVIDES_POSIX_C_LIB_EXT)
6+
return()
7+
endif()
8+
9+
zephyr_library()
10+
zephyr_library_sources(
11+
fnmatch.c
12+
getentropy.c
13+
getopt/getopt.c
14+
getopt/getopt_common.c
15+
)
16+
17+
zephyr_library_sources_ifdef(CONFIG_GETOPT_LONG getopt/getopt_long.c)
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)