diff --git a/include/zephyr/posix/posix_features.h b/include/zephyr/posix/posix_features.h index e4a91c6fc92cec..94789c5acb23a8 100644 --- a/include/zephyr/posix/posix_features.h +++ b/include/zephyr/posix/posix_features.h @@ -223,7 +223,13 @@ #define _XOPEN_VERSION 700 /* #define _XOPEN_CRYPT (-1L) */ /* #define _XOPEN_ENH_I18N (-1L) */ -/* #define _XOPEN_REALTIME (-1L) */ +#if defined(CONFIG_XSI_REALTIME) || \ + (defined(CONFIG_POSIX_FSYNC) && defined(CONFIG_POSIX_MEMLOCK) && \ + defined(CONFIG_POSIX_MEMLOCK_RANGE) && defined(CONFIG_POSIX_MESSAGE_PASSING) && \ + defined(CONFIG_POSIX_PRIORITY_SCHEDULING) && \ + defined(CONFIG_POSIX_SHARED_MEMORY_OBJECTS) && defined(CONFIG_POSIX_SYNCHRONIZED_IO)) +#define _XOPEN_REALTIME _XOPEN_VERSION +#endif /* #define _XOPEN_REALTIME_THREADS (-1L) */ /* #define _XOPEN_SHM (-1L) */ diff --git a/lib/posix/options/CMakeLists.txt b/lib/posix/options/CMakeLists.txt index b6e9d0bad4e209..f9b465d8a2b51e 100644 --- a/lib/posix/options/CMakeLists.txt +++ b/lib/posix/options/CMakeLists.txt @@ -75,10 +75,6 @@ if (NOT CONFIG_TC_PROVIDES_POSIX_FILE_SYSTEM_R) zephyr_library_sources_ifdef(CONFIG_POSIX_FILE_SYSTEM_R file_system_r.c) endif() -zephyr_library_sources_ifdef(CONFIG_POSIX_FSYNC fsync.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_MEMLOCK mlockall.c) -zephyr_library_sources_ifdef(CONFIG_POSIX_MEMLOCK_RANGE mlock.c) - if (NOT CONFIG_TC_PROVIDES_POSIX_MEMORY_PROTECTION) zephyr_library_sources_ifdef(CONFIG_POSIX_MEMORY_PROTECTION mprotect.c) endif() @@ -87,8 +83,6 @@ if (NOT CONFIG_TC_PROVIDES_POSIX_MAPPED_FILES) zephyr_library_sources_ifdef(CONFIG_POSIX_MAPPED_FILES mmap.c) endif() -zephyr_library_sources_ifdef(CONFIG_POSIX_MESSAGE_PASSING mqueue.c) - if (NOT CONFIG_TC_PROVIDES_POSIX_MULTI_PROCESS) zephyr_library_sources_ifdef(CONFIG_POSIX_MULTI_PROCESS sleep.c @@ -100,10 +94,6 @@ if (NOT CONFIG_TC_PROVIDES_POSIX_NETWORKING) zephyr_library_sources_ifdef(CONFIG_POSIX_NETWORKING net.c) endif() -if (NOT CONFIG_TC_PROVIDES_POSIX_SHARED_MEMORY_OBJECTS) - zephyr_library_sources_ifdef(CONFIG_POSIX_SHARED_MEMORY_OBJECTS shm.c) -endif() - if (NOT CONFIG_TC_PROVIDES_POSIX_SIGNALS) zephyr_library_sources_ifdef(CONFIG_POSIX_SIGNALS signal.c ${STRSIGNAL_TABLE_H}) endif() @@ -129,8 +119,6 @@ if (NOT CONFIG_TC_PROVIDES_POSIX_TIMERS) ) endif() -zephyr_library_sources_ifdef(CONFIG_POSIX_PRIORITY_SCHEDULING sched.c) - if (NOT CONFIG_TC_PROVIDES_POSIX_READER_WRITER_LOCKS) # Note: the Option is _POSIX_READER_WRITER_LOCKS, while the Option Group is POSIX_RW_LOCKS. # We have opted to use POSIX_READER_WRITER_LOCKS here to match the Option name. @@ -154,6 +142,15 @@ if (NOT CONFIG_TC_PROVIDES_POSIX_THREADS) ) endif() +if (NOT CONFIG_TC_PROVIDES_XSI_REALTIME) + zephyr_library_sources_ifdef(CONFIG_POSIX_FSYNC fsync.c) + zephyr_library_sources_ifdef(CONFIG_POSIX_MEMLOCK mlockall.c) + zephyr_library_sources_ifdef(CONFIG_POSIX_MEMLOCK_RANGE mlock.c) + zephyr_library_sources_ifdef(CONFIG_POSIX_MESSAGE_PASSING mqueue.c) + zephyr_library_sources_ifdef(CONFIG_POSIX_PRIORITY_SCHEDULING sched.c) + zephyr_library_sources_ifdef(CONFIG_POSIX_SHARED_MEMORY_OBJECTS shm.c) +endif() + zephyr_library_sources_ifdef(CONFIG_XOPEN_STREAMS stropts.c) if (NOT CONFIG_TC_PROVIDES_XSI_SYSTEM_LOGGING) diff --git a/lib/posix/options/Kconfig b/lib/posix/options/Kconfig index 6eef8b804a71d1..15d7f2233e630e 100644 --- a/lib/posix/options/Kconfig +++ b/lib/posix/options/Kconfig @@ -32,6 +32,7 @@ rsource "Kconfig.timer" menu "X/Open system interfaces" +rsource "Kconfig.xsi_realtime" rsource "Kconfig.xsi_single_process" rsource "Kconfig.xsi_streams" rsource "Kconfig.xsi_system_logging" diff --git a/lib/posix/options/Kconfig.toolchain b/lib/posix/options/Kconfig.toolchain index 30f274067e197d..e328a030879447 100644 --- a/lib/posix/options/Kconfig.toolchain +++ b/lib/posix/options/Kconfig.toolchain @@ -135,9 +135,6 @@ config TC_PROVIDES_POSIX_READER_WRITER_LOCKS config TC_PROVIDES_POSIX_SEMAPHORES bool -config TC_PROVIDES_POSIX_SHARED_MEMORY_OBJECTS - bool - config TC_PROVIDES_POSIX_SHELL_FUNC bool @@ -215,6 +212,9 @@ config TC_PROVIDES_XSI_MATH config TC_PROVIDES_XSI_MULTI_PROCESS bool +config TC_PROVIDES_XSI_REALTIME + bool + config TC_PROVIDES_XSI_SIGNALS bool diff --git a/lib/posix/options/Kconfig.xsi_realtime b/lib/posix/options/Kconfig.xsi_realtime new file mode 100644 index 00000000000000..4c232b77a1dd2c --- /dev/null +++ b/lib/posix/options/Kconfig.xsi_realtime @@ -0,0 +1,28 @@ +# Copyright (c) 2024 Tenstorrent AI ULC +# +# SPDX-License-Identifier: Apache-2.0 + +config XSI_REALTIME + bool "X/Open realtime" + select POSIX_FSYNC + select POSIX_MEMLOCK + select POSIX_MEMLOCK_RANGE + select POSIX_MESSAGE_PASSING + # Not yet implemented, but optional + # imply POSIX_PRIORITIZED_IO + select POSIX_PRIORITY_SCHEDULING + select POSIX_SHARED_MEMORY_OBJECTS + select POSIX_SYNCHRONIZED_IO + help + Select 'y' here and the following functions will be provided: + + fsync(), mlockall(), munlockall(), mlock(), munlock(), mq_close(), mq_getattr(), mq_notify(), + mq_open(), mq_receive(), mq_send(), mq_setattr(), mq_unlink(), sched_get_priority_max(), + sched_get_priority_min(), sched_getparam(), sched_getscheduler(), sched_rr_get_interval(), + sched_setparam(), sched_setscheduler(), sched_yield(), mmap(), munmap(), shm_open(), + shm_unlink() + + The functions fsync(), fdatasync(), and open() will provide synchronized I/O capability. + + For more information, please see + https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html