]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Define C23 header version macros
authorJoseph Myers <josmyers@redhat.com>
Thu, 27 Nov 2025 19:32:49 +0000 (19:32 +0000)
committerJoseph Myers <josmyers@redhat.com>
Thu, 27 Nov 2025 19:32:49 +0000 (19:32 +0000)
C23 defines library macros __STDC_VERSION_<header>_H__ to indicate
that a header has support for new / changed features from C23.  Now
that all the required library features are implemented in glibc,
define these macros.  I'm not sure this is sufficiently much of a
user-visible feature to be worth a mention in NEWS.

Tested for x86_64.

There are various optional C23 features we don't yet have, of which I
might look at the Annex H ones (floating-point encoding conversion
functions and _Float16 functions) next.

* Optional time bases TIME_MONOTONIC, TIME_ACTIVE, TIME_THREAD_ACTIVE.
  See
  <https://sourceware.org/pipermail/libc-alpha/2023-June/149264.html>
  - we need to review / update that patch.  (I think patch 2/2,
  inventing new names for all the nonstandard CLOCK_* supported by the
  Linux kernel, is rather more dubious.)

* Updating conform/ tests for C23.

* Defining the rounding mode macro FE_TONEARESTFROMZERO for RISC-V (as
  far as I know, the only architecture supported by glibc that has
  hardware support for this rounding mode for binary floating point)
  and supporting it throughout glibc and its tests (especially the
  string/numeric conversions in both directions that explicitly handle
  each possible rounding mode, and various tests that do likewise).

* Annex H floating-point encoding conversion functions.  (It's not
  entirely clear which are optional even given support for Annex H;
  there's some wording applied inconsistently about only being
  required when non-arithmetic interchange formats are supported; see
  the comments I raised on the WG14 reflector on 23 Oct 2025.)

* _Float16 functions (and other header and testcase support for this
  type).

* Decimal floating-point support.

* Fully supporting __int128 and unsigned __int128 as integer types
  wider than intmax_t, as permitted by C23.  Would need doing in
  coordination with GCC, see GCC bug 113887 for more discussion of
  what's involved.

15 files changed:
assert/assert.h
include/limits.h
libio/stdio.h
math/complex.h
math/fenv.h
math/math.h
math/tgmath.h
setjmp/setjmp.h
stdlib/inttypes.h
stdlib/stdint.h
stdlib/stdlib.h
string/string.h
time/time.h
wcsmbs/uchar.h
wcsmbs/wchar.h

index 839406ddf74a3175656a842b69b1395d40afb936..373a1142d88b9409ce4888f616b09e5552b5031f 100644 (file)
 #define        _ASSERT_H       1
 #include <features.h>
 
+#if __GLIBC_USE (ISOC23)
+# ifndef __STDC_VERSION_ASSERT_H__
+#  define __STDC_VERSION_ASSERT_H__ 202311L
+# endif
+#endif
+
 #if defined __cplusplus && __GNUC_PREREQ (2,95)
 # define __ASSERT_VOID_CAST static_cast<void>
 #else
index 6370ccd84d37c65ceb0451bdde5a133643dd1ee9..baf79df6092b1e3d91497bb494d6bca199a90120 100644 (file)
 
 /* The macros for _Bool are not defined by GCC's <limits.h> before GCC
    11, or if _GNU_SOURCE is defined rather than enabling C23 support
-   with -std.  */
+   with -std; likewise for the version macro before GCC 13.  */
 #if __GLIBC_USE (ISOC23)
 # ifndef BOOL_MAX
 #  define BOOL_MAX 1
 # ifndef BOOL_WIDTH
 #  define BOOL_WIDTH 1
 # endif
+# ifndef __STDC_VERSION_LIMITS_H__
+#  define __STDC_VERSION_LIMITS_H__ 202311L
+# endif
 #endif
 
 #ifdef __USE_POSIX
index e0e70945fab175fafcb0c8bbae96ad7eebe3df5a..d5a44edfa6bbf7842de1c92fd0ccc083e8c00f71 100644 (file)
 
 __BEGIN_DECLS
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_STDIO_H__ 202311L
+#endif
+
 #define __need_size_t
 #define __need_NULL
 #include <stddef.h>
index c925c5c0a3f54cc4415c1b87665c5b2a4f7ed34e..2c84953429c9c48cc42547f61b0c63baed6591eb 100644 (file)
 
 __BEGIN_DECLS
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_COMPLEX_H__ 202311L
+#endif
+
 /* We might need to add support for more compilers here.  But since ISO
    C99 is out hopefully all maintained compilers will soon provide the data
    types `float complex' and `double complex'.  */
