Browse Source

posix: separate shell utilities and posix api implementation

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
Christopher Friedt 1 year ago committed by Chris Friedt
parent
commit
855b8bc6ca
  1. 69
      lib/posix/CMakeLists.txt
  2. 76
      lib/posix/Kconfig
  3. 13
      lib/posix/Kconfig.limits
  4. 68
      lib/posix/options/CMakeLists.txt
  5. 58
      lib/posix/options/Kconfig
  6. 2
      lib/posix/options/Kconfig.barrier
  7. 2
      lib/posix/options/Kconfig.clock
  8. 2
      lib/posix/options/Kconfig.cond
  9. 2
      lib/posix/options/Kconfig.eventfd
  10. 16
      lib/posix/options/Kconfig.fdtable
  11. 0
      lib/posix/options/Kconfig.fnmatch
  12. 2
      lib/posix/options/Kconfig.fs
  13. 2
      lib/posix/options/Kconfig.getopt
  14. 2
      lib/posix/options/Kconfig.key
  15. 4
      lib/posix/options/Kconfig.mqueue
  16. 2
      lib/posix/options/Kconfig.mutex
  17. 2
      lib/posix/options/Kconfig.pthread
  18. 2
      lib/posix/options/Kconfig.rwlock
  19. 2
      lib/posix/options/Kconfig.sched
  20. 4
      lib/posix/options/Kconfig.semaphore
  21. 27
      lib/posix/options/Kconfig.signal
  22. 2
      lib/posix/options/Kconfig.spinlock
  23. 0
      lib/posix/options/Kconfig.stropts
  24. 24
      lib/posix/options/Kconfig.sysconf
  25. 15
      lib/posix/options/Kconfig.template.pooled_ipc_type
  26. 15
      lib/posix/options/Kconfig.template.pooled_type
  27. 0
      lib/posix/options/Kconfig.template.with_logging
  28. 0
      lib/posix/options/Kconfig.template.with_url
  29. 6
      lib/posix/options/Kconfig.timer
  30. 2
      lib/posix/options/Kconfig.uname
  31. 0
      lib/posix/options/_common.c
  32. 0
      lib/posix/options/barrier.c
  33. 0
      lib/posix/options/clock.c
  34. 0
      lib/posix/options/cond.c
  35. 0
      lib/posix/options/eventfd.c
  36. 0
      lib/posix/options/fnmatch.c
  37. 0
      lib/posix/options/fs.c
  38. 0
      lib/posix/options/getopt/CMakeLists.txt
  39. 0
      lib/posix/options/getopt/Kconfig
  40. 0
      lib/posix/options/getopt/README
  41. 0
      lib/posix/options/getopt/getopt.c
  42. 0
      lib/posix/options/getopt/getopt.h
  43. 0
      lib/posix/options/getopt/getopt_common.c
  44. 0
      lib/posix/options/getopt/getopt_common.h
  45. 0
      lib/posix/options/getopt/getopt_long.c
  46. 0
      lib/posix/options/key.c
  47. 0
      lib/posix/options/mqueue.c
  48. 0
      lib/posix/options/mutex.c
  49. 0
      lib/posix/options/nanosleep.c
  50. 0
      lib/posix/options/perror.c
  51. 0
      lib/posix/options/posix_clock.h
  52. 0
      lib/posix/options/posix_internal.h
  53. 0
      lib/posix/options/pthread.c
  54. 0
      lib/posix/options/pthread_sched.h
  55. 0
      lib/posix/options/rwlock.c
  56. 0
      lib/posix/options/sched.c
  57. 0
      lib/posix/options/semaphore.c
  58. 0
      lib/posix/options/signal.c
  59. 0
      lib/posix/options/sleep.c
  60. 0
      lib/posix/options/spinlock.c
  61. 0
      lib/posix/options/stropts.c
  62. 0
      lib/posix/options/timer.c
  63. 0
      lib/posix/options/uname.c
  64. 4
      lib/posix/shell/Kconfig
  65. 2
      samples/posix/philosophers/CMakeLists.txt

69
lib/posix/CMakeLists.txt

@ -1,69 +1,4 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
set(GEN_DIR ${ZEPHYR_BINARY_DIR}/include/generated) add_subdirectory(options)
add_subdirectory(shell)
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)

76
lib/posix/Kconfig

@ -1,82 +1,10 @@
# Copyright (c) 2018 Intel Corporation # Copyright (c) 2024 Meta
# Copyright (c) 2023 Meta
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
menu "POSIX API Support" menu "POSIX API Support"
config POSIX_MAX_FDS rsource "options/Kconfig"
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 "shell/Kconfig" rsource "shell/Kconfig"
endmenu # "POSIX API Support" endmenu # "POSIX API Support"

13
lib/posix/Kconfig.limits

@ -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

