posix: deprecate POSIX_ENV _CONFSTR _SYSCONF and _UNAME

This change deprecates the following Kconfig options
* CONFIG_POSIX_ENV
* CONFIG_POSIX_CONFSTR
* CONFIG_POSIX_SYSCONF
* CONFIG_POSIX_UNAME

and instead groups them into a single Kconfig option that maps
directly to the standard. Namely, CONFIG_POSIX_SINGLE_PROCESS.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This commit is contained in:
Chris Friedt 2024-05-22 18:04:35 -04:00 committed by David Leach
commit 2fe9d6cd68
16 changed files with 133 additions and 117 deletions

View file

@ -52,7 +52,7 @@ The *Minimal Realtime System Profile* (PSE51) includes all of the
:ref:`POSIX_C_LANG_SUPPORT <posix_option_group_c_lang_support>`, yes,
:ref:`POSIX_DEVICE_IO <posix_option_group_device_io>`,, :kconfig:option:`CONFIG_POSIX_DEVICE_IO`
:ref:`POSIX_SIGNALS <posix_option_group_signals>`,,
:ref:`POSIX_SINGLE_PROCESS <posix_option_group_single_process>`, yes,
:ref:`POSIX_SINGLE_PROCESS <posix_option_group_single_process>`, yes, :kconfig:option:`CONFIG_POSIX_SINGLE_PROCESS`
:ref:`POSIX_THREADS_BASE <posix_option_group_threads_base>`, yes,
:ref:`XSI_THREADS_EXT <posix_option_group_xsi_threads_ext>`, yes,

View file

@ -30,7 +30,6 @@ implementation of the POSIX API.
* :kconfig:option:`CONFIG_POSIX_RTSIG_MAX`
* :kconfig:option:`CONFIG_POSIX_SIGNAL`
* :kconfig:option:`CONFIG_POSIX_SIGNAL_STRING_DESC`
* :kconfig:option:`CONFIG_POSIX_UNAME`
* :kconfig:option:`CONFIG_POSIX_UNAME_NODENAME_LEN`
* :kconfig:option:`CONFIG_POSIX_UNAME_VERSION_LEN`
* :kconfig:option:`CONFIG_PTHREAD`

View file

