diff --git a/lib/posix/CMakeLists.txt b/lib/posix/CMakeLists.txt index c8d836f5846..fed728c17ba 100644 --- a/lib/posix/CMakeLists.txt +++ b/lib/posix/CMakeLists.txt @@ -1,69 +1,4 @@ # SPDX-License-Identifier: Apache-2.0 -set(GEN_DIR ${ZEPHYR_BINARY_DIR}/include/generated) - -zephyr_syscall_header( - posix_clock.h -) - -zephyr_interface_library_named(posix_subsys) - -if(CONFIG_POSIX_API) - zephyr_include_directories(${ZEPHYR_BASE}/include/zephyr/posix) -endif() - -if(CONFIG_POSIX_SIGNAL) - set(STRSIGNAL_TABLE_H ${GEN_DIR}/posix/strsignal_table.h) - - add_custom_command( - OUTPUT ${STRSIGNAL_TABLE_H} - COMMAND - ${PYTHON_EXECUTABLE} - ${ZEPHYR_BASE}/scripts/build/gen_strsignal_table.py - -i ${ZEPHYR_BASE}/include/zephyr/posix/signal.h - -o ${STRSIGNAL_TABLE_H} - DEPENDS ${ZEPHYR_BASE}/include/zephyr/posix/signal.h - ) -endif() - -if(CONFIG_POSIX_API OR CONFIG_PTHREAD_IPC OR CONFIG_POSIX_CLOCK OR - CONFIG_POSIX_MQUEUE OR CONFIG_POSIX_FS OR CONFIG_EVENTFD OR CONFIG_GETOPT) - # This is a temporary workaround so that Newlib declares the appropriate - # types for us. POSIX features to be formalized as part of #51211 - zephyr_compile_options($<$:-D_POSIX_THREADS>) - zephyr_compile_options($<$:-D_POSIX_THREADS>) -endif() - -zephyr_library() -add_subdirectory_ifdef(CONFIG_GETOPT getopt) -add_subdirectory_ifdef(CONFIG_SHELL shell) -zephyr_library_sources_ifdef(CONFIG_EVENTFD eventfd.c) -zephyr_library_sources_ifdef(CONFIG_FNMATCH fnmatch.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_API perror.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK clock.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK nanosleep.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK sleep.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_FS fs.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_MQUEUE mqueue.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_SIGNAL signal.c ${STRSIGNAL_TABLE_H}) -zephyr_library_sources_ifdef(CONFIG_POSIX_UNAME uname.c) -zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC _common.c) -zephyr_library_sources_ifdef(CONFIG_PTHREAD_BARRIER barrier.c) -zephyr_library_sources_ifdef(CONFIG_PTHREAD_COND cond.c) -zephyr_library_sources_ifdef(CONFIG_PTHREAD_KEY key.c) -zephyr_library_sources_ifdef(CONFIG_PTHREAD_MUTEX mutex.c) -zephyr_library_sources_ifdef(CONFIG_PTHREAD pthread.c) -zephyr_library_sources_ifdef(CONFIG_PTHREAD_RWLOCK rwlock.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_PRIORITY_SCHEDULING sched.c) -zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC semaphore.c) -zephyr_library_sources_ifdef(CONFIG_PTHREAD_SPINLOCK spinlock.c) -zephyr_library_sources_ifdef(CONFIG_TIMER timer.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_PUTMSG stropts.c) - -zephyr_library_include_directories( - ${ZEPHYR_BASE}/kernel/include - ${ARCH_DIR}/${ARCH}/include -) - -zephyr_library_link_libraries(posix_subsys) -zephyr_library_property(ALLOW_EMPTY TRUE) +add_subdirectory(options) +add_subdirectory(shell) diff --git a/lib/posix/Kconfig b/lib/posix/Kconfig index b2f379be8d1..534baf08cd2 100644 --- a/lib/posix/Kconfig +++ b/lib/posix/Kconfig @@ -1,82 +1,10 @@ -# Copyright (c) 2018 Intel Corporation -# Copyright (c) 2023 Meta +# Copyright (c) 2024 Meta # # SPDX-License-Identifier: Apache-2.0 menu "POSIX API Support" -config POSIX_MAX_FDS - int "Maximum number of open file descriptors" - default 16 if WIFI_NM_WPA_SUPPLICANT - default 16 if POSIX_API - default 4 - help - Maximum number of open file descriptors, this includes - files, sockets, special devices, etc. - -config POSIX_API - depends on !NATIVE_APPLICATION - bool "POSIX APIs" - help - Enable mostly-standards-compliant implementations of - various POSIX (IEEE 1003.1) APIs. - -# The name of this option is mandated by zephyr_interface_library_named -# cmake directive. -config APP_LINK_WITH_POSIX_SUBSYS - bool "Make POSIX headers available to application" - default y - depends on POSIX_API - help - Add POSIX subsystem header files to the 'app' include path. - -config PTHREAD_IPC - bool "POSIX pthread IPC API" - default y if POSIX_API - depends on POSIX_CLOCK - help - This enables a mostly-standards-compliant implementation of - the pthread mutex, condition variable and barrier IPC - mechanisms. - -config POSIX_SYSCONF - bool "Support for sysconf" - default y if POSIX_API - help - The sysconf() function provides a method for the application to determine - the current value of a configurable system limit or option (variable). - -config POSIX_PAGE_SIZE_BITS - int "Number of bits to use for PAGE_SIZE" - range 6 16 - default 12 if POSIX_API - default 6 - help - Define PAGE_SIZE as BIT(n), where n is the value configured here. - PAGE_SIZE is supported in the range [64, 65536] - If CONFIG_POSIX_API=y, PAGE_SIZE defaults to 4096, otherwise, it is 64 bytes. - -source "lib/posix/Kconfig.barrier" -source "lib/posix/Kconfig.clock" -source "lib/posix/Kconfig.cond" -source "lib/posix/Kconfig.eventfd" -source "lib/posix/Kconfig.fnmatch" -source "lib/posix/Kconfig.fs" -source "lib/posix/Kconfig.getopt" -source "lib/posix/Kconfig.key" -source "lib/posix/Kconfig.limits" -source "lib/posix/Kconfig.mqueue" -source "lib/posix/Kconfig.mutex" -source "lib/posix/Kconfig.pthread" -source "lib/posix/Kconfig.rwlock" -source "lib/posix/Kconfig.sched" -source "lib/posix/Kconfig.semaphore" -source "lib/posix/Kconfig.signal" -source "lib/posix/Kconfig.spinlock" -source "lib/posix/Kconfig.timer" -source "lib/posix/Kconfig.uname" -source "lib/posix/Kconfig.stropts" - +rsource "options/Kconfig" rsource "shell/Kconfig" endmenu # "POSIX API Support" diff --git a/lib/posix/Kconfig.limits b/lib/posix/Kconfig.limits deleted file mode 100644 index cc651203961..00000000000 --- a/lib/posix/Kconfig.limits +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2023 Meta -# -# SPDX-License-Identifier: Apache-2.0 - -if POSIX_SIGNAL -config POSIX_LIMITS_RTSIG_MAX - int "_POSIX_RTSIG_MAX value in limits.h" - default 8 - help - Define the _POSIX_RTSIG_MAX value in limits.h. - IEEE 1003.1 defines this to be 8. - -endif diff --git a/lib/posix/options/CMakeLists.txt b/lib/posix/options/CMakeLists.txt new file mode 100644 index 00000000000..b523e859e86 --- /dev/null +++ b/lib/posix/options/CMakeLists.txt @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: Apache-2.0 + +set(GEN_DIR ${ZEPHYR_BINARY_DIR}/include/generated) + +zephyr_syscall_header( + posix_clock.h +) + +zephyr_interface_library_named(posix_subsys) + +if(CONFIG_POSIX_API) + zephyr_include_directories(${ZEPHYR_BASE}/include/zephyr/posix) +endif() + +if(CONFIG_POSIX_SIGNAL) + set(STRSIGNAL_TABLE_H ${GEN_DIR}/posix/strsignal_table.h) + + add_custom_command( + OUTPUT ${STRSIGNAL_TABLE_H} + COMMAND + ${PYTHON_EXECUTABLE} + ${ZEPHYR_BASE}/scripts/build/gen_strsignal_table.py + -i ${ZEPHYR_BASE}/include/zephyr/posix/signal.h + -o ${STRSIGNAL_TABLE_H} + DEPENDS ${ZEPHYR_BASE}/include/zephyr/posix/signal.h + ) +endif() + +if(CONFIG_POSIX_API OR CONFIG_PTHREAD_IPC OR CONFIG_POSIX_CLOCK OR + CONFIG_POSIX_MQUEUE OR CONFIG_POSIX_FS OR CONFIG_EVENTFD OR CONFIG_GETOPT) + # This is a temporary workaround so that Newlib declares the appropriate + # types for us. POSIX features to be formalized as part of #51211 + zephyr_compile_options($<$:-D_POSIX_THREADS>) + zephyr_compile_options($<$:-D_POSIX_THREADS>) +endif() + +zephyr_library() +add_subdirectory_ifdef(CONFIG_GETOPT getopt) +zephyr_library_sources_ifdef(CONFIG_EVENTFD eventfd.c) +zephyr_library_sources_ifdef(CONFIG_FNMATCH fnmatch.c) +zephyr_library_sources_ifdef(CONFIG_POSIX_API perror.c) +zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK clock.c) +zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK nanosleep.c) +zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK sleep.c) +zephyr_library_sources_ifdef(CONFIG_POSIX_FS fs.c) +zephyr_library_sources_ifdef(CONFIG_POSIX_MQUEUE mqueue.c) +zephyr_library_sources_ifdef(CONFIG_POSIX_PUTMSG stropts.c) +zephyr_library_sources_ifdef(CONFIG_POSIX_SIGNAL signal.c ${STRSIGNAL_TABLE_H}) +zephyr_library_sources_ifdef(CONFIG_POSIX_UNAME uname.c) +zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC _common.c) +zephyr_library_sources_ifdef(CONFIG_PTHREAD_BARRIER barrier.c) +zephyr_library_sources_ifdef(CONFIG_PTHREAD_COND cond.c) +zephyr_library_sources_ifdef(CONFIG_PTHREAD_KEY key.c) +zephyr_library_sources_ifdef(CONFIG_PTHREAD_MUTEX mutex.c) +zephyr_library_sources_ifdef(CONFIG_PTHREAD pthread.c) +zephyr_library_sources_ifdef(CONFIG_PTHREAD_RWLOCK rwlock.c) +zephyr_library_sources_ifdef(CONFIG_POSIX_PRIORITY_SCHEDULING sched.c) +zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC semaphore.c) +zephyr_library_sources_ifdef(CONFIG_PTHREAD_SPINLOCK spinlock.c) +zephyr_library_sources_ifdef(CONFIG_TIMER timer.c) + +zephyr_library_include_directories( + ${ZEPHYR_BASE}/kernel/include + ${ARCH_DIR}/${ARCH}/include +) + +zephyr_library_link_libraries(posix_subsys) +zephyr_library_property(ALLOW_EMPTY TRUE) diff --git a/lib/posix/options/Kconfig b/lib/posix/options/Kconfig new file mode 100644 index 00000000000..9b738c9bdba --- /dev/null +++ b/lib/posix/options/Kconfig @@ -0,0 +1,58 @@ +# Copyright (c) 2018 Intel Corporation +# Copyright (c) 2023 Meta +# +# SPDX-License-Identifier: Apache-2.0 + +menu "POSIX Options" + +config POSIX_API + depends on !NATIVE_APPLICATION + bool "POSIX APIs" + help + Enable mostly-standards-compliant implementations of + various POSIX (IEEE 1003.1) APIs. + +# The name of this option is mandated by zephyr_interface_library_named +# cmake directive. +config APP_LINK_WITH_POSIX_SUBSYS + bool "Make POSIX headers available to application" + default y + depends on POSIX_API + help + Add POSIX subsystem header files to the 'app' include path. + +if POSIX_CLOCK + +config PTHREAD_IPC + bool "POSIX pthread IPC API" + default y if POSIX_API + help + This enables a mostly-standards-compliant implementation of + the pthread mutex, condition variable and barrier IPC + mechanisms. + +endif # POSIX_CLOCK + +rsource "Kconfig.barrier" +rsource "Kconfig.clock" +rsource "Kconfig.cond" +rsource "Kconfig.eventfd" +rsource "Kconfig.fdtable" +rsource "Kconfig.fnmatch" +rsource "Kconfig.fs" +rsource "Kconfig.getopt" +rsource "Kconfig.key" +rsource "Kconfig.mqueue" +rsource "Kconfig.mutex" +rsource "Kconfig.pthread" +rsource "Kconfig.rwlock" +rsource "Kconfig.sched" +rsource "Kconfig.semaphore" +rsource "Kconfig.signal" +rsource "Kconfig.spinlock" +rsource "Kconfig.stropts" +rsource "Kconfig.sysconf" +rsource "Kconfig.timer" +rsource "Kconfig.uname" + +endmenu # "POSIX Options" diff --git a/lib/posix/Kconfig.barrier b/lib/posix/options/Kconfig.barrier similarity index 92% rename from lib/posix/Kconfig.barrier rename to lib/posix/options/Kconfig.barrier index e14b39c5b08..72dd8148277 100644 --- a/lib/posix/Kconfig.barrier +++ b/lib/posix/options/Kconfig.barrier @@ -6,7 +6,7 @@ TYPE = PTHREAD_BARRIER type = pthread_barrier_t type-function = pthread_barrier_wait -source "lib/posix/Kconfig.template.pooled_ipc_type" +rsource "Kconfig.template.pooled_ipc_type" if PTHREAD_BARRIER diff --git a/lib/posix/Kconfig.clock b/lib/posix/options/Kconfig.clock similarity index 86% rename from lib/posix/Kconfig.clock rename to lib/posix/options/Kconfig.clock index e306e691b44..0d541c9f32f 100644 --- a/lib/posix/Kconfig.clock +++ b/lib/posix/options/Kconfig.clock @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 config POSIX_CLOCK - bool "POSIX clock and sleep APIs" + bool "clock and sleep APIs" default y if POSIX_API imply TIMER depends on !NATIVE_LIBC diff --git a/lib/posix/Kconfig.cond b/lib/posix/options/Kconfig.cond similarity index 77% rename from lib/posix/Kconfig.cond rename to lib/posix/options/Kconfig.cond index fcdf842a602..b69b35dece6 100644 --- a/lib/posix/Kconfig.cond +++ b/lib/posix/options/Kconfig.cond @@ -6,4 +6,4 @@ TYPE = PTHREAD_COND type = pthread_cond_t type-function = pthread_cond_wait -source "lib/posix/Kconfig.template.pooled_ipc_type" +rsource "Kconfig.template.pooled_ipc_type" diff --git a/lib/posix/Kconfig.eventfd b/lib/posix/options/Kconfig.eventfd similarity index 96% rename from lib/posix/Kconfig.eventfd rename to lib/posix/options/Kconfig.eventfd index 0b6fa171741..eadf8f80916 100644 --- a/lib/posix/Kconfig.eventfd +++ b/lib/posix/options/Kconfig.eventfd @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 -config EVENTFD +menuconfig EVENTFD bool "Support for eventfd" depends on !NATIVE_APPLICATION select POLL diff --git a/lib/posix/options/Kconfig.fdtable b/lib/posix/options/Kconfig.fdtable new file mode 100644 index 00000000000..214e4a04ae9 --- /dev/null +++ b/lib/posix/options/Kconfig.fdtable @@ -0,0 +1,16 @@ +# Copyright (c) 2018 Linaro +# +# SPDX-License-Identifier: Apache-2.0 + +menu "File descriptor table options" + +config POSIX_MAX_FDS + int "Maximum number of open file descriptors" + default 16 if WIFI_NM_WPA_SUPPLICANT + default 16 if POSIX_API + default 4 + help + Maximum number of open file descriptors, this includes + files, sockets, special devices, etc. + +endmenu # "File descriptor table options" diff --git a/lib/posix/Kconfig.fnmatch b/lib/posix/options/Kconfig.fnmatch similarity index 100% rename from lib/posix/Kconfig.fnmatch rename to lib/posix/options/Kconfig.fnmatch diff --git a/lib/posix/Kconfig.fs b/lib/posix/options/Kconfig.fs similarity index 95% rename from lib/posix/Kconfig.fs rename to lib/posix/options/Kconfig.fs index 1d032910539..e4d5f1dea6e 100644 --- a/lib/posix/Kconfig.fs +++ b/lib/posix/options/Kconfig.fs @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -config POSIX_FS +menuconfig POSIX_FS bool "POSIX file system API support" default y if POSIX_API depends on FILE_SYSTEM diff --git a/lib/posix/Kconfig.getopt b/lib/posix/options/Kconfig.getopt similarity index 71% rename from lib/posix/Kconfig.getopt rename to lib/posix/options/Kconfig.getopt index ccd2c37ed56..4d3559cd855 100644 --- a/lib/posix/Kconfig.getopt +++ b/lib/posix/options/Kconfig.getopt @@ -2,4 +2,4 @@ # # SPDX-License-Identifier: Apache-2.0 -source "lib/posix/getopt/Kconfig" +rsource "getopt/Kconfig" diff --git a/lib/posix/Kconfig.key b/lib/posix/options/Kconfig.key similarity index 77% rename from lib/posix/Kconfig.key rename to lib/posix/options/Kconfig.key index 6e8538233eb..671cce10373 100644 --- a/lib/posix/Kconfig.key +++ b/lib/posix/options/Kconfig.key @@ -6,4 +6,4 @@ TYPE = PTHREAD_KEY type = pthread_key_t type-function = pthread_setspecific -source "lib/posix/Kconfig.template.pooled_ipc_type" +rsource "Kconfig.template.pooled_ipc_type" diff --git a/lib/posix/Kconfig.mqueue b/lib/posix/options/Kconfig.mqueue similarity index 92% rename from lib/posix/Kconfig.mqueue rename to lib/posix/options/Kconfig.mqueue index 7c49aee6c21..3688455d781 100644 --- a/lib/posix/Kconfig.mqueue +++ b/lib/posix/options/Kconfig.mqueue @@ -2,8 +2,8 @@ # # SPDX-License-Identifier: Apache-2.0 -config POSIX_MQUEUE - bool "POSIX message queue" +menuconfig POSIX_MQUEUE + bool "Message queue support" default y if POSIX_API help This enabled POSIX message queue related APIs. diff --git a/lib/posix/Kconfig.mutex b/lib/posix/options/Kconfig.mutex similarity index 78% rename from lib/posix/Kconfig.mutex rename to lib/posix/options/Kconfig.mutex index c34881017e5..6d5729e80aa 100644 --- a/lib/posix/Kconfig.mutex +++ b/lib/posix/options/Kconfig.mutex @@ -6,4 +6,4 @@ TYPE = PTHREAD_MUTEX type = pthread_mutex_t type-function = pthread_mutex_lock -source "lib/posix/Kconfig.template.pooled_ipc_type" +rsource "Kconfig.template.pooled_ipc_type" diff --git a/lib/posix/Kconfig.pthread b/lib/posix/options/Kconfig.pthread similarity index 97% rename from lib/posix/Kconfig.pthread rename to lib/posix/options/Kconfig.pthread index 8870b725109..f0c65836b60 100644 --- a/lib/posix/Kconfig.pthread +++ b/lib/posix/options/Kconfig.pthread @@ -6,7 +6,7 @@ TYPE = PTHREAD type = pthread_t type-function = pthread_create -source "lib/posix/Kconfig.template.pooled_ipc_type" +rsource "Kconfig.template.pooled_ipc_type" if PTHREAD diff --git a/lib/posix/Kconfig.rwlock b/lib/posix/options/Kconfig.rwlock similarity index 75% rename from lib/posix/Kconfig.rwlock rename to lib/posix/options/Kconfig.rwlock index 6bd89a0a9f5..fea61551ec3 100644 --- a/lib/posix/Kconfig.rwlock +++ b/lib/posix/options/Kconfig.rwlock @@ -5,4 +5,4 @@ TYPE = PTHREAD_RWLOCK type = pthread_rwlock_t type-function = pthread_rwlock_timedrdlock -source "lib/posix/Kconfig.template.pooled_ipc_type" +rsource "Kconfig.template.pooled_ipc_type" diff --git a/lib/posix/Kconfig.sched b/lib/posix/options/Kconfig.sched similarity index 84% rename from lib/posix/Kconfig.sched rename to lib/posix/options/Kconfig.sched index 62e7541c8e1..b5fb3a5dcb1 100644 --- a/lib/posix/Kconfig.sched +++ b/lib/posix/options/Kconfig.sched @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 config POSIX_PRIORITY_SCHEDULING - bool "_POSIX_PRIORITY_SCHEDULING API support" + bool "Priority scheduling" default y if PTHREAD default y if POSIX_API depends on PTHREAD diff --git a/lib/posix/Kconfig.semaphore b/lib/posix/options/Kconfig.semaphore similarity index 89% rename from lib/posix/Kconfig.semaphore rename to lib/posix/options/Kconfig.semaphore index aa3468fea76..53fb030736b 100644 --- a/lib/posix/Kconfig.semaphore +++ b/lib/posix/options/Kconfig.semaphore @@ -2,6 +2,8 @@ # # SPDX-License-Identifier: Apache-2.0 +menu "sem_t support" + config SEM_VALUE_MAX int "Maximum semaphore limit" default 32767 @@ -16,3 +18,5 @@ config SEM_NAMELEN_MAX help Maximum length of name for a named semaphore. The max value of 255 corresponds to {NAME_MAX}. + +endmenu # "sem_t support" diff --git a/lib/posix/Kconfig.signal b/lib/posix/options/Kconfig.signal similarity index 75% rename from lib/posix/Kconfig.signal rename to lib/posix/options/Kconfig.signal index 1df8cf3ab16..99c225564c7 100644 --- a/lib/posix/Kconfig.signal +++ b/lib/posix/options/Kconfig.signal @@ -2,6 +2,17 @@ # # SPDX-License-Identifier: Apache-2.0 +menu "Signal support" + +# needed outside of if clause above to define constants & types in signal.h +config POSIX_RTSIG_MAX + int "Maximum number of realtime signals" + default 31 if POSIX_SIGNAL + default 0 + help + Define the maximum number of realtime signals (RTSIG_MAX). + The range of realtime signals is [SIGRTMIN .. (SIGRTMIN+RTSIG_MAX)] + config POSIX_SIGNAL bool "Support for POSIX signal APIs" default y if POSIX_API @@ -17,13 +28,13 @@ config POSIX_SIGNAL_STRING_DESC Use full description for the strsignal API. Will use 256 bytes of ROM. +config POSIX_LIMITS_RTSIG_MAX + int "_POSIX_RTSIG_MAX value in limits.h" + default 8 + help + Define the _POSIX_RTSIG_MAX value in limits.h. + IEEE 1003.1 defines this to be 8. + endif -# needed outside of if clause above to define constants & types in signal.h -config POSIX_RTSIG_MAX - int "Maximum number of realtime signals" - default 31 if POSIX_SIGNAL - default 0 - help - Define the maximum number of realtime signals (RTSIG_MAX). - The range of realtime signals is [SIGRTMIN .. (SIGRTMIN+RTSIG_MAX)] +endmenu # "Signal support" diff --git a/lib/posix/Kconfig.spinlock b/lib/posix/options/Kconfig.spinlock similarity index 74% rename from lib/posix/Kconfig.spinlock rename to lib/posix/options/Kconfig.spinlock index 83a95d77ed0..8374aadfd6d 100644 --- a/lib/posix/Kconfig.spinlock +++ b/lib/posix/options/Kconfig.spinlock @@ -5,4 +5,4 @@ TYPE = PTHREAD_SPINLOCK type = pthread_spinlock_t type-function = pthread_spin_lock -source "lib/posix/Kconfig.template.pooled_ipc_type" +rsource "Kconfig.template.pooled_ipc_type" diff --git a/lib/posix/Kconfig.stropts b/lib/posix/options/Kconfig.stropts similarity index 100% rename from lib/posix/Kconfig.stropts rename to lib/posix/options/Kconfig.stropts diff --git a/lib/posix/options/Kconfig.sysconf b/lib/posix/options/Kconfig.sysconf new file mode 100644 index 00000000000..32f37f1c29d --- /dev/null +++ b/lib/posix/options/Kconfig.sysconf @@ -0,0 +1,24 @@ +# Copyright (c) 2024 BayLibre SAS +# +# SPDX-License-Identifier: Apache-2.0 + +menu "Sysconf support" + +config POSIX_SYSCONF + bool "Support for sysconf" + default y if POSIX_API + help + The sysconf() function provides a method for the application to determine + the current value of a configurable system limit or option (variable). + +config POSIX_PAGE_SIZE_BITS + int "Number of bits to use for PAGE_SIZE" + range 6 16 + default 12 if POSIX_API + default 6 + help + Define PAGE_SIZE as BIT(n), where n is the value configured here. + PAGE_SIZE is supported in the range [64, 65536] + If CONFIG_POSIX_API=y, PAGE_SIZE defaults to 4096, otherwise, it is 64 bytes. + +endmenu # "Sysconf support" diff --git a/lib/posix/Kconfig.template.pooled_ipc_type b/lib/posix/options/Kconfig.template.pooled_ipc_type similarity index 67% rename from lib/posix/Kconfig.template.pooled_ipc_type rename to lib/posix/options/Kconfig.template.pooled_ipc_type index d28ed345b6a..08d804382e8 100644 --- a/lib/posix/Kconfig.template.pooled_ipc_type +++ b/lib/posix/options/Kconfig.template.pooled_ipc_type @@ -2,12 +2,11 @@ # # SPDX-License-Identifier: Apache-2.0 -source "lib/posix/Kconfig.template.with_url" -source "lib/posix/Kconfig.template.with_logging" +rsource "Kconfig.template.with_url" # Not user configurable (i.e. private for now) -config $(TYPE) - bool "POSIX $(type) support" +menuconfig $(TYPE) + bool "$(type) support" depends on PTHREAD_IPC default y help @@ -15,10 +14,16 @@ config $(TYPE) For more info, see $(posix-url-base)/$(type-function).html +if $(TYPE) + # eventually, this size should be defaulted to 0 config MAX_$(TYPE)_COUNT - int "Maximum simultaneously active $(type) in POSIX application" + int "Maximum number of $(type)" default 5 depends on $(TYPE) help Maximum simultaneously active $(type) in a POSIX application. + +rsource "Kconfig.template.with_logging" + +endif # $(TYPE) diff --git a/lib/posix/Kconfig.template.pooled_type b/lib/posix/options/Kconfig.template.pooled_type similarity index 63% rename from lib/posix/Kconfig.template.pooled_type rename to lib/posix/options/Kconfig.template.pooled_type index a30686043a1..5a75c2ee890 100644 --- a/lib/posix/Kconfig.template.pooled_type +++ b/lib/posix/options/Kconfig.template.pooled_type @@ -2,19 +2,24 @@ # # SPDX-License-Identifier: Apache-2.0 -source "lib/posix/Kconfig.template.with_url" -source "lib/posix/Kconfig.template.with_logging" +rsource "Kconfig.template.with_url" # This is mainly for TIMER currently. -config $(TYPE) - bool "POSIX $(type) support" +menuconfig $(TYPE) + bool "$(type) support" help For more info, see $(posix-url-base)/$(type-function).html +if $(TYPE) + # eventually, this size should be defaulted to 0 as a safe value config MAX_$(TYPE)_COUNT - int "Maximum simultaneously active $(type) in POSIX application" + int "Maximum number of $(type)" default 5 help Maximum simultaneously active $(type) in a POSIX application. + +rsource "Kconfig.template.with_logging" + +endif # $(TYPE) diff --git a/lib/posix/Kconfig.template.with_logging b/lib/posix/options/Kconfig.template.with_logging similarity index 100% rename from lib/posix/Kconfig.template.with_logging rename to lib/posix/options/Kconfig.template.with_logging diff --git a/lib/posix/Kconfig.template.with_url b/lib/posix/options/Kconfig.template.with_url similarity index 100% rename from lib/posix/Kconfig.template.with_url rename to lib/posix/options/Kconfig.template.with_url diff --git a/lib/posix/Kconfig.timer b/lib/posix/options/Kconfig.timer similarity index 90% rename from lib/posix/Kconfig.timer rename to lib/posix/options/Kconfig.timer index 28173692e0c..10905e9c21d 100644 --- a/lib/posix/Kconfig.timer +++ b/lib/posix/options/Kconfig.timer @@ -5,7 +5,9 @@ TYPE = TIMER type = timer_t type-function = timer_create -source "lib/posix/Kconfig.template.pooled_type" +rsource "Kconfig.template.pooled_type" + +if TIMER config TIMER_CREATE_WAIT int "Time to wait for timer availability (in msec) in POSIX application" @@ -21,3 +23,5 @@ config TIMER_DELAYTIMER_MAX help This controls the maximum number of times a timer can overrun before timer_getoverrun() in POSIX compliant application. + +endif # TIMER diff --git a/lib/posix/Kconfig.uname b/lib/posix/options/Kconfig.uname similarity index 96% rename from lib/posix/Kconfig.uname rename to lib/posix/options/Kconfig.uname index d8c29479986..09b52602db1 100644 --- a/lib/posix/Kconfig.uname +++ b/lib/posix/options/Kconfig.uname @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -config POSIX_UNAME +menuconfig POSIX_UNAME bool "Support for uname" default y if POSIX_API help diff --git a/lib/posix/_common.c b/lib/posix/options/_common.c similarity index 100% rename from lib/posix/_common.c rename to lib/posix/options/_common.c diff --git a/lib/posix/barrier.c b/lib/posix/options/barrier.c similarity index 100% rename from lib/posix/barrier.c rename to lib/posix/options/barrier.c diff --git a/lib/posix/clock.c b/lib/posix/options/clock.c similarity index 100% rename from lib/posix/clock.c rename to lib/posix/options/clock.c diff --git a/lib/posix/cond.c b/lib/posix/options/cond.c similarity index 100% rename from lib/posix/cond.c rename to lib/posix/options/cond.c diff --git a/lib/posix/eventfd.c b/lib/posix/options/eventfd.c similarity index 100% rename from lib/posix/eventfd.c rename to lib/posix/options/eventfd.c diff --git a/lib/posix/fnmatch.c b/lib/posix/options/fnmatch.c similarity index 100% rename from lib/posix/fnmatch.c rename to lib/posix/options/fnmatch.c diff --git a/lib/posix/fs.c b/lib/posix/options/fs.c similarity index 100% rename from lib/posix/fs.c rename to lib/posix/options/fs.c diff --git a/lib/posix/getopt/CMakeLists.txt b/lib/posix/options/getopt/CMakeLists.txt similarity index 100% rename from lib/posix/getopt/CMakeLists.txt rename to lib/posix/options/getopt/CMakeLists.txt diff --git a/lib/posix/getopt/Kconfig b/lib/posix/options/getopt/Kconfig similarity index 100% rename from lib/posix/getopt/Kconfig rename to lib/posix/options/getopt/Kconfig diff --git a/lib/posix/getopt/README b/lib/posix/options/getopt/README similarity index 100% rename from lib/posix/getopt/README rename to lib/posix/options/getopt/README diff --git a/lib/posix/getopt/getopt.c b/lib/posix/options/getopt/getopt.c similarity index 100% rename from lib/posix/getopt/getopt.c rename to lib/posix/options/getopt/getopt.c diff --git a/lib/posix/getopt/getopt.h b/lib/posix/options/getopt/getopt.h similarity index 100% rename from lib/posix/getopt/getopt.h rename to lib/posix/options/getopt/getopt.h diff --git a/lib/posix/getopt/getopt_common.c b/lib/posix/options/getopt/getopt_common.c similarity index 100% rename from lib/posix/getopt/getopt_common.c rename to lib/posix/options/getopt/getopt_common.c diff --git a/lib/posix/getopt/getopt_common.h b/lib/posix/options/getopt/getopt_common.h similarity index 100% rename from lib/posix/getopt/getopt_common.h rename to lib/posix/options/getopt/getopt_common.h diff --git a/lib/posix/getopt/getopt_long.c b/lib/posix/options/getopt/getopt_long.c similarity index 100% rename from lib/posix/getopt/getopt_long.c rename to lib/posix/options/getopt/getopt_long.c diff --git a/lib/posix/key.c b/lib/posix/options/key.c similarity index 100% rename from lib/posix/key.c rename to lib/posix/options/key.c diff --git a/lib/posix/mqueue.c b/lib/posix/options/mqueue.c similarity index 100% rename from lib/posix/mqueue.c rename to lib/posix/options/mqueue.c diff --git a/lib/posix/mutex.c b/lib/posix/options/mutex.c similarity index 100% rename from lib/posix/mutex.c rename to lib/posix/options/mutex.c diff --git a/lib/posix/nanosleep.c b/lib/posix/options/nanosleep.c similarity index 100% rename from lib/posix/nanosleep.c rename to lib/posix/options/nanosleep.c diff --git a/lib/posix/perror.c b/lib/posix/options/perror.c similarity index 100% rename from lib/posix/perror.c rename to lib/posix/options/perror.c diff --git a/lib/posix/posix_clock.h b/lib/posix/options/posix_clock.h similarity index 100% rename from lib/posix/posix_clock.h rename to lib/posix/options/posix_clock.h diff --git a/lib/posix/posix_internal.h b/lib/posix/options/posix_internal.h similarity index 100% rename from lib/posix/posix_internal.h rename to lib/posix/options/posix_internal.h diff --git a/lib/posix/pthread.c b/lib/posix/options/pthread.c similarity index 100% rename from lib/posix/pthread.c rename to lib/posix/options/pthread.c diff --git a/lib/posix/pthread_sched.h b/lib/posix/options/pthread_sched.h similarity index 100% rename from lib/posix/pthread_sched.h rename to lib/posix/options/pthread_sched.h diff --git a/lib/posix/rwlock.c b/lib/posix/options/rwlock.c similarity index 100% rename from lib/posix/rwlock.c rename to lib/posix/options/rwlock.c diff --git a/lib/posix/sched.c b/lib/posix/options/sched.c similarity index 100% rename from lib/posix/sched.c rename to lib/posix/options/sched.c diff --git a/lib/posix/semaphore.c b/lib/posix/options/semaphore.c similarity index 100% rename from lib/posix/semaphore.c rename to lib/posix/options/semaphore.c diff --git a/lib/posix/signal.c b/lib/posix/options/signal.c similarity index 100% rename from lib/posix/signal.c rename to lib/posix/options/signal.c diff --git a/lib/posix/sleep.c b/lib/posix/options/sleep.c similarity index 100% rename from lib/posix/sleep.c rename to lib/posix/options/sleep.c diff --git a/lib/posix/spinlock.c b/lib/posix/options/spinlock.c similarity index 100% rename from lib/posix/spinlock.c rename to lib/posix/options/spinlock.c diff --git a/lib/posix/stropts.c b/lib/posix/options/stropts.c similarity index 100% rename from lib/posix/stropts.c rename to lib/posix/options/stropts.c diff --git a/lib/posix/timer.c b/lib/posix/options/timer.c similarity index 100% rename from lib/posix/timer.c rename to lib/posix/options/timer.c diff --git a/lib/posix/uname.c b/lib/posix/options/uname.c similarity index 100% rename from lib/posix/uname.c rename to lib/posix/options/uname.c diff --git a/lib/posix/shell/Kconfig b/lib/posix/shell/Kconfig index 1ce4ae5a959..d7116b492a8 100644 --- a/lib/posix/shell/Kconfig +++ b/lib/posix/shell/Kconfig @@ -1,6 +1,8 @@ # Copyright (c) 2024 Meta # SPDX-License-Identifier: Apache-2.0 +menu "POSIX Shell Utilities" + if SHELL config POSIX_SHELL @@ -11,3 +13,5 @@ config POSIX_SHELL rsource "Kconfig.uname" endif # SHELL + +endmenu # "POSIX Shell Utilities" diff --git a/samples/posix/philosophers/CMakeLists.txt b/samples/posix/philosophers/CMakeLists.txt index e8a6a207987..2f19561d195 100644 --- a/samples/posix/philosophers/CMakeLists.txt +++ b/samples/posix/philosophers/CMakeLists.txt @@ -7,4 +7,4 @@ project(posix_philosophers) target_sources(app PRIVATE src/main.c) # For translating POSIX scheduler policies and priorities to # Zephyr priorities. -target_include_directories(app PRIVATE ${ZEPHYR_BASE}/lib/posix) +target_include_directories(app PRIVATE ${ZEPHYR_BASE}/lib/posix/options)