diff options
author | Joseph Myers <joseph@codesourcery.com> | 2022-09-07 18:39:28 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2022-09-07 18:39:28 +0000 |
commit | b8cc607f3c1e8371b89158f427a61f28018604a5 (patch) | |
tree | 84d7bcd2b066e677c76ad25ad0c988831f94988e /sysdeps | |
parent | 89d40cacd0aed35e2546513ce01924b879523e46 (diff) | |
download | glibc-b8cc607f3c1e8371b89158f427a61f28018604a5.tar.gz glibc-b8cc607f3c1e8371b89158f427a61f28018604a5.tar.xz glibc-b8cc607f3c1e8371b89158f427a61f28018604a5.zip |
Do not define static_assert or thread_local in headers for C2x
C2x makes static_assert and thread_local into keywords, removing the definitions as macros in assert.h and threads.h. Thus, disable those macros in those glibc headers for C2x. The disabling is done based on a combination of language version and __GNUC_PREREQ, *not* based on __GLIBC_USE (ISOC2X), on the principle that users of the header (when requesting C11 or later APIs - not assert.h for C99 and older API versions) should always have the names static_assert or thread_local available after inclusion of the header, whether as a keyword or as a macro. Thus, when using a compiler without the keywords (whether an older compiler, possibly in C2x mode, or _GNU_SOURCE with any compiler but in an older language mode, for example) the macros should be defined, even when C2x APIs have been requested. The __GNUC_PREREQ conditionals here may well need updating with the versions of other compilers that gained support for these keywords in C2x mode. Tested for x86_64.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/pthread/threads.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h index 687b45c610..13c8f35768 100644 --- a/sysdeps/pthread/threads.h +++ b/sysdeps/pthread/threads.h @@ -27,7 +27,9 @@ __BEGIN_DECLS #include <bits/thread-shared-types.h> #include <bits/types/struct_timespec.h> -#ifndef __cplusplus +#if (!defined __STDC_VERSION__ \ + || __STDC_VERSION__ <= 201710L \ + || !__GNUC_PREREQ (13, 0)) && !defined __cplusplus # define thread_local _Thread_local #endif |