68
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($<$<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)

58
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"

2
lib/posix/Kconfig.barrier → lib/posix/options/Kconfig.barrier

@ -6,7 +6,7 @@
TYPE = PTHREAD_BARRIER TYPE = PTHREAD_BARRIER
type = pthread_barrier_t type = pthread_barrier_t
type-function = pthread_barrier_wait type-function = pthread_barrier_wait
source "lib/posix/Kconfig.template.pooled_ipc_type" rsource "Kconfig.template.pooled_ipc_type"
if PTHREAD_BARRIER if PTHREAD_BARRIER

2
lib/posix/Kconfig.clock → lib/posix/options/Kconfig.clock

@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
config POSIX_CLOCK config POSIX_CLOCK
bool "POSIX clock and sleep APIs" bool "clock and sleep APIs"
default y if POSIX_API default y if POSIX_API
imply TIMER imply TIMER
depends on !NATIVE_LIBC depends on !NATIVE_LIBC

2
lib/posix/Kconfig.cond → lib/posix/options/Kconfig.cond

@ -6,4 +6,4 @@
TYPE = PTHREAD_COND TYPE = PTHREAD_COND
type = pthread_cond_t type = pthread_cond_t
type-function = pthread_cond_wait type-function = pthread_cond_wait
source "lib/posix/Kconfig.template.pooled_ipc_type" rsource "Kconfig.template.pooled_ipc_type"

2
lib/posix/Kconfig.eventfd → lib/posix/options/Kconfig.eventfd

@ -3,7 +3,7 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
config EVENTFD menuconfig EVENTFD
bool "Support for eventfd" bool "Support for eventfd"
depends on !NATIVE_APPLICATION depends on !NATIVE_APPLICATION
select POLL select POLL

16
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"

0
lib/posix/Kconfig.fnmatch → lib/posix/options/Kconfig.fnmatch

2
lib/posix/Kconfig.fs → lib/posix/options/Kconfig.fs

@ -2,7 +2,7 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
config POSIX_FS menuconfig POSIX_FS
bool "POSIX file system API support" bool "POSIX file system API support"
default y if POSIX_API default y if POSIX_API
depends on FILE_SYSTEM depends on FILE_SYSTEM

2
lib/posix/Kconfig.getopt → lib/posix/options/Kconfig.getopt

@ -2,4 +2,4 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
source "lib/posix/getopt/Kconfig" rsource "getopt/Kconfig"

2
lib/posix/Kconfig.key → lib/posix/options/Kconfig.key

@ -6,4 +6,4 @@
TYPE = PTHREAD_KEY TYPE = PTHREAD_KEY
type = pthread_key_t type = pthread_key_t
type-function = pthread_setspecific type-function = pthread_setspecific
source "lib/posix/Kconfig.template.pooled_ipc_type" rsource "Kconfig.template.pooled_ipc_type"

4
lib/posix/Kconfig.mqueue → lib/posix/options/Kconfig.mqueue

@ -2,8 +2,8 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
config POSIX_MQUEUE menuconfig POSIX_MQUEUE
bool "POSIX message queue" bool "Message queue support"
default y if POSIX_API default y if POSIX_API
help help
This enabled POSIX message queue related APIs. This enabled POSIX message queue related APIs.

2
lib/posix/Kconfig.mutex → lib/posix/options/Kconfig.mutex

@ -6,4 +6,4 @@
TYPE = PTHREAD_MUTEX TYPE = PTHREAD_MUTEX
type = pthread_mutex_t type = pthread_mutex_t
type-function = pthread_mutex_lock type-function = pthread_mutex_lock
source "lib/posix/Kconfig.template.pooled_ipc_type" rsource "Kconfig.template.pooled_ipc_type"

2
lib/posix/Kconfig.pthread → lib/posix/options/Kconfig.pthread

@ -6,7 +6,7 @@
TYPE = PTHREAD TYPE = PTHREAD
type = pthread_t type = pthread_t
type-function = pthread_create type-function = pthread_create
source "lib/posix/Kconfig.template.pooled_ipc_type" rsource "Kconfig.template.pooled_ipc_type"
if PTHREAD if PTHREAD

2
lib/posix/Kconfig.rwlock → lib/posix/options/Kconfig.rwlock

@ -5,4 +5,4 @@
TYPE = PTHREAD_RWLOCK TYPE = PTHREAD_RWLOCK
type = pthread_rwlock_t type = pthread_rwlock_t
type-function = pthread_rwlock_timedrdlock type-function = pthread_rwlock_timedrdlock
source "lib/posix/Kconfig.template.pooled_ipc_type" rsource "Kconfig.template.pooled_ipc_type"

2
lib/posix/Kconfig.sched → lib/posix/options/Kconfig.sched

