[PATCH] Add feature test macros for POSIX.1-2024.

Carlos O'Donell carlos@redhat.com
Tue Nov 4 12:57:57 GMT 2025


On 5/23/25 12:00 AM, Collin Funk wrote:
> * include/features.h (_POSIX_C_SOURCE): Document the value of 202405L
> for POSIX.1-2024.  Set it to 202405L when _GNU_SOURCE or _DEFAULT_SOURCE
> is defined.
> (_XOPEN_SOURCE): Document the value of 800 for POSIX-1.2024.  Set it to
> 800 when _GNU_SOURCE is defined.
> (__USE_XOPEN2K24, __USE_XOPEN2K24XSI): New internal macros.  Set them
> when _POSIX_C_SOURCE is 202405L or greater and/or when _XOPEN_SOURCE is
> 800 or greater.
> * manual/creature.texi (Feature Test Macros): Document the new values
> for _POSIX_C_SOURCE and _XOPEN_SOURCE.
> 
> Signed-off-by: Collin Funk <collin.funk1@gmail.com>

The new __USE_XOPEN2K24 should eventually be used in unistd.h to set
_POSIX_VERSION, and _POSIX2_VERSION in unistd.h when we finish the
implementation of the new standard and wish to indicate conformance.

I expect you did not change unistd.h because you don't think we're
conforming yet or haven't done the work to verify? I'm not ask for
that work to be done, just checking. The work to verify conformance
is more than the work to add these checks here for when the user
requests a given version and the system headers are altered to
include or remove those features. This change being the first step
towards conditionalizing the headers.

LGTM.

Please push. No NEWS entry required since we don't have anything really
news-worth yet for new features.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>


> ---
>   include/features.h   | 30 +++++++++++++++++++++++-------
>   manual/creature.texi |  6 +++++-
>   2 files changed, 28 insertions(+), 8 deletions(-)
> 
> diff --git a/include/features.h b/include/features.h
> index 44bc4bbc85..e8d48785ba 100644
> --- a/include/features.h
> +++ b/include/features.h
> @@ -44,9 +44,11 @@
>   			if >=199506L, add IEEE Std 1003.1c-1995;
>   			if >=200112L, all of IEEE 1003.1-2004
>   			if >=200809L, all of IEEE 1003.1-2008
> +			if >=202405L, all of IEEE 1003.1-2024

OK. Correct value for _POSIX_C_SOURCE.

>      _XOPEN_SOURCE	Includes POSIX and XPG things.  Set to 500 if
>   			Single Unix conformance is wanted, to 600 for the
> -			sixth revision, to 700 for the seventh revision.
> +			sixth revision, to 700 for the seventh revision,
> +			to 800 for the eighth revision.

OK. Correct value for _XOPEN_SOURCE.

