[PATCH] newlib: fix macro definitions related to POSIX.1-2024

Alexey Lapshin <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
_GNU_SOURCE already causes _POSIX_C_SOURCE to be set to 202405L via the
_DEFAULT_SOURCE logic. Updated the explicit definition of _POSIX_C_SOURCE to
202405L to avoid confusion and make the behavior more explicit.

This commit adds _XOPEN_SOURCE=800 and related visibility macros to align with 
the expected feature set when _GNU_SOURCE is defined. This also enables Single
UNIX Specification v5 (SUSv5) features.

Also improves clarity and future compatibility for applications relying on
recent POSIX/XSI standards.

---
 newlib/libc/include/sys/features.h | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/newlib/libc/include/sys/features.h b/newlib/libc/include/sys/features.h
index 570bdf27a..436b62ae8 100644
--- a/newlib/libc/include/sys/features.h
+++ b/newlib/libc/include/sys/features.h
@@ -132,9 +132,9 @@ extern "C" {
 #undef _POSIX_SOURCE
 #define	_POSIX_SOURCE		1
 #undef _POSIX_C_SOURCE
-#define	_POSIX_C_SOURCE		200809L
+#define	_POSIX_C_SOURCE		202405L
 #undef _XOPEN_SOURCE
-#define	_XOPEN_SOURCE		700
+#define	_XOPEN_SOURCE		800
 #undef _XOPEN_SOURCE_EXTENDED
 #define	_XOPEN_SOURCE_EXTENDED	1
 #endif /* _GNU_SOURCE */
@@ -158,7 +158,9 @@ extern "C" {
   ((!defined(__STRICT_ANSI__) && !defined(_ANSI_SOURCE)) || \
    (_XOPEN_SOURCE - 0) >= 500)
 #define	_POSIX_SOURCE		1
-#if !defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE - 0) >= 700
+#if !defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE - 0) >= 800
+#define	_POSIX_C_SOURCE		202405L
+#elif (_XOPEN_SOURCE - 0) >= 700
 #define	_POSIX_C_SOURCE		200809L
 #elif (_XOPEN_SOURCE - 0) >= 600
 #define	_POSIX_C_SOURCE		200112L
@@ -206,7 +208,7 @@ extern "C" {
  *
  * __POSIX_VISIBLE >= 202405
  *	POSIX.1-2024; enabled by default, with _POSIX_C_SOURCE >= 202405L,
- *	or _XOPEN_SOURCE >= 700.
+ *	or _XOPEN_SOURCE >= 800.
  *
  * __XSI_VISIBLE
  *	XPG4 XSI extensions; enabled with any version of _XOPEN_SOURCE.
@@ -224,6 +226,9 @@ extern "C" {
  * __XSI_VISIBLE >= 700
  *	SUSv4 XSI extensions; enabled with _XOPEN_SOURCE >= 700.
  *
+ * __XSI_VISIBLE >= 800
+ *	SUSv5 XSI extensions; enabled with _XOPEN_SOURCE >= 800.
+ *
  * __ISO_C_VISIBLE >= 1999
  *	ISO C99; enabled with gcc -std=c99 or newer (on by default since GCC 5),
  *	any version of C++, or with _ISOC99_SOURCE, _POSIX_C_SOURCE >= 200112L,
@@ -334,7 +339,9 @@ extern "C" {
 #define	__SVID_VISIBLE		0
 #endif
 
-#if (_XOPEN_SOURCE - 0) >= 700
+#if (_XOPEN_SOURCE - 0) >= 800
+#define	__XSI_VISIBLE		800
+#elif (_XOPEN_SOURCE - 0) >= 700
 #define	__XSI_VISIBLE		700
 #elif (_XOPEN_SOURCE - 0) >= 600
 #define	__XSI_VISIBLE		600
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.