@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
config POSIX_PRIORITY_SCHEDULING config POSIX_PRIORITY_SCHEDULING
bool "_POSIX_PRIORITY_SCHEDULING API support" bool "Priority scheduling"
default y if PTHREAD default y if PTHREAD
default y if POSIX_API default y if POSIX_API
depends on PTHREAD depends on PTHREAD

4
lib/posix/Kconfig.semaphore → lib/posix/options/Kconfig.semaphore

@ -2,6 +2,8 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
menu "sem_t support"
config SEM_VALUE_MAX config SEM_VALUE_MAX
int "Maximum semaphore limit" int "Maximum semaphore limit"
default 32767 default 32767
@ -16,3 +18,5 @@ config SEM_NAMELEN_MAX
help help
Maximum length of name for a named semaphore. Maximum length of name for a named semaphore.
The max value of 255 corresponds to {NAME_MAX}. The max value of 255 corresponds to {NAME_MAX}.
endmenu # "sem_t support"

27
lib/posix/Kconfig.signal → lib/posix/options/Kconfig.signal

@ -2,6 +2,17 @@
# #
# SPDX-License-Identifier: Apache-2.0 # 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 config POSIX_SIGNAL
bool "Support for POSIX signal APIs" bool "Support for POSIX signal APIs"
default y if POSIX_API default y if POSIX_API
@ -17,13 +28,13 @@ config POSIX_SIGNAL_STRING_DESC
Use full description for the strsignal API. Use full description for the strsignal API.
Will use 256 bytes of ROM. 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 endif
# needed outside of if clause above to define constants & types in signal.h endmenu # "Signal support"
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)]

2
lib/posix/Kconfig.spinlock → lib/posix/options/Kconfig.spinlock

@ -5,4 +5,4 @@
TYPE = PTHREAD_SPINLOCK TYPE = PTHREAD_SPINLOCK
type = pthread_spinlock_t type = pthread_spinlock_t
type-function = pthread_spin_lock type-function = pthread_spin_lock
source "lib/posix/Kconfig.template.pooled_ipc_type" rsource "Kconfig.template.pooled_ipc_type"

0
lib/posix/Kconfig.stropts → lib/posix/options/Kconfig.stropts

24
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"

15
lib/posix/Kconfig.template.pooled_ipc_type → lib/posix/options/Kconfig.template.pooled_ipc_type

@ -2,12 +2,11 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
source "lib/posix/Kconfig.template.with_url" rsource "Kconfig.template.with_url"
source "lib/posix/Kconfig.template.with_logging"
# Not user configurable (i.e. private for now) # Not user configurable (i.e. private for now)
config $(TYPE) menuconfig $(TYPE)
bool "POSIX $(type) support" bool "$(type) support"
depends on PTHREAD_IPC depends on PTHREAD_IPC
default y default y
help help
@ -15,10 +14,16 @@ config $(TYPE)
For more info, see For more info, see
$(posix-url-base)/$(type-function).html $(posix-url-base)/$(type-function).html
if $(TYPE)
# eventually, this size should be defaulted to 0 # eventually, this size should be defaulted to 0
config MAX_$(TYPE)_COUNT config MAX_$(TYPE)_COUNT
int "Maximum simultaneously active $(type) in POSIX application" int "Maximum number of $(type)"
default 5 default 5
depends on $(TYPE) depends on $(TYPE)
help help
Maximum simultaneously active $(type) in a POSIX application. Maximum simultaneously active $(type) in a POSIX application.
rsource "Kconfig.template.with_logging"
endif # $(TYPE)

15
lib/posix/Kconfig.template.pooled_type → lib/posix/options/Kconfig.template.pooled_type

@ -2,19 +2,24 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
source "lib/posix/Kconfig.template.with_url" rsource "Kconfig.template.with_url"
source "lib/posix/Kconfig.template.with_logging"
# This is mainly for TIMER currently. # This is mainly for TIMER currently.
config $(TYPE) menuconfig $(TYPE)
bool "POSIX $(type) support" bool "$(type) support"
help help
For more info, see For more info, see
$(posix-url-base)/$(type-function).html $(posix-url-base)/$(type-function).html
if $(TYPE)
# eventually, this size should be defaulted to 0 as a safe value # eventually, this size should be defaulted to 0 as a safe value
config MAX_$(TYPE)_COUNT config MAX_$(TYPE)_COUNT
int "Maximum simultaneously active $(type) in POSIX application" int "Maximum number of $(type)"
default 5 default 5
help help
Maximum simultaneously active $(type) in a POSIX application. Maximum simultaneously active $(type) in a POSIX application.
rsource "Kconfig.template.with_logging"
endif # $(TYPE)

0
lib/posix/Kconfig.template.with_logging → lib/posix/options/Kconfig.template.with_logging

0
lib/posix/Kconfig.template.with_url → lib/posix/options/Kconfig.template.with_url