index 07bbbf61dfe03e2db6ad1258a7e841c6b06f2f5a..8db719f6873869cc8e2c8583324fb7e010be6994 100644 (file)
 
 __BEGIN_DECLS
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_FENV_H__ 202311L
+#endif
+
 /* Floating-point exception handling.  */
 
 /* Clear the supported exceptions represented by EXCEPTS.  */
index 5f1933a2f9f6cde192b9d2c899718dc36563959b..26cea186fc8de774aed5af6899634947ac8e166b 100644 (file)
@@ -39,6 +39,10 @@ __BEGIN_DECLS
 /* Gather machine dependent type support.  */
 #include <bits/floatn.h>
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_MATH_H__ 202311L
+#endif
+
 /* Value returned on overflow.  With IEEE 754 floating point, this is
    +Infinity, otherwise the largest representable positive value.  */
 #if __GNUC_PREREQ (3, 3)
index 27a87c599d3eac8a156a0a39f176dfb98bb443f9..89ee94e1f7886e30345163f23accf809c1399529 100644 (file)
 #include <math.h>
 #include <complex.h>
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_TGMATH_H__ 202311L
+#endif
+
 
 /* There are two variant implementations of type-generic macros in
    this file: one for GCC 8 and later, using __builtin_tgmath and
index 7a4760e2910bbf519a9c433b99efb815812b042f..f232ddcd6bec847a0cfd406b27d18c03f1752fbb 100644 (file)
 
 __BEGIN_DECLS
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_SETJMP_H__ 202311L
+#endif
+
 #include <bits/setjmp.h>               /* Get `__jmp_buf'.  */
 #include <bits/types/struct___jmp_buf_tag.h>
 
index 6b64917b54cab9d9033c6303afd838fdac2de8df..13cb7fae362043bc576c13fbeb466e0f54d2f080 100644 (file)
 #define _INTTYPES_H    1
 
 #include <features.h>
+
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_INTTYPES_H__ 202311L
+#endif
+
 /* Get the type definitions.  */
 #include <stdint.h>
 
index 302230914cdf0e5cd0dfb569804c9afff3d32133..814718a366d4259e49ae474a051f721051c91dcc 100644 (file)
 #include <bits/wchar.h>
 #include <bits/wordsize.h>
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_STDINT_H__ 202311L
+#endif
+
 /* Exact integral types.  */
 
 /* Signed.  */
index 4a79c612de6b929201a4b006dd252c4a20ff7c3f..a1ea0036586441bdf895e565a45d8255715d51f6 100644 (file)
@@ -35,6 +35,10 @@ __BEGIN_DECLS
 
 #define        _STDLIB_H       1
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_STDLIB_H__ 202311L
+#endif
+
 #if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H
 /* XPG requires a few symbols from <sys/wait.h> being defined.  */
 # include <bits/waitflags.h>
index 1dc5995c17847c269f914d52123bbe54c69a618d..b8747506db9a124b67d7b3ac50b5442ec8f9fa52 100644 (file)
 
 __BEGIN_DECLS
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_STRING_H__ 202311L
+#endif
+
 /* Get size_t and NULL from <stddef.h>.  */
 #define        __need_size_t
 #define        __need_NULL
index 4913508d861f470805007e250270012303562c1e..ca4f2828de99c3bf8e7e2945da1fc74b51434e74 100644 (file)
 #define __need_NULL
 #include <stddef.h>
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_TIME_H__ 202311L
+#endif
+
 /* This defines CLOCKS_PER_SEC, which is the number of processor clock
    ticks per second, and possibly a number of other constants.   */
 #include <bits/time.h>
index 335bfa343d62f7b9beb80c2d744ff84b351eb6ad..c774b1cd34a21880225b488aa734226ce9a5a7fb 100644 (file)
 #include <bits/types.h>
 #include <bits/types/mbstate_t.h>
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_UCHAR_H__ 202311L
+#endif
+
 /* Declare the C23 char8_t typedef in C23 modes, but only if the C++
   __cpp_char8_t feature test macro is not defined.  */
 #if __GLIBC_USE (ISOC23) && !defined __cpp_char8_t
index 19f71f90cfcf361863263eee3018fec84fd1379b..e7170d2173cfe3d0b74d77807e81ef58b668a2a0 100644 (file)
@@ -60,6 +60,10 @@ typedef __gnuc_va_list va_list;
 # include <bits/types/locale_t.h>
 #endif
 
+#if __GLIBC_USE (ISOC23)
+# define __STDC_VERSION_WCHAR_H__ 202311L
+#endif
+
 /* Tell the caller that we provide correct C++ prototypes.  */
 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
 # define __CORRECT_ISO_CPP_WCHAR_H_PROTO