summary refs log tree commit diff
path: root/include/features.h
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2019-08-13 11:26:00 +0000
committerJoseph Myers <joseph@codesourcery.com>2019-08-13 11:26:00 +0000
commit777d75fbc07b98115f4868c3290eb8a5d1f3a5b2 (patch)
tree163caed043feae9018aeccf3c8c9b5724a3d0a6c /include/features.h
parenta33b817f13170b5c24263b92e7e09880fe797d7e (diff)
downloadglibc-777d75fbc07b98115f4868c3290eb8a5d1f3a5b2.tar.gz
glibc-777d75fbc07b98115f4868c3290eb8a5d1f3a5b2.tar.xz
glibc-777d75fbc07b98115f4868c3290eb8a5d1f3a5b2.zip
Add feature test macro _ISOC2X_SOURCE.
This patch starts preparation for C2X support in glibc headers by
adding a feature test macro _ISOC2X_SOURCE and corresponding
__GLIBC_USE (ISOC2X).  (I chose to use the newer __GLIBC_USE style for
this rather than the older __USE_* macros tested with #ifdef.)  As
with other such macros, C2X features are also enabled by compiling for
a standard newer than C17, or by using _GNU_SOURCE.

This patch does not itself enable anything new in the headers for C2X;
that is to be done in followup patches.  (For example, most of the TS
18661-1 functions should be declared for C2X without any
__STDC_WANT_IEC_60559_BFP_EXT__ being needed, but the ones that
18661-1 adds to Annex F because of their close relation to IEEE 754
formats do still need the WANT macro in C2X.)

Once C2X becomes an actual standard we'll presumably move to using the
actual year in the feature test macro and __GLIBC_USE, with some
period when both macro spellings are accepted, as was done with
_ISOC9X_SOURCE.

Tested for x86_64.

	* include/features.h (_ISOC2X_SOURCE): New feature test macro.
	Undefine and define to 1 if [_GNU_SOURCE].
	(__GLIBC_USE_ISOC2X): New macro.  Undefine and redefine depending
	on [_ISOC2X_SOURCE] and [__STDC_VERSION__ > 201710L].
	(__USE_ISOC11): Also define to 1 if [_ISOC2X_SOURCE].
	(__USE_ISOC99): Likewise.
	(__USE_ISOC95): Likewise.
	* manual/creature.texi (_ISOC2X_SOURCE): Document.
Diffstat (limited to 'include/features.h')
-rw-r--r--include/features.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/include/features.h b/include/features.h
index bf47d881dd..8187539581 100644
--- a/include/features.h
+++ b/include/features.h
@@ -24,6 +24,7 @@
    __STRICT_ANSI__	ISO Standard C.
    _ISOC99_SOURCE	Extensions to ISO C89 from ISO C99.
    _ISOC11_SOURCE	Extensions to ISO C99 from ISO C11.
+   _ISOC2X_SOURCE	Extensions to ISO C99 from ISO C2X.
    __STDC_WANT_LIB_EXT2__
 			Extensions to ISO C99 from TR 27431-2:2010.
    __STDC_WANT_IEC_60559_BFP_EXT__
@@ -139,6 +140,7 @@
 #undef	__USE_GNU
 #undef	__USE_FORTIFY_LEVEL
 #undef	__KERNEL_STRICT_NAMES
+#undef	__GLIBC_USE_ISOC2X
 #undef	__GLIBC_USE_DEPRECATED_GETS
 #undef	__GLIBC_USE_DEPRECATED_SCANF
 
@@ -195,6 +197,8 @@
 # define _ISOC99_SOURCE	1
 # undef  _ISOC11_SOURCE
 # define _ISOC11_SOURCE	1
+# undef  _ISOC2X_SOURCE
+# define _ISOC2X_SOURCE	1
 # undef  _POSIX_SOURCE
 # define _POSIX_SOURCE	1
 # undef  _POSIX_C_SOURCE
@@ -216,26 +220,37 @@
 #if (defined _DEFAULT_SOURCE					\
      || (!defined __STRICT_ANSI__				\
 	 && !defined _ISOC99_SOURCE && !defined _ISOC11_SOURCE	\
+	 && !defined _ISOC2X_SOURCE				\
 	 && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE	\
 	 && !defined _XOPEN_SOURCE))
 # undef  _DEFAULT_SOURCE
 # define _DEFAULT_SOURCE	1
 #endif
 
+/* This is to enable the ISO C2X extension.  */
+#if (defined _ISOC2X_SOURCE \
+     || (defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L))
+# define __GLIBC_USE_ISOC2X	1
+#else
+# define __GLIBC_USE_ISOC2X	0
+#endif
+
 /* This is to enable the ISO C11 extension.  */
-#if (defined _ISOC11_SOURCE \
+#if (defined _ISOC11_SOURCE || defined _ISOC2X_SOURCE \
      || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L))
 # define __USE_ISOC11	1
 #endif
 
 /* This is to enable the ISO C99 extension.  */
-#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \
+#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE			\
+     || defined _ISOC2X_SOURCE						\
      || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
 # define __USE_ISOC99	1
 #endif
 
 /* This is to enable the ISO C90 Amendment 1:1995 extension.  */
-#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \
+#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE			\
+     || defined _ISOC2X_SOURCE						\
      || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L))
 # define __USE_ISOC95	1
 #endif