6
lib/posix/Kconfig.timer → lib/posix/options/Kconfig.timer

@ -5,7 +5,9 @@
TYPE = TIMER TYPE = TIMER
type = timer_t type = timer_t
type-function = timer_create type-function = timer_create
source "lib/posix/Kconfig.template.pooled_type" rsource "Kconfig.template.pooled_type"
if TIMER
config TIMER_CREATE_WAIT config TIMER_CREATE_WAIT
int "Time to wait for timer availability (in msec) in POSIX application" int "Time to wait for timer availability (in msec) in POSIX application"
@ -21,3 +23,5 @@ config TIMER_DELAYTIMER_MAX
help help
This controls the maximum number of times a timer can overrun before This controls the maximum number of times a timer can overrun before
timer_getoverrun() in POSIX compliant application. timer_getoverrun() in POSIX compliant application.
endif # TIMER

2
lib/posix/Kconfig.uname → lib/posix/options/Kconfig.uname

@ -2,7 +2,7 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
config POSIX_UNAME menuconfig POSIX_UNAME
bool "Support for uname" bool "Support for uname"
default y if POSIX_API default y if POSIX_API
help help

0
lib/posix/_common.c → lib/posix/options/_common.c

0
lib/posix/barrier.c → lib/posix/options/barrier.c

0
lib/posix/clock.c → lib/posix/options/clock.c

0
lib/posix/cond.c → lib/posix/options/cond.c

0
lib/posix/eventfd.c → lib/posix/options/eventfd.c

0
lib/posix/fnmatch.c → lib/posix/options/fnmatch.c

0
lib/posix/fs.c → lib/posix/options/fs.c

0
lib/posix/getopt/CMakeLists.txt → lib/posix/options/getopt/CMakeLists.txt

0
lib/posix/getopt/Kconfig → lib/posix/options/getopt/Kconfig

0
lib/posix/getopt/README → lib/posix/options/getopt/README

0
lib/posix/getopt/getopt.c → lib/posix/options/getopt/getopt.c

0
lib/posix/getopt/getopt.h → lib/posix/options/getopt/getopt.h

0
lib/posix/getopt/getopt_common.c → lib/posix/options/getopt/getopt_common.c

0
lib/posix/getopt/getopt_common.h → lib/posix/options/getopt/getopt_common.h

0
lib/posix/getopt/getopt_long.c → lib/posix/options/getopt/getopt_long.c

0
lib/posix/key.c → lib/posix/options/key.c

0
lib/posix/mqueue.c → lib/posix/options/mqueue.c

0
lib/posix/mutex.c → lib/posix/options/mutex.c

0
lib/posix/nanosleep.c → lib/posix/options/nanosleep.c

0
lib/posix/perror.c → lib/posix/options/perror.c

0
lib/posix/posix_clock.h → lib/posix/options/posix_clock.h

0
lib/posix/posix_internal.h → lib/posix/options/posix_internal.h

0
lib/posix/pthread.c → lib/posix/options/pthread.c

0
lib/posix/pthread_sched.h → lib/posix/options/pthread_sched.h

0
lib/posix/rwlock.c → lib/posix/options/rwlock.c

0
lib/posix/sched.c → lib/posix/options/sched.c

0
lib/posix/semaphore.c → lib/posix/options/semaphore.c

0
lib/posix/signal.c → lib/posix/options/signal.c

0
lib/posix/sleep.c → lib/posix/options/sleep.c

0
lib/posix/spinlock.c → lib/posix/options/spinlock.c

0
lib/posix/stropts.c → lib/posix/options/stropts.c

0
lib/posix/timer.c → lib/posix/options/timer.c

0
lib/posix/uname.c → lib/posix/options/uname.c

4
lib/posix/shell/Kconfig

@ -1,6 +1,8 @@
# Copyright (c) 2024 Meta # Copyright (c) 2024 Meta
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
menu "POSIX Shell Utilities"
if SHELL if SHELL
config POSIX_SHELL config POSIX_SHELL
@ -11,3 +13,5 @@ config POSIX_SHELL
rsource "Kconfig.uname" rsource "Kconfig.uname"
endif # SHELL endif # SHELL
endmenu # "POSIX Shell Utilities"

2
samples/posix/philosophers/CMakeLists.txt

@ -7,4 +7,4 @@ project(posix_philosophers)
target_sources(app PRIVATE src/main.c) target_sources(app PRIVATE src/main.c)
# For translating POSIX scheduler policies and priorities to # For translating POSIX scheduler policies and priorities to
# Zephyr priorities. # Zephyr priorities.
target_include_directories(app PRIVATE ${ZEPHYR_BASE}/lib/posix) target_include_directories(app PRIVATE ${ZEPHYR_BASE}/lib/posix/options)

Loading…
Cancel
Save