mirror of
https://sourceware.org/git/glibc.git
synced 2025-12-20 01:12:17 +08:00
Define C23 header version macros
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.
This commit is contained in:
@@ -34,6 +34,12 @@
|
||||
#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
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
|
||||
/* 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
|
||||
@@ -188,6 +188,9 @@
|
||||
# ifndef BOOL_WIDTH
|
||||
# define BOOL_WIDTH 1
|
||||
# endif
|
||||
# ifndef __STDC_VERSION_LIMITS_H__
|
||||
# define __STDC_VERSION_LIMITS_H__ 202311L
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __USE_POSIX
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if __GLIBC_USE (ISOC23)
|
||||
# define __STDC_VERSION_STDIO_H__ 202311L
|
||||
#endif
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
|
||||
__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'. */
|
||||
|
||||
@@ -65,6 +65,10 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if __GLIBC_USE (ISOC23)
|
||||
# define __STDC_VERSION_FENV_H__ 202311L
|
||||
#endif
|
||||
|
||||
/* Floating-point exception handling. */
|
||||
|
||||
/* Clear the supported exceptions represented by EXCEPTS. */
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
#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
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
|
||||
__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>
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@
|
||||
#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>
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
#include <bits/wchar.h>
|
||||
#include <bits/wordsize.h>
|
||||
|
||||
#if __GLIBC_USE (ISOC23)
|
||||
# define __STDC_VERSION_STDINT_H__ 202311L
|
||||
#endif
|
||||
|
||||
/* Exact integral types. */
|
||||
|
||||
/* Signed. */
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
|
||||
__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
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
#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>
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
#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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user