From 4e181f70312e8682e222d1e9033316ad91772cfe Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Wed, 22 May 2024 18:16:30 -0400 Subject: [PATCH] posix: deprecate PTHREAD_SPINLOCK for POSIX_SPIN_LOCKS This change deprecates CONFIG_PTHREAD_SPINLOCK in favour of CONFIG_POSIX_SPIN_LOCKS, which maps directly to the name of the standard POSIX Option Group. Signed-off-by: Chris Friedt --- .../portability/posix/conformance/index.rst | 2 +- .../portability/posix/kconfig/index.rst | 1 - include/zephyr/posix/posix_features.h | 2 +- include/zephyr/posix/sys/sysconf.h | 2 +- lib/posix/options/CMakeLists.txt | 2 +- lib/posix/options/Kconfig.deprecated | 9 ++++++ lib/posix/options/Kconfig.spinlock | 28 ++++++++++++++++--- 7 files changed, 37 insertions(+), 9 deletions(-) diff --git a/doc/services/portability/posix/conformance/index.rst b/doc/services/portability/posix/conformance/index.rst index 3e2b9451438..e82565ae83c 100644 --- a/doc/services/portability/posix/conformance/index.rst +++ b/doc/services/portability/posix/conformance/index.rst @@ -69,7 +69,7 @@ POSIX System Interfaces :ref:`_POSIX_READER_WRITER_LOCKS`, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC` :ref:`_POSIX_REALTIME_SIGNALS`, -1, :ref:`_POSIX_SEMAPHORES`, 200809L, :kconfig:option:`CONFIG_PTHREAD_IPC` - :ref:`_POSIX_SPIN_LOCKS`, 200809L, :kconfig:option:`CONFIG_PTHREAD_SPINLOCK` + :ref:`_POSIX_SPIN_LOCKS`, 200809L, :kconfig:option:`CONFIG_POSIX_SPIN_LOCKS` :ref:`_POSIX_THREAD_SAFE_FUNCTIONS`, -1, :ref:`_POSIX_THREADS`, -1, :kconfig:option:`CONFIG_PTHREAD_IPC` :ref:`_POSIX_TIMEOUTS`, 200809L, :kconfig:option:`CONFIG_POSIX_TIMEOUTS` diff --git a/doc/services/portability/posix/kconfig/index.rst b/doc/services/portability/posix/kconfig/index.rst index d04779aa96c..8adc0a4058e 100644 --- a/doc/services/portability/posix/kconfig/index.rst +++ b/doc/services/portability/posix/kconfig/index.rst @@ -39,6 +39,5 @@ implementation of the POSIX API. * :kconfig:option:`CONFIG_PTHREAD_KEY` * :kconfig:option:`CONFIG_PTHREAD_MUTEX` * :kconfig:option:`CONFIG_PTHREAD_RECYCLER_DELAY_MS` -* :kconfig:option:`CONFIG_PTHREAD_SPINLOCK` * :kconfig:option:`CONFIG_SEM_VALUE_MAX` * :kconfig:option:`CONFIG_TIMER_CREATE_WAIT` diff --git a/include/zephyr/posix/posix_features.h b/include/zephyr/posix/posix_features.h index 809f5143bdb..75bb0c0efeb 100644 --- a/include/zephyr/posix/posix_features.h +++ b/include/zephyr/posix/posix_features.h @@ -87,7 +87,7 @@ /* #define _POSIX_SHELL (-1L) */ /* #define _POSIX_SPAWN (-1L) */ -#ifdef CONFIG_PTHREAD_SPINLOCK +#ifdef CONFIG_POSIX_SPIN_LOCKS #define _POSIX_SPIN_LOCKS _POSIX_VERSION #endif diff --git a/include/zephyr/posix/sys/sysconf.h b/include/zephyr/posix/sys/sysconf.h index 40e4e6a7b9b..dcd4eb27922 100644 --- a/include/zephyr/posix/sys/sysconf.h +++ b/include/zephyr/posix/sys/sysconf.h @@ -178,7 +178,7 @@ enum { #define __z_posix_sysconf_SC_SHELL (-1L) #define __z_posix_sysconf_SC_SPAWN (-1L) #define __z_posix_sysconf_SC_SPIN_LOCKS \ - COND_CODE_1(CONFIG_PTHREAD_SPINLOCK, (_POSIX_SPIN_LOCKS), (-1L)) + COND_CODE_1(CONFIG_POSIX_SPIN_LOCKS, (_POSIX_SPIN_LOCKS), (-1L)) #define __z_posix_sysconf_SC_SPORADIC_SERVER (-1L) #define __z_posix_sysconf_SC_SS_REPL_MAX _POSIX_SS_REPL_MAX #define __z_posix_sysconf_SC_SYNCHRONIZED_IO (-1L) diff --git a/lib/posix/options/CMakeLists.txt b/lib/posix/options/CMakeLists.txt index 509f1d3c0e1..02c8c30dd74 100644 --- a/lib/posix/options/CMakeLists.txt +++ b/lib/posix/options/CMakeLists.txt @@ -62,6 +62,7 @@ zephyr_library_sources_ifdef(CONFIG_POSIX_SINGLE_PROCESS sysconf.c uname.c ) +zephyr_library_sources_ifdef(CONFIG_POSIX_SPIN_LOCKS spinlock.c) zephyr_library_sources_ifdef(CONFIG_POSIX_SYSLOG syslog.c) zephyr_library_sources_ifdef(CONFIG_POSIX_TIMERS clock.c @@ -75,7 +76,6 @@ 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_include_directories( ${ZEPHYR_BASE}/kernel/include diff --git a/lib/posix/options/Kconfig.deprecated b/lib/posix/options/Kconfig.deprecated index ecac0365d6c..203b8463bd7 100644 --- a/lib/posix/options/Kconfig.deprecated +++ b/lib/posix/options/Kconfig.deprecated @@ -102,6 +102,15 @@ config PTHREAD_BARRIER Please use CONFIG_POSIX_BARRIERS instead. +config PTHREAD_SPINLOCK + bool "pthread_spinlock_t support [DEPRECATED]" + select DEPRECATED + select POSIX_SPIN_LOCKS + help + This option is deprecated. + + Please use CONFIG_POSIX_SPIN_LOCKS instead. + config TIMER bool "Timer support [DEPRECATED]" select DEPRECATED diff --git a/lib/posix/options/Kconfig.spinlock b/lib/posix/options/Kconfig.spinlock index 8374aadfd6d..d5eb4a7028a 100644 --- a/lib/posix/options/Kconfig.spinlock +++ b/lib/posix/options/Kconfig.spinlock @@ -2,7 +2,27 @@ # # SPDX-License-Identifier: Apache-2.0 -TYPE = PTHREAD_SPINLOCK -type = pthread_spinlock_t -type-function = pthread_spin_lock -rsource "Kconfig.template.pooled_ipc_type" +menuconfig POSIX_SPIN_LOCKS + bool "POSIX spin locks" + default y if POSIX_API + help + Select 'y' here to enable POSIX spin locks. + + For more information please see + https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html + +if POSIX_SPIN_LOCKS + +config MAX_PTHREAD_SPINLOCK_COUNT + int "Maximum number of POSIX spin locks" + default 5 + help + Maximum simultaneously active spin locks in a POSIX application. + + Note: this is a non-standard option. + +module = PTHREAD_SPINLOCK +module-str = POSIX Spin Locks +source "subsys/logging/Kconfig.template.log_config" + +endif # POSIX_SPIN_LOCKS