Browse Source
Previously, the POSIX shell utilities were intermixed with the POSIX API implementation. The POSIX shell utilities only depend on the public POSIX API, so it makes sense to keep them in a separate subdirectory. Signed-off-by: Christopher Friedt <cfriedt@meta.com>pull/68407/head
65 changed files with 238 additions and 189 deletions
@ -1,69 +1,4 @@
@@ -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($<$<COMPILE_LANGUAGE:C>:-D_POSIX_THREADS>) |
||||
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:-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) |
||||
|
@ -1,82 +1,10 @@
@@ -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" |
||||
|
@ -1,13 +0,0 @@
@@ -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 |
@ -0,0 +1,68 @@
@@ -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($<$<COMPILE_LANGUAGE:C>:-D_POSIX_THREADS>) |
||||
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:-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) |
@ -0,0 +1,58 @@
@@ -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" |
@ -0,0 +1,16 @@
@@ -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" |
@ -0,0 +1,24 @@
@@ -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" |
Loading…
Reference in new issue