Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posix: options: add XSI_REALTIME option group #83303

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 10 additions & 1 deletion lib/posix/options/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ rsource "Kconfig.signal"
rsource "Kconfig.spinlock"
rsource "Kconfig.sync_io"
rsource "Kconfig.timer"
rsource "Kconfig.xsi"

menu "X/Open system interfaces"

rsource "Kconfig.xsi_realtime"
rsource "Kconfig.xsi_single_process"
rsource "Kconfig.xsi_streams"
rsource "Kconfig.xsi_system_logging"
rsource "Kconfig.xsi_threads_ext"

endmenu # "X/Open system interfaces"

rsource "Kconfig.compat"

Expand Down
2 changes: 1 addition & 1 deletion lib/posix/options/Kconfig.mem
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ config POSIX_MEMLOCK

config POSIX_MEMLOCK_RANGE
bool "POSIX range memory locking"
imply MMU
imply MMU if (CPU_HAS_MMU && ARCH_HAS_DEMAND_PAGING)
imply DEMAND_PAGING
help
Select 'y' here and Zephyr will provide support for mlock() and munlock().
Expand Down
10 changes: 5 additions & 5 deletions lib/posix/options/Kconfig.profile
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ config POSIX_BASE_DEFINITIONS
select POSIX_ASYNCHRONOUS_IO
select POSIX_BARRIERS
select POSIX_CLOCK_SELECTION
# select POSIX_MAPPED_FILES
# select POSIX_MEMORY_PROTECTION
select POSIX_MAPPED_FILES
select POSIX_MEMORY_PROTECTION
select POSIX_READER_WRITER_LOCKS
select POSIX_REALTIME_SIGNALS
select POSIX_SEMAPHORES
Expand All @@ -128,10 +128,10 @@ config POSIX_AEP_REALTIME_MINIMAL
select XSI_THREADS_EXT
# Options
select POSIX_FSYNC
# select POSIX_MEMLOCK
# select POSIX_MEMLOCK_RANGE
select POSIX_MEMLOCK
select POSIX_MEMLOCK_RANGE
select POSIX_MONOTONIC_CLOCK
# select POSIX_SHARED_MEMORY_OBJECTS
select POSIX_SHARED_MEMORY_OBJECTS
select POSIX_SYNCHRONIZED_IO
select POSIX_THREAD_ATTR_STACKADDR
select POSIX_THREAD_ATTR_STACKSIZE
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
45 changes: 0 additions & 45 deletions lib/posix/options/Kconfig.xsi

This file was deleted.

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
14 changes: 14 additions & 0 deletions lib/posix/options/Kconfig.xsi_single_process
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2024 Tenstorrent AI ULC
#
# SPDX-License-Identifier: Apache-2.0

config XSI_SINGLE_PROCESS
bool "X/Open single process"
depends on POSIX_SINGLE_PROCESS
depends on POSIX_TIMERS
help
Select 'y' here and Zephyr will provide implementations of
gethostid(), gettimeofday(), and putenv().

For more information, please see
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
12 changes: 12 additions & 0 deletions lib/posix/options/Kconfig.xsi_streams
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2024 Tenstorrent AI ULC
#
# SPDX-License-Identifier: Apache-2.0

config XOPEN_STREAMS
bool "X/Open streams"
help
This option provides support for the X/Open Streams interface, including functions such as
fattach(), fdetach(), getmsg(), getpmsg(), putmsg(), and putpmsg().

For more information, please see
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_05_09
12 changes: 12 additions & 0 deletions lib/posix/options/Kconfig.xsi_system_logging
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2024 Tenstorrent AI ULC
#
# SPDX-License-Identifier: Apache-2.0

config XSI_SYSTEM_LOGGING
bool "X/Open system logging"
help
This option provides support for closelog(), openlog(), syslog(),
setlogmask(), and vsyslog().

For more information, please see
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
12 changes: 12 additions & 0 deletions lib/posix/options/Kconfig.xsi_threads_ext
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2024 Tenstorrent AI ULC
#
# SPDX-License-Identifier: Apache-2.0

config XSI_THREADS_EXT
bool "X/Open threads extensions"
help
This option provides support for pthread_attr_getstack(), pthread_attr_setstack(),
pthread_getconcurrency(), and pthread_setconcurrency().

For more information, please see
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
22 changes: 16 additions & 6 deletions lib/posix/options/mlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,28 @@

int mlock(const void *addr, size_t len)
{
void *const _addr = (void *)addr;
if (IS_ENABLED(CONFIG_DEMAND_PAGING)) {
void *const _addr = (void *)addr;

k_mem_pin(_addr, len);
k_mem_pin(_addr, len);

return 0;
return 0;
}

errno = ENOTSUP;
return -1;
}

int munlock(const void *addr, size_t len)
{
void *const _addr = (void *)addr;
if (IS_ENABLED(CONFIG_DEMAND_PAGING)) {
void *const _addr = (void *)addr;

k_mem_unpin(_addr, len);

k_mem_unpin(_addr, len);
return 0;
}

return 0;
errno = ENOTSUP;
return -1;
}
Loading