Skip to content

Commit

Permalink
posix: options: add xsi realtime option group
Browse files Browse the repository at this point in the history
Add a POSIX Option Group called XSI_REALTIME (with Kconfig
option CONFIG_XSI_REALTIME).

When XSI_REALTIME is selected (or when required POSIX Options
are enabled), define _XOPEN_REALTIME to be something other
than -1 (_XOPEN_VERSION seemed appropriate).

Signed-off-by: Chris Friedt <[email protected]>
  • Loading branch information
cfriedt committed Jan 11, 2025
1 parent bffe7ed commit 174b929
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 16 deletions.
8 changes: 7 additions & 1 deletion include/zephyr/posix/posix_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) */

Expand Down
21 changes: 9 additions & 12 deletions lib/posix/options/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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.
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/posix/options/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions lib/posix/options/Kconfig.toolchain
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
28 changes: 28 additions & 0 deletions lib/posix/options/Kconfig.xsi_realtime
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 174b929

Please sign in to comment.