Message ID | alpine.DEB.2.21.1908090001480.5719@digraph.polyomino.org.uk |
---|---|
State | New |
Headers | show |
Series | Add feature test macro _ISOC2X_SOURCE | expand |
* Joseph Myers: > 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.) What happened to the plan to rename the TS 18661-1 functions? Has a formal decision been made? Thanks, Florian
On Fri, 9 Aug 2019, Florian Weimer wrote: > * Joseph Myers: > > > 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.) > > What happened to the plan to rename the TS 18661-1 functions? Has a > formal decision been made? There isn't a plan; there's someone who wants to rename either some or all functions, while the CFP group is against ("3) Renaming functions: Against, since already implemented as is, names fit with pre-part 1 C, consistent with existing C standard, names fit function" - see pages 28-29 of <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2376.pdf>), and no specific decision ("This risk has not yet been evaluated. Several ideas have been discussed to resolve these issue, but none has yet resulted in a proposal that would find consensus." in the editors' report). I don't think that's actually relevant to the feature test macro anyway; it's explicitly stated that the API enabled by the feature test macro might be unstable before C2X is released. (While the ABI would be subject to the usual compatibility rules in the event of API changes that could break ABI compatibility; for example, we should keep compat symbols when changing totalorder to have pointer arguments; because that's considered a defect fix to 18661-1, there would in any case be no need to keep the old totalorder version available as an API as opposed to as an ABI.) Even without renaming it's plausible some 18661-1 functions will not end up in C2X; specifically, the changes to minimum / maximum operations in IEEE 754-2019 could result in fmaxmag / fminmag being removed (see <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2273.pdf>). I expect to have different __GLIBC_USE names for different subsets of 18661-1 (the subset in C2X unconditionally; the subset that's only in C2X when __STDC_WANT_IEC_60559_BFP_EXT__ is defined; any subset that's not in C2X at all so should not be declared for __STDC_WANT_IEC_60559_BFP_EXT__ in strict C2X conformance mode, unless we end up completely obsoleting such names as APIs). Depending on the precise form 18661-3 integration takes there may also be a question about the exact feature test macros for 18661-3 functions corresponding to the functions that, in C2X, need __STDC_WANT_IEC_60559_BFP_EXT__ for float / double / long double (a subset of the ones currently using "__GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN").
* Joseph Myers: > On Fri, 9 Aug 2019, Florian Weimer wrote: > >> * Joseph Myers: >> >> > 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.) >> >> What happened to the plan to rename the TS 18661-1 functions? Has a >> formal decision been made? > > There isn't a plan; there's someone who wants to rename either some or all > functions, while the CFP group is against ("3) Renaming functions: > Against, since already implemented as is, names fit with pre-part 1 C, > consistent with existing C standard, names fit function" - see pages 28-29 > of <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2376.pdf>), and no > specific decision ("This risk has not yet been evaluated. Several ideas > have been discussed to resolve these issue, but none has yet resulted in a > proposal that would find consensus." in the editors' report). I see, thanks for the explanation. Regarding the actual patch, do you expect _ISOC2X_SOURCE to enable C11 and earlier extensions? If not, why not? Thanks, Florian
On Fri, 9 Aug 2019, Florian Weimer wrote: > Regarding the actual patch, do you expect _ISOC2X_SOURCE to enable C11 > and earlier extensions? If not, why not? Here is a version that makes it also enable all the earlier C standard versions. 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. 2019-08-09 Joseph Myers <joseph@codesourcery.com> * 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. diff --git a/NEWS b/NEWS index 4326997ddd..8ca7585c2c 100644 --- a/NEWS +++ b/NEWS @@ -9,7 +9,12 @@ Version 2.31 Major new features: - [Add new features here] +* The GNU C Library now supports a feature test macro _ISOC2X_SOURCE to + enable features from the draft ISO C2X standard. Only some features from + this draft standard are supported by the GNU C Library, and as the draft + is under active development, the set of features enabled by this macro is + liable to change. Features from C2X are also enabled by _GNU_SOURCE, or + by compiling with "gcc -std=gnu2x". Deprecated and removed features, and other changes affecting compatibility: 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 diff --git a/manual/creature.texi b/manual/creature.texi index 8876b2ab77..be5050468b 100644 --- a/manual/creature.texi +++ b/manual/creature.texi @@ -177,6 +177,13 @@ when the compiler uses an earlier language version. If this macro is defined, ISO C11 extensions to ISO C99 are included. @end defvr +@defvr Macro _ISOC2X_SOURCE +@standards{C2X, (none)} +If this macro is defined, ISO C2X extensions to ISO C11 are included. +Only some features from this draft standard are supported by +@theglibc{}. +@end defvr + @defvr Macro __STDC_WANT_LIB_EXT2__ @standards{ISO, (none)} If you define this macro to the value @code{1}, features from ISO/IEC
On Aug 09 2019, Joseph Myers <joseph@codesourcery.com> wrote: > * 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. Ok. Andreas.
diff --git a/NEWS b/NEWS index 4326997ddd..8ca7585c2c 100644 --- a/NEWS +++ b/NEWS @@ -9,7 +9,12 @@ Version 2.31 Major new features: - [Add new features here] +* The GNU C Library now supports a feature test macro _ISOC2X_SOURCE to + enable features from the draft ISO C2X standard. Only some features from + this draft standard are supported by the GNU C Library, and as the draft + is under active development, the set of features enabled by this macro is + liable to change. Features from C2X are also enabled by _GNU_SOURCE, or + by compiling with "gcc -std=gnu2x". Deprecated and removed features, and other changes affecting compatibility: diff --git a/include/features.h b/include/features.h index bf47d881dd..126222ad7a 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,12 +220,21 @@ #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 \ || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) diff --git a/manual/creature.texi b/manual/creature.texi index 8876b2ab77..23c1f834f3 100644 --- a/manual/creature.texi +++ b/manual/creature.texi @@ -177,6 +177,13 @@ when the compiler uses an earlier language version. If this macro is defined, ISO C11 extensions to ISO C99 are included. @end defvr +@defvr Macro _ISOC2X_SOURCE +@standards{C2X, (none)} +If this macro is defined, ISO C2X extensions to ISO C99 are included. +Only some features from this draft standard are supported by +@theglibc{}. +@end defvr + @defvr Macro __STDC_WANT_LIB_EXT2__ @standards{ISO, (none)} If you define this macro to the value @code{1}, features from ISO/IEC