From a201987d2c5353975cd56e63179c2bc828cabb57 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Fri, 17 Oct 2025 22:25:46 -0400 Subject: [PATCH 01/13] posix: xsi: streams: deprecate CONFIG_XOPEN_STREAMS CONFIG_XOPEN_STREAMS does not follow the pattern of other XSI Option Groups, where the Option Group name is not the same as the feature test macro that indicates it is supported by the implementation. Deprecate CONFIG_XOPEN_STREAMS and rename it to CONFIG_XSI_STREAMS. For more information, please see https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/\ V1_chap02.html#tag_02_01_05_09 Signed-off-by: Chris Friedt --- doc/services/portability/posix/conformance/index.rst | 2 +- doc/services/portability/posix/option_groups/index.rst | 2 +- lib/posix/options/CMakeLists.txt | 9 +++++++-- lib/posix/options/Kconfig.xsi_streams | 9 ++++++++- samples/modules/thrift/hello/client/prj.conf | 2 +- samples/modules/thrift/hello/server/prj.conf | 2 +- tests/modules/thrift/ThriftTest/prj.conf | 2 +- tests/posix/common/prj.conf | 2 +- tests/posix/eventfd/prj.conf | 2 +- tests/posix/headers/prj.conf | 2 +- tests/posix/xsi_streams/prj.conf | 2 +- 11 files changed, 24 insertions(+), 12 deletions(-) diff --git a/doc/services/portability/posix/conformance/index.rst b/doc/services/portability/posix/conformance/index.rst index 23faa7568fa01..cea2ed3d15b4f 100644 --- a/doc/services/portability/posix/conformance/index.rst +++ b/doc/services/portability/posix/conformance/index.rst @@ -97,7 +97,7 @@ POSIX System Interfaces _XOPEN_CRYPT, -1, :ref:`_XOPEN_REALTIME `, 700, :kconfig:option:`CONFIG_XSI_REALTIME` _XOPEN_REALTIME_THREADS, -1, - :ref:`_XOPEN_STREAMS`, 200809L, :kconfig:option:`CONFIG_XOPEN_STREAMS` + :ref:`_XOPEN_STREAMS`, 200809L, :kconfig:option:`CONFIG_XSI_STREAMS` _XOPEN_UNIX, -1, diff --git a/doc/services/portability/posix/option_groups/index.rst b/doc/services/portability/posix/option_groups/index.rst index 695d57051da38..4f33044fad7b9 100644 --- a/doc/services/portability/posix/option_groups/index.rst +++ b/doc/services/portability/posix/option_groups/index.rst @@ -1111,7 +1111,7 @@ implemented in Zephyr but are provided so that conformant applications can still Unimplemented functions in this option group will fail, setting ``errno`` to ``ENOSYS`` :ref:`†`. -Enable this option with :kconfig:option:`CONFIG_XOPEN_STREAMS`. +Enable this option with :kconfig:option:`CONFIG_XSI_STREAMS`. .. csv-table:: _XOPEN_STREAMS :header: API, Supported diff --git a/lib/posix/options/CMakeLists.txt b/lib/posix/options/CMakeLists.txt index 3c0a886edd2eb..c901853041aee 100644 --- a/lib/posix/options/CMakeLists.txt +++ b/lib/posix/options/CMakeLists.txt @@ -165,8 +165,6 @@ if(NOT CONFIG_TC_PROVIDES_XSI_REALTIME) 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_SINGLE_PROCESS) zephyr_library_sources_ifdef(CONFIG_XSI_SINGLE_PROCESS env_common.c @@ -174,6 +172,13 @@ if (NOT CONFIG_TC_PROVIDES_XSI_SINGLE_PROCESS) ) endif() +if(NOT CONFIG_TC_PROVIDES_XSI_STREAMS) + zephyr_library_sources_ifdef(CONFIG_XSI_STREAMS stropts.c) +endif() +if(CONFIG_XSI_STREAMS) + zephyr_compile_definitions(-D_XOPEN_STREAMS=${POSIX_VERSION}) +endif() + if (NOT CONFIG_TC_PROVIDES_XSI_SYSTEM_LOGGING) zephyr_library_sources_ifdef(CONFIG_XSI_SYSTEM_LOGGING syslog.c) endif() diff --git a/lib/posix/options/Kconfig.xsi_streams b/lib/posix/options/Kconfig.xsi_streams index 21b7e2010b517..06088d48455b5 100644 --- a/lib/posix/options/Kconfig.xsi_streams +++ b/lib/posix/options/Kconfig.xsi_streams @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -config XOPEN_STREAMS +config XSI_STREAMS bool "X/Open streams" help This option provides support for the X/Open Streams interface, including functions such as @@ -10,3 +10,10 @@ config XOPEN_STREAMS For more information, please see https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_05_09 + +config XOPEN_STREAMS + bool "X/Open Streams [DEPRECATED]" + select XSI_STREAMS + select DEPRECATED + help + This option is deprecated. Please use XSI_STREAMS instead. diff --git a/samples/modules/thrift/hello/client/prj.conf b/samples/modules/thrift/hello/client/prj.conf index 3c3cfcdbbe8e1..bce2363d7f1ee 100644 --- a/samples/modules/thrift/hello/client/prj.conf +++ b/samples/modules/thrift/hello/client/prj.conf @@ -5,7 +5,7 @@ CONFIG_CPP=y CONFIG_STD_CPP17=y CONFIG_CPP_EXCEPTIONS=y CONFIG_POSIX_API=y -CONFIG_XOPEN_STREAMS=y +CONFIG_XSI_STREAMS=y CONFIG_COMMON_LIBC_THRD=y CONFIG_DYNAMIC_THREAD=y CONFIG_THREAD_STACK_INFO=y diff --git a/samples/modules/thrift/hello/server/prj.conf b/samples/modules/thrift/hello/server/prj.conf index 78b009fb3e285..4095642c136d0 100644 --- a/samples/modules/thrift/hello/server/prj.conf +++ b/samples/modules/thrift/hello/server/prj.conf @@ -6,7 +6,7 @@ CONFIG_CPP=y CONFIG_STD_CPP17=y CONFIG_CPP_EXCEPTIONS=y CONFIG_POSIX_API=y -CONFIG_XOPEN_STREAMS=y +CONFIG_XSI_STREAMS=y CONFIG_NET_SOCKETPAIR=y CONFIG_HEAP_MEM_POOL_SIZE=16384 CONFIG_EVENTFD=y diff --git a/tests/modules/thrift/ThriftTest/prj.conf b/tests/modules/thrift/ThriftTest/prj.conf index 4bc7153026a10..c304c7b3434d4 100755 --- a/tests/modules/thrift/ThriftTest/prj.conf +++ b/tests/modules/thrift/ThriftTest/prj.conf @@ -7,7 +7,7 @@ CONFIG_STD_CPP17=y CONFIG_CPP_EXCEPTIONS=y CONFIG_GLIBCXX_LIBCPP=y CONFIG_POSIX_API=y -CONFIG_XOPEN_STREAMS=y +CONFIG_XSI_STREAMS=y CONFIG_NETWORKING=y CONFIG_NET_TCP=y CONFIG_NET_SOCKETS=y diff --git a/tests/posix/common/prj.conf b/tests/posix/common/prj.conf index f50d956f8b274..7c34c53b0e21c 100644 --- a/tests/posix/common/prj.conf +++ b/tests/posix/common/prj.conf @@ -16,7 +16,7 @@ CONFIG_TEST_EXTRA_STACK_SIZE=4096 CONFIG_POSIX_C_LIB_EXT=y # for putmsg() -CONFIG_XOPEN_STREAMS=y +CONFIG_XSI_STREAMS=y # for sleep(), getpid() CONFIG_POSIX_MULTI_PROCESS=y diff --git a/tests/posix/eventfd/prj.conf b/tests/posix/eventfd/prj.conf index a5839a7a447a7..d3c4ddb9296f2 100644 --- a/tests/posix/eventfd/prj.conf +++ b/tests/posix/eventfd/prj.conf @@ -9,5 +9,5 @@ CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_ZTEST=y CONFIG_POSIX_API=y -CONFIG_XOPEN_STREAMS=y +CONFIG_XSI_STREAMS=y CONFIG_EVENTFD=y diff --git a/tests/posix/headers/prj.conf b/tests/posix/headers/prj.conf index e5c34983aeaf2..c7dc4bb313a38 100644 --- a/tests/posix/headers/prj.conf +++ b/tests/posix/headers/prj.conf @@ -14,7 +14,7 @@ CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_POSIX_PRIORITY_SCHEDULING=y # For putmsg(), etc -CONFIG_XOPEN_STREAMS=y +CONFIG_XSI_STREAMS=y # for when CONFIG_POSIX_API is not selected CONFIG_POSIX_THREADS=y diff --git a/tests/posix/xsi_streams/prj.conf b/tests/posix/xsi_streams/prj.conf index 6a39c38d1c684..ee23313bd2950 100644 --- a/tests/posix/xsi_streams/prj.conf +++ b/tests/posix/xsi_streams/prj.conf @@ -2,4 +2,4 @@ CONFIG_POSIX_API=y CONFIG_ZTEST=y CONFIG_POSIX_AEP_CHOICE_BASE=y -CONFIG_XOPEN_STREAMS=y +CONFIG_XSI_STREAMS=y From 052718efe9399eea5c777edd4721fdb02f71b540 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Fri, 17 Oct 2025 22:35:35 -0400 Subject: [PATCH 02/13] doc: release: 4.3: deprecate CONFIG_XOPEN_STREAMS Deprecate the CONFIG_XOPEN_STREAMS Kconfig option in favour of CONFIG_XSI_STREAMS, which matches the naming conventions of other XSI Kconfig options and the actual Option Group name in the specification. Please use CONFIG_XSI_STREAMS instead. Signed-off-by: Chris Friedt --- doc/releases/release-notes-4.3.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/releases/release-notes-4.3.rst b/doc/releases/release-notes-4.3.rst index 5644568846b44..2d709b7512311 100644 --- a/doc/releases/release-notes-4.3.rst +++ b/doc/releases/release-notes-4.3.rst @@ -84,6 +84,8 @@ Deprecated APIs and options * :c:func:`bt_ctlr_set_public_addr` is deprecated in favor of using :c:struct:`bt_hci_cp_vs_write_bd_addr` for setting the public Bluetooth device address. +* :kconfig:option:`CONFIG_XOPEN_STREAMS` was deprecated. Use :kconfig:option:`CONFIG_XSI_STREAMS` instead. + New APIs and options ==================== From 435a5e7051e790eff9fba1b0fb7423146b8e57e4 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Mon, 13 Oct 2025 11:16:59 -0400 Subject: [PATCH 03/13] libc: newlib + picolibc: indicate sigevent and sigval are declared Indicate that C library headers have declared `struct sigevent` and `struct sigval` to avoid redefinition warnings / errors. Signed-off-by: Chris Friedt --- lib/libc/newlib/include/signal.h | 5 +++++ lib/libc/picolibc/include/signal.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/libc/newlib/include/signal.h b/lib/libc/newlib/include/signal.h index 6d61c9d65a70b..7601ed05827cf 100644 --- a/lib/libc/newlib/include/signal.h +++ b/lib/libc/newlib/include/signal.h @@ -34,6 +34,11 @@ #undef sigdelset #undef sigismember +#if defined(_POSIX_REALTIME_SIGNALS) +#define _SIGEVENT_DECLARED +#define _SIGVAL_DECLARED +#endif + #endif /* defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__) */ #endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SIGNAL_H_ */ diff --git a/lib/libc/picolibc/include/signal.h b/lib/libc/picolibc/include/signal.h index a65b544c3fcd1..1bef4691069fd 100644 --- a/lib/libc/picolibc/include/signal.h +++ b/lib/libc/picolibc/include/signal.h @@ -47,6 +47,11 @@ int pthread_sigmask(int how, const sigset_t *ZRESTRICT set, sigset_t *ZRESTRICT #undef sigdelset #undef sigismember +#if defined(_POSIX_REALTIME_SIGNALS) +#define _SIGEVENT_DECLARED +#define _SIGVAL_DECLARED +#endif + #endif /* defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__) */ #endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SIGNAL_H_ */ From 51ece0c6c942fe5088f337e6f230ce644f82e2c5 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Mon, 13 Oct 2025 10:01:09 -0400 Subject: [PATCH 04/13] libc: indicate timespec is defined In order to avoid multiple definition errors, indicate that struct timespec is declared. Signed-off-by: Chris Friedt --- lib/libc/arcmwdt/include/sys/timespec.h | 2 ++ lib/libc/armstdc/include/sys/_timespec.h | 1 + lib/libc/minimal/include/sys/_timespec.h | 4 ++++ lib/libc/newlib/include/sys/_timespec.h | 14 ++++++++++++++ lib/libc/picolibc/include/sys/_timespec.h | 14 ++++++++++++++ 5 files changed, 35 insertions(+) create mode 100644 lib/libc/newlib/include/sys/_timespec.h create mode 100644 lib/libc/picolibc/include/sys/_timespec.h diff --git a/lib/libc/arcmwdt/include/sys/timespec.h b/lib/libc/arcmwdt/include/sys/timespec.h index 4f9c4f44d19d7..676bc3687b1eb 100644 --- a/lib/libc/arcmwdt/include/sys/timespec.h +++ b/lib/libc/arcmwdt/include/sys/timespec.h @@ -9,6 +9,8 @@ #include +#define _TIMESPEC_DECLARED + struct itimerspec { struct timespec it_interval; /* Timer interval */ struct timespec it_value; /* Timer expiration */ diff --git a/lib/libc/armstdc/include/sys/_timespec.h b/lib/libc/armstdc/include/sys/_timespec.h index ce29c446b94f0..f0af1ee15deaf 100644 --- a/lib/libc/armstdc/include/sys/_timespec.h +++ b/lib/libc/armstdc/include/sys/_timespec.h @@ -13,5 +13,6 @@ struct timespec { time_t tv_sec; long tv_nsec; }; +#define __timespec_defined #endif /* ZEPHYR_LIB_LIBC_ARMSTDC_INCLUDE_SYS__TIMESPEC_H_ */ diff --git a/lib/libc/minimal/include/sys/_timespec.h b/lib/libc/minimal/include/sys/_timespec.h index 8d64edd6933e9..4ea849b673a72 100644 --- a/lib/libc/minimal/include/sys/_timespec.h +++ b/lib/libc/minimal/include/sys/_timespec.h @@ -19,9 +19,13 @@ typedef _TIME_T_ time_t; typedef _SUSECONDS_T_ suseconds_t; #endif +#if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined) struct timespec { time_t tv_sec; long tv_nsec; }; +#define __timespec_defined +#define _TIMESPEC_DECLARED +#endif #endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS__TIMESPEC_H_ */ diff --git a/lib/libc/newlib/include/sys/_timespec.h b/lib/libc/newlib/include/sys/_timespec.h new file mode 100644 index 0000000000000..57989d67640fc --- /dev/null +++ b/lib/libc/newlib/include/sys/_timespec.h @@ -0,0 +1,14 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS__TIMESPEC_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS__TIMESPEC_H_ + +#include_next + +#define _TIMESPEC_DECLARED + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS__TIMESPEC_H_ */ diff --git a/lib/libc/picolibc/include/sys/_timespec.h b/lib/libc/picolibc/include/sys/_timespec.h new file mode 100644 index 0000000000000..6b5c58d8ea68a --- /dev/null +++ b/lib/libc/picolibc/include/sys/_timespec.h @@ -0,0 +1,14 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS__TIMESPEC_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS__TIMESPEC_H_ + +#include_next + +#define _TIMESPEC_DECLARED + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS__TIMESPEC_H_ */ From c98c0f18252cdd4419e6f6fcfa55b378b28e2dad Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Tue, 14 Oct 2025 15:07:10 -0400 Subject: [PATCH 05/13] libc: indicate timeval is defined In order to avoid multiple definition errors, indicate that struct timeval is declared. Signed-off-by: Chris Friedt --- lib/libc/armstdc/include/sys/_timeval.h | 1 + lib/libc/iar/include/sys/_timeval.h | 1 + lib/libc/minimal/include/sys/_timeval.h | 4 ++++ lib/libc/newlib/include/sys/_timeval.h | 14 ++++++++++++++ lib/libc/picolibc/include/sys/_timeval.h | 14 ++++++++++++++ 5 files changed, 34 insertions(+) create mode 100644 lib/libc/newlib/include/sys/_timeval.h create mode 100644 lib/libc/picolibc/include/sys/_timeval.h diff --git a/lib/libc/armstdc/include/sys/_timeval.h b/lib/libc/armstdc/include/sys/_timeval.h index fd81c8d3e0f9f..67fb1355aa667 100644 --- a/lib/libc/armstdc/include/sys/_timeval.h +++ b/lib/libc/armstdc/include/sys/_timeval.h @@ -23,5 +23,6 @@ struct timeval { time_t tv_sec; suseconds_t tv_usec; }; +#define __timeval_defined #endif /* ZEPHYR_LIB_LIBC_ARMSTDC_INCLUDE_SYS__TIMEVAL_H_ */ diff --git a/lib/libc/iar/include/sys/_timeval.h b/lib/libc/iar/include/sys/_timeval.h index 43f8f7f8c8973..3ec444519b1e5 100644 --- a/lib/libc/iar/include/sys/_timeval.h +++ b/lib/libc/iar/include/sys/_timeval.h @@ -23,5 +23,6 @@ struct timeval { time_t tv_sec; suseconds_t tv_usec; }; +#define __timeval_defined #endif /* ZEPHYR_LIB_LIBC_IAR_INCLUDE_SYS__TIMEVAL_H_ */ diff --git a/lib/libc/minimal/include/sys/_timeval.h b/lib/libc/minimal/include/sys/_timeval.h index f62043491c7a0..2b8fcb59fd4d3 100644 --- a/lib/libc/minimal/include/sys/_timeval.h +++ b/lib/libc/minimal/include/sys/_timeval.h @@ -19,9 +19,13 @@ typedef _TIME_T_ time_t; typedef _SUSECONDS_T_ suseconds_t; #endif +#if !defined(_TIMEVAL_DECLARED) && !defined(__timeval_defined) struct timeval { time_t tv_sec; suseconds_t tv_usec; }; +#define _TIMEVAL_DECLARED +#define __timeval_defined +#endif #endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS__TIMEVAL_H_ */ diff --git a/lib/libc/newlib/include/sys/_timeval.h b/lib/libc/newlib/include/sys/_timeval.h new file mode 100644 index 0000000000000..2a1ade762dddd --- /dev/null +++ b/lib/libc/newlib/include/sys/_timeval.h @@ -0,0 +1,14 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS__TIMEVAL_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS__TIMEVAL_H_ + +#include_next + +#define _TIMEVAL_DECLARED + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS__TIMEVAL_H_ */ diff --git a/lib/libc/picolibc/include/sys/_timeval.h b/lib/libc/picolibc/include/sys/_timeval.h new file mode 100644 index 0000000000000..b1a80bb6d10f7 --- /dev/null +++ b/lib/libc/picolibc/include/sys/_timeval.h @@ -0,0 +1,14 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS__TIMEVAL_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS__TIMEVAL_H_ + +#include_next + +#define _TIMEVAL_DECLARED + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS__TIMEVAL_H_ */ From 54fc20300d2949a93d6da509c3faaf72b05c2589 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Mon, 13 Oct 2025 08:48:27 -0400 Subject: [PATCH 06/13] posix: signal.h: always pull in time_t definition from libc Avoid redefining `time_t` by always including the definition from ``, since the C library may use something other than `long`. This is still safe according to the specification, since it explicitly states: > Inclusion of the header may make visible all symbols from > the header. For more information, please see https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html Signed-off-by: Chris Friedt --- include/zephyr/posix/posix_signal.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/zephyr/posix/posix_signal.h b/include/zephyr/posix/posix_signal.h index bfb1f30efdc6a..7522c3daf8ae5 100644 --- a/include/zephyr/posix/posix_signal.h +++ b/include/zephyr/posix/posix_signal.h @@ -43,11 +43,8 @@ typedef int uid_t; #define __uid_t_defined #endif -#if !defined(_TIME_T_DECLARED) && !defined(__time_t_defined) -typedef long time_t; -#define _TIME_T_DECLARED -#define __time_t_defined -#endif +/* time_t must be defined by the libc time.h */ +#include #if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined) struct timespec { From 7cb0a00fe042d67fe91dae6274168bc806fe0af5 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Mon, 13 Oct 2025 08:56:00 -0400 Subject: [PATCH 07/13] posix: signal.h: do not define struct timespec when >= c11 C11 requires `` to define `struct timespec`, so do not define it when C11 is already known. Signed-off-by: Chris Friedt --- include/zephyr/posix/posix_signal.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/zephyr/posix/posix_signal.h b/include/zephyr/posix/posix_signal.h index 7522c3daf8ae5..ce48ffecdd2fd 100644 --- a/include/zephyr/posix/posix_signal.h +++ b/include/zephyr/posix/posix_signal.h @@ -46,6 +46,9 @@ typedef int uid_t; /* time_t must be defined by the libc time.h */ #include +#if __STDC_VERSION__ >= 201112L +/* struct timespec must be defined in the libc time.h */ +#else #if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined) struct timespec { time_t tv_sec; @@ -54,6 +57,7 @@ struct timespec { #define _TIMESPEC_DECLARED #define __timespec_defined #endif +#endif /* sig_atomic_t must be defined by the libc signal.h */ From 0ffc71f8cdb9de39e2587bdacb0fab8a98c756b0 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Mon, 13 Oct 2025 08:57:32 -0400 Subject: [PATCH 08/13] posix: time.h: timepsec is a struct not a typedef A previous typo went undetected that declared a type-defined `timespec_t`, which is obviously incorrect, since it is only specified as `struct timespec`. Signed-off-by: Chris Friedt --- include/zephyr/posix/posix_time.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/zephyr/posix/posix_time.h b/include/zephyr/posix/posix_time.h index f2027e82875fc..1d6fabba64698 100644 --- a/include/zephyr/posix/posix_time.h +++ b/include/zephyr/posix/posix_time.h @@ -61,10 +61,10 @@ struct sigevent; /* struct timespec must be defined in the libc time.h */ #else #if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined) -typedef struct { +struct timespec { time_t tv_sec; long tv_nsec; -} timespec_t; +}; #define _TIMESPEC_DECLARED #define __timespec_defined #endif From 9c8de13a7fdea9095bf5afd7f6d44dce7fd8de83 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Mon, 13 Oct 2025 09:12:36 -0400 Subject: [PATCH 09/13] posix: signal.h: sigevent is a struct not a typedef A previous typo went undetected that declared a type-defined `sigevent_t`, which is obviously incorrect, since it is only specified as `struct sigevent`. Signed-off-by: Chris Friedt --- include/zephyr/posix/posix_signal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/zephyr/posix/posix_signal.h b/include/zephyr/posix/posix_signal.h index ce48ffecdd2fd..3e23fdf9295d0 100644 --- a/include/zephyr/posix/posix_signal.h +++ b/include/zephyr/posix/posix_signal.h @@ -101,14 +101,14 @@ typedef struct { union sigval; /* forward declaration (to preserve spec order) */ #if !defined(_SIGEVENT_DECLARED) && !defined(__sigevent_defined) -typedef struct { +struct sigevent { #if defined(_POSIX_THREADS) || defined(__DOXYGEN__) pthread_attr_t *sigev_thread_attr; #endif union sigval sigev_value; int sigev_notify; int sigev_signo; -} sigevent_t; +}; #define _SIGEVENT_DECLARED #define __sigevent_defined #endif From ed06190438287502fcb99eb2eb83d7efca8772c6 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Mon, 13 Oct 2025 09:14:53 -0400 Subject: [PATCH 10/13] posix: signal.h: reorder where sigval and siginfo_t are declared In order to avoid warnings, declare `union sigval` ahead of `struct sigevent` and declare `siginfo_t` ahead of `struct sigaction`. Signed-off-by: Chris Friedt --- include/zephyr/posix/posix_signal.h | 59 ++++++++++++++--------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/include/zephyr/posix/posix_signal.h b/include/zephyr/posix/posix_signal.h index 3e23fdf9295d0..d0e89079f79c8 100644 --- a/include/zephyr/posix/posix_signal.h +++ b/include/zephyr/posix/posix_signal.h @@ -98,7 +98,15 @@ typedef struct { #if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) -union sigval; /* forward declaration (to preserve spec order) */ +/* slightly out of order w.r.t. the specification */ +#if !defined(_SIGVAL_DECLARED) && !defined(__sigval_defined) +union sigval { + int sival_int; + void *sival_ptr; +}; +#define _SIGVAL_DECLARED +#define __sigval_defined +#endif #if !defined(_SIGEVENT_DECLARED) && !defined(__sigevent_defined) struct sigevent { @@ -121,17 +129,28 @@ struct sigevent { #endif /* defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) */ -#if !defined(_SIGVAL_DECLARED) && !defined(__sigval_defined) -union sigval { - int sival_int; - void *sival_ptr; -}; -#define _SIGVAL_DECLARED -#define __sigval_defined -#endif - /* SIGRTMIN and SIGRTMAX defined above */ +#if !defined(_SIGINFO_T_DECLARED) && !defined(__siginfo_t_defined) +typedef struct { + void *si_addr; +#if defined(_XOPEN_STREAMS) || defined(__DOXYGEN__) + long si_band; +#endif + union sigval si_value; + pid_t si_pid; + uid_t si_uid; + int si_signo; + int si_code; +#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__) + int si_errno; +#endif + int si_status; +} siginfo_t; +#define _SIGINFO_T_DECLARED +#define __siginfo_t_defined +#endif + #if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) #if !defined(_SIGACTION_DECLARED) && !defined(__sigaction_defined) @@ -200,26 +219,6 @@ typedef struct { #endif /* defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) */ -#if !defined(_SIGINFO_T_DECLARED) && !defined(__siginfo_t_defined) -typedef struct { - void *si_addr; -#if defined(_XOPEN_STREAMS) || defined(__DOXYGEN__) - long si_band; -#endif - union sigval si_value; - pid_t si_pid; - uid_t si_uid; - int si_signo; - int si_code; -#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__) - int si_errno; -#endif - int si_status; -} siginfo_t; -#define _SIGINFO_T_DECLARED -#define __siginfo_t_defined -#endif - /* Siginfo codes are defined below */ #if !defined(_SIGHANDLER_T_DECLARED) && !defined(__sighandler_t_defined) From 0dfa07013c5a9c7950191259e5d8d56e3b3c80cc Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Mon, 13 Oct 2025 09:18:51 -0400 Subject: [PATCH 11/13] posix: signal.h: include sigev_notify_function field in struct sigevent Previously, the `sigev_notify_function` field was missing from `struct sigevent`. Additionally, `sigev_notify_attributes` were incorrectly named `sigev_thread_attr`. Add it back to ensure that we are able to support realtime signals. Signed-off-by: Chris Friedt --- include/zephyr/posix/posix_signal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/zephyr/posix/posix_signal.h b/include/zephyr/posix/posix_signal.h index d0e89079f79c8..b1c7e717e2018 100644 --- a/include/zephyr/posix/posix_signal.h +++ b/include/zephyr/posix/posix_signal.h @@ -111,7 +111,8 @@ union sigval { #if !defined(_SIGEVENT_DECLARED) && !defined(__sigevent_defined) struct sigevent { #if defined(_POSIX_THREADS) || defined(__DOXYGEN__) - pthread_attr_t *sigev_thread_attr; + pthread_attr_t *sigev_notify_attributes; + void (*sigev_notify_function)(union sigval value); #endif union sigval sigev_value; int sigev_notify; From 7b65697f667387a9a97c4319091ae4807ee7eeb9 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Sun, 5 Oct 2025 14:23:44 -0400 Subject: [PATCH 12/13] posix: remove zephyr/posix in header prefixes If C libraries provide conformant POSIX headers, then use the headers provided by the C library. Otherwise, C library maintainers may add `include/zephyr/posix` to their standard search path. Signed-off-by: Chris Friedt --- drivers/modem/ublox-sara-r4.c | 2 +- drivers/net/nsos_fcntl.c | 4 ---- drivers/net/nsos_sockets.c | 2 +- drivers/net/ppp.c | 2 +- drivers/wifi/simplelink/simplelink_sockets.c | 2 +- include/zephyr/net/socket.h | 10 +++++----- include/zephyr/posix/arpa/inet.h | 4 ++-- include/zephyr/posix/dirent.h | 2 +- include/zephyr/posix/grp.h | 2 +- include/zephyr/posix/mqueue.h | 6 +++--- include/zephyr/posix/pthread.h | 4 ++-- include/zephyr/posix/pwd.h | 2 +- include/zephyr/posix/unistd.h | 2 +- lib/libc/common/source/thrd/cnd.c | 2 +- lib/libc/common/source/thrd/mtx.c | 2 +- lib/libc/common/source/thrd/once.c | 2 +- lib/libc/common/source/thrd/thrd.c | 4 ++-- lib/libc/common/source/thrd/tss.c | 2 +- lib/libc/newlib/libc-hooks.c | 2 +- lib/libc/picolibc/picolibc-hooks.h | 2 +- lib/os/zvfs/zvfs_eventfd.c | 2 +- lib/posix/c_lib_ext/fnmatch.c | 2 +- lib/posix/c_lib_ext/getentropy.c | 2 +- lib/posix/c_lib_ext/getopt/getopt.c | 2 +- lib/posix/eventfd/eventfd.c | 2 +- lib/posix/options/CMakeLists.txt | 4 ---- lib/posix/options/aio.c | 2 +- lib/posix/options/barrier.c | 2 +- lib/posix/options/clock.c | 4 ++-- lib/posix/options/cond.c | 2 +- lib/posix/options/confstr.c | 2 +- lib/posix/options/device_io.c | 8 ++++---- lib/posix/options/fd_mgmt.c | 6 +++--- lib/posix/options/file_system_r.c | 2 +- lib/posix/options/fs.c | 8 ++++---- lib/posix/options/fsync.c | 2 +- lib/posix/options/grp.c | 2 +- lib/posix/options/key.c | 2 +- lib/posix/options/mlock.c | 2 +- lib/posix/options/mlockall.c | 2 +- lib/posix/options/mmap.c | 4 ++-- lib/posix/options/mprotect.c | 2 +- lib/posix/options/mqueue.c | 4 ++-- lib/posix/options/multi_process.c | 4 ++-- lib/posix/options/mutex.c | 2 +- lib/posix/options/net.c | 8 ++++---- lib/posix/options/posix_clock.h | 2 +- lib/posix/options/posix_internal.h | 2 +- lib/posix/options/pthread.c | 4 ++-- lib/posix/options/pthread_sched.h | 2 +- lib/posix/options/pwd.c | 2 +- lib/posix/options/rwlock.c | 2 +- lib/posix/options/sched.c | 2 +- lib/posix/options/semaphore.c | 6 +++--- lib/posix/options/shm.c | 6 +++--- lib/posix/options/signal.c | 2 +- lib/posix/options/sleep.c | 2 +- lib/posix/options/spinlock.c | 2 +- lib/posix/options/stropts.c | 2 +- lib/posix/options/sysconf.c | 5 +++-- lib/posix/options/syslog.c | 2 +- lib/posix/options/timer.c | 2 +- lib/posix/options/uname.c | 2 +- lib/posix/shell/uname.c | 2 +- modules/openthread/platform/dhcp6_pd.c | 2 +- modules/openthread/platform/udp.c | 4 ++-- modules/thrift/src/thrift/server/TFDServer.cpp | 6 +++--- .../thrift/src/thrift/transport/TSSLServerSocket.cpp | 4 ++-- modules/thrift/src/thrift/transport/TSSLSocket.cpp | 2 +- modules/thrift/src/thrift/transport/TSSLSocket.h | 2 +- modules/thrift/src/thrift/transport/TServerSocket.h | 4 ++-- samples/drivers/ipm/ipm_esp32/src/procpu_shell.c | 2 +- samples/net/capture/src/main.c | 2 +- samples/net/common/vlan.c | 2 +- samples/net/mdns_responder/src/service.c | 2 +- samples/net/sockets/echo_async/src/socket_echo.c | 2 +- .../sockets/echo_async_select/src/socket_echo_select.c | 4 ++-- samples/net/sockets/echo_client/src/echo-client.c | 2 +- samples/net/sockets/echo_service/src/main.c | 8 ++++---- samples/shields/npm6001_ek/src/main.c | 2 +- samples/subsys/shell/shell_module/src/main.c | 2 +- subsys/crc/crc_shell.c | 2 +- subsys/fs/virtiofs/virtiofs_zfs.c | 2 +- subsys/net/l2/wifi/wifi_shell.c | 2 +- subsys/net/lib/http/http_server_core.c | 4 ++-- subsys/net/lib/lwm2m/lwm2m_engine.c | 2 +- subsys/net/lib/ptp/clock.c | 2 +- subsys/net/lib/sockets/socketpair.c | 2 +- subsys/net/lib/sockets/sockets_can.c | 2 +- subsys/net/lib/sockets/sockets_inet.c | 2 +- subsys/net/lib/sockets/sockets_net_mgmt.c | 2 +- subsys/net/lib/sockets/sockets_packet.c | 2 +- subsys/net/lib/sockets/sockets_tls.c | 2 +- subsys/net/lib/websocket/websocket.c | 4 ++-- subsys/shell/modules/devmem_service.c | 2 +- subsys/shell/shell_wildcard.c | 2 +- tests/net/ipv4_fragment/src/main.c | 2 +- tests/net/lib/http_server/core/src/main.c | 2 +- tests/net/socket/af_packet/src/main.c | 2 +- tests/net/socket/offload_dispatcher/src/main.c | 2 +- tests/net/socket/socket_helpers.h | 6 +++--- tests/net/socket/socketpair/src/_main.h | 2 +- tests/net/socket/tcp/src/main.c | 2 +- tests/net/socket/tls/src/main.c | 2 +- tests/net/socket/tls_configurations/src/main.c | 2 +- tests/net/socket/tls_ext/src/main.c | 2 +- tests/posix/c_lib_ext/src/fnmatch.c | 2 +- tests/posix/c_lib_ext/src/getentropy.c | 2 +- tests/posix/c_lib_ext/src/getopt.c | 2 +- tests/posix/eventfd/src/_main.h | 6 +++--- tests/posix/eventfd/src/ioctl.c | 4 ++-- tests/posix/fs/src/test_fs_dir.c | 4 ++-- tests/posix/fs/src/test_fs_file.c | 2 +- tests/posix/fs/src/test_fs_open_flags.c | 2 +- tests/posix/fs/src/test_fs_stat.c | 6 +++--- tests/posix/headers/src/aio_h.c | 2 +- tests/posix/headers/src/arpa_inet_h.c | 4 ---- tests/posix/headers/src/dirent_h.c | 4 ---- tests/posix/headers/src/mqueue_h.c | 4 ---- tests/posix/headers/src/net_if_h.c | 4 ---- tests/posix/headers/src/netdb_h.c | 4 ---- tests/posix/headers/src/netinet_in_h.c | 4 ---- tests/posix/headers/src/netinet_tcp_h.c | 4 ---- tests/posix/headers/src/poll_h.c | 4 ---- tests/posix/headers/src/pthread_h.c | 4 ---- tests/posix/headers/src/sched_h.c | 4 ---- tests/posix/headers/src/semaphore_h.c | 4 ---- tests/posix/headers/src/stropts_h.c | 5 +---- tests/posix/headers/src/sys_eventfd_h.c | 4 ---- tests/posix/headers/src/sys_ioctl_h.c | 4 ---- tests/posix/headers/src/sys_select_h.c | 4 ---- tests/posix/headers/src/sys_socket_h.c | 4 ---- tests/posix/headers/src/sys_time_h.c | 4 ---- tests/posix/headers/src/unistd_h.c | 4 ---- tests/posix/net/src/if.c | 2 +- tests/posix/net/src/inet_addr.c | 4 ++-- tests/posix/net/src/inet_ntoa.c | 4 ++-- tests/posix/single_process/src/confstr.c | 2 +- tests/posix/single_process/src/sysconf.c | 2 +- tests/posix/single_process/src/uname.c | 4 ++-- tests/posix/xsi_realtime/src/shm.c | 2 +- tests/posix/xsi_realtime/src/sync_io.c | 2 +- tests/posix/xsi_system_logging/src/main.c | 4 ++-- 143 files changed, 178 insertions(+), 256 deletions(-) diff --git a/drivers/modem/ublox-sara-r4.c b/drivers/modem/ublox-sara-r4.c index d0bf44b0eb662..b8dc9b76be504 100644 --- a/drivers/modem/ublox-sara-r4.c +++ b/drivers/modem/ublox-sara-r4.c @@ -15,7 +15,7 @@ LOG_MODULE_REGISTER(modem_ublox_sara_r4, CONFIG_MODEM_LOG_LEVEL); #include #include #include -#include +#include #include #include diff --git a/drivers/net/nsos_fcntl.c b/drivers/net/nsos_fcntl.c index ad6a61285c921..6a0fa55555e1d 100644 --- a/drivers/net/nsos_fcntl.c +++ b/drivers/net/nsos_fcntl.c @@ -19,11 +19,7 @@ /* * When building for Zephyr, use Zephyr specific fcntl definitions. */ -#ifdef __ZEPHYR__ -#include -#else #include -#endif #include "nsi_errno.h" #include "nsos_fcntl.h" diff --git a/drivers/net/nsos_sockets.c b/drivers/net/nsos_sockets.c index 9f50512cda5d1..b5b90d1659424 100644 --- a/drivers/net/nsos_sockets.c +++ b/drivers/net/nsos_sockets.c @@ -24,7 +24,7 @@ LOG_MODULE_REGISTER(nsos_sockets); #include #include #include -#include +#include #include #include diff --git a/drivers/net/ppp.c b/drivers/net/ppp.c index e6682a76b43fb..8d5d9d933a57e 100644 --- a/drivers/net/ppp.c +++ b/drivers/net/ppp.c @@ -31,7 +31,7 @@ LOG_MODULE_REGISTER(net_ppp, LOG_LEVEL); #include #include #include -#include +#include #include #include diff --git a/drivers/wifi/simplelink/simplelink_sockets.c b/drivers/wifi/simplelink/simplelink_sockets.c index 29819ad456486..ab7bcba7032d4 100644 --- a/drivers/wifi/simplelink/simplelink_sockets.c +++ b/drivers/wifi/simplelink/simplelink_sockets.c @@ -9,7 +9,7 @@ LOG_MODULE_DECLARE(LOG_MODULE_NAME); #include #include -#include +#include #include /* Define sockaddr, etc, before simplelink.h */ diff --git a/include/zephyr/net/socket.h b/include/zephyr/net/socket.h index 2eab2d964628f..72ddcb768a8d2 100644 --- a/include/zephyr/net/socket.h +++ b/include/zephyr/net/socket.h @@ -1280,19 +1280,19 @@ struct socket_op_vtable { */ #if defined(CONFIG_POSIX_API) #if !defined(ZEPHYR_INCLUDE_POSIX_ARPA_INET_H_) -#include +#include #endif #if !defined(ZEPHYR_INCLUDE_POSIX_NETDB_H_) -#include +#include #endif #if !defined(ZEPHYR_INCLUDE_POSIX_UNISTD_H_) -#include +#include #endif #if !defined(ZEPHYR_INCLUDE_POSIX_POLL_H_) -#include +#include #endif #if !defined(ZEPHYR_INCLUDE_POSIX_SYS_SOCKET_H_) -#include +#include #endif #endif /* CONFIG_POSIX_API */ diff --git a/include/zephyr/posix/arpa/inet.h b/include/zephyr/posix/arpa/inet.h index 39b6cf6232e68..3b8cd49d28fa1 100644 --- a/include/zephyr/posix/arpa/inet.h +++ b/include/zephyr/posix/arpa/inet.h @@ -8,8 +8,8 @@ #include -#include -#include +#include +#include #include diff --git a/include/zephyr/posix/dirent.h b/include/zephyr/posix/dirent.h index b4327ac45f936..b11705d279231 100644 --- a/include/zephyr/posix/dirent.h +++ b/include/zephyr/posix/dirent.h @@ -8,7 +8,7 @@ #ifndef ZEPHYR_INCLUDE_POSIX_DIRENT_H_ #define ZEPHYR_INCLUDE_POSIX_DIRENT_H_ -#include +#include #include #ifdef __cplusplus diff --git a/include/zephyr/posix/grp.h b/include/zephyr/posix/grp.h index 3f5616c34e1bf..464fdaf1853a5 100644 --- a/include/zephyr/posix/grp.h +++ b/include/zephyr/posix/grp.h @@ -10,7 +10,7 @@ extern "C" { #endif -#include +#include /** * @brief Group structure diff --git a/include/zephyr/posix/mqueue.h b/include/zephyr/posix/mqueue.h index 28c42d7e30649..cd7e1b754a4c0 100644 --- a/include/zephyr/posix/mqueue.h +++ b/include/zephyr/posix/mqueue.h @@ -11,9 +11,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/include/zephyr/posix/pthread.h b/include/zephyr/posix/pthread.h index 8b9b03e490c54..adf1cfd4b77f0 100644 --- a/include/zephyr/posix/pthread.h +++ b/include/zephyr/posix/pthread.h @@ -12,8 +12,8 @@ #include #include -#include -#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/include/zephyr/posix/pwd.h b/include/zephyr/posix/pwd.h index 3557b20ab9797..48af8afddc24e 100644 --- a/include/zephyr/posix/pwd.h +++ b/include/zephyr/posix/pwd.h @@ -10,7 +10,7 @@ extern "C" { #endif -#include +#include struct passwd { /* user's login name */ diff --git a/include/zephyr/posix/unistd.h b/include/zephyr/posix/unistd.h index d9498ce9a3e4b..936e55fa53a08 100644 --- a/include/zephyr/posix/unistd.h +++ b/include/zephyr/posix/unistd.h @@ -14,7 +14,7 @@ #include #endif #include -#include +#include #include #include "posix_features.h" diff --git a/lib/libc/common/source/thrd/cnd.c b/lib/libc/common/source/thrd/cnd.c index aea6f5cb78a42..457a9ae0ee8c3 100644 --- a/lib/libc/common/source/thrd/cnd.c +++ b/lib/libc/common/source/thrd/cnd.c @@ -7,7 +7,7 @@ #include #include -#include +#include int cnd_broadcast(cnd_t *cond) { diff --git a/lib/libc/common/source/thrd/mtx.c b/lib/libc/common/source/thrd/mtx.c index 9746ea64fe690..17b41a99709b8 100644 --- a/lib/libc/common/source/thrd/mtx.c +++ b/lib/libc/common/source/thrd/mtx.c @@ -8,7 +8,7 @@ #include #include -#include +#include int mtx_init(mtx_t *mutex, int type) { diff --git a/lib/libc/common/source/thrd/once.c b/lib/libc/common/source/thrd/once.c index 7cfd9983df895..2125e25bf0771 100644 --- a/lib/libc/common/source/thrd/once.c +++ b/lib/libc/common/source/thrd/once.c @@ -8,7 +8,7 @@ #include #include -#include +#include void call_once(once_flag *flag, void (*func)(void)) { diff --git a/lib/libc/common/source/thrd/thrd.c b/lib/libc/common/source/thrd/thrd.c index ad2cb72b602fb..0946e2cb2b95a 100644 --- a/lib/libc/common/source/thrd/thrd.c +++ b/lib/libc/common/source/thrd/thrd.c @@ -8,8 +8,8 @@ #include #include -#include -#include +#include +#include #include struct thrd_trampoline_arg { diff --git a/lib/libc/common/source/thrd/tss.c b/lib/libc/common/source/thrd/tss.c index 4b110d17170d6..dca1a3a757741 100644 --- a/lib/libc/common/source/thrd/tss.c +++ b/lib/libc/common/source/thrd/tss.c @@ -8,7 +8,7 @@ #include #include -#include +#include int tss_create(tss_t *key, tss_dtor_t destructor) { diff --git a/lib/libc/newlib/libc-hooks.c b/lib/libc/newlib/libc-hooks.c index 4ec1887f1cb54..98b434e91a82b 100644 --- a/lib/libc/newlib/libc-hooks.c +++ b/lib/libc/newlib/libc-hooks.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/libc/picolibc/picolibc-hooks.h b/lib/libc/picolibc/picolibc-hooks.h index 1800e5ee404e3..0105c94512beb 100644 --- a/lib/libc/picolibc/picolibc-hooks.h +++ b/lib/libc/picolibc/picolibc-hooks.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/lib/os/zvfs/zvfs_eventfd.c b/lib/os/zvfs/zvfs_eventfd.c index c4c329826db78..bdd93b10a9a8d 100644 --- a/lib/os/zvfs/zvfs_eventfd.c +++ b/lib/os/zvfs/zvfs_eventfd.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/posix/c_lib_ext/fnmatch.c b/lib/posix/c_lib_ext/fnmatch.c index 911b6f41afa70..878fe3dd8661e 100644 --- a/lib/posix/c_lib_ext/fnmatch.c +++ b/lib/posix/c_lib_ext/fnmatch.c @@ -43,7 +43,7 @@ #include #include -#include +#include #include #define EOS '\0' diff --git a/lib/posix/c_lib_ext/getentropy.c b/lib/posix/c_lib_ext/getentropy.c index 974ea4dce507f..20578107d5e4c 100644 --- a/lib/posix/c_lib_ext/getentropy.c +++ b/lib/posix/c_lib_ext/getentropy.c @@ -8,7 +8,7 @@ #include #include -#include +#include #define ENTROPY_NODE DEVICE_DT_GET_OR_NULL(DT_CHOSEN(zephyr_entropy)) diff --git a/lib/posix/c_lib_ext/getopt/getopt.c b/lib/posix/c_lib_ext/getopt/getopt.c index a81e0ca279a2d..f14bd820b20a1 100644 --- a/lib/posix/c_lib_ext/getopt/getopt.c +++ b/lib/posix/c_lib_ext/getopt/getopt.c @@ -33,7 +33,7 @@ #ifdef CONFIG_NATIVE_LIBC #include #else -#include +#include #endif #include "getopt.h" #include "getopt_common.h" diff --git a/lib/posix/eventfd/eventfd.c b/lib/posix/eventfd/eventfd.c index b272bfa636fc2..c021b5dadb667 100644 --- a/lib/posix/eventfd/eventfd.c +++ b/lib/posix/eventfd/eventfd.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include #include int eventfd(unsigned int initval, int flags) diff --git a/lib/posix/options/CMakeLists.txt b/lib/posix/options/CMakeLists.txt index c901853041aee..d2469a3a0eae8 100644 --- a/lib/posix/options/CMakeLists.txt +++ b/lib/posix/options/CMakeLists.txt @@ -9,10 +9,6 @@ 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_SYSTEM_INTERFACES) - zephyr_include_directories(${ZEPHYR_BASE}/include/zephyr/posix) -endif() - if (NOT CONFIG_TC_PROVIDES_POSIX_SIGNALS) if(CONFIG_POSIX_SIGNALS) set(STRSIGNAL_TABLE_H ${GEN_DIR}/posix/strsignal_table.h) diff --git a/lib/posix/options/aio.c b/lib/posix/options/aio.c index 538333345dd9f..8e51d44207aa5 100644 --- a/lib/posix/options/aio.c +++ b/lib/posix/options/aio.c @@ -7,7 +7,7 @@ #include #include -#include +#include int aio_cancel(int fildes, struct aiocb *aiocbp) { diff --git a/lib/posix/options/barrier.c b/lib/posix/options/barrier.c index c108b28da2171..8cab1b2f9675b 100644 --- a/lib/posix/options/barrier.c +++ b/lib/posix/options/barrier.c @@ -9,7 +9,7 @@ #include #include -#include +#include #include struct posix_barrier { diff --git a/lib/posix/options/clock.c b/lib/posix/options/clock.c index faa85cae775fc..bcd2cef9328c3 100644 --- a/lib/posix/options/clock.c +++ b/lib/posix/options/clock.c @@ -9,8 +9,8 @@ #include #include -#include -#include +#include +#include #include int clock_gettime(clockid_t clock_id, struct timespec *ts) diff --git a/lib/posix/options/cond.c b/lib/posix/options/cond.c index 84ad6ff571c40..158f33b7ceff0 100644 --- a/lib/posix/options/cond.c +++ b/lib/posix/options/cond.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include LOG_MODULE_REGISTER(pthread_cond, CONFIG_PTHREAD_COND_LOG_LEVEL); diff --git a/lib/posix/options/confstr.c b/lib/posix/options/confstr.c index f319fe5540ebc..c6d2b8f3a8318 100644 --- a/lib/posix/options/confstr.c +++ b/lib/posix/options/confstr.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include size_t confstr(int name, char *buf, size_t len) { diff --git a/lib/posix/options/device_io.c b/lib/posix/options/device_io.c index 6fea22d01545d..adf13506651e1 100644 --- a/lib/posix/options/device_io.c +++ b/lib/posix/options/device_io.c @@ -8,10 +8,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include /* prototypes for external, not-yet-public, functions in fdtable.c or fs.c */ int zvfs_close(int fd); diff --git a/lib/posix/options/fd_mgmt.c b/lib/posix/options/fd_mgmt.c index c1f60aca8e490..7127fa23386f5 100644 --- a/lib/posix/options/fd_mgmt.c +++ b/lib/posix/options/fd_mgmt.c @@ -8,9 +8,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include /* prototypes for external, not-yet-public, functions in fdtable.c or fs.c */ diff --git a/lib/posix/options/file_system_r.c b/lib/posix/options/file_system_r.c index 6cd14f9f81ad6..78f10de6e646d 100644 --- a/lib/posix/options/file_system_r.c +++ b/lib/posix/options/file_system_r.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) diff --git a/lib/posix/options/fs.c b/lib/posix/options/fs.c index 23d4cf669f6b8..04a7d688b60d9 100644 --- a/lib/posix/options/fs.c +++ b/lib/posix/options/fs.c @@ -12,12 +12,12 @@ #include #include #include -#include -#include +#include +#include #include #include -#include -#include +#include +#include #include int zvfs_fstat(int fd, struct stat *buf); diff --git a/lib/posix/options/fsync.c b/lib/posix/options/fsync.c index e41a1dc5bfacf..1152caf0931d4 100644 --- a/lib/posix/options/fsync.c +++ b/lib/posix/options/fsync.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include /* prototypes for external, not-yet-public, functions in fdtable.c */ int zvfs_fsync(int fd); diff --git a/lib/posix/options/grp.c b/lib/posix/options/grp.c index af395c88fa00c..1333a1c8ed35a 100644 --- a/lib/posix/options/grp.c +++ b/lib/posix/options/grp.c @@ -7,7 +7,7 @@ #include #include -#include +#include int getgrnam_r(const char *name, struct group *grp, char *buffer, size_t bufsize, struct group **result) diff --git a/lib/posix/options/key.c b/lib/posix/options/key.c index db70394914287..0b481a1f5982f 100644 --- a/lib/posix/options/key.c +++ b/lib/posix/options/key.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/posix/options/mlock.c b/lib/posix/options/mlock.c index 00fee6a296562..a5b5ece82bb0d 100644 --- a/lib/posix/options/mlock.c +++ b/lib/posix/options/mlock.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include diff --git a/lib/posix/options/mlockall.c b/lib/posix/options/mlockall.c index 506eeb621022f..da0225e8b9825 100644 --- a/lib/posix/options/mlockall.c +++ b/lib/posix/options/mlockall.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include int mlockall(int flags) diff --git a/lib/posix/options/mmap.c b/lib/posix/options/mmap.c index c26268edafc91..afea68f8113cf 100644 --- a/lib/posix/options/mmap.c +++ b/lib/posix/options/mmap.c @@ -12,8 +12,8 @@ #include #include #include -#include -#include +#include +#include #define _page_size COND_CODE_1(CONFIG_MMU, (CONFIG_MMU_PAGE_SIZE), (CONFIG_POSIX_PAGE_SIZE)) diff --git a/lib/posix/options/mprotect.c b/lib/posix/options/mprotect.c index 6c795e3b96339..9bc250b967cf2 100644 --- a/lib/posix/options/mprotect.c +++ b/lib/posix/options/mprotect.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include int mprotect(void *addr, size_t len, int prot) diff --git a/lib/posix/options/mqueue.c b/lib/posix/options/mqueue.c index 0eef3f81ccf35..489de9ee3b273 100644 --- a/lib/posix/options/mqueue.c +++ b/lib/posix/options/mqueue.c @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include #define SIGEV_MASK (SIGEV_NONE | SIGEV_SIGNAL | SIGEV_THREAD) diff --git a/lib/posix/options/multi_process.c b/lib/posix/options/multi_process.c index 42ed26dcaec69..a88d260304267 100644 --- a/lib/posix/options/multi_process.c +++ b/lib/posix/options/multi_process.c @@ -5,11 +5,11 @@ */ #include +#include #include +#include #include -#include -#include #include #include #include diff --git a/lib/posix/options/mutex.c b/lib/posix/options/mutex.c index 219c6dbaf8946..b1473ce04a8ed 100644 --- a/lib/posix/options/mutex.c +++ b/lib/posix/options/mutex.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include diff --git a/lib/posix/options/net.c b/lib/posix/options/net.c index 5a045a9b10c7e..9f403aa2d19dc 100644 --- a/lib/posix/options/net.c +++ b/lib/posix/options/net.c @@ -12,10 +12,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include /* From arpa/inet.h */ diff --git a/lib/posix/options/posix_clock.h b/lib/posix/options/posix_clock.h index b955d81f914b3..3ef01c9097e80 100644 --- a/lib/posix/options/posix_clock.h +++ b/lib/posix/options/posix_clock.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include diff --git a/lib/posix/options/posix_internal.h b/lib/posix/options/posix_internal.h index d149b51e63a62..aea7c0524db31 100644 --- a/lib/posix/options/posix_internal.h +++ b/lib/posix/options/posix_internal.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include diff --git a/lib/posix/options/pthread.c b/lib/posix/options/pthread.c index b7a727557c694..c488212d119d8 100644 --- a/lib/posix/options/pthread.c +++ b/lib/posix/options/pthread.c @@ -15,8 +15,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/lib/posix/options/pthread_sched.h b/lib/posix/options/pthread_sched.h index f51d05a985f09..a5f70694996b5 100644 --- a/lib/posix/options/pthread_sched.h +++ b/lib/posix/options/pthread_sched.h @@ -10,7 +10,7 @@ #include #include -#include +#include static inline bool valid_posix_policy(int policy) { diff --git a/lib/posix/options/pwd.c b/lib/posix/options/pwd.c index 5cafbb0a3a94a..1d656f9dec9d0 100644 --- a/lib/posix/options/pwd.c +++ b/lib/posix/options/pwd.c @@ -7,7 +7,7 @@ #include #include -#include +#include int getpwnam_r(const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result) diff --git a/lib/posix/options/rwlock.c b/lib/posix/options/rwlock.c index b7eb21bd6be2e..4067ef6d83ed0 100644 --- a/lib/posix/options/rwlock.c +++ b/lib/posix/options/rwlock.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/lib/posix/options/sched.c b/lib/posix/options/sched.c index a37b01d0106b2..270332e77bef4 100644 --- a/lib/posix/options/sched.c +++ b/lib/posix/options/sched.c @@ -7,7 +7,7 @@ #include "pthread_sched.h" #include -#include +#include /** * @brief Get minimum priority value for a given policy diff --git a/lib/posix/options/semaphore.c b/lib/posix/options/semaphore.c index 55ac57c5cfd3f..263af27598200 100644 --- a/lib/posix/options/semaphore.c +++ b/lib/posix/options/semaphore.c @@ -10,9 +10,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include struct nsem_obj { sys_snode_t snode; diff --git a/lib/posix/options/shm.c b/lib/posix/options/shm.c index 120d7625e7cc5..9ef76bf01664a 100644 --- a/lib/posix/options/shm.c +++ b/lib/posix/options/shm.c @@ -13,9 +13,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/lib/posix/options/signal.c b/lib/posix/options/signal.c index f1024d234450b..a759d492042a6 100644 --- a/lib/posix/options/signal.c +++ b/lib/posix/options/signal.c @@ -10,7 +10,7 @@ #include #include -#include +#include #define SIGNO_WORD_IDX(_signo) (_signo / BITS_PER_LONG) #define SIGNO_WORD_BIT(_signo) (_signo & BIT_MASK(LOG2(BITS_PER_LONG))) diff --git a/lib/posix/options/sleep.c b/lib/posix/options/sleep.c index dd739322c75ee..d45cb3e6a82e2 100644 --- a/lib/posix/options/sleep.c +++ b/lib/posix/options/sleep.c @@ -7,7 +7,7 @@ #include #include -#include +#include /** * @brief Sleep for a specified number of seconds. diff --git a/lib/posix/options/spinlock.c b/lib/posix/options/spinlock.c index 302b15591e355..c249eb3bd8f1b 100644 --- a/lib/posix/options/spinlock.c +++ b/lib/posix/options/spinlock.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include union _spinlock_storage { diff --git a/lib/posix/options/stropts.c b/lib/posix/options/stropts.c index 61d5e6abf5d68..08fa5bc67e199 100644 --- a/lib/posix/options/stropts.c +++ b/lib/posix/options/stropts.c @@ -8,7 +8,7 @@ #include #include -#include +#include int putmsg(int fildes, const struct strbuf *ctlptr, const struct strbuf *dataptr, int flags) { diff --git a/lib/posix/options/sysconf.c b/lib/posix/options/sysconf.c index 881d83ceebf6a..7581c2423fbdf 100644 --- a/lib/posix/options/sysconf.c +++ b/lib/posix/options/sysconf.c @@ -6,9 +6,10 @@ #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200809L -#include +#include +#include + #include -#include #ifdef CONFIG_POSIX_SYSCONF_IMPL_FULL diff --git a/lib/posix/options/syslog.c b/lib/posix/options/syslog.c index 488e8429954e8..9f7f7c1e47252 100644 --- a/lib/posix/options/syslog.c +++ b/lib/posix/options/syslog.c @@ -8,7 +8,7 @@ #include #include #undef LOG_ERR -#include +#include #include static struct k_spinlock syslog_lock; diff --git a/lib/posix/options/timer.c b/lib/posix/options/timer.c index 90ccce5dda04f..04977bfae7d1b 100644 --- a/lib/posix/options/timer.c +++ b/lib/posix/options/timer.c @@ -16,7 +16,7 @@ #include #include -#include +#include #define ACTIVE 1 #define NOT_ACTIVE 0 diff --git a/lib/posix/options/uname.c b/lib/posix/options/uname.c index decba8dd01435..b57d9281c1594 100644 --- a/lib/posix/options/uname.c +++ b/lib/posix/options/uname.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #ifdef CONFIG_NET_HOSTNAME_ENABLE diff --git a/lib/posix/shell/uname.c b/lib/posix/shell/uname.c index 54e12de9a5930..305e32bc5ef5a 100644 --- a/lib/posix/shell/uname.c +++ b/lib/posix/shell/uname.c @@ -8,7 +8,7 @@ #include "posix_shell.h" -#include +#include #include #define UNAME_KERNEL BIT(0) diff --git a/modules/openthread/platform/dhcp6_pd.c b/modules/openthread/platform/dhcp6_pd.c index 5b0cf93c8139d..b22c4d4da0617 100644 --- a/modules/openthread/platform/dhcp6_pd.c +++ b/modules/openthread/platform/dhcp6_pd.c @@ -9,7 +9,7 @@ #include "openthread_border_router.h" #include #include -#include +#include #include #include #include diff --git a/modules/openthread/platform/udp.c b/modules/openthread/platform/udp.c index e3ba036f94136..fbccf0a69f505 100644 --- a/modules/openthread/platform/udp.c +++ b/modules/openthread/platform/udp.c @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include #include static struct zsock_pollfd sockfd_udp[CONFIG_OPENTHREAD_ZEPHYR_BORDER_ROUTER_MAX_UDP_SERVICES]; diff --git a/modules/thrift/src/thrift/server/TFDServer.cpp b/modules/thrift/src/thrift/server/TFDServer.cpp index f87bcb5684e06..e59643a69f165 100644 --- a/modules/thrift/src/thrift/server/TFDServer.cpp +++ b/modules/thrift/src/thrift/server/TFDServer.cpp @@ -8,9 +8,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include diff --git a/modules/thrift/src/thrift/transport/TSSLServerSocket.cpp b/modules/thrift/src/thrift/transport/TSSLServerSocket.cpp index f4390e521546a..41e78cac95644 100644 --- a/modules/thrift/src/thrift/transport/TSSLServerSocket.cpp +++ b/modules/thrift/src/thrift/transport/TSSLServerSocket.cpp @@ -6,8 +6,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/modules/thrift/src/thrift/transport/TSSLSocket.cpp b/modules/thrift/src/thrift/transport/TSSLSocket.cpp index f23c6b4f96dc3..3c085593fdd02 100644 --- a/modules/thrift/src/thrift/transport/TSSLSocket.cpp +++ b/modules/thrift/src/thrift/transport/TSSLSocket.cpp @@ -11,7 +11,7 @@ #include #include #ifdef HAVE_ARPA_INET_H -#include +#include #endif #include #ifdef HAVE_POLL_H diff --git a/modules/thrift/src/thrift/transport/TSSLSocket.h b/modules/thrift/src/thrift/transport/TSSLSocket.h index db6fa359183cd..650aed5222df6 100644 --- a/modules/thrift/src/thrift/transport/TSSLSocket.h +++ b/modules/thrift/src/thrift/transport/TSSLSocket.h @@ -13,7 +13,7 @@ #include #include -#include +#include namespace apache { diff --git a/modules/thrift/src/thrift/transport/TServerSocket.h b/modules/thrift/src/thrift/transport/TServerSocket.h index f213bd7bcfa76..2478095c69938 100644 --- a/modules/thrift/src/thrift/transport/TServerSocket.h +++ b/modules/thrift/src/thrift/transport/TServerSocket.h @@ -15,10 +15,10 @@ #include #ifdef HAVE_SYS_SOCKET_H -#include +#include #endif #ifdef HAVE_NETDB_H -#include +#include #endif namespace apache diff --git a/samples/drivers/ipm/ipm_esp32/src/procpu_shell.c b/samples/drivers/ipm/ipm_esp32/src/procpu_shell.c index e036b6608e62b..d043146887fed 100644 --- a/samples/drivers/ipm/ipm_esp32/src/procpu_shell.c +++ b/samples/drivers/ipm/ipm_esp32/src/procpu_shell.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include diff --git a/samples/net/capture/src/main.c b/samples/net/capture/src/main.c index eb9fe6a62b107..74ed2387b4546 100644 --- a/samples/net/capture/src/main.c +++ b/samples/net/capture/src/main.c @@ -12,7 +12,7 @@ LOG_MODULE_REGISTER(net_capture_sample, LOG_LEVEL_DBG); #define ARPHRD_CAN 280 #define ARPHRD_PPP 512 #else -#include +#include #endif #include #include diff --git a/samples/net/common/vlan.c b/samples/net/common/vlan.c index 0c04ff15b2e96..6f03ff9c26bac 100644 --- a/samples/net/common/vlan.c +++ b/samples/net/common/vlan.c @@ -10,7 +10,7 @@ LOG_MODULE_DECLARE(net_samples_common, LOG_LEVEL_DBG); #include #include -#include +#include #include /* User data for the interface callback */ diff --git a/samples/net/mdns_responder/src/service.c b/samples/net/mdns_responder/src/service.c index 31f65c0492fc3..5694131767833 100644 --- a/samples/net/mdns_responder/src/service.c +++ b/samples/net/mdns_responder/src/service.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/samples/net/sockets/echo_async/src/socket_echo.c b/samples/net/sockets/echo_async/src/socket_echo.c index 60067baf91cdf..4d1917e0a247a 100644 --- a/samples/net/sockets/echo_async/src/socket_echo.c +++ b/samples/net/sockets/echo_async/src/socket_echo.c @@ -22,7 +22,7 @@ #else -#include +#include #include #include diff --git a/samples/net/sockets/echo_async_select/src/socket_echo_select.c b/samples/net/sockets/echo_async_select/src/socket_echo_select.c index 6ff8a6d52552b..641e63756b6d9 100644 --- a/samples/net/sockets/echo_async_select/src/socket_echo_select.c +++ b/samples/net/sockets/echo_async_select/src/socket_echo_select.c @@ -24,8 +24,8 @@ #else -#include -#include +#include +#include #include #include diff --git a/samples/net/sockets/echo_client/src/echo-client.c b/samples/net/sockets/echo_client/src/echo-client.c index 9c451b9c3ccf5..be7fe0ece1157 100644 --- a/samples/net/sockets/echo_client/src/echo-client.c +++ b/samples/net/sockets/echo_client/src/echo-client.c @@ -24,7 +24,7 @@ LOG_MODULE_REGISTER(net_echo_client_sample, LOG_LEVEL_DBG); #include #include -#include +#include #include #include diff --git a/samples/net/sockets/echo_service/src/main.c b/samples/net/sockets/echo_service/src/main.c index 5f2b12c7298b2..da45bb34cc34e 100644 --- a/samples/net/sockets/echo_service/src/main.c +++ b/samples/net/sockets/echo_service/src/main.c @@ -12,10 +12,10 @@ LOG_MODULE_REGISTER(net_echo_server_svc_sample, LOG_LEVEL_DBG); #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #define MY_PORT 4242 diff --git a/samples/shields/npm6001_ek/src/main.c b/samples/shields/npm6001_ek/src/main.c index ec3e24e3354fd..76eee49bb6141 100644 --- a/samples/shields/npm6001_ek/src/main.c +++ b/samples/shields/npm6001_ek/src/main.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include diff --git a/samples/subsys/shell/shell_module/src/main.c b/samples/subsys/shell/shell_module/src/main.c index 7c633eb7c7f7d..97435dd78d331 100644 --- a/samples/subsys/shell/shell_module/src/main.c +++ b/samples/subsys/shell/shell_module/src/main.c @@ -15,7 +15,7 @@ #ifdef CONFIG_ARCH_POSIX #include #else -#include +#include #endif LOG_MODULE_REGISTER(app); diff --git a/subsys/crc/crc_shell.c b/subsys/crc/crc_shell.c index 189ec764806e6..b15aa48ff0d25 100644 --- a/subsys/crc/crc_shell.c +++ b/subsys/crc/crc_shell.c @@ -11,7 +11,7 @@ #ifdef CONFIG_ARCH_POSIX #include #else -#include +#include #endif #include diff --git a/subsys/fs/virtiofs/virtiofs_zfs.c b/subsys/fs/virtiofs/virtiofs_zfs.c index 4a0f50fcb1ec4..ba0cccdf33aca 100644 --- a/subsys/fs/virtiofs/virtiofs_zfs.c +++ b/subsys/fs/virtiofs/virtiofs_zfs.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include "../fs_impl.h" #include #include "virtiofs.h" diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 5aaabebf697a5..4386efdcfea2d 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -25,7 +25,7 @@ LOG_MODULE_REGISTER(net_wifi_shell, LOG_LEVEL_INF); #include #include #include -#include +#include #include #include "net_shell_private.h" diff --git a/subsys/net/lib/http/http_server_core.c b/subsys/net/lib/http/http_server_core.c index 8010dd9f88e72..9ab1cea9c86de 100644 --- a/subsys/net/lib/http/http_server_core.c +++ b/subsys/net/lib/http/http_server_core.c @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include #include LOG_MODULE_REGISTER(net_http_server, CONFIG_NET_HTTP_SERVER_LOG_LEVEL); diff --git a/subsys/net/lib/lwm2m/lwm2m_engine.c b/subsys/net/lib/lwm2m/lwm2m_engine.c index b4dc1d7f5361f..09fd53baf7e5d 100644 --- a/subsys/net/lib/lwm2m/lwm2m_engine.c +++ b/subsys/net/lib/lwm2m/lwm2m_engine.c @@ -32,7 +32,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include #include #include -#include +#include #include #if defined(CONFIG_LWM2M_DTLS_SUPPORT) diff --git a/subsys/net/lib/ptp/clock.c b/subsys/net/lib/ptp/clock.c index 2d2d2fb27a61f..dd52c9bb47548 100644 --- a/subsys/net/lib/ptp/clock.c +++ b/subsys/net/lib/ptp/clock.c @@ -11,7 +11,7 @@ LOG_MODULE_REGISTER(ptp_clock, CONFIG_PTP_LOG_LEVEL); #include #include -#include +#include #include #include diff --git a/subsys/net/lib/sockets/socketpair.c b/subsys/net/lib/sockets/socketpair.c index d7fbe6e162306..b0de6e72385a8 100644 --- a/subsys/net/lib/sockets/socketpair.c +++ b/subsys/net/lib/sockets/socketpair.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/subsys/net/lib/sockets/sockets_can.c b/subsys/net/lib/sockets/sockets_can.c index 70659c0284108..5eeae6f5cf75c 100644 --- a/subsys/net/lib/sockets/sockets_can.c +++ b/subsys/net/lib/sockets/sockets_can.c @@ -6,7 +6,7 @@ */ #include -#include +#include #include LOG_MODULE_REGISTER(net_sock_can, CONFIG_NET_SOCKETS_LOG_LEVEL); diff --git a/subsys/net/lib/sockets/sockets_inet.c b/subsys/net/lib/sockets/sockets_inet.c index 93254fa0024a6..540c9f3482f23 100644 --- a/subsys/net/lib/sockets/sockets_inet.c +++ b/subsys/net/lib/sockets/sockets_inet.c @@ -19,7 +19,7 @@ LOG_MODULE_DECLARE(net_sock, CONFIG_NET_SOCKETS_LOG_LEVEL); #include #include #include -#include +#include #include #include #include diff --git a/subsys/net/lib/sockets/sockets_net_mgmt.c b/subsys/net/lib/sockets/sockets_net_mgmt.c index dcb4194ec85df..69d99b55c3e59 100644 --- a/subsys/net/lib/sockets/sockets_net_mgmt.c +++ b/subsys/net/lib/sockets/sockets_net_mgmt.c @@ -5,7 +5,7 @@ */ #include -#include +#include #include LOG_MODULE_REGISTER(net_sock_mgmt, CONFIG_NET_SOCKETS_LOG_LEVEL); diff --git a/subsys/net/lib/sockets/sockets_packet.c b/subsys/net/lib/sockets/sockets_packet.c index 5ea90a00272e8..68ea38d638b83 100644 --- a/subsys/net/lib/sockets/sockets_packet.c +++ b/subsys/net/lib/sockets/sockets_packet.c @@ -6,7 +6,7 @@ */ #include -#include +#include #include LOG_MODULE_REGISTER(net_sock_packet, CONFIG_NET_SOCKETS_LOG_LEVEL); diff --git a/subsys/net/lib/sockets/sockets_tls.c b/subsys/net/lib/sockets/sockets_tls.c index 6f4919dc99e72..71b0b418a3ccd 100644 --- a/subsys/net/lib/sockets/sockets_tls.c +++ b/subsys/net/lib/sockets/sockets_tls.c @@ -6,7 +6,7 @@ */ #include -#include +#include #include LOG_MODULE_REGISTER(net_sock_tls, CONFIG_NET_SOCKETS_LOG_LEVEL); diff --git a/subsys/net/lib/websocket/websocket.c b/subsys/net/lib/websocket/websocket.c index bf395190744a2..ac198c3b09dd5 100644 --- a/subsys/net/lib/websocket/websocket.c +++ b/subsys/net/lib/websocket/websocket.c @@ -23,8 +23,8 @@ LOG_MODULE_REGISTER(net_websocket, CONFIG_NET_WEBSOCKET_LOG_LEVEL); #include #include #if defined(CONFIG_POSIX_API) -#include -#include +#include +#include #else #include #endif diff --git a/subsys/shell/modules/devmem_service.c b/subsys/shell/modules/devmem_service.c index 559a946d6d677..787363ccab790 100644 --- a/subsys/shell/modules/devmem_service.c +++ b/subsys/shell/modules/devmem_service.c @@ -13,7 +13,7 @@ #ifdef CONFIG_NATIVE_LIBC #include #else -#include +#include #endif #include #include diff --git a/subsys/shell/shell_wildcard.c b/subsys/shell/shell_wildcard.c index cfa23d00f782b..f8a4779466193 100644 --- a/subsys/shell/shell_wildcard.c +++ b/subsys/shell/shell_wildcard.c @@ -5,7 +5,7 @@ */ #include -#include +#include #include "shell_wildcard.h" #include "shell_utils.h" #include "shell_ops.h" diff --git a/tests/net/ipv4_fragment/src/main.c b/tests/net/ipv4_fragment/src/main.c index c61ff40addc63..8abeb9c4bc830 100644 --- a/tests/net/ipv4_fragment/src/main.c +++ b/tests/net/ipv4_fragment/src/main.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(net_ipv4_test, CONFIG_NET_IPV4_LOG_LEVEL); #include #include #include -#include +#include #include #include #include diff --git a/tests/net/lib/http_server/core/src/main.c b/tests/net/lib/http_server/core/src/main.c index 5e0f08ddee76e..6514f9d85accd 100644 --- a/tests/net/lib/http_server/core/src/main.c +++ b/tests/net/lib/http_server/core/src/main.c @@ -12,7 +12,7 @@ #include #include -#include +#include #include #define BUFFER_SIZE 1024 diff --git a/tests/net/socket/af_packet/src/main.c b/tests/net/socket/af_packet/src/main.c index 71777ddb7107d..022caf9b63c9b 100644 --- a/tests/net/socket/af_packet/src/main.c +++ b/tests/net/socket/af_packet/src/main.c @@ -12,7 +12,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL); #include #include -#include +#include #include #include #include diff --git a/tests/net/socket/offload_dispatcher/src/main.c b/tests/net/socket/offload_dispatcher/src/main.c index 47fc4d7b2205e..e7d8d14dbab74 100644 --- a/tests/net/socket/offload_dispatcher/src/main.c +++ b/tests/net/socket/offload_dispatcher/src/main.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include #include #include #include diff --git a/tests/net/socket/socket_helpers.h b/tests/net/socket/socket_helpers.h index 7ac4e0f8edd32..59f3909f7d461 100644 --- a/tests/net/socket/socket_helpers.h +++ b/tests/net/socket/socket_helpers.h @@ -7,9 +7,9 @@ #include #if defined(CONFIG_POSIX_API) -#include -#include -#include +#include +#include +#include #else #include #endif diff --git a/tests/net/socket/socketpair/src/_main.h b/tests/net/socket/socketpair/src/_main.h index d1dbe939b1589..9004c230c95d2 100644 --- a/tests/net/socket/socketpair/src/_main.h +++ b/tests/net/socket/socketpair/src/_main.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include diff --git a/tests/net/socket/tcp/src/main.c b/tests/net/socket/tcp/src/main.c index 76a4d62925385..678ee774a2c67 100644 --- a/tests/net/socket/tcp/src/main.c +++ b/tests/net/socket/tcp/src/main.c @@ -8,7 +8,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL); #include -#include +#include #include #include #include diff --git a/tests/net/socket/tls/src/main.c b/tests/net/socket/tls/src/main.c index 44254e2f2975f..5b04507e86193 100644 --- a/tests/net/socket/tls/src/main.c +++ b/tests/net/socket/tls/src/main.c @@ -8,7 +8,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL); #include -#include +#include #include #include #include diff --git a/tests/net/socket/tls_configurations/src/main.c b/tests/net/socket/tls_configurations/src/main.c index 35598ee5759af..7d89ba928246b 100644 --- a/tests/net/socket/tls_configurations/src/main.c +++ b/tests/net/socket/tls_configurations/src/main.c @@ -10,7 +10,7 @@ LOG_MODULE_REGISTER(tls_configuration_sample, LOG_LEVEL_INF); #include #include -#include +#include #include #include diff --git a/tests/net/socket/tls_ext/src/main.c b/tests/net/socket/tls_ext/src/main.c index ffc4c5630fd0e..36d6f211a87a7 100644 --- a/tests/net/socket/tls_ext/src/main.c +++ b/tests/net/socket/tls_ext/src/main.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include diff --git a/tests/posix/c_lib_ext/src/fnmatch.c b/tests/posix/c_lib_ext/src/fnmatch.c index 42c84d7ca1a0f..e3dd298ca8eaf 100644 --- a/tests/posix/c_lib_ext/src/fnmatch.c +++ b/tests/posix/c_lib_ext/src/fnmatch.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include #include /* diff --git a/tests/posix/c_lib_ext/src/getentropy.c b/tests/posix/c_lib_ext/src/getentropy.c index f04e54becb031..7ce502b298892 100644 --- a/tests/posix/c_lib_ext/src/getentropy.c +++ b/tests/posix/c_lib_ext/src/getentropy.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include #include ZTEST(posix_c_lib_ext, test_getentropy_too_large) diff --git a/tests/posix/c_lib_ext/src/getopt.c b/tests/posix/c_lib_ext/src/getopt.c index 4fa9a670f0606..2385db917086c 100644 --- a/tests/posix/c_lib_ext/src/getopt.c +++ b/tests/posix/c_lib_ext/src/getopt.c @@ -13,7 +13,7 @@ #include #include -#include +#include #include ZTEST(posix_c_lib_ext, test_getopt_basic) diff --git a/tests/posix/eventfd/src/_main.h b/tests/posix/eventfd/src/_main.h index 2f11b468db26f..fd277935eeff7 100644 --- a/tests/posix/eventfd/src/_main.h +++ b/tests/posix/eventfd/src/_main.h @@ -11,9 +11,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #define TESTVAL 10 diff --git a/tests/posix/eventfd/src/ioctl.c b/tests/posix/eventfd/src/ioctl.c index 8e200d0b07e90..d035b5d6cecfa 100644 --- a/tests/posix/eventfd/src/ioctl.c +++ b/tests/posix/eventfd/src/ioctl.c @@ -6,8 +6,8 @@ #include "_main.h" -#include -#include +#include +#include #define EFD_IN_USE_INTERNAL 0x1 diff --git a/tests/posix/fs/src/test_fs_dir.c b/tests/posix/fs/src/test_fs_dir.c index 9b97413a4bc6f..23b844ce2a789 100644 --- a/tests/posix/fs/src/test_fs_dir.c +++ b/tests/posix/fs/src/test_fs_dir.c @@ -6,8 +6,8 @@ #include #include -#include -#include +#include +#include #include "test_fs.h" extern int test_file_write(void); diff --git a/tests/posix/fs/src/test_fs_file.c b/tests/posix/fs/src/test_fs_file.c index 23496c92b8c22..1845aaa0dfa2c 100644 --- a/tests/posix/fs/src/test_fs_file.c +++ b/tests/posix/fs/src/test_fs_file.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include "test_fs.h" const char test_str[] = "hello world!"; diff --git a/tests/posix/fs/src/test_fs_open_flags.c b/tests/posix/fs/src/test_fs_open_flags.c index 7c35145343b75..a655affcbda09 100644 --- a/tests/posix/fs/src/test_fs_open_flags.c +++ b/tests/posix/fs/src/test_fs_open_flags.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include "test_fs.h" #define THE_FILE FATFS_MNTP"/the_file.txt" diff --git a/tests/posix/fs/src/test_fs_stat.c b/tests/posix/fs/src/test_fs_stat.c index 2850368de4af4..9d85c31355e01 100644 --- a/tests/posix/fs/src/test_fs_stat.c +++ b/tests/posix/fs/src/test_fs_stat.c @@ -8,9 +8,9 @@ #define _POSIX_C_SOURCE 200809L #include -#include -#include -#include +#include +#include +#include #include "test_fs.h" #define FILL_SIZE 128 diff --git a/tests/posix/headers/src/aio_h.c b/tests/posix/headers/src/aio_h.c index 5888b83925d81..3b5fdfa10783f 100644 --- a/tests/posix/headers/src/aio_h.c +++ b/tests/posix/headers/src/aio_h.c @@ -9,7 +9,7 @@ #ifdef CONFIG_POSIX_API #include #else -#include +#include #endif ZTEST(posix_headers, test_aio_h) diff --git a/tests/posix/headers/src/arpa_inet_h.c b/tests/posix/headers/src/arpa_inet_h.c index 1b3b90dc0de1b..2426e46bdabef 100644 --- a/tests/posix/headers/src/arpa_inet_h.c +++ b/tests/posix/headers/src/arpa_inet_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/dirent_h.c b/tests/posix/headers/src/dirent_h.c index 3502d19e99b0b..a53d6967a811d 100644 --- a/tests/posix/headers/src/dirent_h.c +++ b/tests/posix/headers/src/dirent_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/mqueue_h.c b/tests/posix/headers/src/mqueue_h.c index 68fa4b2c9c082..5cef75ee2a803 100644 --- a/tests/posix/headers/src/mqueue_h.c +++ b/tests/posix/headers/src/mqueue_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/net_if_h.c b/tests/posix/headers/src/net_if_h.c index 3843d2b83d620..3ebba2333d7c0 100644 --- a/tests/posix/headers/src/net_if_h.c +++ b/tests/posix/headers/src/net_if_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/netdb_h.c b/tests/posix/headers/src/netdb_h.c index 9426c56b5a389..1c5eb6ffea7b0 100644 --- a/tests/posix/headers/src/netdb_h.c +++ b/tests/posix/headers/src/netdb_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/netinet_in_h.c b/tests/posix/headers/src/netinet_in_h.c index bd89cab22c2ea..ae89b9b399d8c 100644 --- a/tests/posix/headers/src/netinet_in_h.c +++ b/tests/posix/headers/src/netinet_in_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/netinet_tcp_h.c b/tests/posix/headers/src/netinet_tcp_h.c index e476b4cbcd8d3..57deaf5eccdee 100644 --- a/tests/posix/headers/src/netinet_tcp_h.c +++ b/tests/posix/headers/src/netinet_tcp_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/poll_h.c b/tests/posix/headers/src/poll_h.c index 260a054722b9d..28ddfc1acd85a 100644 --- a/tests/posix/headers/src/poll_h.c +++ b/tests/posix/headers/src/poll_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/pthread_h.c b/tests/posix/headers/src/pthread_h.c index 7cf79dc79702c..1cdad9cfbe655 100644 --- a/tests/posix/headers/src/pthread_h.c +++ b/tests/posix/headers/src/pthread_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/sched_h.c b/tests/posix/headers/src/sched_h.c index b04a56277754d..3680e1473af9c 100644 --- a/tests/posix/headers/src/sched_h.c +++ b/tests/posix/headers/src/sched_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/semaphore_h.c b/tests/posix/headers/src/semaphore_h.c index b4c2e151fa1d6..951162742e191 100644 --- a/tests/posix/headers/src/semaphore_h.c +++ b/tests/posix/headers/src/semaphore_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/stropts_h.c b/tests/posix/headers/src/stropts_h.c index fe928e04c2ce1..c80053bd501ad 100644 --- a/tests/posix/headers/src/stropts_h.c +++ b/tests/posix/headers/src/stropts_h.c @@ -4,11 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ #include "_common.h" -#ifdef CONFIG_POSIX_API + #include -#else -#include -#endif /** * @brief Test existence and basic functionality of stropts.h diff --git a/tests/posix/headers/src/sys_eventfd_h.c b/tests/posix/headers/src/sys_eventfd_h.c index 6f666393f2cc5..c9933ecca7e3c 100644 --- a/tests/posix/headers/src/sys_eventfd_h.c +++ b/tests/posix/headers/src/sys_eventfd_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/sys_ioctl_h.c b/tests/posix/headers/src/sys_ioctl_h.c index 286cd78353d81..526e62d7548bb 100644 --- a/tests/posix/headers/src/sys_ioctl_h.c +++ b/tests/posix/headers/src/sys_ioctl_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/sys_select_h.c b/tests/posix/headers/src/sys_select_h.c index ad1014c5b446d..be651deae6ae9 100644 --- a/tests/posix/headers/src/sys_select_h.c +++ b/tests/posix/headers/src/sys_select_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/sys_socket_h.c b/tests/posix/headers/src/sys_socket_h.c index 60f25514dae5c..e90d38b7d7935 100644 --- a/tests/posix/headers/src/sys_socket_h.c +++ b/tests/posix/headers/src/sys_socket_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/sys_time_h.c b/tests/posix/headers/src/sys_time_h.c index 4de47eaf78590..aa87eadf5896c 100644 --- a/tests/posix/headers/src/sys_time_h.c +++ b/tests/posix/headers/src/sys_time_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/headers/src/unistd_h.c b/tests/posix/headers/src/unistd_h.c index 33a17dc72f307..7e24e59d72978 100644 --- a/tests/posix/headers/src/unistd_h.c +++ b/tests/posix/headers/src/unistd_h.c @@ -6,11 +6,7 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif /** * @brief existence test for `` diff --git a/tests/posix/net/src/if.c b/tests/posix/net/src/if.c index 218fff82f517f..b51e62a5490b1 100644 --- a/tests/posix/net/src/if.c +++ b/tests/posix/net/src/if.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/tests/posix/net/src/inet_addr.c b/tests/posix/net/src/inet_addr.c index 4cf66a1e066ba..c12bc786e900c 100644 --- a/tests/posix/net/src/inet_addr.c +++ b/tests/posix/net/src/inet_addr.c @@ -6,8 +6,8 @@ #include -#include -#include +#include +#include #include #include diff --git a/tests/posix/net/src/inet_ntoa.c b/tests/posix/net/src/inet_ntoa.c index 963fe371d2f31..c214f7ff7d259 100644 --- a/tests/posix/net/src/inet_ntoa.c +++ b/tests/posix/net/src/inet_ntoa.c @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include -#include +#include +#include #include diff --git a/tests/posix/single_process/src/confstr.c b/tests/posix/single_process/src/confstr.c index 1dd9ad1434f3d..0754a49bc3e01 100644 --- a/tests/posix/single_process/src/confstr.c +++ b/tests/posix/single_process/src/confstr.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include ZTEST(posix_single_process, test_confstr) diff --git a/tests/posix/single_process/src/sysconf.c b/tests/posix/single_process/src/sysconf.c index e92bba686b908..4a8aface15085 100644 --- a/tests/posix/single_process/src/sysconf.c +++ b/tests/posix/single_process/src/sysconf.c @@ -7,7 +7,7 @@ #include -#include +#include ZTEST(posix_single_process, test_posix_sysconf) { diff --git a/tests/posix/single_process/src/uname.c b/tests/posix/single_process/src/uname.c index fcc52e02be518..35171981d9392 100644 --- a/tests/posix/single_process/src/uname.c +++ b/tests/posix/single_process/src/uname.c @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include -#include +#include +#include #include ZTEST(posix_single_process, test_uname) diff --git a/tests/posix/xsi_realtime/src/shm.c b/tests/posix/xsi_realtime/src/shm.c index 6755798ef5a33..72d7e9bc810e5 100644 --- a/tests/posix/xsi_realtime/src/shm.c +++ b/tests/posix/xsi_realtime/src/shm.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include diff --git a/tests/posix/xsi_realtime/src/sync_io.c b/tests/posix/xsi_realtime/src/sync_io.c index 09593dbb7500a..b801d3f3ff15b 100644 --- a/tests/posix/xsi_realtime/src/sync_io.c +++ b/tests/posix/xsi_realtime/src/sync_io.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include static const char test_str[] = "Hello World!"; diff --git a/tests/posix/xsi_system_logging/src/main.c b/tests/posix/xsi_system_logging/src/main.c index b3d023fb83fb3..e85213d163cf7 100644 --- a/tests/posix/xsi_system_logging/src/main.c +++ b/tests/posix/xsi_system_logging/src/main.c @@ -4,9 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include +#include #undef LOG_ERR -#include +#include #include #define N_PRIOS 8 From b45f81d4a2d9f94ca6b14ce837290c87dded94f2 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Sun, 5 Oct 2025 19:20:22 -0400 Subject: [PATCH 13/13] posix: remove zephyr posix headers from include path WIP Signed-off-by: Chris Friedt --- include/zephyr/posix/aio.h | 41 ++- include/zephyr/posix/dirent.h | 18 +- include/zephyr/posix/fnmatch.h | 64 ++-- include/zephyr/posix/mqueue.h | 5 - include/zephyr/posix/posix_features.h | 107 ------- include/zephyr/posix/posix_limits.h | 3 + include/zephyr/posix/posix_signal.h | 22 +- include/zephyr/posix/posix_stdlib.h | 34 ++ include/zephyr/posix/posix_string.h | 27 ++ include/zephyr/posix/posix_time.h | 2 - include/zephyr/posix/posix_types.h | 158 ---------- include/zephyr/posix/pthread.h | 8 +- include/zephyr/posix/sched.h | 6 +- include/zephyr/posix/semaphore.h | 9 +- include/zephyr/posix/sys/_pthreadtypes.h | 128 ++++++++ include/zephyr/posix/sys/dirent.h | 35 --- include/zephyr/posix/sys/select.h | 53 +++- include/zephyr/posix/sys/stat.h | 363 ++++++++++------------ include/zephyr/posix/sys/sysconf.h | 18 +- include/zephyr/posix/sys/types.h | 159 ++++++++++ include/zephyr/posix/unistd.h | 5 +- lib/libc/common/source/time/gmtime_r.c | 3 +- lib/libc/minimal/CMakeLists.txt | 2 + lib/libc/minimal/include/stdlib.h | 10 +- lib/libc/minimal/include/string.h | 2 + lib/libc/minimal/include/sys/_types.h | 1 + lib/libc/minimal/include/time.h | 5 + lib/libc/newlib/CMakeLists.txt | 8 + lib/libc/newlib/include/aio.h | 12 + lib/libc/newlib/include/arpa/inet.h | 12 + lib/libc/newlib/include/dirent.h | 12 + lib/libc/newlib/include/fnmatch.h | 17 + lib/libc/newlib/include/mqueue.h | 12 + lib/libc/newlib/include/net/if.h | 12 + lib/libc/newlib/include/net/if_arp.h | 12 + lib/libc/newlib/include/netdb.h | 12 + lib/libc/newlib/include/netinet/in.h | 12 + lib/libc/newlib/include/netinet/tcp.h | 12 + lib/libc/newlib/include/poll.h | 12 + lib/libc/newlib/include/pthread.h | 44 +++ lib/libc/newlib/include/semaphore.h | 12 + lib/libc/newlib/include/stropts.h | 12 + lib/libc/newlib/include/sys/_types.h | 14 + lib/libc/newlib/include/sys/eventfd.h | 12 + lib/libc/newlib/include/sys/ioctl.h | 12 + lib/libc/newlib/include/sys/mman.h | 12 + lib/libc/newlib/include/sys/socket.h | 12 + lib/libc/newlib/include/sys/stat.h | 23 ++ lib/libc/newlib/include/sys/utsname.h | 12 + lib/libc/newlib/include/syslog.h | 12 + lib/libc/newlib/include/time.h | 15 + lib/libc/newlib/include/unistd.h | 29 ++ lib/libc/picolibc/CMakeLists.txt | 4 + lib/libc/picolibc/include/aio.h | 12 + lib/libc/picolibc/include/arpa/inet.h | 12 + lib/libc/picolibc/include/dirent.h | 12 + lib/libc/picolibc/include/fnmatch.h | 17 + lib/libc/picolibc/include/limits.h | 16 + lib/libc/picolibc/include/mqueue.h | 12 + lib/libc/picolibc/include/net/if.h | 12 + lib/libc/picolibc/include/net/if_arp.h | 12 + lib/libc/picolibc/include/netdb.h | 12 + lib/libc/picolibc/include/netinet/in.h | 12 + lib/libc/picolibc/include/netinet/tcp.h | 12 + lib/libc/picolibc/include/poll.h | 12 + lib/libc/picolibc/include/pthread.h | 52 ++++ lib/libc/picolibc/include/semaphore.h | 12 + lib/libc/picolibc/include/stropts.h | 12 + lib/libc/picolibc/include/sys/eventfd.h | 12 + lib/libc/picolibc/include/sys/ioctl.h | 12 + lib/libc/picolibc/include/sys/mman.h | 12 + lib/libc/picolibc/include/sys/socket.h | 12 + lib/libc/picolibc/include/sys/stat.h | 23 ++ lib/libc/picolibc/include/sys/utsname.h | 12 + lib/libc/picolibc/include/syslog.h | 12 + lib/libc/picolibc/include/time.h | 3 + lib/libc/picolibc/include/unistd.h | 29 ++ lib/posix/Kconfig.profile | 3 +- lib/posix/Kconfig.toolchain | 3 + lib/posix/c_lib_ext/fnmatch.c | 12 + lib/posix/options/CMakeLists.txt | 67 +++- lib/posix/options/Kconfig | 9 +- lib/posix/options/Kconfig.device_io | 1 - lib/posix/options/Kconfig.net | 2 +- lib/posix/options/Kconfig.proc1 | 3 +- lib/posix/options/Kconfig.xsi | 24 ++ lib/posix/options/aio.c | 4 +- lib/posix/options/barrier.c | 23 +- lib/posix/options/cond.c | 5 + lib/posix/options/confstr.c | 6 + lib/posix/options/device_io.c | 19 +- lib/posix/options/fs.c | 8 + lib/posix/options/mmap.c | 4 +- lib/posix/options/mqueue.c | 11 +- lib/posix/options/multi_process.c | 1 + lib/posix/options/mutex.c | 15 +- lib/posix/options/posix_internal.h | 5 + lib/posix/options/pthread.c | 65 ++-- lib/posix/options/pthread_sched.h | 3 +- lib/posix/options/shm.c | 11 +- lib/posix/options/signal.c | 3 +- lib/posix/options/spinlock.c | 3 +- lib/posix/options/sysconf.c | 270 ++++++++-------- lib/posix/options/syslog.c | 3 +- samples/net/sockets/echo_server/prj.conf | 2 +- samples/net/sockets/echo_server/src/tcp.c | 2 + samples/net/sockets/echo_server/src/udp.c | 15 +- samples/posix/philosophers/src/main.c | 13 +- subsys/fs/virtiofs/virtiofs_zfs.c | 1 + subsys/net/lib/http/http_server_core.c | 3 +- subsys/net/lib/sockets/sockets.c | 21 ++ tests/benchmarks/posix/threads/src/main.c | 1 + tests/lib/c_lib/common/src/main.c | 10 +- tests/posix/barriers/src/main.c | 4 +- tests/posix/c_lib_ext/src/getentropy.c | 5 +- tests/posix/common/prj.conf | 1 + tests/posix/common/src/mutex.c | 14 +- tests/posix/common/src/pthread.c | 33 +- tests/posix/common/src/pthread_attr.c | 5 +- tests/posix/fs/src/test_fs_dir.c | 1 + tests/posix/fs/src/test_fs_file.c | 1 + tests/posix/fs/src/test_fs_stat.c | 1 + tests/posix/headers/src/aio_h.c | 26 +- tests/posix/headers/src/pthread_h.c | 2 +- tests/posix/headers/src/sched_h.c | 22 +- tests/posix/headers/src/unistd_h.c | 4 + tests/posix/signals/src/main.c | 1 + tests/posix/single_process/src/confstr.c | 2 +- tests/posix/xsi_realtime/src/shm.c | 5 +- 129 files changed, 1928 insertions(+), 864 deletions(-) create mode 100644 include/zephyr/posix/posix_stdlib.h create mode 100644 include/zephyr/posix/posix_string.h delete mode 100644 include/zephyr/posix/posix_types.h create mode 100644 include/zephyr/posix/sys/_pthreadtypes.h delete mode 100644 include/zephyr/posix/sys/dirent.h create mode 100644 include/zephyr/posix/sys/types.h create mode 100644 lib/libc/newlib/include/aio.h create mode 100644 lib/libc/newlib/include/arpa/inet.h create mode 100644 lib/libc/newlib/include/dirent.h create mode 100644 lib/libc/newlib/include/fnmatch.h create mode 100644 lib/libc/newlib/include/mqueue.h create mode 100644 lib/libc/newlib/include/net/if.h create mode 100644 lib/libc/newlib/include/net/if_arp.h create mode 100644 lib/libc/newlib/include/netdb.h create mode 100644 lib/libc/newlib/include/netinet/in.h create mode 100644 lib/libc/newlib/include/netinet/tcp.h create mode 100644 lib/libc/newlib/include/poll.h create mode 100644 lib/libc/newlib/include/pthread.h create mode 100644 lib/libc/newlib/include/semaphore.h create mode 100644 lib/libc/newlib/include/stropts.h create mode 100644 lib/libc/newlib/include/sys/_types.h create mode 100644 lib/libc/newlib/include/sys/eventfd.h create mode 100644 lib/libc/newlib/include/sys/ioctl.h create mode 100644 lib/libc/newlib/include/sys/mman.h create mode 100644 lib/libc/newlib/include/sys/socket.h create mode 100644 lib/libc/newlib/include/sys/stat.h create mode 100644 lib/libc/newlib/include/sys/utsname.h create mode 100644 lib/libc/newlib/include/syslog.h create mode 100644 lib/libc/newlib/include/time.h create mode 100644 lib/libc/newlib/include/unistd.h create mode 100644 lib/libc/picolibc/include/aio.h create mode 100644 lib/libc/picolibc/include/arpa/inet.h create mode 100644 lib/libc/picolibc/include/dirent.h create mode 100644 lib/libc/picolibc/include/fnmatch.h create mode 100644 lib/libc/picolibc/include/limits.h create mode 100644 lib/libc/picolibc/include/mqueue.h create mode 100644 lib/libc/picolibc/include/net/if.h create mode 100644 lib/libc/picolibc/include/net/if_arp.h create mode 100644 lib/libc/picolibc/include/netdb.h create mode 100644 lib/libc/picolibc/include/netinet/in.h create mode 100644 lib/libc/picolibc/include/netinet/tcp.h create mode 100644 lib/libc/picolibc/include/poll.h create mode 100644 lib/libc/picolibc/include/pthread.h create mode 100644 lib/libc/picolibc/include/semaphore.h create mode 100644 lib/libc/picolibc/include/stropts.h create mode 100644 lib/libc/picolibc/include/sys/eventfd.h create mode 100644 lib/libc/picolibc/include/sys/ioctl.h create mode 100644 lib/libc/picolibc/include/sys/mman.h create mode 100644 lib/libc/picolibc/include/sys/socket.h create mode 100644 lib/libc/picolibc/include/sys/stat.h create mode 100644 lib/libc/picolibc/include/sys/utsname.h create mode 100644 lib/libc/picolibc/include/syslog.h create mode 100644 lib/libc/picolibc/include/unistd.h create mode 100644 lib/posix/options/Kconfig.xsi diff --git a/include/zephyr/posix/aio.h b/include/zephyr/posix/aio.h index 55ec9d873c978..1faa7fc036c52 100644 --- a/include/zephyr/posix/aio.h +++ b/include/zephyr/posix/aio.h @@ -7,9 +7,10 @@ #ifndef ZEPHYR_INCLUDE_ZEPHYR_POSIX_AIO_H_ #define ZEPHYR_INCLUDE_ZEPHYR_POSIX_AIO_H_ +/* size_t must be defined by the libc stddef.h */ +#include +#include #include -#include -#include #include @@ -17,13 +18,49 @@ extern "C" { #endif +#if !defined(_OFF_T_DECLARED) && !defined(__off_t_defined) +typedef long off_t; +#define _OFF_T_DECLARED +#define __off_t_defined +#endif + +#ifndef __SIZE_TYPE__ +#define __SIZE_TYPE__ unsigned long +#endif + +#if !defined(_SSIZE_T_DECLARED) && !defined(__ssize_t_defined) +#define unsigned signed /* parasoft-suppress MISRAC2012-RULE_20_4-a MISRAC2012-RULE_20_4-b */ +typedef __SIZE_TYPE__ ssize_t; +#undef unsigned +#define _SSIZE_T_DECLARED +#define __ssize_t_defined +#endif + +/* time_t must be defined by the libc time.h */ +#include + +#if __STDC_VERSION__ >= 201112L +/* struct timespec must be defined in the libc time.h */ +#else +#if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined) +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +#define _TIMESPEC_DECLARED +#define __timespec_defined +#endif +#endif + struct aiocb { int aio_fildes; off_t aio_offset; volatile void *aio_buf; size_t aio_nbytes; int aio_reqprio; +#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) struct sigevent aio_sigevent; +#endif /* defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) */ int aio_lio_opcode; }; diff --git a/include/zephyr/posix/dirent.h b/include/zephyr/posix/dirent.h index b11705d279231..7db41373b9c1d 100644 --- a/include/zephyr/posix/dirent.h +++ b/include/zephyr/posix/dirent.h @@ -8,13 +8,29 @@ #ifndef ZEPHYR_INCLUDE_POSIX_DIRENT_H_ #define ZEPHYR_INCLUDE_POSIX_DIRENT_H_ -#include +#include + #include #ifdef __cplusplus extern "C" { #endif +#if !defined(NAME_MAX) && defined(_XOPEN_SOURCE) +#define NAME_MAX _XOPEN_NAME_MAX +#endif + +#if !defined(NAME_MAX) && defined(_POSIX_C_SOURCE) +#define NAME_MAX _POSIX_NAME_MAX +#endif + +typedef void DIR; + +struct dirent { + unsigned int d_ino; + char d_name[NAME_MAX + 1]; +}; + #if (_POSIX_C_SOURCE >= 200809L) || (_XOPEN_SOURCE >= 700) int alphasort(const struct dirent **d1, const struct dirent **d2); #endif diff --git a/include/zephyr/posix/fnmatch.h b/include/zephyr/posix/fnmatch.h index 41e77aa70c149..6bf846f5e3d62 100644 --- a/include/zephyr/posix/fnmatch.h +++ b/include/zephyr/posix/fnmatch.h @@ -1,59 +1,31 @@ -/* SPDX-License-Identifier: BSD-3-Clause */ - -/* $NetBSD: fnmatch.h,v 1.12.50.1 2011/02/08 16:18:55 bouyer Exp $ */ - -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. +/* + * Copyright The Zephyr Project Contributors * - * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 + * SPDX-License-Identifier: Apache-2.0 */ -#ifndef _FNMATCH_H_ -#define _FNMATCH_H_ - -#define FNM_NOMATCH 1 /* Match failed. */ -#define FNM_NOSYS 2 /* Function not implemented. */ -#define FNM_NORES 3 /* Out of resources */ - -#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ -#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ -#define FNM_PERIOD 0x04 /* Period must be matched by period. */ -#define FNM_CASEFOLD 0x08 /* Pattern is matched case-insensitive */ -#define FNM_LEADING_DIR 0x10 /* Ignore / after Imatch. */ +#ifndef ZEPHYR_INCLUDE_POSIX_FNMATCH_H_ +#define ZEPHYR_INCLUDE_POSIX_FNMATCH_H_ #ifdef __cplusplus extern "C" { #endif -int fnmatch(const char *, const char *, int); +#define FNM_NOMATCH 1 +#define FNM_NOESCAPE 0x01 +#define FNM_PATHNAME 0x02 +#define FNM_PERIOD 0x04 +#if defined(__GNU_SOURCE) +#define FNM_LEADING_DIR 0x08 +#endif +#define FNM_CASEFOLD 0x10 +#define FNM_EXTMATCH 0x20 +#define FNM_IGNORECASE FNM_CASEFOLD + +int fnmatch(const char *pattern, const char *string, int flags); #ifdef __cplusplus } #endif -#endif /* !_FNMATCH_H_ */ +#endif /* ZEPHYR_INCLUDE_POSIX_FNMATCH_H_ */ diff --git a/include/zephyr/posix/mqueue.h b/include/zephyr/posix/mqueue.h index cd7e1b754a4c0..879a939a98aa1 100644 --- a/include/zephyr/posix/mqueue.h +++ b/include/zephyr/posix/mqueue.h @@ -10,11 +10,6 @@ #include #include -#include -#include -#include -#include - #ifdef __cplusplus extern "C" { #endif diff --git a/include/zephyr/posix/posix_features.h b/include/zephyr/posix/posix_features.h index b253dbd8fc5a7..299d7536cee67 100644 --- a/include/zephyr/posix/posix_features.h +++ b/include/zephyr/posix/posix_features.h @@ -36,130 +36,30 @@ * POSIX System Interfaces */ -#define _POSIX_VERSION 200809L - #define _POSIX_CHOWN_RESTRICTED (0) #define _POSIX_NO_TRUNC (0) #define _POSIX_VDISABLE ('\0') /* #define _POSIX_ADVISORY_INFO (-1L) */ -#ifdef CONFIG_POSIX_ASYNCHRONOUS_IO -#define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_BARRIERS -#define _POSIX_BARRIERS _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_FSYNC -#define _POSIX_FSYNC _POSIX_VERSION -#endif - -#ifdef CONFIG_NET_IPV6 -#define _POSIX_IPV6 _POSIX_VERSION -#endif - /* #define _POSIX_JOB_CONTROL (-1L) */ -#ifdef CONFIG_POSIX_MAPPED_FILES -#define _POSIX_MAPPED_FILES _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_MEMLOCK -#define _POSIX_MEMLOCK _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_MEMLOCK_RANGE -#define _POSIX_MEMLOCK_RANGE _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_MEMORY_PROTECTION -#define _POSIX_MEMORY_PROTECTION _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_MESSAGE_PASSING -#define _POSIX_MESSAGE_PASSING _POSIX_VERSION -#endif - /* #define _POSIX_PRIORITIZED_IO (-1L) */ -#ifdef CONFIG_POSIX_PRIORITY_SCHEDULING -#define _POSIX_PRIORITY_SCHEDULING _POSIX_VERSION -#endif - -#ifdef CONFIG_NET_SOCKETS_PACKET -#define _POSIX_RAW_SOCKETS _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_RW_LOCKS -#define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION -#endif - /* #define _POSIX_REGEXP (-1L) */ /* #define _POSIX_SAVED_IDS (-1L) */ -#ifdef CONFIG_POSIX_SEMAPHORES -#define _POSIX_SEMAPHORES _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_SHARED_MEMORY_OBJECTS -#define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_VERSION -#endif - /* #define _POSIX_SHELL (-1L) */ /* #define _POSIX_SPAWN (-1L) */ -#ifdef CONFIG_POSIX_SPIN_LOCKS -#define _POSIX_SPIN_LOCKS _POSIX_VERSION -#endif - /* #define _POSIX_SPORADIC_SERVER (-1L) */ -#ifdef CONFIG_POSIX_SYNCHRONIZED_IO -#define _POSIX_SYNCHRONIZED_IO _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_THREAD_ATTR_STACKADDR -#define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_THREAD_ATTR_STACKSIZE -#define _POSIX_THREAD_ATTR_STACKSIZE _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_THREAD_CPUTIME -#define _POSIX_THREAD_CPUTIME _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_THREAD_PRIO_INHERIT -#define _POSIX_THREAD_PRIO_INHERIT _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_THREAD_PRIO_PROTECT -#define _POSIX_THREAD_PRIO_PROTECT _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_THREAD_PRIORITY_SCHEDULING -#define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION -#endif - /* #define _POSIX_THREAD_PROCESS_SHARED (-1L) */ /* #define _POSIX_THREAD_ROBUST_PRIO_INHERIT (-1L) */ /* #define _POSIX_THREAD_ROBUST_PRIO_PROTECT (-1L) */ /* #define _POSIX_THREAD_SPORADIC_SERVER (-1L) */ -#ifdef CONFIG_POSIX_THREADS -#ifndef _POSIX_THREADS -#define _POSIX_THREADS _POSIX_VERSION -#endif -#endif - -#ifdef CONFIG_POSIX_TIMEOUTS -#define _POSIX_TIMEOUTS _POSIX_VERSION -#endif - /* #define _POSIX_TRACE (-1L) */ /* #define _POSIX_TRACE_EVENT_FILTER (-1L) */ /* #define _POSIX_TRACE_INHERIT (-1L) */ @@ -185,8 +85,6 @@ /* * POSIX2 Options */ -/* #define _POSIX2_VERSION (-1) */ -#define _POSIX2_C_BIND _POSIX_VERSION /* #define _POSIX2_C_DEV (-1) */ /* #define _POSIX2_CHAR_TERM (-1L) */ /* #define _POSIX2_FORT_DEV (-1L) */ @@ -204,7 +102,6 @@ /* * X/Open System Interfaces */ -#define _XOPEN_VERSION 700 /* #define _XOPEN_CRYPT (-1L) */ /* #define _XOPEN_ENH_I18N (-1L) */ #if defined(CONFIG_XSI_REALTIME) || \ @@ -217,10 +114,6 @@ /* #define _XOPEN_REALTIME_THREADS (-1L) */ /* #define _XOPEN_SHM (-1L) */ -#ifdef CONFIG_XOPEN_STREAMS -#define _XOPEN_STREAMS _XOPEN_VERSION -#endif - /* #define _XOPEN_UNIX (-1L) */ /* #define _XOPEN_UUCP (-1L) */ diff --git a/include/zephyr/posix/posix_limits.h b/include/zephyr/posix/posix_limits.h index 9c225b4b4d4e0..0440873c4b949 100644 --- a/include/zephyr/posix/posix_limits.h +++ b/include/zephyr/posix/posix_limits.h @@ -122,6 +122,9 @@ #define POSIX_REC_XFER_ALIGN (4) #define SYMLINK_MAX _POSIX_SYMLINK_MAX +/* Other invariant values */ +#define GETENTROPY_MAX (256) + /* clang-format on */ #endif diff --git a/include/zephyr/posix/posix_signal.h b/include/zephyr/posix/posix_signal.h index b1c7e717e2018..c6b3d6110d09d 100644 --- a/include/zephyr/posix/posix_signal.h +++ b/include/zephyr/posix/posix_signal.h @@ -132,6 +132,7 @@ struct sigevent { /* SIGRTMIN and SIGRTMAX defined above */ +/* slightly out of order w.r.t. the specification */ #if !defined(_SIGINFO_T_DECLARED) && !defined(__siginfo_t_defined) typedef struct { void *si_addr; @@ -197,6 +198,17 @@ typedef struct { #define __mcontext_defined #endif +/* slightly out of order w.r.t. the specification */ +#if !defined(_STACK_T_DECLARED) && !defined(__stack_t_defined) +typedef struct { + void *ss_sp; + size_t ss_size; + int ss_flags; +} stack_t; +#define _STACK_T_DECLARED +#define __stack_t_defined +#endif + #if !defined(_UCONTEXT_T_DECLARED) && !defined(__ucontext_t_defined) typedef struct { struct ucontext *uc_link; @@ -208,16 +220,6 @@ typedef struct { #define __ucontext_defined #endif -#if !defined(_STACK_T_DECLARED) && !defined(__stack_t_defined) -typedef struct { - void *ss_sp; - size_t ss_size; - int ss_flags; -} stack_t; -#define _STACK_T_DECLARED -#define __stack_t_defined -#endif - #endif /* defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) */ /* Siginfo codes are defined below */ diff --git a/include/zephyr/posix/posix_stdlib.h b/include/zephyr/posix/posix_stdlib.h new file mode 100644 index 0000000000000..807fcf5fc76c8 --- /dev/null +++ b/include/zephyr/posix/posix_stdlib.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 The Zephyr Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef ZEPHYR_INCLUDE_POSIX_POSIX_STDLIB_H_ +#define ZEPHYR_INCLUDE_POSIX_POSIX_STDLIB_H_ + +#include /* NULL, size_t */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* TODO: additional POSIX signatures here */ + +#if defined(_BSD_SOURCE) || defined(__DOXYGEN__) +int getenv_r(const char *name, char *buf, size_t len); +#endif + +#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__) +int putenv(char *string); +#endif + +#if defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__) +int setenv(const char *envname, const char *envval, int overwrite); +int unsetenv(const char *name); +#endif /* defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__) */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_POSIX_POSIX_STDLIB_H_ */ diff --git a/include/zephyr/posix/posix_string.h b/include/zephyr/posix/posix_string.h new file mode 100644 index 0000000000000..2770942a3afbe --- /dev/null +++ b/include/zephyr/posix/posix_string.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 The Zephyr Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef ZEPHYR_INCLUDE_POSIX_POSIX_STRING_H_ +#define ZEPHYR_INCLUDE_POSIX_POSIX_STRING_H_ + +#if defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__) + +#include /* NULL, size_t */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* TODO: additional POSIX signatures here */ + +char *strsignal(int signo); + +#ifdef __cplusplus +} +#endif + +#endif /* defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__) */ + +#endif /* ZEPHYR_INCLUDE_POSIX_POSIX_STRING_H_ */ diff --git a/include/zephyr/posix/posix_time.h b/include/zephyr/posix/posix_time.h index 1d6fabba64698..ed3d1c37b8ed3 100644 --- a/include/zephyr/posix/posix_time.h +++ b/include/zephyr/posix/posix_time.h @@ -51,9 +51,7 @@ typedef int pid_t; #define __pid_t_defined #endif -#if defined(_POSIX_REALTIME_SIGNALS) struct sigevent; -#endif /* struct tm must be defined in the libc time.h */ diff --git a/include/zephyr/posix/posix_types.h b/include/zephyr/posix/posix_types.h deleted file mode 100644 index e65a398cdcc9c..0000000000000 --- a/include/zephyr/posix/posix_types.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2018 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef ZEPHYR_INCLUDE_POSIX_TYPES_H_ -#define ZEPHYR_INCLUDE_POSIX_TYPES_H_ - -#if !(defined(CONFIG_ARCH_POSIX) && defined(CONFIG_EXTERNAL_LIBC)) -#include -#endif - -#if !defined(_CLOCK_T_DECLARED) && !defined(__clock_t_defined) -typedef unsigned long clock_t; -#define _CLOCK_T_DECLARED -#define __clock_t_defined -#endif - -#if !defined(_CLOCKID_T_DECLARED) && !defined(__clockid_t_defined) -typedef unsigned long clockid_t; -#define _CLOCKID_T_DECLARED -#define __clockid_t_defined -#endif - -#ifdef CONFIG_NEWLIB_LIBC -#include -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_DEV_T_DECLARED) && !defined(__dev_t_defined) -typedef int dev_t; -#define _DEV_T_DECLARED -#define __dev_t_defined -#endif - -#if !defined(_INO_T_DECLARED) && !defined(__ino_t_defined) -typedef int ino_t; -#define _INO_T_DECLARED -#define __ino_t_defined -#endif - -#if !defined(_NLINK_T_DECLARED) && !defined(__nlink_t_defined) -typedef unsigned short nlink_t; -#define _NLINK_T_DECLARED -#define __nlink_t_defined -#endif - -#if !defined(_UID_T_DECLARED) && !defined(__uid_t_defined) -typedef unsigned short uid_t; -#define _UID_T_DECLARED -#define __uid_t_defined -#endif - -#if !defined(_GID_T_DECLARED) && !defined(__gid_t_defined) -typedef unsigned short gid_t; -#define _GID_T_DECLARED -#define __gid_t_defined -#endif - -#if !defined(_BLKSIZE_T_DECLARED) && !defined(__blksize_t_defined) -typedef unsigned long blksize_t; -#define _BLKSIZE_T_DECLARED -#define __blksize_t_defined -#endif - -#if !defined(_BLKCNT_T_DECLARED) && !defined(__blkcnt_t_defined) -typedef unsigned long blkcnt_t; -#define _BLKCNT_T_DECLARED -#define __blkcnt_t_defined -#endif - -#if !defined(CONFIG_ARCMWDT_LIBC) -typedef int pid_t; -#endif - -#ifndef __useconds_t_defined -typedef unsigned long useconds_t; -#endif - -/* time related attributes */ -#if !defined(__timer_t_defined) && !defined(_TIMER_T_DECLARED) -typedef unsigned long timer_t; -#endif - -/* Thread attributes */ -struct pthread_attr { - void *stack; - uint32_t details[2]; -}; - -#if !defined(CONFIG_NEWLIB_LIBC) -typedef struct pthread_attr pthread_attr_t; -BUILD_ASSERT(sizeof(pthread_attr_t) >= sizeof(struct pthread_attr)); -#endif - -typedef uint32_t pthread_t; -typedef uint32_t pthread_spinlock_t; - -/* Semaphore */ -typedef struct k_sem sem_t; - -/* Mutex */ -typedef uint32_t pthread_mutex_t; - -struct pthread_mutexattr { - unsigned char type: 2; - bool initialized: 1; -}; -#if !defined(CONFIG_NEWLIB_LIBC) -typedef struct pthread_mutexattr pthread_mutexattr_t; -BUILD_ASSERT(sizeof(pthread_mutexattr_t) >= sizeof(struct pthread_mutexattr)); -#endif - -/* Condition variables */ -typedef uint32_t pthread_cond_t; - -struct pthread_condattr { - clockid_t clock; -}; - -#if !defined(CONFIG_NEWLIB_LIBC) -typedef struct pthread_condattr pthread_condattr_t; -BUILD_ASSERT(sizeof(pthread_condattr_t) >= sizeof(struct pthread_condattr)); -#endif - -/* Barrier */ -typedef uint32_t pthread_barrier_t; - -typedef struct pthread_barrierattr { - int pshared; -} pthread_barrierattr_t; - -typedef uint32_t pthread_rwlockattr_t; - -typedef uint32_t pthread_rwlock_t; - -struct pthread_once { - bool flag; -}; - -#if !defined(CONFIG_NEWLIB_LIBC) -typedef uint32_t pthread_key_t; -typedef struct pthread_once pthread_once_t; -/* Newlib typedefs pthread_once_t as a struct with two ints */ -BUILD_ASSERT(sizeof(pthread_once_t) >= sizeof(struct pthread_once)); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ZEPHYR_INCLUDE_POSIX_TYPES_H_ */ diff --git a/include/zephyr/posix/pthread.h b/include/zephyr/posix/pthread.h index adf1cfd4b77f0..ac7b0f133a731 100644 --- a/include/zephyr/posix/pthread.h +++ b/include/zephyr/posix/pthread.h @@ -15,6 +15,8 @@ #include #include +#include + #ifdef __cplusplus extern "C" { #endif @@ -168,7 +170,7 @@ int pthread_condattr_setclock(pthread_condattr_t *att, clockid_t clock_id); #define PTHREAD_MUTEX_NORMAL 0 #define PTHREAD_MUTEX_RECURSIVE 1 #define PTHREAD_MUTEX_ERRORCHECK 2 -#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL +#define PTHREAD_MUTEX_DEFAULT 3 /* * Mutex attributes - protocol @@ -283,8 +285,8 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t *attr); /* * Barrier attributes - type */ -#define PTHREAD_PROCESS_PRIVATE 0 -#define PTHREAD_PROCESS_PUBLIC 1 +#define PTHREAD_PROCESS_PRIVATE 0 +#define PTHREAD_PROCESS_SHARED 1 /** * @brief POSIX threading compatibility API diff --git a/include/zephyr/posix/sched.h b/include/zephyr/posix/sched.h index 572475df02f33..384c7553c9860 100644 --- a/include/zephyr/posix/sched.h +++ b/include/zephyr/posix/sched.h @@ -6,11 +6,11 @@ #ifndef ZEPHYR_INCLUDE_POSIX_SCHED_H_ #define ZEPHYR_INCLUDE_POSIX_SCHED_H_ -#include -#include - +#include #include +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/include/zephyr/posix/semaphore.h b/include/zephyr/posix/semaphore.h index 943df122cff59..1b8548104c442 100644 --- a/include/zephyr/posix/semaphore.h +++ b/include/zephyr/posix/semaphore.h @@ -8,7 +8,8 @@ #include -#include +#include +#include #ifdef __cplusplus extern "C" { @@ -16,6 +17,12 @@ extern "C" { #define SEM_FAILED ((sem_t *) 0) +#if !(defined(_SEM_T_DECLARED) || defined(__sem_t_defined)) || defined(__DOXYGEN__) +typedef struct k_sem sem_t; +#define _SEM_T_DECLARED +#define __sem_t_defined +#endif + int sem_destroy(sem_t *semaphore); int sem_getvalue(sem_t *ZRESTRICT semaphore, int *ZRESTRICT value); int sem_init(sem_t *semaphore, int pshared, unsigned int value); diff --git a/include/zephyr/posix/sys/_pthreadtypes.h b/include/zephyr/posix/sys/_pthreadtypes.h new file mode 100644 index 0000000000000..1a388586b01d3 --- /dev/null +++ b/include/zephyr/posix/sys/_pthreadtypes.h @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2025 The Zephyr Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_POSIX_SYS__PTHREADTYPES_H_ +#define ZEPHYR_INCLUDE_POSIX_SYS__PTHREADTYPES_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !(defined(_PTHREAD_ATTR_T_DECLARED) || defined(__pthread_attr_t_defined)) || \ + defined(__DOXYGEN__) +typedef struct { + void *stack; + uint32_t details[2]; +} pthread_attr_t; +#define _PTHREAD_ATTR_T_DECLARED +#define __pthread_attr_t_defined +#endif + +#if !(defined(_PTHREAD_BARRIER_T_DECLARED) && defined(__pthread_barrier_t_defined)) || \ + defined(__DOXYGEN__) +typedef uint32_t pthread_barrier_t; +#define _PTHREAD_BARRIER_T_DECLARED +#define __pthread_barrier_t_defined +#endif + +#if !(defined(_PTHREAD_BARRIERATTR_T_DECLARED) && defined(__pthread_barrierattr_t_defined)) || \ + defined(__DOXYGEN__) +typedef struct { +#if defined(_POSIX_PROCESS_SHARED) || defined(__DOXYGEN__) + int pshared; +#endif +} pthread_barrierattr_t; +#define _PTHREAD_BARRIERATTR_T_DECLARED +#define __pthread_barrierattr_t_defined +#endif + +#if !(defined(_PTHREAD_COND_T_DECLARED) && defined(__pthread_cond_t_defined)) || \ + defined(__DOXYGEN__) +/* TODO: convert this to a long so that it can refer to a k_condvar (pointer) */ +typedef uint32_t pthread_cond_t; +#define _PTHREAD_COND_T_DECLARED +#define __pthread_cond_t_defined +#endif + +#if !(defined(_PTHREAD_CONDATTR_T_DECLARED) && defined(__pthread_condattr_t_defined)) || \ + defined(__DOXYGEN__) +typedef struct { + clockid_t clock; +} pthread_condattr_t; +#define _PTHREAD_CONDATTR_T_DECLARED +#define __pthread_condattr_t_defined +#endif + +#if !(defined(_PTHREAD_KEY_T_DECLARED) && defined(__pthread_key_t_defined)) || defined(__DOXYGEN__) +typedef uint32_t pthread_key_t; +#define _PTHREAD_KEY_T_DECLARED +#define __pthread_key_t_defined +#endif + +#if !(defined(_PTHREAD_MUTEX_T_DECLARED) && defined(__pthread_mutex_t_defined)) || \ + defined(__DOXYGEN__) +/* TODO: convert this to a long so that it can refer to a k_mutex (pointer) */ +typedef uint32_t pthread_mutex_t; +#define _PTHREAD_MUTEX_T_DECLARED +#define __pthread_mutex_t_defined +#endif + +#if !(defined(_PTHREAD_MUTEXATTR_T_DECLARED) && defined(__pthread_mutexattr_t_defined)) || \ + defined(__DOXYGEN__) +typedef struct { + unsigned char type: 2; + bool initialized: 1; +} pthread_mutexattr_t; +#define _PTHREAD_MUTEXATTR_T_DECLARED +#define __pthread_mutexattr_t_defined +#endif + +#if !(defined(_PTHREAD_ONCE_T_DECLARED) && defined(__pthread_once_t_defined)) || \ + defined(__DOXYGEN__) +typedef struct { + bool flag; +} pthread_once_t; +#define _PTHREAD_ONCE_T_DECLARED +#define __pthread_once_t_defined +#endif + +#if !(defined(_PTHREAD_RWLOCK_T_DECLARED) && defined(__pthread_rwlock_t_defined)) || \ + defined(__DOXYGEN__) +typedef uint32_t pthread_rwlock_t; +#define _PTHREAD_RWLOCK_T_DECLARED +#define __pthread_rwlock_t_defined +#endif + +#if !(defined(_PTHREAD_RWLOCKATTR_T_DECLARED) && defined(__pthread_rwlockattr_t_defined)) || \ + defined(__DOXYGEN__) +typedef uint32_t pthread_rwlockattr_t; +#define _PTHREAD_RWLOCKATTR_T_DECLARED +#define __pthread_rwlockattr_t_defined +#endif + +#if !(defined(_PTHREAD_SPINLOCK_T_DECLARED) && defined(__pthread_spinlock_t_defined)) || \ + defined(__DOXYGEN__) +/* TODO: convert this to a long so that it can refer to a sys_sem_t (pointer) */ +typedef uint32_t pthread_spinlock_t; +#define _PTHREAD_SPINLOCK_T_DECLARED +#define __pthread_spinlock_t_defined +#endif + +#if !(defined(_PTHREAD_T_DECLARED) && defined(__pthread_t_defined)) || defined(__DOXYGEN__) +/* TODO: convert this to a long so that it can refer to a k_thread (pointer) */ +typedef uint32_t pthread_t; +#define _PTHREAD_T_DECLARED +#define __pthread_t_defined +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_POSIX_SYS__PTHREADTYPES_H_ */ diff --git a/include/zephyr/posix/sys/dirent.h b/include/zephyr/posix/sys/dirent.h deleted file mode 100644 index fde312136ebb2..0000000000000 --- a/include/zephyr/posix/sys/dirent.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2024 Tenstorrent AI ULC - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef ZEPHYR_INCLUDE_POSIX_SYS_DIRENT_H_ -#define ZEPHYR_INCLUDE_POSIX_SYS_DIRENT_H_ - -#include - -#if !defined(NAME_MAX) && defined(_XOPEN_SOURCE) -#define NAME_MAX _XOPEN_NAME_MAX -#endif - -#if !defined(NAME_MAX) && defined(_POSIX_C_SOURCE) -#define NAME_MAX _POSIX_NAME_MAX -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void DIR; - -struct dirent { - unsigned int d_ino; - char d_name[NAME_MAX + 1]; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ZEPHYR_INCLUDE_POSIX_SYS_DIRENT_H_ */ diff --git a/include/zephyr/posix/sys/select.h b/include/zephyr/posix/sys/select.h index b51ace79828b2..495bc919ae090 100644 --- a/include/zephyr/posix/sys/select.h +++ b/include/zephyr/posix/sys/select.h @@ -6,7 +6,6 @@ #ifndef ZEPHYR_INCLUDE_POSIX_SYS_SELECT_H_ #define ZEPHYR_INCLUDE_POSIX_SYS_SELECT_H_ -#include #include #ifdef __cplusplus @@ -15,12 +14,62 @@ extern "C" { #define FD_SETSIZE ZVFS_FD_SETSIZE +#if !defined(_SIGSET_T_DECLARED) && !defined(__sigset_t_defined) + +#ifndef SIGRTMIN +#define SIGRTMIN 32 +#endif +#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) +BUILD_ASSERT(CONFIG_POSIX_RTSIG_MAX >= 0); +#define SIGRTMAX (SIGRTMIN + CONFIG_POSIX_RTSIG_MAX) +#else +#define SIGRTMAX SIGRTMIN +#endif + +typedef struct { + unsigned long sig[DIV_ROUND_UP(SIGRTMAX + 1, BITS_PER_LONG)]; +} sigset_t; +#define _SIGSET_T_DECLARED +#define __sigset_t_defined +#endif + +#if !defined(_SUSECONDS_T_DECLARED) && !defined(__suseconds_t_defined) +typedef long suseconds_t; +#define _SUSECONDS_T_DECLARED +#define __suseconds_t_defined +#endif + +/* time_t must be defined by the libc time.h */ +#include + +#if __STDC_VERSION__ >= 201112L +/* struct timespec must be defined in the libc time.h */ +#else +#if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined) +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +#define _TIMESPEC_DECLARED +#define __timespec_defined +#endif +#endif + +#if !defined(_TIMEVAL_DECLARED) && !defined(__timeval_defined) +struct timeval { + time_t tv_sec; + suseconds_t tv_usec; +}; +#define _TIMEVAL_DECLARED +#define __timeval_defined +#endif + typedef struct zvfs_fd_set fd_set; struct timeval; int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - const struct timespec *timeout, const void *sigmask); + const struct timespec *timeout, const sigset_t *sigmask); int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout); void FD_CLR(int fd, fd_set *fdset); int FD_ISSET(int fd, fd_set *fdset); diff --git a/include/zephyr/posix/sys/stat.h b/include/zephyr/posix/sys/stat.h index fdd4e0934ee2b..ac34028caa216 100644 --- a/include/zephyr/posix/sys/stat.h +++ b/include/zephyr/posix/sys/stat.h @@ -1,59 +1,95 @@ -/* SPDX-License-Identifier: BSD-3-Clause */ /* - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. + * Copyright The Zephyr Project Contributors * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * SPDX-License-Identifier: Apache-2.0 */ -#ifndef ZEPHYR_POSIX_SYS_STAT_H_ -#define ZEPHYR_POSIX_SYS_STAT_H_ + +#ifndef ZEPHYR_INCLUDE_ZEPHYR_POSIX_SYS_STAT_H_ +#define ZEPHYR_INCLUDE_ZEPHYR_POSIX_SYS_STAT_H_ + +#include + +#include +#include #ifdef __cplusplus extern "C" { #endif -#include -#include +#if defined(_POSIX_C_SOURCE) || defined(__DOXYGEN__) -#include +/* slightly out of order w.r.t. the specification */ +#if !defined(_BLKCNT_T_DECLARED) && !defined(__blkcnt_t_defined) +typedef long blkcnt_t; +#define _BLKCNT_T_DECLARED +#define __blkcnt_t_defined +#endif -/* dj's stat defines _STAT_H_ */ -#ifndef _STAT_H_ +#if !defined(_BLKSIZE_T_DECLARED) && !defined(__blksize_t_defined) +typedef unsigned long blksize_t; +#define _BLKSIZE_T_DECLARED +#define __blksize_t_defined +#endif -/* - * It is intended that the layout of this structure not change when the - * sizes of any of the basic types change (short, int, long) [via a compile - * time option]. - */ +#if !defined(_DEV_T_DECLARED) && !defined(__dev_t_defined) +typedef int dev_t; +#define _DEV_T_DECLARED +#define __dev_t_defined +#endif + +#if !defined(_GID_T_DECLARED) && !defined(__gid_t_defined) +typedef unsigned short gid_t; +#define _GID_T_DECLARED +#define __gid_t_defined +#endif -#ifdef __CYGWIN__ -#include -#ifdef _LIBC -#define stat64 stat +#if !defined(_INO_T_DECLARED) && !defined(__ino_t_defined) +typedef long ino_t; +#define _INO_T_DECLARED +#define __ino_t_defined #endif + +#if !defined(_MODE_T_DECLARED) && !defined(__mode_t_defined) +typedef int mode_t; +#define _MODE_T_DECLARED +#define __mode_t_defined +#endif + +#if !defined(_NLINK_T_DECLARED) && !defined(__nlink_t_defined) +typedef unsigned short nlink_t; +#define _NLINK_T_DECLARED +#define __nlink_t_defined +#endif + +#if !defined(_OFF_T_DECLARED) && !defined(__off_t_defined) +typedef long off_t; +#define _OFF_T_DECLARED +#define __off_t_defined +#endif + +/* time_t must be defined by the libc time.h */ +#include + +#if __STDC_VERSION__ >= 201112L +/* struct timespec must be defined in the libc time.h */ #else +#if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined) +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +#define _TIMESPEC_DECLARED +#define __timespec_defined +#endif +#endif + +#if !defined(_UID_T_DECLARED) && !defined(__uid_t_defined) +typedef unsigned short uid_t; +#define _UID_T_DECLARED +#define __uid_t_defined +#endif + +#if !(defined(_STAT_DECLARED) || defined(__stat_defined)) || defined(__DOXYGEN__) struct stat { dev_t st_dev; ino_t st_ino; @@ -61,181 +97,98 @@ struct stat { nlink_t st_nlink; uid_t st_uid; gid_t st_gid; -#if defined(__linux) && defined(__x86_64__) - int __pad0; -#endif +#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__) dev_t st_rdev; -#if defined(__linux) && !defined(__x86_64__) - unsigned short int __pad2; #endif off_t st_size; -#if defined(__linux) - blksize_t st_blksize; - blkcnt_t st_blocks; - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; -#define st_atime st_atim.tv_sec /* Backward compatibility */ -#define st_mtime st_mtim.tv_sec -#define st_ctime st_ctim.tv_sec -#if defined(__linux) && defined(__x86_64__) - uint64_t __glibc_reserved[3]; -#endif -#else -#if defined(__rtems__) - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; - blksize_t st_blksize; - blkcnt_t st_blocks; -#else - /* SysV/sco doesn't have the rest... But Solaris, eabi does. */ -#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__) - time_t st_atime; - time_t st_mtime; - time_t st_ctime; -#else struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; - blksize_t st_blksize; +#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__) + blkcnt_t st_blksize; blkcnt_t st_blocks; -#if !defined(__rtems__) - long st_spare4[2]; -#endif -#endif -#endif #endif }; +#define _STAT_DECLARED +#define __stat_defined +#endif + +#define S_IFMT 00170000 +#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__) +#define S_IFBLK ZVFS_MODE_IFBLK +#define S_IFCHR ZVFS_MODE_IFCHR +#define S_IFIFO ZVFS_MODE_IFIFO +#define S_IFREG ZVFS_MODE_IFREG +#define S_IFDIR ZVFS_MODE_IFDIR +#define S_IFLNK ZVFS_MODE_IFLNK +#define S_IFSOCK ZVFS_MODE_IFSOCK +#define S_IFSHM ZVFS_MODE_IFSHM +#endif + +#define S_IRWXU 0000700 +#define S_IRUSR 0000400 +#define S_IWUSR 0000200 +#define S_IXUSR 0000100 +#define S_IRWXG 0000070 +#define S_IRGRP 0000040 +#define S_IWGRP 0000020 +#define S_IXGRP 0000010 +#define S_IRWXO 0000007 +#define S_IROTH 0000004 +#define S_IWOTH 0000002 +#define S_IXOTH 0000001 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__) +#define S_ISVTX 0001000 +#endif + +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__) +#define S_TYPEISMQ(buf) (0) +#define S_TYPEISSEM(buf) (0) +#define S_TYPEISSHM(st) (((st)->st_mode & S_IFMT) == S_IFSHM) +#endif + +#if defined(_POSIX_TYPED_MEMORY_OBJECTS) || defined(__DOXYGEN__) +#define S_TYPEISTMO(buf) (0) +#endif + +#define UTIME_NOW -1 +#define UTIME_OMIT -2 + +int chmod(const char *path, mode_t mode); +int fchmod(int fildes, mode_t mode); +int fchmodat(int fd, const char *path, mode_t mode, int flag); +int fstat(int fildes, struct stat *buf); +int fstatat(int fd, const char *ZRESTRICT path, struct stat *ZRESTRICT buf, int flag); +int futimens(int fildes, const struct timespec times[2]); +int lstat(const char *ZRESTRICT path, struct stat *ZRESTRICT buf); +int mkdir(const char *path, mode_t mode); +int mkdirat(int fd, const char *path, mode_t mode); +int mkfifo(const char *path, mode_t mode); +int mkfifoat(int fd, const char *path, mode_t mode); +#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__) +int mknod(const char *path, mode_t mode, dev_t dev); +int mknodat(int fd, const char *path, mode_t mode, dev_t dev); +#endif +TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_SHADOW); +int stat(const char *ZRESTRICT path, struct stat *ZRESTRICT buf); +TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_SHADOW); +mode_t umask(mode_t cmask); +int utimensat(int fd, const char *path, const struct timespec times[2], int flag); -#if !(defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)) -#define st_atime st_atim.tv_sec -#define st_ctime st_ctim.tv_sec -#define st_mtime st_mtim.tv_sec -#endif - -#endif - -#define _IFMT 0170000 /* type of file */ -#define _IFDIR 0040000 /* directory */ -#define _IFCHR 0020000 /* character special */ -#define _IFBLK 0060000 /* block special */ -#define _IFREG 0100000 /* regular */ -#define _IFLNK 0120000 /* symbolic link */ -#define _IFSOCK 0140000 /* socket */ -#define _IFIFO 0010000 /* fifo */ - -#define S_BLKSIZE 1024 /* size of a block */ - -#define S_ISUID 0004000 /* set user id on execution */ -#define S_ISGID 0002000 /* set group id on execution */ -#define S_ISVTX 0001000 /* save swapped text even after use */ -#if __BSD_VISIBLE -#define S_IREAD 0000400 /* read permission, owner */ -#define S_IWRITE 0000200 /* write permission, owner */ -#define S_IEXEC 0000100 /* execute/search permission, owner */ -#define S_ENFMT 0002000 /* enforcement-mode locking */ -#endif /* !_BSD_VISIBLE */ - -#define S_IFMT _IFMT -#define S_IFDIR _IFDIR -#define S_IFCHR _IFCHR -#define S_IFBLK _IFBLK -#define S_IFREG _IFREG -#define S_IFLNK _IFLNK -#define S_IFSOCK _IFSOCK -#define S_IFIFO _IFIFO - -#ifdef _WIN32 -/* - * The Windows header files define _S_ forms of these, so we do too - * for easier portability. - */ -#define _S_IFMT _IFMT -#define _S_IFDIR _IFDIR -#define _S_IFCHR _IFCHR -#define _S_IFIFO _IFIFO -#define _S_IFREG _IFREG -#define _S_IREAD 0000400 -#define _S_IWRITE 0000200 -#define _S_IEXEC 0000100 -#endif - -#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) -#define S_IRUSR 0000400 /* read permission, owner */ -#define S_IWUSR 0000200 /* write permission, owner */ -#define S_IXUSR 0000100 /* execute/search permission, owner */ -#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) -#define S_IRGRP 0000040 /* read permission, group */ -#define S_IWGRP 0000020 /* write permission, grougroup */ -#define S_IXGRP 0000010 /* execute/search permission, group */ -#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) -#define S_IROTH 0000004 /* read permission, other */ -#define S_IWOTH 0000002 /* write permission, other */ -#define S_IXOTH 0000001 /* execute/search permission, other */ - -#if __BSD_VISIBLE -#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */ -#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */ -#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */ -#endif - -#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK) -#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR) -#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR) -#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO) -#define S_ISREG(m) (((m)&_IFMT) == _IFREG) -#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK) -#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK) - -#if defined(__CYGWIN__) || defined(__rtems__) -/* Special tv_nsec values for futimens(2) and utimensat(2). */ -#define UTIME_NOW -2L -#define UTIME_OMIT -1L -#endif - -int chmod(const char *__path, mode_t __mode); -int fchmod(int __fd, mode_t __mode); -int fstat(int __fd, struct stat *__sbuf); -int mkdir(const char *_path, mode_t __mode); -int mkfifo(const char *__path, mode_t __mode); -int stat(const char *__restrict __path, struct stat *__restrict __sbuf); -mode_t umask(mode_t __mask); - -#if defined(__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__) -int lstat(const char *__restrict __path, struct stat *__restrict __buf); -int mknod(const char *__path, mode_t __mode, dev_t __dev); -#endif - -#if __ATFILE_VISIBLE && !defined(__INSIDE_CYGWIN__) -int fchmodat(int __fd, const char *__path, mode_t __mode, int __flag); -int fstatat(int __fd, const char *__restrict __path, struct stat *__restrict __buf, int __flag); -int mkdirat(int __fd, const char *__path, mode_t __mode); -int mkfifoat(int __fd, const char *__path, mode_t __mode); -int mknodat(int __fd, const char *__path, mode_t __mode, dev_t __dev); -int utimensat(int __fd, const char *__path, const struct timespec __times[2], int __flag); -#endif -#if __POSIX_VISIBLE >= 200809 && !defined(__INSIDE_CYGWIN__) -int futimens(int __fd, const struct timespec __times[2]); #endif -/* - * Provide prototypes for most of the _ names that are - * provided in newlib for some compilers. - */ -#ifdef _LIBC -int _fstat(int __fd, struct stat *__sbuf); -int _stat(const char *__restrict __path, struct stat *__restrict __sbuf); -int _mkdir(const char *_path, mode_t __mode); -#ifdef __LARGE64_FILES -struct stat64; -int _stat64(const char *__restrict __path, struct stat64 *__restrict __sbuf); -int _fstat64(int __fd, struct stat64 *__sbuf); -#endif -#endif - -#endif /* !_STAT_H_ */ #ifdef __cplusplus } #endif -#endif /* ZEPHYR_POSIX_SYS_STAT_H_ */ + +#endif /* ZEPHYR_INCLUDE_ZEPHYR_POSIX_SYS_STAT_H_ */ diff --git a/include/zephyr/posix/sys/sysconf.h b/include/zephyr/posix/sys/sysconf.h index 76a1b78d3acfd..a330bfa0432e3 100644 --- a/include/zephyr/posix/sys/sysconf.h +++ b/include/zephyr/posix/sys/sysconf.h @@ -15,6 +15,8 @@ extern "C" { #endif +#if defined(CONFIG_MINIMAL_LIBC) + enum { _SC_ADVISORY_INFO, _SC_ASYNCHRONOUS_IO, @@ -228,7 +230,8 @@ enum { #define __z_posix_sysconf_SC_TRACE_SYS_MAX _POSIX_TRACE_SYS_MAX #define __z_posix_sysconf_SC_TRACE_USER_EVENT_MAX _POSIX_TRACE_USER_EVENT_MAX #define __z_posix_sysconf_SC_TYPED_MEMORY_OBJECTS (-1L) -#define __z_posix_sysconf_SC_VERSION _POSIX_VERSION +#define __z_posix_sysconf_SC_VERSION \ + COND_CODE_1(CONFIG_POSIX_SYSTEM_INTERFACES, (_POSIX_VERSION), (0)) #define __z_posix_sysconf_SC_V6_ILP32_OFF32 (-1L) #define __z_posix_sysconf_SC_V6_ILP32_OFFBIG (-1L) #define __z_posix_sysconf_SC_V6_LP64_OFF64 (-1L) @@ -265,14 +268,17 @@ enum { COND_CODE_1(_POSIX2_VERSION > 0, (_POSIX2_VERSION), (-1)) #define __z_posix_sysconf_SC_XOPEN_CRYPT (-1L) #define __z_posix_sysconf_SC_XOPEN_ENH_I18N (-1L) -#define __z_posix_sysconf_SC_XOPEN_REALTIME (-1L) +#define __z_posix_sysconf_SC_XOPEN_REALTIME \ + COND_CODE_1(CONFIG_XSI_REALTIME, (_XOPEN_VERSION), (-1)) #define __z_posix_sysconf_SC_XOPEN_REALTIME_THREADS (-1L) #define __z_posix_sysconf_SC_XOPEN_SHM (-1L) #define __z_posix_sysconf_SC_XOPEN_STREAMS \ - COND_CODE_1(CONFIG_XOPEN_STREAMS, (_XOPEN_STREAMS), (-1)) -#define __z_posix_sysconf_SC_XOPEN_UNIX (-1L) + COND_CODE_1(CONFIG_XSI_STREAMS, (_XOPEN_STREAMS), (-1)) +#define __z_posix_sysconf_SC_XOPEN_UNIX \ + COND_CODE_1(CONFIG_XSI, (_XOPEN_UNIX), (-1)) #define __z_posix_sysconf_SC_XOPEN_UUCP (-1L) -#define __z_posix_sysconf_SC_XOPEN_VERSION _XOPEN_VERSION +#define __z_posix_sysconf_SC_XOPEN_VERSION \ + COND_CODE_1(CONFIG_XSI, (_XOPEN_VERSION), (0)) #define __z_posix_sysconf_SC_CLK_TCK (100L) #define __z_posix_sysconf_SC_GETGR_R_SIZE_MAX (0L) #define __z_posix_sysconf_SC_GETPW_R_SIZE_MAX (0L) @@ -319,6 +325,8 @@ enum { /* clang-format on */ +#endif + #ifdef __cplusplus } #endif diff --git a/include/zephyr/posix/sys/types.h b/include/zephyr/posix/sys/types.h new file mode 100644 index 0000000000000..e578bd83e3281 --- /dev/null +++ b/include/zephyr/posix/sys/types.h @@ -0,0 +1,159 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_POSIX_TYPES_H_ +#define ZEPHYR_INCLUDE_POSIX_TYPES_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_BLKCNT_T_DECLARED) && !defined(__blkcnt_t_defined) +typedef long blkcnt_t; +#define _BLKCNT_T_DECLARED +#define __blkcnt_t_defined +#endif + +#if !defined(_BLKSIZE_T_DECLARED) && !defined(__blksize_t_defined) +typedef unsigned long blksize_t; +#define _BLKSIZE_T_DECLARED +#define __blksize_t_defined +#endif + +#if !defined(_CLOCK_T_DECLARED) && !defined(__clock_t_defined) +typedef unsigned long clock_t; +#define _CLOCK_T_DECLARED +#define __clock_t_defined +#endif + +#if !defined(_CLOCKID_T_DECLARED) && !defined(__clockid_t_defined) +typedef unsigned long clockid_t; +#define _CLOCKID_T_DECLARED +#define __clockid_t_defined +#endif + +#if !defined(_DEV_T_DECLARED) && !defined(__dev_t_defined) +typedef int dev_t; +#define _DEV_T_DECLARED +#define __dev_t_defined +#endif + +#if !defined(_FSBLKCNT_T_DECLARED) && !defined(__fsblkcnt_t_defined) +typedef unsigned long fsblkcnt_t; +#define _FSBLKCNT_T_DECLARED +#define __fsblkcnt_t_defined +#endif + +#if !defined(_FSFILCNT_T_DECLARED) && !defined(__fsfilcnt_t_defined) +typedef unsigned long fsfilcnt_t; +#define _FSFILCNT_T_DECLARED +#define __fsfilcnt_t_defined +#endif + +#if !defined(_GID_T_DECLARED) && !defined(__gid_t_defined) +typedef unsigned short gid_t; +#define _GID_T_DECLARED +#define __gid_t_defined +#endif + +#if !defined(_INO_T_DECLARED) && !defined(__ino_t_defined) +typedef long ino_t; +#define _INO_T_DECLARED +#define __ino_t_defined +#endif + +/* Maybe limit to when _XOPEN_SOURCE is defined? */ +#if !defined(_KEY_T_DECLARED) && !defined(__key_t_defined) +typedef unsigned long key_t; +#define _KEY_T_DECLARED +#define __key_t_defined +#endif + +#if !defined(_MODE_T_DECLARED) && !defined(__mode_t_defined) +typedef int mode_t; +#define _MODE_T_DECLARED +#define __mode_t_defined +#endif + +#if !defined(_NLINK_T_DECLARED) && !defined(__nlink_t_defined) +typedef unsigned short nlink_t; +#define _NLINK_T_DECLARED +#define __nlink_t_defined +#endif + +#if !defined(_OFF_T_DECLARED) && !defined(__off_t_defined) +typedef long off_t; +#define _OFF_T_DECLARED +#define __off_t_defined +#endif + +#if !defined(_PID_T_DECLARED) && !defined(__pid_t_defined) +/* TODO: it would be nice to convert this to a long */ +typedef int pid_t; +#define _PID_T_DECLARED +#define __pid_t_defined +#endif + +/* size_t must be defined by the libc stddef.h */ +#include + +#ifndef __SIZE_TYPE__ +#define __SIZE_TYPE__ unsigned long +#endif + +#if !defined(_SSIZE_T_DECLARED) && !defined(__ssize_t_defined) +#define unsigned signed /* parasoft-suppress MISRAC2012-RULE_20_4-a MISRAC2012-RULE_20_4-b */ +typedef __SIZE_TYPE__ ssize_t; +#undef unsigned +#define _SSIZE_T_DECLARED +#define __ssize_t_defined +#endif + +#if !defined(_SUSECONDS_T_DECLARED) && !defined(__suseconds_t_defined) +typedef long suseconds_t; +#define _SUSECONDS_T_DECLARED +#define __suseconds_t_defined +#endif + +/* time_t must be defined by the libc time.h */ +#include + +#if __STDC_VERSION__ >= 201112L +/* struct timespec must be defined in the libc time.h */ +#else +#if !defined(_TIMESPEC_DECLARED) && !defined(__timespec_defined) +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +#define _TIMESPEC_DECLARED +#define __timespec_defined +#endif +#endif + +/* TODO: trace_attr_t, trace_event_id_t, trace_event_set_t, trace_id_t */ + +#if !defined(_UID_T_DECLARED) && !defined(__uid_t_defined) +typedef unsigned short uid_t; +#define _UID_T_DECLARED +#define __uid_t_defined +#endif + +#if !defined(_USECONDS_T_DECLARED) && !defined(__useconds_t_defined) +typedef unsigned long useconds_t; +#define _USECONDS_T_DECLARED +#define __useconds_t_defined +#endif + +#ifdef __cplusplus +} +#endif + +#include + +#endif /* ZEPHYR_INCLUDE_POSIX_TYPES_H_ */ diff --git a/include/zephyr/posix/unistd.h b/include/zephyr/posix/unistd.h index 936e55fa53a08..586271592607a 100644 --- a/include/zephyr/posix/unistd.h +++ b/include/zephyr/posix/unistd.h @@ -6,15 +6,14 @@ #ifndef ZEPHYR_INCLUDE_POSIX_UNISTD_H_ #define ZEPHYR_INCLUDE_POSIX_UNISTD_H_ +#include +#include #include -#include - #ifdef CONFIG_POSIX_API #include #endif #include -#include #include #include "posix_features.h" diff --git a/lib/libc/common/source/time/gmtime_r.c b/lib/libc/common/source/time/gmtime_r.c index 96afa6bc7425f..5f240b77dceaf 100644 --- a/lib/libc/common/source/time/gmtime_r.c +++ b/lib/libc/common/source/time/gmtime_r.c @@ -10,9 +10,10 @@ * http://howardhinnant.github.io/date_algorithms.html#civil_from_days */ -#include #include +#include + /* A signed type with the representation of time_t without its * implications. */ diff --git a/lib/libc/minimal/CMakeLists.txt b/lib/libc/minimal/CMakeLists.txt index 29f2db74367ba..e0a47206f05c5 100644 --- a/lib/libc/minimal/CMakeLists.txt +++ b/lib/libc/minimal/CMakeLists.txt @@ -52,3 +52,5 @@ add_custom_command( DEPENDS include/errno.h WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) + +zephyr_include_directories(${ZEPHYR_BASE}/include/zephyr/posix) diff --git a/lib/libc/minimal/include/stdlib.h b/lib/libc/minimal/include/stdlib.h index a62a4a1e4d61f..5749f75eb43ad 100644 --- a/lib/libc/minimal/include/stdlib.h +++ b/lib/libc/minimal/include/stdlib.h @@ -73,17 +73,11 @@ static inline long long llabs(long long __n) } char *getenv(const char *name); -#if _POSIX_C_SOURCE >= 200112L -int setenv(const char *name, const char *val, int overwrite); -int unsetenv(const char *name); -#endif - -#ifdef _BSD_SOURCE -int getenv_r(const char *name, char *buf, size_t len); -#endif #ifdef __cplusplus } #endif +#include + #endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDLIB_H_ */ diff --git a/lib/libc/minimal/include/string.h b/lib/libc/minimal/include/string.h index 35052c0c06c8f..0cf173a560e51 100644 --- a/lib/libc/minimal/include/string.h +++ b/lib/libc/minimal/include/string.h @@ -48,4 +48,6 @@ extern void *memchr(const void *s, int c, size_t n); } #endif +#include + #endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STRING_H_ */ diff --git a/lib/libc/minimal/include/sys/_types.h b/lib/libc/minimal/include/sys/_types.h index a5ed9aff8477b..4a4673f970040 100644 --- a/lib/libc/minimal/include/sys/_types.h +++ b/lib/libc/minimal/include/sys/_types.h @@ -12,6 +12,7 @@ #include +typedef long _CLOCK_T_; typedef int64_t _TIME_T_; typedef int32_t _SUSECONDS_T_; diff --git a/lib/libc/minimal/include/time.h b/lib/libc/minimal/include/time.h index 55c8a0fb6320c..98814672a4c58 100644 --- a/lib/libc/minimal/include/time.h +++ b/lib/libc/minimal/include/time.h @@ -43,6 +43,11 @@ typedef _TIME_T_ time_t; typedef _SUSECONDS_T_ suseconds_t; #endif +#if !defined(__clock_t_defined) +#define __clock_t_defined +typedef _CLOCK_T_ clock_t; +#endif + /* * Conversion between civil time and UNIX time. The companion * mktime() is not provided here since it diff --git a/lib/libc/newlib/CMakeLists.txt b/lib/libc/newlib/CMakeLists.txt index d3dc448eccafc..f25f97f752e49 100644 --- a/lib/libc/newlib/CMakeLists.txt +++ b/lib/libc/newlib/CMakeLists.txt @@ -49,3 +49,11 @@ if(CONFIG_NEWLIB_LIBC_NANO) -specs=nano.specs ) endif() + +if(CONFIG_POSIX_DEVICE_IO) + zephyr_compile_definitions(-D_READ_WRITE_RETURN_TYPE=ssize_t) +endif() + +if(CONFIG_POSIX_THREADS) + zephyr_compile_definitions(_UNIX98_THREAD_MUTEX_ATTRIBUTES) +endif() diff --git a/lib/libc/newlib/include/aio.h b/lib/libc/newlib/include/aio.h new file mode 100644 index 0000000000000..f261c2c87e0bd --- /dev/null +++ b/lib/libc/newlib/include/aio.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_AIO_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_AIO_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_AIO_H_ */ diff --git a/lib/libc/newlib/include/arpa/inet.h b/lib/libc/newlib/include/arpa/inet.h new file mode 100644 index 0000000000000..cff1406728ca4 --- /dev/null +++ b/lib/libc/newlib/include/arpa/inet.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_ARPA_INET_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_ARPA_INET_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_ARPA_INET_H_ */ diff --git a/lib/libc/newlib/include/dirent.h b/lib/libc/newlib/include/dirent.h new file mode 100644 index 0000000000000..cd2f2ea8d0411 --- /dev/null +++ b/lib/libc/newlib/include/dirent.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_DIRENT_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_DIRENT_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_DIRENT_H_ */ diff --git a/lib/libc/newlib/include/fnmatch.h b/lib/libc/newlib/include/fnmatch.h new file mode 100644 index 0000000000000..15f9ce76984e3 --- /dev/null +++ b/lib/libc/newlib/include/fnmatch.h @@ -0,0 +1,17 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_FNMATCH_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_FNMATCH_H_ + +#include_next + +/* Note: this is a GNU Extension */ +#ifndef FNM_LEADING_DIR +#define FNM_LEADING_DIR 0x08 +#endif + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_FNMATCH_H_ */ diff --git a/lib/libc/newlib/include/mqueue.h b/lib/libc/newlib/include/mqueue.h new file mode 100644 index 0000000000000..6e6fc6ce64b99 --- /dev/null +++ b/lib/libc/newlib/include/mqueue.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_MQUEUE_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_MQUEUE_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_MQUEUE_H_ */ diff --git a/lib/libc/newlib/include/net/if.h b/lib/libc/newlib/include/net/if.h new file mode 100644 index 0000000000000..0cfd8e19dd742 --- /dev/null +++ b/lib/libc/newlib/include/net/if.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NET_IF_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NET_IF_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NET_IF_H_ */ diff --git a/lib/libc/newlib/include/net/if_arp.h b/lib/libc/newlib/include/net/if_arp.h new file mode 100644 index 0000000000000..4705821cd9c2b --- /dev/null +++ b/lib/libc/newlib/include/net/if_arp.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_IF_ARP_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_IF_ARP_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_IF_ARP_H_ */ diff --git a/lib/libc/newlib/include/netdb.h b/lib/libc/newlib/include/netdb.h new file mode 100644 index 0000000000000..931366f20e9bd --- /dev/null +++ b/lib/libc/newlib/include/netdb.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NETDB_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NETDB_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NETDB_H_ */ diff --git a/lib/libc/newlib/include/netinet/in.h b/lib/libc/newlib/include/netinet/in.h new file mode 100644 index 0000000000000..b62909b07cf22 --- /dev/null +++ b/lib/libc/newlib/include/netinet/in.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NETINET_IN_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NETINET_IN_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NETINET_IN_H_ */ diff --git a/lib/libc/newlib/include/netinet/tcp.h b/lib/libc/newlib/include/netinet/tcp.h new file mode 100644 index 0000000000000..8f28f9d142c71 --- /dev/null +++ b/lib/libc/newlib/include/netinet/tcp.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NETINET_TCP_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NETINET_TCP_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_NETINET_TCP_H_ */ diff --git a/lib/libc/newlib/include/poll.h b/lib/libc/newlib/include/poll.h new file mode 100644 index 0000000000000..0ea95ede61892 --- /dev/null +++ b/lib/libc/newlib/include/poll.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_POLL_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_POLL_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_POLL_H_ */ diff --git a/lib/libc/newlib/include/pthread.h b/lib/libc/newlib/include/pthread.h new file mode 100644 index 0000000000000..448836f0ccf21 --- /dev/null +++ b/lib/libc/newlib/include/pthread.h @@ -0,0 +1,44 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_PTHREAD_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_PTHREAD_H_ + +#if defined(_POSIX_THREADS) +#undef __dead2 +#define __dead2 + +#include_next + +#define _PTHREAD_ATTR_T_DECLARED + +#undef PTHREAD_ONCE_INIT +#define PTHREAD_ONCE_INIT \ + { \ + 0 \ + } + +/* The minimum allowable stack size */ +#define PTHREAD_STACK_MIN K_KERNEL_STACK_LEN(0) + +void __z_pthread_cleanup_push(void *cleanup[3], void (*routine)(void *arg), void *arg); +void __z_pthread_cleanup_pop(int execute); + +#undef pthread_cleanup_push +#define pthread_cleanup_push(_rtn, _arg) \ + do /* enforce '{'-like behaviour */ { \ + void *_z_pthread_cleanup[3]; \ + __z_pthread_cleanup_push(_z_pthread_cleanup, _rtn, _arg) + +#undef pthread_cleanup_pop +#define pthread_cleanup_pop(_ex) \ + __z_pthread_cleanup_pop(_ex); \ + } /* enforce '}'-like behaviour */ \ + while (0) + +#endif + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_PTHREAD_H_ */ diff --git a/lib/libc/newlib/include/semaphore.h b/lib/libc/newlib/include/semaphore.h new file mode 100644 index 0000000000000..08c7d81e50c2f --- /dev/null +++ b/lib/libc/newlib/include/semaphore.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SEMAPHORE_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SEMAPHORE_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SEMAPHORE_H_ */ diff --git a/lib/libc/newlib/include/stropts.h b/lib/libc/newlib/include/stropts.h new file mode 100644 index 0000000000000..e634a7da64317 --- /dev/null +++ b/lib/libc/newlib/include/stropts.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_STROPTS_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_STROPTS_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_STROPTS_H_ */ diff --git a/lib/libc/newlib/include/sys/_types.h b/lib/libc/newlib/include/sys/_types.h new file mode 100644 index 0000000000000..83dad7edd4829 --- /dev/null +++ b/lib/libc/newlib/include/sys/_types.h @@ -0,0 +1,14 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS__TYPES_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS__TYPES_H_ + +#include_next + +typedef _ssize_t ssize_t; + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS__TYPES_H_ */ diff --git a/lib/libc/newlib/include/sys/eventfd.h b/lib/libc/newlib/include/sys/eventfd.h new file mode 100644 index 0000000000000..6b1f9fd1680c7 --- /dev/null +++ b/lib/libc/newlib/include/sys/eventfd.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_EVENTFD_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_EVENTFD_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_EVENTFD_H_ */ diff --git a/lib/libc/newlib/include/sys/ioctl.h b/lib/libc/newlib/include/sys/ioctl.h new file mode 100644 index 0000000000000..27b11b3175f8f --- /dev/null +++ b/lib/libc/newlib/include/sys/ioctl.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_IOCTL_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_IOCTL_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_IOCTL_H_ */ diff --git a/lib/libc/newlib/include/sys/mman.h b/lib/libc/newlib/include/sys/mman.h new file mode 100644 index 0000000000000..b7c10d5bb6ae4 --- /dev/null +++ b/lib/libc/newlib/include/sys/mman.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_MMAN_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_MMAN_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_MMAN_H_ */ diff --git a/lib/libc/newlib/include/sys/socket.h b/lib/libc/newlib/include/sys/socket.h new file mode 100644 index 0000000000000..5c9710b49127a --- /dev/null +++ b/lib/libc/newlib/include/sys/socket.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_SOCKET_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_SOCKET_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_SOCKET_H_ */ diff --git a/lib/libc/newlib/include/sys/stat.h b/lib/libc/newlib/include/sys/stat.h new file mode 100644 index 0000000000000..fb50609f72000 --- /dev/null +++ b/lib/libc/newlib/include/sys/stat.h @@ -0,0 +1,23 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_STAT_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_STAT_H_ + +#include_next + +#if defined(_XOPEN_SOURCE) + +#include + +#define S_IFSHM ZVFS_MODE_IFSHM + +#define S_TYPEISMQ(buf) (0) +#define S_TYPEISSEM(buf) (0) +#define S_TYPEISSHM(st) (((st)->st_mode & S_IFMT) == S_IFSHM) +#endif + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_STAT_H_ */ diff --git a/lib/libc/newlib/include/sys/utsname.h b/lib/libc/newlib/include/sys/utsname.h new file mode 100644 index 0000000000000..fad08d9ee9960 --- /dev/null +++ b/lib/libc/newlib/include/sys/utsname.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_UTSNAME_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_UTSNAME_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYS_UTSNAME_H_ */ diff --git a/lib/libc/newlib/include/syslog.h b/lib/libc/newlib/include/syslog.h new file mode 100644 index 0000000000000..e9c6b1bf2cb7e --- /dev/null +++ b/lib/libc/newlib/include/syslog.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYSLOG_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYSLOG_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_SYSLOG_H_ */ diff --git a/lib/libc/newlib/include/time.h b/lib/libc/newlib/include/time.h new file mode 100644 index 0000000000000..a92d4651c50aa --- /dev/null +++ b/lib/libc/newlib/include/time.h @@ -0,0 +1,15 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_TIME_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_TIME_H_ + +#include_next + +#define _TIMESPEC_DECLARED +#define _TIMEVAL_DECLARED + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_TIME_H_ */ diff --git a/lib/libc/newlib/include/unistd.h b/lib/libc/newlib/include/unistd.h new file mode 100644 index 0000000000000..d2b1dda20bb53 --- /dev/null +++ b/lib/libc/newlib/include/unistd.h @@ -0,0 +1,29 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_UNISTD_H_ +#define ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_UNISTD_H_ + +#include_next + +#ifdef __cplusplus +extern "C" { +#endif + +int getentropy(void *buffer, size_t length); + +#if _POSIX_C_SOURCE >= 2 +#include +#endif + +/* Note: usleep() was declared obsolescent as of POSIX.1-2001 and removed from POSIX.1-2008 */ +int usleep(__useconds_t __useconds); + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_LIB_LIBC_NEWLIB_INCLUDE_UNISTD_H_ */ diff --git a/lib/libc/picolibc/CMakeLists.txt b/lib/libc/picolibc/CMakeLists.txt index 280a16a89454e..3aae6979dc5a5 100644 --- a/lib/libc/picolibc/CMakeLists.txt +++ b/lib/libc/picolibc/CMakeLists.txt @@ -18,6 +18,10 @@ zephyr_library_compile_options($) # used by the network stack zephyr_compile_definitions(__LINUX_ERRNO_EXTENSIONS__) +if(CONFIG_POSIX_THREADS) + zephyr_compile_definitions(_UNIX98_THREAD_MUTEX_ATTRIBUTES) +endif() + if(NOT CONFIG_PICOLIBC_USE_MODULE) # Use picolibc provided with the toolchain. This requires a new enough diff --git a/lib/libc/picolibc/include/aio.h b/lib/libc/picolibc/include/aio.h new file mode 100644 index 0000000000000..bf198234118ff --- /dev/null +++ b/lib/libc/picolibc/include/aio.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_AIO_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_AIO_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_AIO_H_ */ diff --git a/lib/libc/picolibc/include/arpa/inet.h b/lib/libc/picolibc/include/arpa/inet.h new file mode 100644 index 0000000000000..cbd9e7c57c7ec --- /dev/null +++ b/lib/libc/picolibc/include/arpa/inet.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_ARPA_INET_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_ARPA_INET_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_ARPA_INET_H_ */ diff --git a/lib/libc/picolibc/include/dirent.h b/lib/libc/picolibc/include/dirent.h new file mode 100644 index 0000000000000..34b564b45ffa8 --- /dev/null +++ b/lib/libc/picolibc/include/dirent.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_DIRENT_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_DIRENT_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_DIRENT_H_ */ diff --git a/lib/libc/picolibc/include/fnmatch.h b/lib/libc/picolibc/include/fnmatch.h new file mode 100644 index 0000000000000..194140b8800e6 --- /dev/null +++ b/lib/libc/picolibc/include/fnmatch.h @@ -0,0 +1,17 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_FNMATCH_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_FNMATCH_H_ + +#include_next + +/* Note: this is a GNU Extension */ +#ifndef FNM_LEADING_DIR +#define FNM_LEADING_DIR 0x08 +#endif + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_FNMATCH_H_ */ diff --git a/lib/libc/picolibc/include/limits.h b/lib/libc/picolibc/include/limits.h new file mode 100644 index 0000000000000..ee95ebed0aa69 --- /dev/null +++ b/lib/libc/picolibc/include/limits.h @@ -0,0 +1,16 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_LIMITS_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_LIMITS_H_ + +#include_next + +#if defined(_POSIX_C_SOURCE) +#define GETENTROPY_MAX 256 +#endif + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_LIMITS_H_ */ diff --git a/lib/libc/picolibc/include/mqueue.h b/lib/libc/picolibc/include/mqueue.h new file mode 100644 index 0000000000000..117e2c394a8eb --- /dev/null +++ b/lib/libc/picolibc/include/mqueue.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_MQUEUE_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_MQUEUE_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_MQUEUE_H_ */ diff --git a/lib/libc/picolibc/include/net/if.h b/lib/libc/picolibc/include/net/if.h new file mode 100644 index 0000000000000..53dcdd8d31884 --- /dev/null +++ b/lib/libc/picolibc/include/net/if.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NET_IF_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NET_IF_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NET_IF_H_ */ diff --git a/lib/libc/picolibc/include/net/if_arp.h b/lib/libc/picolibc/include/net/if_arp.h new file mode 100644 index 0000000000000..b0179ad16d309 --- /dev/null +++ b/lib/libc/picolibc/include/net/if_arp.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_IF_ARP_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_IF_ARP_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_IF_ARP_H_ */ diff --git a/lib/libc/picolibc/include/netdb.h b/lib/libc/picolibc/include/netdb.h new file mode 100644 index 0000000000000..726384afd513f --- /dev/null +++ b/lib/libc/picolibc/include/netdb.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NETDB_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NETDB_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NETDB_H_ */ diff --git a/lib/libc/picolibc/include/netinet/in.h b/lib/libc/picolibc/include/netinet/in.h new file mode 100644 index 0000000000000..2f2eada72e933 --- /dev/null +++ b/lib/libc/picolibc/include/netinet/in.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NETINET_IN_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NETINET_IN_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NETINET_IN_H_ */ diff --git a/lib/libc/picolibc/include/netinet/tcp.h b/lib/libc/picolibc/include/netinet/tcp.h new file mode 100644 index 0000000000000..9ba9a55d5e08c --- /dev/null +++ b/lib/libc/picolibc/include/netinet/tcp.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NETINET_TCP_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NETINET_TCP_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_NETINET_TCP_H_ */ diff --git a/lib/libc/picolibc/include/poll.h b/lib/libc/picolibc/include/poll.h new file mode 100644 index 0000000000000..a59c0eb60e61b --- /dev/null +++ b/lib/libc/picolibc/include/poll.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_POLL_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_POLL_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_POLL_H_ */ diff --git a/lib/libc/picolibc/include/pthread.h b/lib/libc/picolibc/include/pthread.h new file mode 100644 index 0000000000000..fc5c6fd545a03 --- /dev/null +++ b/lib/libc/picolibc/include/pthread.h @@ -0,0 +1,52 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_PTHREAD_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_PTHREAD_H_ + +#if defined(_POSIX_THREADS) +#undef __dead2 +#define __dead2 + +/* workaround until https://github.com/picolibc/picolibc/pull/1096 is fixed */ +#include /* for clock_t */ +#if defined(CONFIG_PICOLIBC_USE_MODULE) +/* not available in module */ +#include +/* not available in module */ +#include +#else +#include +#include_next +#endif + +#undef PTHREAD_ONCE_INIT +#define PTHREAD_ONCE_INIT \ + { \ + 0 \ + } + +/* The minimum allowable stack size */ +#define PTHREAD_STACK_MIN K_KERNEL_STACK_LEN(0) + +void __z_pthread_cleanup_push(void *cleanup[3], void (*routine)(void *arg), void *arg); +void __z_pthread_cleanup_pop(int execute); + +#undef pthread_cleanup_push +#define pthread_cleanup_push(_rtn, _arg) \ + do /* enforce '{'-like behaviour */ { \ + void *_z_pthread_cleanup[3]; \ + __z_pthread_cleanup_push(_z_pthread_cleanup, _rtn, _arg) + +#undef pthread_cleanup_pop +#define pthread_cleanup_pop(_ex) \ + __z_pthread_cleanup_pop(_ex); \ + } /* enforce '}'-like behaviour */ \ + while (0) + +#endif + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_PTHREAD_H_ */ diff --git a/lib/libc/picolibc/include/semaphore.h b/lib/libc/picolibc/include/semaphore.h new file mode 100644 index 0000000000000..76a192143b528 --- /dev/null +++ b/lib/libc/picolibc/include/semaphore.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SEMAPHORE_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SEMAPHORE_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SEMAPHORE_H_ */ diff --git a/lib/libc/picolibc/include/stropts.h b/lib/libc/picolibc/include/stropts.h new file mode 100644 index 0000000000000..88d43b8efe387 --- /dev/null +++ b/lib/libc/picolibc/include/stropts.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_STROPTS_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_STROPTS_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_STROPTS_H_ */ diff --git a/lib/libc/picolibc/include/sys/eventfd.h b/lib/libc/picolibc/include/sys/eventfd.h new file mode 100644 index 0000000000000..db2c6d80e4e4e --- /dev/null +++ b/lib/libc/picolibc/include/sys/eventfd.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_EVENTFD_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_EVENTFD_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_EVENTFD_H_ */ diff --git a/lib/libc/picolibc/include/sys/ioctl.h b/lib/libc/picolibc/include/sys/ioctl.h new file mode 100644 index 0000000000000..d2f2b408d4f3d --- /dev/null +++ b/lib/libc/picolibc/include/sys/ioctl.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_IOCTL_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_IOCTL_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_IOCTL_H_ */ diff --git a/lib/libc/picolibc/include/sys/mman.h b/lib/libc/picolibc/include/sys/mman.h new file mode 100644 index 0000000000000..1c9414acdb74c --- /dev/null +++ b/lib/libc/picolibc/include/sys/mman.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_MMAN_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_MMAN_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_MMAN_H_ */ diff --git a/lib/libc/picolibc/include/sys/socket.h b/lib/libc/picolibc/include/sys/socket.h new file mode 100644 index 0000000000000..791262af51d8e --- /dev/null +++ b/lib/libc/picolibc/include/sys/socket.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_SOCKET_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_SOCKET_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_SOCKET_H_ */ diff --git a/lib/libc/picolibc/include/sys/stat.h b/lib/libc/picolibc/include/sys/stat.h new file mode 100644 index 0000000000000..edd0dd144d2c7 --- /dev/null +++ b/lib/libc/picolibc/include/sys/stat.h @@ -0,0 +1,23 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_STAT_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_STAT_H_ + +#include_next + +#if defined(_XOPEN_SOURCE) + +#include + +#define S_IFSHM ZVFS_MODE_IFSHM + +#define S_TYPEISMQ(buf) (0) +#define S_TYPEISSEM(buf) (0) +#define S_TYPEISSHM(st) (((st)->st_mode & S_IFMT) == S_IFSHM) +#endif + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_STAT_H_ */ diff --git a/lib/libc/picolibc/include/sys/utsname.h b/lib/libc/picolibc/include/sys/utsname.h new file mode 100644 index 0000000000000..4ebda772bd177 --- /dev/null +++ b/lib/libc/picolibc/include/sys/utsname.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_UTSNAME_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_UTSNAME_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYS_UTSNAME_H_ */ diff --git a/lib/libc/picolibc/include/syslog.h b/lib/libc/picolibc/include/syslog.h new file mode 100644 index 0000000000000..451257002b4b3 --- /dev/null +++ b/lib/libc/picolibc/include/syslog.h @@ -0,0 +1,12 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYSLOG_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYSLOG_H_ + +#include + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_SYSLOG_H_ */ diff --git a/lib/libc/picolibc/include/time.h b/lib/libc/picolibc/include/time.h index b6ff65137e69d..bc9d5ff87eb9d 100644 --- a/lib/libc/picolibc/include/time.h +++ b/lib/libc/picolibc/include/time.h @@ -29,4 +29,7 @@ typedef __pid_t pid_t; #include_next +#define _TIMESPEC_DECLARED +#define _TIMEVAL_DECLARED + #endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_TIME_H_ */ diff --git a/lib/libc/picolibc/include/unistd.h b/lib/libc/picolibc/include/unistd.h new file mode 100644 index 0000000000000..4b3549efd3bdf --- /dev/null +++ b/lib/libc/picolibc/include/unistd.h @@ -0,0 +1,29 @@ +/* + * Copyright The Zephyr Project Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_UNISTD_H_ +#define ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_UNISTD_H_ + +#include_next + +#ifdef __cplusplus +extern "C" { +#endif + +int getentropy(void *buffer, size_t length); + +#if _POSIX_C_SOURCE >= 2 +#include +#endif + +/* Note: usleep() was declared obsolescent as of POSIX.1-2001 and removed from POSIX.1-2008 */ +int usleep(__useconds_t __useconds); + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_LIB_LIBC_PICOLIBC_INCLUDE_UNISTD_H_ */ diff --git a/lib/posix/Kconfig.profile b/lib/posix/Kconfig.profile index 39d4ea2a6ee8e..c4ae7468cd920 100644 --- a/lib/posix/Kconfig.profile +++ b/lib/posix/Kconfig.profile @@ -150,6 +150,7 @@ config POSIX_AEP_REALTIME_MINIMAL select POSIX_DEVICE_IO select POSIX_SIGNALS select POSIX_SINGLE_PROCESS + select XSI select XSI_THREADS_EXT # Options select POSIX_FSYNC @@ -210,4 +211,4 @@ config POSIX_AEP_REALTIME_DEDICATED For more information, please see https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html -endif # POSIX_SYSTEM_INTERFACE +endif # POSIX_SYSTEM_INTERFACES diff --git a/lib/posix/Kconfig.toolchain b/lib/posix/Kconfig.toolchain index 4ee30a8246540..e22d357b2a50e 100644 --- a/lib/posix/Kconfig.toolchain +++ b/lib/posix/Kconfig.toolchain @@ -219,6 +219,9 @@ config TC_PROVIDES_XSI_SIGNALS config TC_PROVIDES_XSI_SINGLE_PROCESS bool +config TC_PROVIDES_XSI_STREAMS + bool + config TC_PROVIDES_XSI_SYSTEM_DATABASE bool diff --git a/lib/posix/c_lib_ext/fnmatch.c b/lib/posix/c_lib_ext/fnmatch.c index 878fe3dd8661e..3773178728206 100644 --- a/lib/posix/c_lib_ext/fnmatch.c +++ b/lib/posix/c_lib_ext/fnmatch.c @@ -48,6 +48,18 @@ #define EOS '\0' +#ifndef FNM_NORES +#define FNM_NORES 3 +#endif + +#ifndef FNM_LEADING_DIR +#define FNM_LEADING_DIR 0x08 +#endif + +#ifndef FNM_CASEFOLD +#define FNM_CASEFOLD 0x10 +#endif + static inline int foldcase(int ch, int flags) { diff --git a/lib/posix/options/CMakeLists.txt b/lib/posix/options/CMakeLists.txt index d2469a3a0eae8..9b1fa8cfe00c5 100644 --- a/lib/posix/options/CMakeLists.txt +++ b/lib/posix/options/CMakeLists.txt @@ -1,9 +1,20 @@ # SPDX-License-Identifier: Apache-2.0 set(POSIX_VERSION 200809L) +set(XOPEN_VERSION 700) set(GEN_DIR ${ZEPHYR_BINARY_DIR}/include/generated) -zephyr_compile_definitions(-D_POSIX_C_SOURCE=${POSIX_VERSION}) +if(CONFIG_POSIX_SYSTEM_INTERFACES) + zephyr_compile_definitions(-D_POSIX_VERSION=${POSIX_VERSION}) + zephyr_compile_definitions(-D_POSIX_C_SOURCE=${POSIX_VERSION}) + zephyr_compile_definitions(-D_POSIX2_C_BIND=${POSIX_VERSION}) +endif() +if (CONFIG_XSI) + zephyr_compile_definitions(-D_XOPEN_VERSION=${XOPEN_VERSION}) + zephyr_compile_definitions(-D_XOPEN_SOURCE=${XOPEN_VERSION}) + zephyr_compile_definitions(-D_XOPEN_UNIX=${XOPEN_VERSION}) +endif() + zephyr_syscall_header_ifdef(CONFIG_POSIX_CLOCK_SELECTION posix_clock.h) zephyr_syscall_header_ifdef(CONFIG_POSIX_TIMERS posix_clock.h) @@ -30,10 +41,16 @@ zephyr_library() if (NOT CONFIG_TC_PROVIDES_POSIX_ASYNCHRONOUS_IO) zephyr_library_sources_ifdef(CONFIG_POSIX_ASYNCHRONOUS_IO aio.c) endif() +if (CONFIG_POSIX_ASYNCHRONOUS_IO) + zephyr_compile_definitions(-D_POSIX_ASYNCHRONOUS_IO=${POSIX_VERSION}) +endif() if (NOT CONFIG_TC_PROVIDES_POSIX_BARRIERS) zephyr_library_sources_ifdef(CONFIG_POSIX_BARRIERS barrier.c) endif() +if (CONFIG_POSIX_BARRIERS) + zephyr_compile_definitions(-D_POSIX_BARRIERS=${POSIX_VERSION}) +endif() if (NOT CONFIG_TC_PROVIDES_POSIX_CLOCK_SELECTION) zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK_SELECTION clock_selection.c) @@ -70,10 +87,16 @@ endif() if (NOT CONFIG_TC_PROVIDES_POSIX_MEMORY_PROTECTION) zephyr_library_sources_ifdef(CONFIG_POSIX_MEMORY_PROTECTION mprotect.c) endif() +if (CONFIG_POSIX_MEMORY_PROTECTION) + zephyr_compile_definitions(-D_POSIX_MEMORY_PROTECTION=${POSIX_VERSION}) +endif() if (NOT CONFIG_TC_PROVIDES_POSIX_MAPPED_FILES) zephyr_library_sources_ifdef(CONFIG_POSIX_MAPPED_FILES mmap.c) endif() +if(CONFIG_POSIX_MAPPED_FILES) + zephyr_compile_definitions(-D_POSIX_MAPPED_FILES=${POSIX_VERSION}) +endif() if (NOT CONFIG_TC_PROVIDES_POSIX_MULTI_PROCESS) zephyr_library_sources_ifdef(CONFIG_POSIX_MULTI_PROCESS @@ -88,6 +111,12 @@ endif() if (NOT CONFIG_TC_PROVIDES_POSIX_NETWORKING) zephyr_library_sources_ifdef(CONFIG_POSIX_NETWORKING net.c) endif() +if(CONFIG_POSIX_IPV6) + zephyr_compile_definitions(-D_POSIX_IPV6=${POSIX_VERSION}) +endif() +if (CONFIG_POSIX_RAW_SOCKETS) + zephyr_compile_definitions(-D_POSIX_RAW_SOCKETS=${POSIX_VERSION}) +endif() if (CONFIG_POSIX_REALTIME_SIGNALS) zephyr_compile_definitions(-D_POSIX_REALTIME_SIGNALS=${POSIX_VERSION}) @@ -96,6 +125,14 @@ endif() if (NOT CONFIG_TC_PROVIDES_POSIX_SIGNALS) zephyr_library_sources_ifdef(CONFIG_POSIX_SIGNALS signal.c ${STRSIGNAL_TABLE_H}) endif() +if (CONFIG_POSIX_SIGNALS) + zephyr_compile_definitions(-D_POSIX_SIGNALS=${POSIX_VERSION}) + # FIXME: Until we have a Kconfig for POSIX_REALTIME_SIGNALS, define _POSIX_REALTIME_SIGNALS + # with _POSIX_SIGNALS. + # For more information on the Advanced Realtime Option Group, please see + # https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html + zephyr_compile_definitions(-D_POSIX_REALTIME_SIGNALS=${POSIX_VERSION}) +endif() if (NOT CONFIG_TC_PROVIDES_POSIX_SINGLE_PROCESS) zephyr_library_sources_ifdef(CONFIG_POSIX_SINGLE_PROCESS @@ -110,6 +147,9 @@ endif() if (NOT CONFIG_TC_PROVIDES_POSIX_SPIN_LOCKS) zephyr_library_sources_ifdef(CONFIG_POSIX_SPIN_LOCKS spinlock.c) endif() +if (CONFIG_POSIX_SPIN_LOCKS) + zephyr_compile_definitions(-D_POSIX_SPIN_LOCKS=${POSIX_VERSION}) +endif() if (NOT CONFIG_TC_PROVIDES_POSIX_TIMERS) zephyr_library_sources_ifdef(CONFIG_POSIX_TIMERS @@ -120,6 +160,7 @@ if (NOT CONFIG_TC_PROVIDES_POSIX_TIMERS) endif() if (CONFIG_POSIX_TIMERS) zephyr_compile_definitions(-D_POSIX_TIMERS=${POSIX_VERSION}) + zephyr_compile_definitions(-D_POSIX_TIMEOUTS=${POSIX_VERSION}) # FIXME: Until we have a Kconfig for XSI_ADVANCED_REALTIME, define _POSIX_CPUTIME and # _POSIX_MONOTONIC_CLOCK with _POSIX_TIMERS. # For more information on the Advanced Realtime Option Group, please see @@ -131,10 +172,16 @@ endif() if (NOT CONFIG_TC_PROVIDES_POSIX_RW_LOCKS) zephyr_library_sources_ifdef(CONFIG_POSIX_RW_LOCKS rwlock.c) endif() +if (CONFIG_POSIX_RW_LOCKS) + zephyr_compile_definitions(-D_POSIX_READER_WRITER_LOCKS=${POSIX_VERSION}) +endif() if (NOT CONFIG_TC_PROVIDES_POSIX_SEMAPHORES) zephyr_library_sources_ifdef(CONFIG_POSIX_SEMAPHORES semaphore.c) endif() +if (CONFIG_POSIX_SEMAPHORES) + zephyr_compile_definitions(-D_POSIX_SEMAPHORES=${POSIX_VERSION}) +endif() if (NOT CONFIG_TC_PROVIDES_POSIX_THREADS) # Note: the Option is _POSIX_THREADS, while the Option Group is POSIX_THREADS_BASE. @@ -150,6 +197,24 @@ if (NOT CONFIG_TC_PROVIDES_POSIX_THREADS) endif() if (CONFIG_POSIX_THREADS) zephyr_compile_definitions(-D_POSIX_THREADS=${POSIX_VERSION}) + zephyr_compile_definitions(-D_POSIX_THREAD_PROCESS_SHARED=${POSIX_VERSION}) + zephyr_compile_definitions(-D_POSIX_PRIORITY_SCHEDULING=${POSIX_VERSION}) + zephyr_compile_definitions(-D_POSIX_THREAD_PRIORITY_SCHEDULING=${POSIX_VERSION}) +endif() +if(CONFIG_POSIX_THREAD_ATTR_STACKADDR) + zephyr_compile_definitions(-D_POSIX_THREAD_ATTR_STACKADDR=${POSIX_VERSION}) +endif() +if(CONFIG_POSIX_THREAD_ATTR_STACKSIZE) + zephyr_compile_definitions(-D_POSIX_THREAD_ATTR_STACKSIZE=${POSIX_VERSION}) +endif() +if(CONFIG_POSIX_THREAD_CPUTIME) + zephyr_compile_definitions(-D_POSIX_THREAD_CPUTIME=${POSIX_VERSION}) +endif() +if(CONFIG_POSIX_THREAD_PRIO_INHERIT) + zephyr_compile_definitions(-D_POSIX_THREAD_PRIO_INHERIT=${POSIX_VERSION}) +endif() +if(CONFIG_POSIX_THREAD_PRIO_PROTECT) + zephyr_compile_definitions(-D_POSIX_THREAD_PRIO_PROTECT=${POSIX_VERSION}) endif() if(NOT CONFIG_TC_PROVIDES_XSI_REALTIME) diff --git a/lib/posix/options/Kconfig b/lib/posix/options/Kconfig index 3f072a293f6be..908f9ac189904 100644 --- a/lib/posix/options/Kconfig +++ b/lib/posix/options/Kconfig @@ -27,13 +27,6 @@ rsource "Kconfig.timer" # zephyr-keep-sorted-stop menu "X/Open system interfaces" - -# zephyr-keep-sorted-start -rsource "Kconfig.xsi_realtime" -rsource "Kconfig.xsi_single_process" -rsource "Kconfig.xsi_streams" -rsource "Kconfig.xsi_system_logging" -rsource "Kconfig.xsi_threads_ext" -# zephyr-keep-sorted-stop +rsource "Kconfig.xsi" endmenu # "X/Open system interfaces" diff --git a/lib/posix/options/Kconfig.device_io b/lib/posix/options/Kconfig.device_io index 416ccf74a6218..affe770afda7f 100644 --- a/lib/posix/options/Kconfig.device_io +++ b/lib/posix/options/Kconfig.device_io @@ -6,7 +6,6 @@ menu "POSIX device I/O" config POSIX_DEVICE_IO bool "POSIX device I/O" - select REQUIRES_FULL_LIBC select ZVFS select ZVFS_POLL select ZVFS_SELECT diff --git a/lib/posix/options/Kconfig.net b/lib/posix/options/Kconfig.net index f63aaaf141152..88aecc0459233 100644 --- a/lib/posix/options/Kconfig.net +++ b/lib/posix/options/Kconfig.net @@ -30,7 +30,7 @@ config POSIX_HOST_NAME_MAX config POSIX_IPV6 bool "POSIX IPv6 support" - select NET_IPV6 + default y if NET_CONFIG_NEED_IPV6 help Enable this option to support the POSIX IPv6 API. diff --git a/lib/posix/options/Kconfig.proc1 b/lib/posix/options/Kconfig.proc1 index 30f9c8fe601d6..721db930e87d3 100644 --- a/lib/posix/options/Kconfig.proc1 +++ b/lib/posix/options/Kconfig.proc1 @@ -18,7 +18,8 @@ if POSIX_SINGLE_PROCESS choice POSIX_SYSCONF_IMPL_CHOICE default POSIX_SYSCONF_IMPL_FULL if CPP - default POSIX_SYSCONF_IMPL_MACRO + default POSIX_SYSCONF_IMPL_MACRO if MINIMAL_LIBC + default POSIX_SYSCONF_IMPL_FULL prompt "Sysconf implementation method" config POSIX_SYSCONF_IMPL_MACRO diff --git a/lib/posix/options/Kconfig.xsi b/lib/posix/options/Kconfig.xsi new file mode 100644 index 0000000000000..72105b5565a25 --- /dev/null +++ b/lib/posix/options/Kconfig.xsi @@ -0,0 +1,24 @@ +# Copyright (c) 2025 Tenstorrent AI ULC +# +# SPDX-License-Identifier: Apache-2.0 + +menuconfig XSI + bool "X/Open System Interfaces (XSI)" + select POSIX_FSYNC + select POSIX_THREAD_ATTR_STACKADDR + select POSIX_THREAD_ATTR_STACKSIZE + help + For more information, please see + https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_04_01 + +if XSI + +# zephyr-keep-sorted-start +rsource "Kconfig.xsi_realtime" +rsource "Kconfig.xsi_single_process" +rsource "Kconfig.xsi_streams" +rsource "Kconfig.xsi_system_logging" +rsource "Kconfig.xsi_threads_ext" +# zephyr-keep-sorted-stop + +endif # XSI diff --git a/lib/posix/options/aio.c b/lib/posix/options/aio.c index 8e51d44207aa5..f0a9e55ab1591 100644 --- a/lib/posix/options/aio.c +++ b/lib/posix/options/aio.c @@ -4,10 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include -#include - #include +#include int aio_cancel(int fildes, struct aiocb *aiocbp) { diff --git a/lib/posix/options/barrier.c b/lib/posix/options/barrier.c index 8cab1b2f9675b..008d677ab276b 100644 --- a/lib/posix/options/barrier.c +++ b/lib/posix/options/barrier.c @@ -19,6 +19,10 @@ struct posix_barrier { uint32_t count; }; +struct posix_barrierattr { + uint32_t pshared; +}; + __pinned_bss static struct posix_barrier posix_barrier_pool[CONFIG_MAX_PTHREAD_BARRIER_COUNT]; @@ -166,29 +170,40 @@ int pthread_barrier_destroy(pthread_barrier_t *b) int pthread_barrierattr_init(pthread_barrierattr_t *attr) { __ASSERT_NO_MSG(attr != NULL); + struct posix_barrierattr *_attr = (struct posix_barrierattr *)attr; - attr->pshared = PTHREAD_PROCESS_PRIVATE; +#if defined(_POSIX_THREAD_PROCESS_SHARED) + _attr->pshared = PTHREAD_PROCESS_PRIVATE; +#endif return 0; } +#if defined(_POSIX_THREAD_PROCESS_SHARED) int pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared) { - if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_PUBLIC) { + __ASSERT_NO_MSG(attr != NULL); + struct posix_barrierattr *_attr = (struct posix_barrierattr *)attr; + + if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED) { return -EINVAL; } - attr->pshared = pshared; + _attr->pshared = pshared; return 0; } int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict attr, int *restrict pshared) { - *pshared = attr->pshared; + __ASSERT_NO_MSG(attr != NULL); + struct posix_barrierattr *_attr = (struct posix_barrierattr *)attr; + + *pshared = _attr->pshared; return 0; } +#endif int pthread_barrierattr_destroy(pthread_barrierattr_t *attr) { diff --git a/lib/posix/options/cond.c b/lib/posix/options/cond.c index 158f33b7ceff0..b508d93e880bf 100644 --- a/lib/posix/options/cond.c +++ b/lib/posix/options/cond.c @@ -14,6 +14,11 @@ #include #include +struct pthread_condattr { + clockid_t clock; +}; +BUILD_ASSERT(sizeof(pthread_condattr_t) >= sizeof(struct pthread_condattr)); + LOG_MODULE_REGISTER(pthread_cond, CONFIG_PTHREAD_COND_LOG_LEVEL); static __pinned_bss struct posix_cond posix_cond_pool[CONFIG_MAX_PTHREAD_COND_COUNT]; diff --git a/lib/posix/options/confstr.c b/lib/posix/options/confstr.c index c6d2b8f3a8318..aec796c19faf7 100644 --- a/lib/posix/options/confstr.c +++ b/lib/posix/options/confstr.c @@ -4,8 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + #include +#ifndef _CS_V6_ENV +#define _CS_V6_ENV 20 +#endif + size_t confstr(int name, char *buf, size_t len) { if (name < 0 || name > _CS_V6_ENV) { diff --git a/lib/posix/options/device_io.c b/lib/posix/options/device_io.c index adf13506651e1..66372ff91f786 100644 --- a/lib/posix/options/device_io.c +++ b/lib/posix/options/device_io.c @@ -21,22 +21,26 @@ int zvfs_open(const char *name, int flags, int mode); ssize_t zvfs_read(int fd, void *buf, size_t sz, size_t *from_offset); ssize_t zvfs_write(int fd, const void *buf, size_t sz, size_t *from_offset); +#undef FD_CLR void FD_CLR(int fd, struct zvfs_fd_set *fdset) { - return ZVFS_FD_CLR(fd, fdset); + ZVFS_FD_CLR(fd, fdset); } +#undef FD_ISSET int FD_ISSET(int fd, struct zvfs_fd_set *fdset) { return ZVFS_FD_ISSET(fd, fdset); } +#undef FD_SET void FD_SET(int fd, struct zvfs_fd_set *fdset) { ZVFS_FD_SET(fd, fdset); } -void FD_ZERO(fd_set *fdset) +#undef FD_ZERO +void FD_ZERO(struct zvfs_fd_set *fdset) { ZVFS_FD_ZERO(fdset); } @@ -94,12 +98,13 @@ ssize_t pread(int fd, void *buf, size_t count, off_t offset) } int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - const struct timespec *timeout, const void *sigmask) + const struct timespec *timeout, const sigset_t *sigmask) { - return zvfs_select(nfds, readfds, writefds, exceptfds, timeout, sigmask); + return zvfs_select(nfds, (struct zvfs_fd_set *)readfds, (struct zvfs_fd_set *)writefds, + (struct zvfs_fd_set *)exceptfds, timeout, sigmask); } -ssize_t pwrite(int fd, void *buf, size_t count, off_t offset) +ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) { size_t off = (size_t)offset; @@ -125,8 +130,8 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struc .tv_sec = (timeout == NULL) ? 0 : timeout->tv_sec, .tv_nsec = (long)((timeout == NULL) ? 0 : timeout->tv_usec * NSEC_PER_USEC)}; - return zvfs_select(nfds, readfds, writefds, exceptfds, (timeout == NULL) ? NULL : &to, - NULL); + return zvfs_select(nfds, (struct zvfs_fd_set *)readfds, (struct zvfs_fd_set *)writefds, + (struct zvfs_fd_set *)exceptfds, &to, NULL); } ssize_t write(int fd, const void *buf, size_t sz) diff --git a/lib/posix/options/fs.c b/lib/posix/options/fs.c index 04a7d688b60d9..0217ef4ddb0c0 100644 --- a/lib/posix/options/fs.c +++ b/lib/posix/options/fs.c @@ -173,7 +173,9 @@ static int fs_ioctl_vmeth(void *obj, unsigned int request, va_list args) current = fs_tell(&ptr->file); if (current >= 0) { buf->st_size = current; +#if defined(_XOPEN_SOURCE) buf->st_mode = ptr->is_dir ? S_IFDIR : S_IFREG; +#endif } rc = fs_seek(&ptr->file, offset, FS_SEEK_SET); @@ -427,22 +429,28 @@ int stat(const char *path, struct stat *buf) switch (stat_file.type) { case FS_DIR_ENTRY_FILE: +#if defined(_XOPEN_SOURCE) buf->st_mode = S_IFREG; +#endif break; case FS_DIR_ENTRY_DIR: +#if defined(_XOPEN_SOURCE) buf->st_mode = S_IFDIR; +#endif break; default: errno = EIO; return -1; } buf->st_size = stat_file.size; +#if defined(_XOPEN_SOURCE) buf->st_blksize = stat_vfs.f_bsize; /* * This is a best effort guess, as this information is not provided * by the fs_stat function. */ buf->st_blocks = (stat_file.size + stat_vfs.f_bsize - 1) / stat_vfs.f_bsize; +#endif return 0; } diff --git a/lib/posix/options/mmap.c b/lib/posix/options/mmap.c index afea68f8113cf..08e56d1c635d6 100644 --- a/lib/posix/options/mmap.c +++ b/lib/posix/options/mmap.c @@ -6,14 +6,14 @@ #include #include +#include #include +#include #include #include #include #include -#include -#include #define _page_size COND_CODE_1(CONFIG_MMU, (CONFIG_MMU_PAGE_SIZE), (CONFIG_POSIX_PAGE_SIZE)) diff --git a/lib/posix/options/mqueue.c b/lib/posix/options/mqueue.c index 489de9ee3b273..2382790f8c2e5 100644 --- a/lib/posix/options/mqueue.c +++ b/lib/posix/options/mqueue.c @@ -7,12 +7,17 @@ #include "posix_clock.h" -#include #include -#include -#include +#include #include #include +#include +#include +#include +#include + +#include +#include #define SIGEV_MASK (SIGEV_NONE | SIGEV_SIGNAL | SIGEV_THREAD) diff --git a/lib/posix/options/multi_process.c b/lib/posix/options/multi_process.c index a88d260304267..81e8652e9c540 100644 --- a/lib/posix/options/multi_process.c +++ b/lib/posix/options/multi_process.c @@ -13,6 +13,7 @@ #include #include #include +#include pid_t getpid(void) { diff --git a/lib/posix/options/mutex.c b/lib/posix/options/mutex.c index b1473ce04a8ed..9b46110ea4815 100644 --- a/lib/posix/options/mutex.c +++ b/lib/posix/options/mutex.c @@ -8,10 +8,12 @@ #include "posix_clock.h" #include "posix_internal.h" +#include +#include + #include #include #include -#include #include #include @@ -21,6 +23,12 @@ static SYS_SEM_DEFINE(lock, 1, 1); #define MUTEX_MAX_REC_LOCK 32767 +struct pthread_mutexattr { + unsigned char type: 2; + bool initialized: 1; +}; +BUILD_ASSERT(sizeof(pthread_mutexattr_t) >= sizeof(struct pthread_mutexattr)); + /* * Default mutex attrs. */ @@ -137,6 +145,7 @@ static int acquire_mutex(pthread_mutex_t *mu, k_timeout_t timeout) if (owner == k_current_get()) { switch (type) { + case PTHREAD_MUTEX_DEFAULT: case PTHREAD_MUTEX_NORMAL: if (K_TIMEOUT_EQ(timeout, K_NO_WAIT)) { LOG_DBG("Timeout locking mutex %p", m); @@ -312,6 +321,7 @@ int pthread_mutex_destroy(pthread_mutex_t *mu) return 0; } +#if defined(_POSIX_THREAD_PRIO_PROTECT) /** * @brief Read protocol attribute for mutex. * @@ -350,6 +360,7 @@ int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol) return EINVAL; } } +#endif int pthread_mutexattr_init(pthread_mutexattr_t *attr) { @@ -413,6 +424,7 @@ int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) case PTHREAD_MUTEX_NORMAL: case PTHREAD_MUTEX_RECURSIVE: case PTHREAD_MUTEX_ERRORCHECK: + case PTHREAD_MUTEX_DEFAULT: a->type = type; return 0; default: @@ -465,6 +477,7 @@ static int pthread_mutex_pool_init(void) for (i = 0; i < CONFIG_MAX_PTHREAD_MUTEX_COUNT; ++i) { err = k_mutex_init(&posix_mutex_pool[i]); __ASSERT_NO_MSG(err == 0); + posix_mutex_type[i] = PTHREAD_MUTEX_DEFAULT; } return 0; diff --git a/lib/posix/options/posix_internal.h b/lib/posix/options/posix_internal.h index aea7c0524db31..3cd8e3f324ddc 100644 --- a/lib/posix/options/posix_internal.h +++ b/lib/posix/options/posix_internal.h @@ -80,6 +80,11 @@ struct posix_condattr { #endif }; +struct pthread_once { + bool flag; +}; +BUILD_ASSERT(sizeof(pthread_once_t) >= sizeof(struct pthread_once)); + struct posix_cond { struct k_condvar condvar; struct posix_condattr attr; diff --git a/lib/posix/options/pthread.c b/lib/posix/options/pthread.c index c488212d119d8..9df377adc5bab 100644 --- a/lib/posix/options/pthread.c +++ b/lib/posix/options/pthread.c @@ -519,17 +519,18 @@ static void posix_thread_finalize(struct posix_thread *t, void *retval) FUNC_NORETURN static void zephyr_thread_wrapper(void *arg1, void *arg2, void *arg3) { - int err; - int barrier; void *(*fun_ptr)(void *arg) = arg2; struct posix_thread *t = CONTAINER_OF(k_current_get(), struct posix_thread, thread); - if (IS_ENABLED(CONFIG_PTHREAD_CREATE_BARRIER)) { - /* cross the barrier so that pthread_create() can continue */ - barrier = POINTER_TO_UINT(arg3); - err = pthread_barrier_wait(&barrier); - __ASSERT_NO_MSG(err == 0 || err == PTHREAD_BARRIER_SERIAL_THREAD); - } +#if defined(CONFIG_PTHREAD_CREATE_BARRIER) + int err; + int barrier; + + /* cross the barrier so that pthread_create() can continue */ + barrier = POINTER_TO_UINT(arg3); + err = pthread_barrier_wait(&barrier); + __ASSERT_NO_MSG(err == 0 || err == PTHREAD_BARRIER_SERIAL_THREAD); +#endif posix_thread_finalize(t, fun_ptr(arg1)); @@ -589,7 +590,7 @@ int pthread_create(pthread_t *th, const pthread_attr_t *_attr, void *(*threadrou void *arg) { int err; - pthread_barrier_t barrier; + void *barrier_ptr = NULL; struct posix_thread *t = NULL; if (!(_attr == NULL || __attr_is_runnable((struct posix_thread_attr *)_attr))) { @@ -611,7 +612,15 @@ int pthread_create(pthread_t *th, const pthread_attr_t *_attr, void *(*threadrou } } - if (t != NULL && IS_ENABLED(CONFIG_PTHREAD_CREATE_BARRIER)) { +#if defined(CONFIG_PTHREAD_CREATE_BARRIER) + struct pthread_barrier barrier; + + /* use a barrier to ensure that the new thread has started + * before pthread_create() returns + */ + barrier_ptr = &barrier; + + if (t != NULL) { err = pthread_barrier_init(&barrier, NULL, 2); if (err != 0) { /* cannot allocate barrier. move thread back to ready_q */ @@ -622,6 +631,7 @@ int pthread_create(pthread_t *th, const pthread_attr_t *_attr, void *(*threadrou t = NULL; } } +#endif if (t == NULL) { /* no threads are ready */ @@ -661,17 +671,16 @@ int pthread_create(pthread_t *th, const pthread_attr_t *_attr, void *(*threadrou /* spawn the thread */ k_thread_create( &t->thread, t->attr.stack, __get_attr_stacksize(&t->attr) + t->attr.guardsize, - zephyr_thread_wrapper, (void *)arg, threadroutine, - IS_ENABLED(CONFIG_PTHREAD_CREATE_BARRIER) ? UINT_TO_POINTER(barrier) : NULL, + zephyr_thread_wrapper, (void *)arg, threadroutine, barrier_ptr, posix_to_zephyr_priority(t->attr.priority, t->attr.schedpolicy), 0, K_NO_WAIT); - if (IS_ENABLED(CONFIG_PTHREAD_CREATE_BARRIER)) { - /* wait for the spawned thread to cross our barrier */ - err = pthread_barrier_wait(&barrier); - __ASSERT_NO_MSG(err == 0 || err == PTHREAD_BARRIER_SERIAL_THREAD); - err = pthread_barrier_destroy(&barrier); - __ASSERT_NO_MSG(err == 0); - } +#if defined(CONFIG_PTHREAD_CREATE_BARRIER) + /* wait for the spawned thread to cross our barrier */ + err = pthread_barrier_wait(&barrier); + __ASSERT_NO_MSG(err == 0 || err == PTHREAD_BARRIER_SERIAL_THREAD); + err = pthread_barrier_destroy(&barrier); + __ASSERT_NO_MSG(err == 0); +#endif /* finally provide the initialized thread to the caller */ *th = mark_pthread_obj_initialized(posix_thread_to_offset(t)); @@ -944,10 +953,20 @@ int pthread_attr_init(pthread_attr_t *_attr) BUILD_ASSERT(DYNAMIC_STACK_SIZE <= PTHREAD_STACK_MAX); - *attr = (struct posix_thread_attr){0}; - attr->guardsize = CONFIG_POSIX_PTHREAD_ATTR_GUARDSIZE_DEFAULT; - attr->contentionscope = PTHREAD_SCOPE_SYSTEM; - attr->inheritsched = PTHREAD_INHERIT_SCHED; + *attr = (struct posix_thread_attr){ + .guardsize = CONFIG_POSIX_PTHREAD_ATTR_GUARDSIZE_DEFAULT, + .contentionscope = PTHREAD_SCOPE_SYSTEM, + .inheritsched = PTHREAD_INHERIT_SCHED, + .detachstate = PTHREAD_CREATE_JOINABLE, + .cancelstate = PTHREAD_CANCEL_ENABLE, + .canceltype = PTHREAD_CANCEL_DEFERRED, + .priority = DEFAULT_PTHREAD_PRIORITY, + .schedpolicy = DEFAULT_PTHREAD_POLICY, + .stack = NULL, + .stacksize = 0, + .initialized = false, + .caller_destroys = true, + }; if (DYNAMIC_STACK_SIZE > 0) { attr->stack = k_thread_stack_alloc(DYNAMIC_STACK_SIZE + attr->guardsize, diff --git a/lib/posix/options/pthread_sched.h b/lib/posix/options/pthread_sched.h index a5f70694996b5..990e0f4aad3e7 100644 --- a/lib/posix/options/pthread_sched.h +++ b/lib/posix/options/pthread_sched.h @@ -8,9 +8,10 @@ #define ZEPHYR_LIB_POSIX_POSIX_PTHREAD_SCHED_H_ #include +#include #include -#include +#include static inline bool valid_posix_policy(int policy) { diff --git a/lib/posix/options/shm.c b/lib/posix/options/shm.c index 9ef76bf01664a..2883e9b48afe5 100644 --- a/lib/posix/options/shm.c +++ b/lib/posix/options/shm.c @@ -7,15 +7,18 @@ #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200809L -#include +#include +#include +#include #include +#include +#include +#include +#include #include #include #include -#include -#include -#include #include #include #include diff --git a/lib/posix/options/signal.c b/lib/posix/options/signal.c index a759d492042a6..f7f0a7fd4213e 100644 --- a/lib/posix/options/signal.c +++ b/lib/posix/options/signal.c @@ -6,11 +6,12 @@ #include "posix/strsignal_table.h" #include +#include #include #include #include -#include +#include #define SIGNO_WORD_IDX(_signo) (_signo / BITS_PER_LONG) #define SIGNO_WORD_BIT(_signo) (_signo & BIT_MASK(LOG2(BITS_PER_LONG))) diff --git a/lib/posix/options/spinlock.c b/lib/posix/options/spinlock.c index c249eb3bd8f1b..54ee44f4834ff 100644 --- a/lib/posix/options/spinlock.c +++ b/lib/posix/options/spinlock.c @@ -6,9 +6,10 @@ #include "posix_internal.h" +#include + #include #include -#include #include union _spinlock_storage { diff --git a/lib/posix/options/sysconf.c b/lib/posix/options/sysconf.c index 7581c2423fbdf..b9c2d2a974d1c 100644 --- a/lib/posix/options/sysconf.c +++ b/lib/posix/options/sysconf.c @@ -4,274 +4,262 @@ * SPDX-License-Identifier: Apache-2.0 */ -#undef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200809L -#include -#include - -#include - #ifdef CONFIG_POSIX_SYSCONF_IMPL_FULL -#define z_sysconf(x) (long)CONCAT(__z_posix_sysconf, x) +#include +#include +#include + +#include -long sysconf(int x) +long sysconf(int name) { - switch (x) { + switch (name) { case _SC_ADVISORY_INFO: - return z_sysconf(_SC_ADVISORY_INFO); + return -1L; case _SC_ASYNCHRONOUS_IO: - return z_sysconf(_SC_ASYNCHRONOUS_IO); + return COND_CODE_1(CONFIG_POSIX_ASYNCHRONOUS_IO, (_POSIX_VERSION), (-1L)); case _SC_BARRIERS: - return z_sysconf(_SC_BARRIERS); + return COND_CODE_1(CONFIG_POSIX_BARRIERS, (_POSIX_VERSION), (-1L)); case _SC_CLOCK_SELECTION: - return z_sysconf(_SC_CLOCK_SELECTION); + return COND_CODE_1(CONFIG_POSIX_CLOCK_SELECTION, (_POSIX_VERSION), (-1L)); case _SC_CPUTIME: - return z_sysconf(_SC_CPUTIME); + return COND_CODE_1(CONFIG_POSIX_CPUTIME, (_POSIX_VERSION), (-1L)); case _SC_FSYNC: - return z_sysconf(_SC_FSYNC); + return COND_CODE_1(CONFIG_POSIX_FSYNC, (_POSIX_VERSION), (-1L)); case _SC_IPV6: - return z_sysconf(_SC_IPV6); + return COND_CODE_1(CONFIG_NET_IPV6, (_POSIX_VERSION), (-1L)); case _SC_JOB_CONTROL: - return z_sysconf(_SC_JOB_CONTROL); + return -1L; case _SC_MAPPED_FILES: - return z_sysconf(_SC_MAPPED_FILES); + return COND_CODE_1(CONFIG_POSIX_MAPPED_FILES, (_POSIX_VERSION), (-1L)); case _SC_MEMLOCK: - return z_sysconf(_SC_MEMLOCK); + return COND_CODE_1(CONFIG_POSIX_MEMLOCK, (_POSIX_VERSION), (-1L)); case _SC_MEMLOCK_RANGE: - return z_sysconf(_SC_MEMLOCK_RANGE); + return COND_CODE_1(CONFIG_POSIX_MEMLOCK_RANGE, (_POSIX_VERSION), (-1L)); case _SC_MEMORY_PROTECTION: - return z_sysconf(_SC_MEMORY_PROTECTION); + return COND_CODE_1(CONFIG_POSIX_MEMORY_PROTECTION, (_POSIX_VERSION), (-1L)); case _SC_MESSAGE_PASSING: - return z_sysconf(_SC_MESSAGE_PASSING); + return COND_CODE_1(CONFIG_POSIX_MESSAGE_PASSING, (_POSIX_VERSION), (-1L)); case _SC_MONOTONIC_CLOCK: - return z_sysconf(_SC_MONOTONIC_CLOCK); + return COND_CODE_1(CONFIG_POSIX_MONOTONIC_CLOCK, (_POSIX_VERSION), (-1L)); case _SC_PRIORITIZED_IO: - return z_sysconf(_SC_PRIORITIZED_IO); + return -1L; case _SC_PRIORITY_SCHEDULING: - return z_sysconf(_SC_PRIORITY_SCHEDULING); + return COND_CODE_1(CONFIG_POSIX_PRIORITY_SCHEDULING, (_POSIX_VERSION), (-1L)); case _SC_RAW_SOCKETS: - return z_sysconf(_SC_RAW_SOCKETS); + return COND_CODE_1(CONFIG_NET_SOCKETS_PACKET, (_POSIX_VERSION), (-1L)); case _SC_RE_DUP_MAX: - return z_sysconf(_SC_RE_DUP_MAX); + return _POSIX_RE_DUP_MAX; case _SC_READER_WRITER_LOCKS: - return z_sysconf(_SC_READER_WRITER_LOCKS); + return COND_CODE_1(CONFIG_POSIX_RW_LOCKS, (_POSIX_VERSION), (-1L)); case _SC_REALTIME_SIGNALS: - return z_sysconf(_SC_REALTIME_SIGNALS); + return -1L; case _SC_REGEXP: - return z_sysconf(_SC_REGEXP); + return -1L; case _SC_SAVED_IDS: - return z_sysconf(_SC_SAVED_IDS); + return -1L; case _SC_SEMAPHORES: - return z_sysconf(_SC_SEMAPHORES); + return COND_CODE_1(CONFIG_POSIX_SEMAPHORES, (_POSIX_VERSION), (-1L)); case _SC_SHARED_MEMORY_OBJECTS: - return z_sysconf(_SC_SHARED_MEMORY_OBJECTS); + return COND_CODE_1(CONFIG_POSIX_SHARED_MEMORY_OBJECTS, (_POSIX_VERSION), (-1L)); case _SC_SHELL: - return z_sysconf(_SC_SHELL); + return -1L; case _SC_SPAWN: - return z_sysconf(_SC_SPAWN); + return -1L; case _SC_SPIN_LOCKS: - return z_sysconf(_SC_SPIN_LOCKS); + return COND_CODE_1(CONFIG_POSIX_SPIN_LOCKS, (_POSIX_VERSION), (-1L)); case _SC_SPORADIC_SERVER: - return z_sysconf(_SC_SPORADIC_SERVER); + return -1L; case _SC_SS_REPL_MAX: - return z_sysconf(_SC_SS_REPL_MAX); + return _POSIX_SS_REPL_MAX; case _SC_SYNCHRONIZED_IO: - return z_sysconf(_SC_SYNCHRONIZED_IO); + return -1L; case _SC_THREAD_ATTR_STACKADDR: - return z_sysconf(_SC_THREAD_ATTR_STACKADDR); + return COND_CODE_1(CONFIG_POSIX_THREAD_ATTR_STACKADDR, (_POSIX_VERSION), (-1L)); case _SC_THREAD_ATTR_STACKSIZE: - return z_sysconf(_SC_THREAD_ATTR_STACKSIZE); + return COND_CODE_1(CONFIG_POSIX_THREAD_ATTR_STACKSIZE, (_POSIX_VERSION), (-1L)); case _SC_THREAD_CPUTIME: - return z_sysconf(_SC_THREAD_CPUTIME); + return -1L; case _SC_THREAD_PRIO_INHERIT: - return z_sysconf(_SC_THREAD_PRIO_INHERIT); + return COND_CODE_1(CONFIG_POSIX_THREAD_PRIO_INHERIT, (_POSIX_VERSION), (-1L)); case _SC_THREAD_PRIO_PROTECT: - return z_sysconf(_SC_THREAD_PRIO_PROTECT); + return -1L; case _SC_THREAD_PRIORITY_SCHEDULING: - return z_sysconf(_SC_THREAD_PRIORITY_SCHEDULING); + return COND_CODE_1(CONFIG_POSIX_THREAD_PRIORITY_SCHEDULING, (_POSIX_VERSION), + (-1L)); case _SC_THREAD_PROCESS_SHARED: - return z_sysconf(_SC_THREAD_PROCESS_SHARED); + return -1L; case _SC_THREAD_ROBUST_PRIO_INHERIT: - return z_sysconf(_SC_THREAD_ROBUST_PRIO_INHERIT); + return -1L; case _SC_THREAD_ROBUST_PRIO_PROTECT: - return z_sysconf(_SC_THREAD_ROBUST_PRIO_PROTECT); + return -1L; case _SC_THREAD_SAFE_FUNCTIONS: - return z_sysconf(_SC_THREAD_SAFE_FUNCTIONS); + return COND_CODE_1(CONFIG_POSIX_THREAD_SAFE_FUNCTIONS, (_POSIX_VERSION), (-1L)); case _SC_THREAD_SPORADIC_SERVER: - return z_sysconf(_SC_THREAD_SPORADIC_SERVER); + return -1L; case _SC_THREADS: - return z_sysconf(_SC_THREADS); + return COND_CODE_1(CONFIG_POSIX_THREADS, (_POSIX_VERSION), (-1L)); case _SC_TIMEOUTS: - return z_sysconf(_SC_TIMEOUTS); + return COND_CODE_1(CONFIG_POSIX_TIMEOUTS, (_POSIX_VERSION), (-1L)); case _SC_TIMERS: - return z_sysconf(_SC_TIMERS); + return COND_CODE_1(CONFIG_POSIX_TIMERS, (_POSIX_VERSION), (-1L)); case _SC_TRACE: - return z_sysconf(_SC_TRACE); + return -1L; case _SC_TRACE_EVENT_FILTER: - return z_sysconf(_SC_TRACE_EVENT_FILTER); + return -1L; case _SC_TRACE_EVENT_NAME_MAX: - return z_sysconf(_SC_TRACE_EVENT_NAME_MAX); + return _POSIX_TRACE_NAME_MAX; case _SC_TRACE_INHERIT: - return z_sysconf(_SC_TRACE_INHERIT); + return -1L; case _SC_TRACE_LOG: - return z_sysconf(_SC_TRACE_LOG); + return -1L; case _SC_TRACE_NAME_MAX: - return z_sysconf(_SC_TRACE_NAME_MAX); + return _POSIX_TRACE_NAME_MAX; case _SC_TRACE_SYS_MAX: - return z_sysconf(_SC_TRACE_SYS_MAX); + return _POSIX_TRACE_SYS_MAX; case _SC_TRACE_USER_EVENT_MAX: - return z_sysconf(_SC_TRACE_USER_EVENT_MAX); + return _POSIX_TRACE_USER_EVENT_MAX; case _SC_TYPED_MEMORY_OBJECTS: - return z_sysconf(_SC_TYPED_MEMORY_OBJECTS); + return -1L; case _SC_VERSION: - return z_sysconf(_SC_VERSION); - case _SC_V6_ILP32_OFF32: - return z_sysconf(_SC_V6_ILP32_OFF32); - case _SC_V6_ILP32_OFFBIG: - return z_sysconf(_SC_V6_ILP32_OFFBIG); - case _SC_V6_LP64_OFF64: - return z_sysconf(_SC_V6_LP64_OFF64); - case _SC_V6_LPBIG_OFFBIG: - return z_sysconf(_SC_V6_LPBIG_OFFBIG); + return _POSIX_VERSION; case _SC_V7_ILP32_OFF32: - return z_sysconf(_SC_V7_ILP32_OFF32); + return -1L; case _SC_V7_ILP32_OFFBIG: - return z_sysconf(_SC_V7_ILP32_OFFBIG); + return -1L; case _SC_V7_LP64_OFF64: - return z_sysconf(_SC_V7_LP64_OFF64); + return -1L; case _SC_V7_LPBIG_OFFBIG: - return z_sysconf(_SC_V7_LPBIG_OFFBIG); + return -1L; case _SC_BC_BASE_MAX: - return z_sysconf(_SC_BC_BASE_MAX); + return -1L; case _SC_BC_DIM_MAX: - return z_sysconf(_SC_BC_DIM_MAX); + return -1L; case _SC_BC_SCALE_MAX: - return z_sysconf(_SC_BC_SCALE_MAX); + return -1L; case _SC_BC_STRING_MAX: - return z_sysconf(_SC_BC_STRING_MAX); + return -1L; case _SC_2_C_BIND: - return z_sysconf(_SC_2_C_BIND); + return -1L; case _SC_2_C_DEV: - return z_sysconf(_SC_2_C_DEV); + return COND_CODE_1(_POSIX2_C_DEV > 0, (_POSIX2_C_DEV), (-1)); case _SC_2_CHAR_TERM: - return z_sysconf(_SC_2_CHAR_TERM); + return -1L; case _SC_COLL_WEIGHTS_MAX: - return z_sysconf(_SC_COLL_WEIGHTS_MAX); + return -1L; case _SC_DELAYTIMER_MAX: - return z_sysconf(_SC_DELAYTIMER_MAX); + return COND_CODE_1(CONFIG_POSIX_TIMERS, (CONFIG_POSIX_DELAYTIMER_MAX), (0)); case _SC_EXPR_NEST_MAX: - return z_sysconf(_SC_EXPR_NEST_MAX); + return -1L; case _SC_2_FORT_DEV: - return z_sysconf(_SC_2_FORT_DEV); + return -1L; case _SC_2_FORT_RUN: - return z_sysconf(_SC_2_FORT_RUN); + return -1L; case _SC_LINE_MAX: - return z_sysconf(_SC_LINE_MAX); + return -1L; case _SC_2_LOCALEDEF: - return z_sysconf(_SC_2_LOCALEDEF); + return -1L; case _SC_2_PBS: - return z_sysconf(_SC_2_PBS); + return -1L; case _SC_2_PBS_ACCOUNTING: - return z_sysconf(_SC_2_PBS_ACCOUNTING); + return -1L; case _SC_2_PBS_CHECKPOINT: - return z_sysconf(_SC_2_PBS_CHECKPOINT); + return -1L; case _SC_2_PBS_LOCATE: - return z_sysconf(_SC_2_PBS_LOCATE); + return -1L; case _SC_2_PBS_MESSAGE: - return z_sysconf(_SC_2_PBS_MESSAGE); + return -1L; case _SC_2_PBS_TRACK: - return z_sysconf(_SC_2_PBS_TRACK); + return -1L; case _SC_2_SW_DEV: - return z_sysconf(_SC_2_SW_DEV); + return -1L; case _SC_2_UPE: - return z_sysconf(_SC_2_UPE); + return -1L; case _SC_2_VERSION: - return z_sysconf(_SC_2_VERSION); + return COND_CODE_1(_POSIX2_VERSION > 0, (_POSIX2_VERSION), (-1)); case _SC_XOPEN_CRYPT: - return z_sysconf(_SC_XOPEN_CRYPT); + return -1L; case _SC_XOPEN_ENH_I18N: - return z_sysconf(_SC_XOPEN_ENH_I18N); + return -1L; case _SC_XOPEN_REALTIME: - return z_sysconf(_SC_XOPEN_REALTIME); + return COND_CODE_1(CONFIG_XSI_REALTIME, (_XOPEN_VERSION), (-1)); case _SC_XOPEN_REALTIME_THREADS: - return z_sysconf(_SC_XOPEN_REALTIME_THREADS); + return -1L; case _SC_XOPEN_SHM: - return z_sysconf(_SC_XOPEN_SHM); + return -1L; case _SC_XOPEN_STREAMS: - return z_sysconf(_SC_XOPEN_STREAMS); + return COND_CODE_1(CONFIG_XSI_STREAMS, (_XOPEN_STREAMS), (-1)); case _SC_XOPEN_UNIX: - return z_sysconf(_SC_XOPEN_UNIX); + return COND_CODE_1(CONFIG_XSI, (_XOPEN_UNIX), (-1)); case _SC_XOPEN_UUCP: - return z_sysconf(_SC_XOPEN_UUCP); + return -1L; case _SC_XOPEN_VERSION: - return z_sysconf(_SC_XOPEN_VERSION); + return COND_CODE_1(CONFIG_XSI, (_XOPEN_VERSION), (0)); case _SC_CLK_TCK: - return z_sysconf(_SC_CLK_TCK); + return 100L; case _SC_GETGR_R_SIZE_MAX: - return z_sysconf(_SC_GETGR_R_SIZE_MAX); + return 0L; case _SC_GETPW_R_SIZE_MAX: - return z_sysconf(_SC_GETPW_R_SIZE_MAX); + return 0L; case _SC_AIO_LISTIO_MAX: - return z_sysconf(_SC_AIO_LISTIO_MAX); + return _POSIX_AIO_LISTIO_MAX; case _SC_AIO_MAX: - return z_sysconf(_SC_AIO_MAX); + return _POSIX_AIO_MAX; case _SC_AIO_PRIO_DELTA_MAX: - return z_sysconf(_SC_AIO_PRIO_DELTA_MAX); + return 0; case _SC_ARG_MAX: - return z_sysconf(_SC_ARG_MAX); + return _POSIX_ARG_MAX; case _SC_ATEXIT_MAX: - return z_sysconf(_SC_ATEXIT_MAX); + return 32; case _SC_CHILD_MAX: - return z_sysconf(_SC_CHILD_MAX); + return _POSIX_CHILD_MAX; case _SC_HOST_NAME_MAX: - return z_sysconf(_SC_HOST_NAME_MAX); + return COND_CODE_1(CONFIG_POSIX_NETWORKING, (CONFIG_POSIX_HOST_NAME_MAX), (0)); case _SC_IOV_MAX: - return z_sysconf(_SC_IOV_MAX); + return 16; case _SC_LOGIN_NAME_MAX: - return z_sysconf(_SC_LOGIN_NAME_MAX); + return _POSIX_LOGIN_NAME_MAX; case _SC_NGROUPS_MAX: - return z_sysconf(_SC_NGROUPS_MAX); + return _POSIX_NGROUPS_MAX; case _SC_MQ_OPEN_MAX: - return z_sysconf(_SC_MQ_OPEN_MAX); + return COND_CODE_1(CONFIG_POSIX_MESSAGE_PASSING, (CONFIG_POSIX_MQ_OPEN_MAX), (0)); case _SC_MQ_PRIO_MAX: - return z_sysconf(_SC_MQ_PRIO_MAX); + return _POSIX_MQ_PRIO_MAX; case _SC_OPEN_MAX: - return z_sysconf(_SC_OPEN_MAX); + return CONFIG_POSIX_OPEN_MAX; case _SC_PAGE_SIZE: - return z_sysconf(_SC_PAGE_SIZE); - case _SC_PAGESIZE: - return z_sysconf(_SC_PAGESIZE); + return CONFIG_POSIX_PAGE_SIZE; case _SC_THREAD_DESTRUCTOR_ITERATIONS: - return z_sysconf(_SC_THREAD_DESTRUCTOR_ITERATIONS); + return _POSIX_THREAD_DESTRUCTOR_ITERATIONS; case _SC_THREAD_KEYS_MAX: - return z_sysconf(_SC_THREAD_KEYS_MAX); + return COND_CODE_1(CONFIG_POSIX_THREADS, (CONFIG_POSIX_THREAD_KEYS_MAX), (0)); case _SC_THREAD_STACK_MIN: - return z_sysconf(_SC_THREAD_STACK_MIN); + return 0; case _SC_THREAD_THREADS_MAX: - return z_sysconf(_SC_THREAD_THREADS_MAX); + return COND_CODE_1(CONFIG_POSIX_THREADS, (CONFIG_POSIX_THREAD_THREADS_MAX), (0)); case _SC_RTSIG_MAX: - return z_sysconf(_SC_RTSIG_MAX); + return COND_CODE_1(CONFIG_POSIX_REALTIME_SIGNALS, (CONFIG_POSIX_RTSIG_MAX), (0)); case _SC_SEM_NSEMS_MAX: - return z_sysconf(_SC_SEM_NSEMS_MAX); + return COND_CODE_1(CONFIG_POSIX_SEMAPHORES, (CONFIG_POSIX_SEM_NSEMS_MAX), (0)); case _SC_SEM_VALUE_MAX: - return z_sysconf(_SC_SEM_VALUE_MAX); + return COND_CODE_1(CONFIG_POSIX_SEMAPHORES, (CONFIG_POSIX_SEM_VALUE_MAX), (0)); case _SC_SIGQUEUE_MAX: - return z_sysconf(_SC_SIGQUEUE_MAX); + return _POSIX_SIGQUEUE_MAX; case _SC_STREAM_MAX: - return z_sysconf(_SC_STREAM_MAX); + return _POSIX_STREAM_MAX; case _SC_SYMLOOP_MAX: - return z_sysconf(_SC_SYMLOOP_MAX); + return _POSIX_SYMLOOP_MAX; case _SC_TIMER_MAX: - return z_sysconf(_SC_TIMER_MAX); + return COND_CODE_1(CONFIG_POSIX_TIMERS, (CONFIG_POSIX_TIMER_MAX), (0)); case _SC_TTY_NAME_MAX: - return z_sysconf(_SC_TTY_NAME_MAX); + return _POSIX_TTY_NAME_MAX; case _SC_TZNAME_MAX: - return z_sysconf(_SC_TZNAME_MAX); + return _POSIX_TZNAME_MAX; default: errno = EINVAL; return -1; } } -#endif /* CONFIG_POSIX_SYSCONF_IMPL_FULL */ +#endif diff --git a/lib/posix/options/syslog.c b/lib/posix/options/syslog.c index 9f7f7c1e47252..791b7258d2b61 100644 --- a/lib/posix/options/syslog.c +++ b/lib/posix/options/syslog.c @@ -7,9 +7,10 @@ #include #include +#include + #undef LOG_ERR #include -#include static struct k_spinlock syslog_lock; static uint8_t syslog_mask; diff --git a/samples/net/sockets/echo_server/prj.conf b/samples/net/sockets/echo_server/prj.conf index 6038f6bb1083a..3210ca166aa03 100644 --- a/samples/net/sockets/echo_server/prj.conf +++ b/samples/net/sockets/echo_server/prj.conf @@ -5,7 +5,7 @@ CONFIG_NET_TCP=y CONFIG_NET_IPV6=y CONFIG_NET_IPV4=y CONFIG_NET_SOCKETS=y -CONFIG_POSIX_API=y +CONFIG_POSIX_AEP_CHOICE_PSE53=y CONFIG_NET_CONNECTION_MANAGER=y # Kernel options diff --git a/samples/net/sockets/echo_server/src/tcp.c b/samples/net/sockets/echo_server/src/tcp.c index 584ff0ffc02ed..9a33dd05de197 100644 --- a/samples/net/sockets/echo_server/src/tcp.c +++ b/samples/net/sockets/echo_server/src/tcp.c @@ -13,6 +13,8 @@ LOG_MODULE_DECLARE(net_echo_server_sample, LOG_LEVEL_DBG); #include #include #include +#include +#include #include #include diff --git a/samples/net/sockets/echo_server/src/udp.c b/samples/net/sockets/echo_server/src/udp.c index 6847ebd3eb634..8f2c270a421fe 100644 --- a/samples/net/sockets/echo_server/src/udp.c +++ b/samples/net/sockets/echo_server/src/udp.c @@ -7,22 +7,23 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include -LOG_MODULE_DECLARE(net_echo_server_sample, LOG_LEVEL_DBG); +#include "common.h" +#include "certificate.h" -#include #include #include +#include +#include -#include +#include +#include #include -#include "common.h" -#include "certificate.h" - static void process_udp4(void); static void process_udp6(void); +LOG_MODULE_DECLARE(net_echo_server_sample, LOG_LEVEL_DBG); + K_THREAD_DEFINE(udp4_thread_id, STACK_SIZE, process_udp4, NULL, NULL, NULL, THREAD_PRIORITY, diff --git a/samples/posix/philosophers/src/main.c b/samples/posix/philosophers/src/main.c index bfac15861fd6d..2ad8e963bd78f 100644 --- a/samples/posix/philosophers/src/main.c +++ b/samples/posix/philosophers/src/main.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,7 @@ static inline void fork_init(fork_t frk) } } -static inline fork_t fork(size_t idx) +static inline fork_t philosopher_fork(size_t idx) { return &forks[idx]; } @@ -148,11 +149,11 @@ static void *philosopher(void *arg) /* Djkstra's solution: always pick up the lowest numbered fork first */ if (is_last_philosopher(my_id)) { - my_fork1 = fork(0); - my_fork2 = fork(my_id); + my_fork1 = philosopher_fork(0); + my_fork2 = philosopher_fork(my_id); } else { - my_fork1 = fork(my_id); - my_fork2 = fork(my_id + 1); + my_fork1 = philosopher_fork(my_id); + my_fork2 = philosopher_fork(my_id + 1); } while (1) { @@ -204,7 +205,7 @@ static void init_objects(void) { ARRAY_FOR_EACH(forks, i) { LOG_DBG("Initializing fork %zu", i); - fork_init(fork(i)); + fork_init(philosopher_fork(i)); } } diff --git a/subsys/fs/virtiofs/virtiofs_zfs.c b/subsys/fs/virtiofs/virtiofs_zfs.c index ba0cccdf33aca..d8544f5e63a32 100644 --- a/subsys/fs/virtiofs/virtiofs_zfs.c +++ b/subsys/fs/virtiofs/virtiofs_zfs.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include diff --git a/subsys/net/lib/http/http_server_core.c b/subsys/net/lib/http/http_server_core.c index 9ab1cea9c86de..d7066ea7f00bd 100644 --- a/subsys/net/lib/http/http_server_core.c +++ b/subsys/net/lib/http/http_server_core.c @@ -6,6 +6,8 @@ */ #include +#define __GNU_SOURCE +#include #include #include #include @@ -21,7 +23,6 @@ #include #include #include -#include #include LOG_MODULE_REGISTER(net_http_server, CONFIG_NET_HTTP_SERVER_LOG_LEVEL); diff --git a/subsys/net/lib/sockets/sockets.c b/subsys/net/lib/sockets/sockets.c index 441ed438472b4..a9b8f82be17c8 100644 --- a/subsys/net/lib/sockets/sockets.c +++ b/subsys/net/lib/sockets/sockets.c @@ -1013,3 +1013,24 @@ static inline int z_vrfy_zsock_getsockname(int sock, struct sockaddr *addr, } #include #endif /* CONFIG_USERSPACE */ + +#if !defined(CONFIG_POSIX_NETWORKING) +/* + * this is defined here, weakly, since mbedtls assumes it is available based on the presence of + * the header. + * + * ``` + * $HOME/zephyrproject/modules/crypto/mbedtls/library/x509_crt.c:2872: undefined reference to + * `inet_pton' + * + * #if __has_include() + * #include + * #endif + * ``` + */ + +int inet_pton(int af, const char *restrict src, void *restrict dst) +{ + return zsock_inet_pton(af, src, dst); +} +#endif diff --git a/tests/benchmarks/posix/threads/src/main.c b/tests/benchmarks/posix/threads/src/main.c index 86ae9eaf09b8a..8e48a1a32f1f3 100644 --- a/tests/benchmarks/posix/threads/src/main.c +++ b/tests/benchmarks/posix/threads/src/main.c @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/tests/lib/c_lib/common/src/main.c b/tests/lib/c_lib/common/src/main.c index e5aae4ba45950..918672a311f4f 100644 --- a/tests/lib/c_lib/common/src/main.c +++ b/tests/lib/c_lib/common/src/main.c @@ -1075,6 +1075,7 @@ ZTEST(libc_common, test_time_gmtime) */ ZTEST(libc_common, test_time_asctime) { + char *s; char buf[26] = {0}; struct tm tp = { .tm_sec = 10, /* Seconds */ @@ -1086,11 +1087,12 @@ ZTEST(libc_common, test_time_asctime) .tm_year = 124, /* Year (current year - 1900) */ }; - zassert_not_null(asctime_r(&tp, buf)); - zassert_equal(strncmp("Fri Jun 1 14:30:10 2024\n", buf, sizeof(buf)), 0); + s = asctime_r(&tp, buf); + zassert_equal(s, buf); + zassert_str_equal("Fri Jun 1 14:30:10 2024\n", buf); - zassert_not_null(asctime(&tp)); - zassert_equal(strncmp("Fri Jun 1 14:30:10 2024\n", asctime(&tp), sizeof(buf)), 0); + s = asctime(&tp); + zassert_str_equal("Fri Jun 1 14:30:10 2024\n", s); if (IS_ENABLED(CONFIG_COMMON_LIBC_ASCTIME_R)) { tp.tm_wday = 8; diff --git a/tests/posix/barriers/src/main.c b/tests/posix/barriers/src/main.c index 9e76a9ca7b510..37ebd13f1af2a 100644 --- a/tests/posix/barriers/src/main.c +++ b/tests/posix/barriers/src/main.c @@ -25,11 +25,11 @@ ZTEST(posix_barriers, test_barrier) ret = pthread_barrierattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE); zassert_equal(ret, 0, "pthread_barrierattr_setpshared failed"); - ret = pthread_barrierattr_setpshared(&attr, PTHREAD_PROCESS_PUBLIC); + ret = pthread_barrierattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); zassert_equal(ret, 0, "pthread_barrierattr_setpshared failed"); ret = pthread_barrierattr_getpshared(&attr, &pshared); - zassert_equal(pshared, PTHREAD_PROCESS_PUBLIC, "pshared attribute not retrieved correctly"); + zassert_equal(pshared, PTHREAD_PROCESS_SHARED, "pshared attribute not retrieved correctly"); ret = pthread_barrierattr_setpshared(&attr, 42); zassert_equal(ret, -EINVAL, "pthread_barrierattr_setpshared did not return EINVAL"); diff --git a/tests/posix/c_lib_ext/src/getentropy.c b/tests/posix/c_lib_ext/src/getentropy.c index 7ce502b298892..873e4bbdb2713 100644 --- a/tests/posix/c_lib_ext/src/getentropy.c +++ b/tests/posix/c_lib_ext/src/getentropy.c @@ -5,11 +5,12 @@ */ #include + #include ZTEST(posix_c_lib_ext, test_getentropy_too_large) { - uint8_t buf[256 + 1] = {0}; + uint8_t buf[GETENTROPY_MAX + 1] = {0}; int ret; ret = getentropy(buf, sizeof(buf)); @@ -28,7 +29,7 @@ ZTEST(posix_c_lib_ext, test_getentropy_null_buffer) ZTEST(posix_c_lib_ext, test_getentropy_max_size) { - uint8_t buf[256] = {0}; + uint8_t buf[GETENTROPY_MAX] = {0}; int ret; ret = getentropy(buf, sizeof(buf)); diff --git a/tests/posix/common/prj.conf b/tests/posix/common/prj.conf index 7c34c53b0e21c..bbb332340e7b7 100644 --- a/tests/posix/common/prj.conf +++ b/tests/posix/common/prj.conf @@ -1,4 +1,5 @@ CONFIG_POSIX_API=y +CONFIG_POSIX_SEMAPHORES=y CONFIG_POSIX_THREAD_THREADS_MAX=6 CONFIG_ZTEST=y CONFIG_POSIX_SEM_VALUE_MAX=32767 diff --git a/tests/posix/common/src/mutex.c b/tests/posix/common/src/mutex.c index 20b992620eb8a..f2ea38ef64a51 100644 --- a/tests/posix/common/src/mutex.c +++ b/tests/posix/common/src/mutex.c @@ -48,7 +48,7 @@ static void *recursive_mutex_entry(void *p1) static void test_mutex_common(int type, void *(*entry)(void *arg)) { pthread_t th; - int protocol; + __maybe_unused int protocol; int actual_type; pthread_mutexattr_t mut_attr; struct sched_param schedparam; @@ -61,6 +61,7 @@ static void test_mutex_common(int type, void *(*entry)(void *arg)) zassert_ok(pthread_mutexattr_gettype(&mut_attr, &actual_type), "reading mutex type is failed"); +#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) zassert_not_ok(pthread_mutexattr_getprotocol(NULL, &protocol)); zassert_not_ok(pthread_mutexattr_getprotocol(&mut_attr, NULL)); zassert_not_ok(pthread_mutexattr_getprotocol(NULL, NULL)); @@ -70,12 +71,16 @@ static void test_mutex_common(int type, void *(*entry)(void *arg)) zassert_ok(pthread_mutexattr_setprotocol(&mut_attr, PTHREAD_PRIO_NONE)); zassert_ok(pthread_mutexattr_getprotocol(&mut_attr, &protocol), "reading mutex protocol is failed"); +#endif /* defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) */ + zassert_ok(pthread_mutexattr_destroy(&mut_attr)); zassert_ok(pthread_mutex_lock(&mutex)); zassert_equal(actual_type, type, "mutex type is not normal"); +#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) zassert_equal(protocol, PTHREAD_PRIO_NONE, "mutex protocol is not prio_none"); +#endif /* defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) */ zassert_ok(pthread_create(&th, NULL, entry, NULL)); @@ -88,13 +93,14 @@ static void test_mutex_common(int type, void *(*entry)(void *arg)) ZTEST(mutex, test_mutex_prioceiling_stubs) { -#ifdef CONFIG_POSIX_THREAD_PRIO_PROTECT +#if defined(_POSIX_THREAD_PRIO_PROTECT) zassert_equal(pthread_mutex_getprioceiling(NULL, NULL), ENOSYS); zassert_equal(pthread_mutex_setprioceiling(NULL, 0, NULL), ENOSYS); +#endif + +#if defined(_POSIX_THREAD_PRIO_INHERIT) || defined(_POSIX_THREAD_PRIO_PROTECT) zassert_equal(pthread_mutexattr_getprioceiling(NULL, NULL), ENOSYS); zassert_equal(pthread_mutexattr_setprioceiling(NULL, 0), ENOSYS); -#else - ztest_test_skip(); #endif /* CONFIG_POSIX_THREAD_PRIO_PROTECT */ } diff --git a/tests/posix/common/src/pthread.c b/tests/posix/common/src/pthread.c index 96a16f7ddb33b..582ab75c27f16 100644 --- a/tests/posix/common/src/pthread.c +++ b/tests/posix/common/src/pthread.c @@ -22,11 +22,23 @@ #define PTHREAD_CANCEL_INVALID -1 #define SCHED_INVALID -1 #define PRIO_INVALID -1 -#define PTHREAD_INVALID -1 +#define PTHREAD_INVALID ((pthread_t)(-1)) + +/* TODO: move tests that use non-portable calls to an "np" testsuite */ +int pthread_setname_np(pthread_t thread, const char *name); +int pthread_getname_np(pthread_t thread, char *name, size_t len); +int pthread_tryjoin_np(pthread_t thread, void **retval); +int pthread_timedjoin_np(pthread_t thread, void **retval, const struct timespec *abstime); static void *thread_top_exec(void *p1); static void *thread_top_term(void *p1); +struct pthread_attr { + void *stack; + uint32_t details[2]; +}; +BUILD_ASSERT(sizeof(pthread_attr_t) >= sizeof(struct pthread_attr)); + static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cvar0 = PTHREAD_COND_INITIALIZER; static pthread_cond_t cvar1 = PTHREAD_COND_INITIALIZER; @@ -59,12 +71,16 @@ static int barrier_return[N_THR_E]; static void *thread_top_exec(void *p1) { int i, j, id = (int)POINTER_TO_INT(p1); + +#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) int policy; struct sched_param schedparam; pthread_getschedparam(pthread_self(), &policy, &schedparam); printk("Thread %d starting with scheduling policy %d & priority %d\n", id, policy, schedparam.sched_priority); +#endif + /* Try a double-lock here to exercise the failing case of * trylock. We don't support RECURSIVE locks, so this is * guaranteed to fail. @@ -189,14 +205,18 @@ static int barrier_test_done(void) static void *thread_top_term(void *p1) { pthread_t self; - int policy, ret; + int ret; int id = POINTER_TO_INT(p1); - struct sched_param param, getschedparam; - - param.sched_priority = N_THR_T - id; self = pthread_self(); +#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) + int policy; + struct sched_param param = { + .sched_priority = N_THR_T - id, + }; + struct sched_param getschedparam; + /* Change priority of thread */ zassert_false(pthread_setschedparam(self, SCHED_RR, ¶m), "Unable to set thread priority!"); @@ -205,6 +225,7 @@ static void *thread_top_term(void *p1) "Unable to get thread priority!"); printk("Thread %d starting with a priority of %d\n", id, getschedparam.sched_priority); +#endif if (id % 2) { ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); @@ -533,6 +554,7 @@ ZTEST(pthread, test_pthread_testcancel) zassert_false(testcancel_failed); } +#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) static void *test_pthread_setschedprio_fn(void *arg) { int policy; @@ -558,6 +580,7 @@ ZTEST(pthread, test_pthread_setschedprio) zassert_ok(pthread_create(&th, NULL, test_pthread_setschedprio_fn, NULL)); zassert_ok(pthread_join(th, NULL)); } +#endif static void before(void *arg) { diff --git a/tests/posix/common/src/pthread_attr.c b/tests/posix/common/src/pthread_attr.c index 7f09b93a9729d..96de97d31c680 100644 --- a/tests/posix/common/src/pthread_attr.c +++ b/tests/posix/common/src/pthread_attr.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -19,7 +20,7 @@ static const pthread_attr_t uninit_attr; static bool detached_thread_has_finished; /* TODO: this should be optional */ -#define STATIC_THREAD_STACK_SIZE (MAX(1024, PTHREAD_STACK_MIN + CONFIG_TEST_EXTRA_STACK_SIZE)) +#define STATIC_THREAD_STACK_SIZE (MAX(1024, K_KERNEL_STACK_LEN(0) + CONFIG_TEST_EXTRA_STACK_SIZE)) static K_THREAD_STACK_DEFINE(static_thread_stack, STATIC_THREAD_STACK_SIZE); static void *thread_entry(void *arg) @@ -147,6 +148,7 @@ ZTEST(pthread_attr, test_pthread_attr_init_destroy) /* note: attr is still valid and is destroyed in after() */ } +#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) ZTEST(pthread_attr, test_pthread_attr_getschedparam) { struct sched_param param = { @@ -393,6 +395,7 @@ ZTEST(pthread_attr, test_pthread_attr_setinheritsched) test_pthread_attr_setinheritsched_common(PTHREAD_INHERIT_SCHED); test_pthread_attr_setinheritsched_common(PTHREAD_EXPLICIT_SCHED); } +#endif ZTEST(pthread_attr, test_pthread_attr_large_stacksize) { diff --git a/tests/posix/fs/src/test_fs_dir.c b/tests/posix/fs/src/test_fs_dir.c index 23b844ce2a789..1eeaea9b42941 100644 --- a/tests/posix/fs/src/test_fs_dir.c +++ b/tests/posix/fs/src/test_fs_dir.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include "test_fs.h" diff --git a/tests/posix/fs/src/test_fs_file.c b/tests/posix/fs/src/test_fs_file.c index 1845aaa0dfa2c..cbaa86a1c317b 100644 --- a/tests/posix/fs/src/test_fs_file.c +++ b/tests/posix/fs/src/test_fs_file.c @@ -6,6 +6,7 @@ #include #include +#include #include #include "test_fs.h" diff --git a/tests/posix/fs/src/test_fs_stat.c b/tests/posix/fs/src/test_fs_stat.c index 9d85c31355e01..2d799c9a27334 100644 --- a/tests/posix/fs/src/test_fs_stat.c +++ b/tests/posix/fs/src/test_fs_stat.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include "test_fs.h" diff --git a/tests/posix/headers/src/aio_h.c b/tests/posix/headers/src/aio_h.c index 3b5fdfa10783f..45a15ca38bdb4 100644 --- a/tests/posix/headers/src/aio_h.c +++ b/tests/posix/headers/src/aio_h.c @@ -6,30 +6,28 @@ #include "_common.h" -#ifdef CONFIG_POSIX_API #include -#else -#include -#endif ZTEST(posix_headers, test_aio_h) { +#ifdef CONFIG_POSIX_ASYNCHRONOUS_IO zassert_not_equal(offsetof(struct aiocb, aio_fildes), -1); zassert_not_equal(offsetof(struct aiocb, aio_offset), -1); zassert_not_equal(offsetof(struct aiocb, aio_buf), -1); zassert_not_equal(offsetof(struct aiocb, aio_nbytes), -1); zassert_not_equal(offsetof(struct aiocb, aio_reqprio), -1); +#ifdef CONFIG_POSIX_REALTIME_SIGNALS zassert_not_equal(offsetof(struct aiocb, aio_sigevent), -1); +#endif zassert_not_equal(offsetof(struct aiocb, aio_lio_opcode), -1); - if (IS_ENABLED(CONFIG_POSIX_API)) { - zassert_not_null(aio_cancel); - zassert_not_null(aio_error); - zassert_not_null(aio_fsync); - zassert_not_null(aio_read); - zassert_not_null(aio_return); - zassert_not_null(aio_suspend); - zassert_not_null(aio_write); - zassert_not_null(lio_listio); - } + zassert_not_null(aio_cancel); + zassert_not_null(aio_error); + zassert_not_null(aio_fsync); + zassert_not_null(aio_read); + zassert_not_null(aio_return); + zassert_not_null(aio_suspend); + zassert_not_null(aio_write); + zassert_not_null(lio_listio); +#endif } diff --git a/tests/posix/headers/src/pthread_h.c b/tests/posix/headers/src/pthread_h.c index 1cdad9cfbe655..a55fcafa4b814 100644 --- a/tests/posix/headers/src/pthread_h.c +++ b/tests/posix/headers/src/pthread_h.c @@ -16,7 +16,7 @@ ZTEST(posix_headers, test_pthread_h) { #ifdef CONFIG_POSIX_API - zassert_not_equal(-1, PTHREAD_BARRIER_SERIAL_THREAD); + zassert_not_equal(-42, PTHREAD_BARRIER_SERIAL_THREAD); zassert_not_equal(-1, PTHREAD_CANCEL_ASYNCHRONOUS); zassert_not_equal(-1, PTHREAD_CANCEL_DEFERRED); diff --git a/tests/posix/headers/src/sched_h.c b/tests/posix/headers/src/sched_h.c index 3680e1473af9c..76133d83d48d5 100644 --- a/tests/posix/headers/src/sched_h.c +++ b/tests/posix/headers/src/sched_h.c @@ -22,18 +22,20 @@ ZTEST(posix_headers, test_sched_h) /* zassert_not_equal(-1, SCHED_SPORADIC); */ /* not implemented */ /* zassert_not_equal(-1, SCHED_OTHER); */ /* not implemented */ - if (IS_ENABLED(CONFIG_POSIX_API)) { - zassert_not_null(sched_get_priority_max); - zassert_not_null(sched_get_priority_min); +#ifdef CONFIG_POSIX_PRIORITY_SCHEDULING + zassert_not_null(sched_get_priority_max); + zassert_not_null(sched_get_priority_min); - zassert_not_null(sched_getparam); - zassert_not_null(sched_getscheduler); + zassert_not_null(sched_getparam); + zassert_not_null(sched_getscheduler); - zassert_not_null(sched_rr_get_interval); + zassert_not_null(sched_rr_get_interval); - zassert_not_null(sched_setparam); - zassert_not_null(sched_setscheduler); + zassert_not_null(sched_setparam); + zassert_not_null(sched_setscheduler); +#endif - zassert_not_null(sched_yield); - } +#ifdef CONFIG_POSIX_THREADS + zassert_not_null(sched_yield); +#endif } diff --git a/tests/posix/headers/src/unistd_h.c b/tests/posix/headers/src/unistd_h.c index 7e24e59d72978..09cdd2c58e460 100644 --- a/tests/posix/headers/src/unistd_h.c +++ b/tests/posix/headers/src/unistd_h.c @@ -20,6 +20,7 @@ ZTEST(posix_headers, test_unistd_h) /* zassert_not_equal(-1, W_OK); */ /* not implemented */ /* zassert_not_equal(-1, X_OK); */ /* not implemented */ +#if defined(POSIX_SINGLE_PROCESS) zassert_not_equal(INT_MIN, _CS_PATH); zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFF32_CFLAGS); zassert_not_equal(INT_MIN, _CS_POSIX_V7_ILP32_OFF32_LDFLAGS); @@ -37,6 +38,7 @@ ZTEST(posix_headers, test_unistd_h) zassert_not_equal(INT_MIN, _CS_POSIX_V7_THREADS_LDFLAGS); zassert_not_equal(INT_MIN, _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS); zassert_not_equal(INT_MIN, _CS_V7_ENV); +#endif /* zassert_not_equal(-1, F_LOCK); */ /* not implemented */ /* zassert_not_equal(-1, F_TEST); */ /* not implemented */ @@ -195,7 +197,9 @@ ZTEST(posix_headers, test_unistd_h) /* zassert_equal(STDIN_FILENO, 0); */ /* not implemented */ /* zassert_equal(STDOUT_FILENO, 1); */ /* not implemented */ +#if !defined(_POSIX_C_SOURCE) zassert_not_equal(INT_MIN, _POSIX_VDISABLE); +#endif /* * FIXME: this should really use IS_ENABLED() diff --git a/tests/posix/signals/src/main.c b/tests/posix/signals/src/main.c index e1508f87fbc9a..69f8bd7a5ebdf 100644 --- a/tests/posix/signals/src/main.c +++ b/tests/posix/signals/src/main.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/tests/posix/single_process/src/confstr.c b/tests/posix/single_process/src/confstr.c index 0754a49bc3e01..f11ccf1ba89ab 100644 --- a/tests/posix/single_process/src/confstr.c +++ b/tests/posix/single_process/src/confstr.c @@ -5,9 +5,9 @@ */ #include +#include #include -#include #include ZTEST(posix_single_process, test_confstr) diff --git a/tests/posix/xsi_realtime/src/shm.c b/tests/posix/xsi_realtime/src/shm.c index 72d7e9bc810e5..c3bd1d8b2a5f5 100644 --- a/tests/posix/xsi_realtime/src/shm.c +++ b/tests/posix/xsi_realtime/src/shm.c @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include +#include #include #include -#include #include #include @@ -36,8 +37,6 @@ /* we need to have at least 2 shared memory objects */ BUILD_ASSERT(N >= 2, "CONFIG_ZVFS_OPEN_MAX must be > 4"); -#define S_TYPEISSHM(st) (((st)->st_mode & ZVFS_MODE_IFMT) == ZVFS_MODE_IFSHM) - ZTEST(xsi_realtime, test_shm_open) { int ret;