>      _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
>      _LARGEFILE_SOURCE	Some more functions for correct standard I/O.
>      _LARGEFILE64_SOURCE	Additional functionality from LFS for large files.
> @@ -69,7 +71,7 @@
>      options such as `-std=c99', define __STRICT_ANSI__.  If none of
>      these are defined, or if _DEFAULT_SOURCE is defined, the default is
>      to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
> -   200809L, as well as enabling miscellaneous functions from BSD and
> +   202405L, as well as enabling miscellaneous functions from BSD and

OK. Latest.

>      SVID.  If more than one of these are defined, they accumulate.  For
>      example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together
>      give you ISO C, 1003.1, and 1003.2, but nothing else.
> @@ -96,6 +98,8 @@
>      __USE_XOPEN2KXSI     Define XPG6 XSI things.
>      __USE_XOPEN2K8       Define XPG7 things.
>      __USE_XOPEN2K8XSI    Define XPG7 XSI things.
> +   __USE_XOPEN2K24      Define XPG8 things.
> +   __USE_XOPEN2K24XSI   Define XPG8 XSI things.

OK. Internal only use for new features.

>      __USE_LARGEFILE	Define correct standard I/O things.
>      __USE_LARGEFILE64	Define LFS things with separate names.
>      __USE_FILE_OFFSET64	Define 64bit interface as default.
> @@ -141,6 +145,8 @@
>   #undef	__USE_XOPEN2KXSI
>   #undef	__USE_XOPEN2K8
>   #undef	__USE_XOPEN2K8XSI
> +#undef	__USE_XOPEN2K24
> +#undef	__USE_XOPEN2K24XSI

OK.

>   #undef	__USE_LARGEFILE
>   #undef	__USE_LARGEFILE64
>   #undef	__USE_FILE_OFFSET64
> @@ -223,9 +229,9 @@
>   # undef  _POSIX_SOURCE
>   # define _POSIX_SOURCE	1
>   # undef  _POSIX_C_SOURCE
> -# define _POSIX_C_SOURCE	200809L
> +# define _POSIX_C_SOURCE	202405L

OK. Default to latest.

>   # undef  _XOPEN_SOURCE
> -# define _XOPEN_SOURCE	700
> +# define _XOPEN_SOURCE	800

OK. Likewise.

>   # undef  _XOPEN_SOURCE_EXTENDED
>   # define _XOPEN_SOURCE_EXTENDED	1
>   # undef	 _LARGEFILE64_SOURCE
> @@ -301,7 +307,7 @@
>   #endif
>   
>   /* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE
> -   is defined, use POSIX.1-2008 (or another version depending on
> +   is defined, use POSIX.1-2024 (or another version depending on

OK.

>      _XOPEN_SOURCE).  */
>   #ifdef _DEFAULT_SOURCE
>   # if !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE
> @@ -310,7 +316,7 @@
>   # undef  _POSIX_SOURCE
>   # define _POSIX_SOURCE	1
>   # undef  _POSIX_C_SOURCE
> -# define _POSIX_C_SOURCE	200809L
> +# define _POSIX_C_SOURCE	202405L

OK.

>   #endif
>   
>   #if ((!defined __STRICT_ANSI__					\
> @@ -323,8 +329,10 @@
>   #  define _POSIX_C_SOURCE	199506L
>   # elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700
>   #  define _POSIX_C_SOURCE	200112L
> -# else
> +# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 800
>   #  define _POSIX_C_SOURCE	200809L
> +# else
> +#  define _POSIX_C_SOURCE	202405L

OK.

>   # endif
>   # define __USE_POSIX_IMPLICITLY	1
>   #endif
> @@ -374,6 +382,10 @@
>   # define _ATFILE_SOURCE	1
>   #endif
>   
> +#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 202405L
> +# define __USE_XOPEN2K24	1
> +#endif

OK.

> +
>   #ifdef	_XOPEN_SOURCE
>   # define __USE_XOPEN	1
>   # if (_XOPEN_SOURCE - 0) >= 500
> @@ -385,6 +397,10 @@
>   #   if (_XOPEN_SOURCE - 0) >= 700
>   #    define __USE_XOPEN2K8	1
>   #    define __USE_XOPEN2K8XSI	1
> +#    if (_XOPEN_SOURCE - 0) >= 800
> +#     define __USE_XOPEN2K24	1
> +#     define __USE_XOPEN2K24XSI	1

OK.

> +#    endif
>   #   endif
>   #   define __USE_XOPEN2K	1
>   #   define __USE_XOPEN2KXSI	1
> diff --git a/manual/creature.texi b/manual/creature.texi
> index 09e1c9670f..9085640c28 100644
> --- a/manual/creature.texi
> +++ b/manual/creature.texi
> @@ -73,6 +73,10 @@ @node Feature Test Macros
>   @code{200809L}, then the functionality from the 2008 edition of the
>   POSIX standard (IEEE Standard 1003.1-2008) is made available.
>   
> +If you define this macro to a value greater than or equal to
> +@code{202405L}, then the functionality from the 2024 edition of the
> +POSIX standard (IEEE Standard 1003.1-2024) is made available.

OK.

> +
>   Greater values for @code{_POSIX_C_SOURCE} will enable future extensions.
>   The POSIX standards process will define these values as necessary, and
>   @theglibc{} should support them some time after they become standardized.
> @@ -104,7 +108,7 @@ @node Feature Test Macros
>   Single Unix Specification, @w{version 2}.  The value @math{600}
>   (corresponding to the sixth revision) includes definitions from SUSv3,
>   and using @math{700} (the seventh revision) includes definitions from
> -SUSv4.
> +SUSv4.  The value @math{800} includes definitions from POSIX.1-2024.

OK.

>   @end defvr
>   
>   @defvr Macro _LARGEFILE_SOURCE


-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list