@ -6,15 +6,23 @@
#ifndef ZEPHYR_INCLUDE_POSIX_SYS_UTSNAME_H_
#define ZEPHYR_INCLUDE_POSIX_SYS_UTSNAME_H_
#include <zephyr/sys/util_macro.h>
#ifdef __cplusplus
extern "C" {
#endif
/* These are for compatibility / practicality */
#define _UTSNAME_NODENAME_LENGTH \
COND_CODE_1(CONFIG_POSIX_SINGLE_PROCESS, (CONFIG_POSIX_UNAME_VERSION_LEN), (0))
#define _UTSNAME_VERSION_LENGTH \
COND_CODE_1(CONFIG_POSIX_SINGLE_PROCESS, (CONFIG_POSIX_UNAME_VERSION_LEN), (0))
struct utsname {
char sysname[sizeof("Zephyr")];
char nodename[CONFIG_POSIX_UNAME_NODENAME_LEN + 1];
char nodename[_UTSNAME_NODENAME_LENGTH + 1];
char release[sizeof("99.99.99-rc1")];
char version[CONFIG_POSIX_UNAME_VERSION_LEN + 1];
char version[_UTSNAME_VERSION_LENGTH + 1];
char machine[sizeof(CONFIG_ARCH)];
};

View file

@ -25,7 +25,8 @@ if(CONFIG_POSIX_SIGNAL)
endif()
if(CONFIG_POSIX_API OR CONFIG_PTHREAD_IPC OR CONFIG_POSIX_TIMERS OR
CONFIG_POSIX_MQUEUE OR CONFIG_POSIX_FS OR CONFIG_EVENTFD OR CONFIG_GETOPT)
CONFIG_POSIX_MQUEUE OR CONFIG_POSIX_FS OR CONFIG_EVENTFD OR CONFIG_GETOPT OR
CONFIG_POSIX_SINGLE_PROCESS)
# This is a temporary workaround so that Newlib declares the appropriate
# types for us. POSIX features to be formalized as part of #51211
zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:-D_POSIX_THREADS>)
@ -39,13 +40,11 @@ zephyr_library_sources_ifdef(CONFIG_FNMATCH fnmatch.c)
zephyr_library_sources_ifdef(CONFIG_GETENTROPY getentropy.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_ASYNCHRONOUS_IO aio.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_BARRIERS barrier.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CONFSTR confstr.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_DEVICE_IO
# perror should be moved to the common libc
perror.c
device_io.c
)
zephyr_library_sources_ifdef(CONFIG_POSIX_ENV env.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_FD_MGMT
fd_mgmt.c
)
@ -57,13 +56,17 @@ zephyr_library_sources_ifdef(CONFIG_POSIX_MULTI_PROCESS
zephyr_library_sources_ifdef(CONFIG_POSIX_NETWORKING net.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_PUTMSG stropts.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_SIGNAL signal.c ${STRSIGNAL_TABLE_H})
zephyr_library_sources_ifdef(CONFIG_POSIX_SYSCONF_IMPL_FULL sysconf.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_SINGLE_PROCESS
confstr.c
env.c
sysconf.c
uname.c
)
zephyr_library_sources_ifdef(CONFIG_POSIX_SYSLOG syslog.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_TIMERS
clock.c
timer.c
)
zephyr_library_sources_ifdef(CONFIG_POSIX_UNAME uname.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_IPC _common.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_COND cond.c)
zephyr_library_sources_ifdef(CONFIG_PTHREAD_KEY key.c)

View file

@ -26,9 +26,7 @@ config PTHREAD_IPC
rsource "Kconfig.aio"
rsource "Kconfig.barrier"
rsource "Kconfig.cond"
rsource "Kconfig.confstr"
rsource "Kconfig.device_io"
rsource "Kconfig.env"
rsource "Kconfig.eventfd"
rsource "Kconfig.fd_mgmt"
rsource "Kconfig.fnmatch"
@ -36,9 +34,11 @@ rsource "Kconfig.fs"
rsource "Kconfig.getentropy"
rsource "Kconfig.getopt"
rsource "Kconfig.key"
rsource "Kconfig.mem"
rsource "Kconfig.mqueue"
rsource "Kconfig.mutex"
rsource "Kconfig.net"
rsource "Kconfig.proc1"
rsource "Kconfig.procN"
rsource "Kconfig.pthread"
rsource "Kconfig.rwlock"
@ -47,10 +47,8 @@ rsource "Kconfig.semaphore"
rsource "Kconfig.signal"
rsource "Kconfig.spinlock"
rsource "Kconfig.stropts"
rsource "Kconfig.sysconf"
rsource "Kconfig.syslog"
rsource "Kconfig.timer"
rsource "Kconfig.uname"
rsource "Kconfig.xsi"
rsource "Kconfig.deprecated"

View file

@ -1,9 +0,0 @@
# Copyright (c) 2024, Meta
#
# SPDX-License-Identifier: Apache-2.0
config POSIX_CONFSTR
bool "Retrieve string system configuration"
default y if POSIX_API
help
This enables the POSIX confstr() function.

View file

@ -28,6 +28,24 @@ config POSIX_CLOCK
Please use CONFIG_POSIX_TIMERS instead.
config POSIX_CONFSTR
bool "Retrieve string system configuration [DEPRECATED]"
select DEPRECATED
select POSIX_SINGLE_PROCESS
help
This option is deprecated.
Please use CONFIG_POSIX_SINGLE_PROCESS instead.
config POSIX_ENV
bool "Support for environ, getenv(), getenv_r(), setenv(), and unsetenv() [DEPRECATED]"
select DEPRECATED
select POSIX_SINGLE_PROCESS
help
This option is deprecated.
Please use CONFIG_POSIX_SINGLE_PROCESS instead.
config POSIX_LIMITS_RTSIG_MAX
int "_POSIX_RTSIG_MAX value in limits.h [DEPRECATED]"
default POSIX_RTSIG_MAX if POSIX_REALTIME_SIGNALS
@ -57,6 +75,24 @@ config POSIX_MAX_OPEN_FILES
See also CONFIG_ZVFS_OPEN_MAX.
config POSIX_SYSCONF
bool "Support for sysconf() [DEPRECATED]"
select DEPRECATED
select POSIX_SINGLE_PROCESS
help
This option is deprecated.
Please use CONFIG_POSIX_SINGLE_PROCESS instead.
config POSIX_UNAME
bool "Support for uname [DEPRECATED]"
select DEPRECATED
select POSIX_SINGLE_PROCESS
help
This option is deprecated.
Please use CONFIG_POSIX_SINGLE_PROCESS instead.
config PTHREAD_BARRIER
bool "pthread_barrier_t support [DEPRECATED]"
select DEPRECATED

View file

@ -1,14 +0,0 @@
# Copyright (c) 2023, Meta
#
# SPDX-License-Identifier: Apache-2.0
config POSIX_ENV
bool "Support for environ, getenv(), getenv_r(), setenv(), and unsetenv()"
depends on COMMON_LIBC_MALLOC
default y if POSIX_API
help
Select this option to add support for environment variables.
module = POSIX_ENV
module-str = POSIX env logging
source "subsys/logging/Kconfig.template.log_config"

View file

@ -0,0 +1,13 @@
# Copyright (c) 2024 BayLibre SAS
#
# SPDX-License-Identifier: Apache-2.0
config POSIX_PAGE_SIZE_BITS
int "Number of bits to use for PAGE_SIZE"
range 6 16
default 12 if POSIX_API
default 6
help
Define PAGE_SIZE as BIT(n), where n is the value configured here.
PAGE_SIZE is supported in the range [64, 65536]
If CONFIG_POSIX_API=y, PAGE_SIZE defaults to 4096, otherwise, it is 64 bytes.

View file

@ -0,0 +1,57 @@
# Copyright (c) 2023 Meta
# Copyright (c) 2024 BayLibre SAS
# Copyright (c) 2024 Tenstorrent AI ULC
#
# SPDX-License-Identifier: Apache-2.0
menuconfig POSIX_SINGLE_PROCESS
bool "POSIX single process support"
default y if POSIX_API
# imply COMMON_LIBC_MALLOC # for env.c
help
Select 'y' here to use confstr(), environ, errno, getenv(), setenv(), sysconf(), uname(),
or unsetenv().
For more information, please see
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
if POSIX_SINGLE_PROCESS
choice POSIX_SYSCONF_IMPL_CHOICE
default POSIX_SYSCONF_IMPL_FULL if CPP
default POSIX_SYSCONF_IMPL_MACRO
prompt "Sysconf implementation method"
config POSIX_SYSCONF_IMPL_MACRO
bool "Macro"
help
The sysconf() function is implemented compile-time constant via macros. This is the option
with the least overhead. The downside is that sysconf() is not an addressable function.
config POSIX_SYSCONF_IMPL_FULL
bool "Full"
help
The sysconf() function is implemented as a large integer-integer array. The advantage if this
option is that all sysconf() options can be queried and that the sysconf() symbol is
addressable.
endchoice
config POSIX_UNAME_VERSION_LEN
int "uname version string length"
default 70
help
Defines the maximum string length of uname version.
config POSIX_UNAME_NODENAME_LEN
int "uname nodename string length"
default 6 if !NET_HOSTNAME_UNIQUE
default 22 if NET_HOSTNAME_UNIQUE
help
Defines the maximum string length of nodename version.
module = POSIX_ENV
module-str = POSIX env logging
source "subsys/logging/Kconfig.template.log_config"
endif # POSIX_SINGLE_PROCESS

View file

@ -1,48 +0,0 @@
# Copyright (c) 2024 BayLibre SAS
#
# SPDX-License-Identifier: Apache-2.0
menu "Sysconf support"
config POSIX_SYSCONF
bool "Support for sysconf"
default y if POSIX_API
help
The sysconf() function provides a method for the application to determine
the current value of a configurable system limit or option (variable).
config POSIX_PAGE_SIZE_BITS
int "Number of bits to use for PAGE_SIZE"
range 6 16
default 12 if POSIX_API
default 6
help
Define PAGE_SIZE as BIT(n), where n is the value configured here.
PAGE_SIZE is supported in the range [64, 65536]
If CONFIG_POSIX_API=y, PAGE_SIZE defaults to 4096, otherwise, it is 64 bytes.
if POSIX_SYSCONF
choice POSIX_SYSCONF_IMPL_CHOICE
default POSIX_SYSCONF_IMPL_FULL if CPP
default POSIX_SYSCONF_IMPL_MACRO
prompt "Sysconf implementation method"
config POSIX_SYSCONF_IMPL_MACRO
bool "Macro"
help
The sysconf() function is implemented compile-time constant via macros. This is the option
with the least overhead. The downside is that sysconf() is not an addressable function.
config POSIX_SYSCONF_IMPL_FULL
bool "Full"
help
The sysconf() function is implemented as a large integer-integer array. The advantage if this
option is that all sysconf() options can be queried and that the sysconf() symbol is
addressable.
endchoice
endif # POSIX_SYSCONF
endmenu # "Sysconf support"

View file

@ -1,26 +0,0 @@
# Copyright (c) 2023 Meta
#
# SPDX-License-Identifier: Apache-2.0
menuconfig POSIX_UNAME
bool "Support for uname"
default y if POSIX_API
help
The uname() function shall store information identifying the current
system in the structure pointed to by name.
if POSIX_UNAME
config POSIX_UNAME_VERSION_LEN
int "uname version string length"
default 70
help
Defines the maximum string length of uname version.
config POSIX_UNAME_NODENAME_LEN
int "uname nodename string length"
default 6 if !NET_HOSTNAME_UNIQUE
default 22 if NET_HOSTNAME_UNIQUE
help
Defines the maximum string length of nodename version.
endif # POSIX_UNAME

View file

@ -5,9 +5,8 @@
config XSI_SINGLE_PROCESS
bool "X/Open single process"
default y if POSIX_API
depends on POSIX_ENV
depends on POSIX_UNAME
depends on POSIX_CLOCK_SELECTION
depends on POSIX_SINGLE_PROCESS
depends on POSIX_TIMERS
help
Select 'y' here and Zephyr will provide implementations of
gethostid(), gettimeofday(), and putenv().

View file

@ -3,7 +3,7 @@
config POSIX_ENV_SHELL
bool "Support for shell"
select POSIX_ENV
select POSIX_SINGLE_PROCESS
select POSIX_SHELL
help
This shell provides access to system environment variables.

View file

@ -1,7 +1,7 @@
# Copyright (c) 2024 Meta
# SPDX-License-Identifier: Apache-2.0
if POSIX_UNAME
if POSIX_SINGLE_PROCESS
config POSIX_UNAME_SHELL
bool "Support for `uname` command"
@ -10,4 +10,4 @@ config POSIX_UNAME_SHELL
help
Support for `uname` command in the terminal.
endif # POSIX_UNAME
endif # POSIX_SINGLE_PROCESS

View file

@ -1,5 +1,5 @@
CONFIG_ZTEST=y
CONFIG_POSIX_ENV=y
CONFIG_POSIX_SINGLE_PROCESS=y
# Let's explicitly choose PICOLIBC, so it is used if supported even if it would not have been the
# default (otherwise native targets default to the host C library)
CONFIG_PICOLIBC=y