Skip to content
Merged
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
15 changes: 15 additions & 0 deletions doc/services/portability/posix/option_groups/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,21 @@ Enable this option group with :kconfig:option:`CONFIG_XSI_REALTIME`.
When this option group is enabled, the ``_XOPEN_REALTIME`` feature test macro will be defined to a
value other than -1.

.. _posix_option_group_xsi_single_process:

XSI_SINGLE_PROCESS
++++++++++++++++++

Enable this option group with :kconfig:option:`CONFIG_XSI_SINGLE_PROCESS`.

.. csv-table:: XSI_SINGLE_PROCESS
:header: API, Supported
:widths: 50,10

gethostid(),yes
gettimeofday(),yes
putenv(),yes

.. _posix_option_group_xsi_system_logging:

XSI_SYSTEM_LOGGING
Expand Down
4 changes: 4 additions & 0 deletions include/zephyr/posix/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ size_t confstr(int name, char *buf, size_t len);
long sysconf(int opt);
#endif /* CONFIG_POSIX_SYSCONF_IMPL_FULL */

#if _XOPEN_SOURCE >= 500
long gethostid(void);
#endif

#ifdef __cplusplus
}
#endif
Expand Down
19 changes: 19 additions & 0 deletions lib/posix/options/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

set(GEN_DIR ${ZEPHYR_BINARY_DIR}/include/generated)

zephyr_syscall_header_ifdef(CONFIG_POSIX_CLOCK_SELECTION posix_clock.h)
zephyr_syscall_header_ifdef(CONFIG_POSIX_TIMERS posix_clock.h)
zephyr_syscall_header_ifdef(CONFIG_XSI_SINGLE_PROCESS posix_clock.h)

if(CONFIG_POSIX_API)
zephyr_include_directories(${ZEPHYR_BASE}/include/zephyr/posix)
Expand Down Expand Up @@ -44,6 +46,13 @@ if (NOT CONFIG_TC_PROVIDES_POSIX_BARRIERS)
zephyr_library_sources_ifdef(CONFIG_POSIX_BARRIERS barrier.c)
endif()

if (NOT CONFIG_TC_PROVIDES_POSIX_CLOCK_SELECTION)
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK_SELECTION
clock_common.c
clock_selection.c
)
endif()

if (NOT CONFIG_TC_PROVIDES_POSIX_C_LIB_EXT)
zephyr_library_sources_ifdef(CONFIG_POSIX_C_LIB_EXT
fnmatch.c
Expand Down Expand Up @@ -102,6 +111,7 @@ if (NOT CONFIG_TC_PROVIDES_POSIX_SINGLE_PROCESS)
zephyr_library_sources_ifdef(CONFIG_POSIX_SINGLE_PROCESS
confstr.c
env.c
env_common.c
sysconf.c
uname.c
)
Expand All @@ -114,6 +124,7 @@ endif()
if (NOT CONFIG_TC_PROVIDES_POSIX_TIMERS)
zephyr_library_sources_ifdef(CONFIG_POSIX_TIMERS
clock.c
clock_common.c
timer.c
timespec_to_timeout.c
)
Expand Down Expand Up @@ -153,6 +164,14 @@ endif()

zephyr_library_sources_ifdef(CONFIG_XOPEN_STREAMS stropts.c)

if (NOT CONFIG_TC_PROVIDES_XSI_SINGLE_PROCESS)
zephyr_library_sources_ifdef(CONFIG_XSI_SINGLE_PROCESS
clock_common.c
env_common.c
xsi_single_process.c
)
endif()

if (NOT CONFIG_TC_PROVIDES_XSI_SYSTEM_LOGGING)
zephyr_library_sources_ifdef(CONFIG_XSI_SYSTEM_LOGGING syslog.c)
endif()
Expand Down
13 changes: 13 additions & 0 deletions lib/posix/options/Kconfig.clock_selection
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2025 Tenstorrent AI ULC
#
# SPDX-License-Identifier: Apache-2.0

config POSIX_CLOCK_SELECTION
bool "POSIX Clock Selection"
help
Select 'y' here and Zephyr will provide an implementation of the POSIX_CLOCK_SELECTION Option
Group, which includes the functions clock_nanosleep(), pthread_condattr_getclock(),
pthread_condattr_setclock().

For more information, please see
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
6 changes: 5 additions & 1 deletion lib/posix/options/Kconfig.proc1
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ config POSIX_UNAME_NODENAME_LEN
help
Defines the maximum string length of nodename version.

endif # POSIX_SINGLE_PROCESS

if POSIX_SINGLE_PROCESS || XSI_SINGLE_PROCESS

module = POSIX_ENV
module-str = POSIX env logging
source "subsys/logging/Kconfig.template.log_config"

endif # POSIX_SINGLE_PROCESS
endif # POSIX_SINGLE_PROCESS || XSI_SINGLE_PROCESS
1 change: 1 addition & 0 deletions lib/posix/options/Kconfig.profile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ config POSIX_API
imply EVENTFD # eventfd(), eventfd_read(), eventfd_write()
imply POSIX_FD_MGMT # open(), close(), read(), write()
imply POSIX_MULTI_PROCESS # sleep(), getpid(), etc
imply XSI_SINGLE_PROCESS # gettimeofday()
help
This option enables the required POSIX System Interfaces (base definitions), all of PSE51,
and some features found in PSE52.
Expand Down
7 changes: 5 additions & 2 deletions lib/posix/options/Kconfig.xsi_single_process
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

config XSI_SINGLE_PROCESS
bool "X/Open single process"
depends on POSIX_SINGLE_PROCESS
depends on POSIX_TIMERS
select HWINFO
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

module = XSI_SINGLE_PROCESS
module-str = XSI Single Process
source "subsys/logging/Kconfig.template.log_config"
Loading