This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Define __STDC_IEC_559* based on __GCC_IEC_559*


include/stdc-predef presently defines __STDC_IEC_559__ and
__STDC_IEC_559_COMPLEX__ unconditionally.  While, like
__STDC_VERSION__, these predefined macros are used to indicate intent
rather than completeness, and generally such macros can only be fully
interpreted in conjunction with conformance documentation for an
implementation rather than on their own when using an implementation
not claiming to be a conforming implementation of a relevant C
standard, there are cases where the intent of the combination of the
compiler configuration and command-line options (such as -ffast-math)
is directly contrary to the Annex F requirements and so it seems
appropriate not to define these macros.

The thread starting at
<https://sourceware.org/ml/libc-alpha/2005-03/msg00196.html> discussed
adding a sysdeps mechanism for controlling these macros, specifically
with regard to ARM software floating point not supporting exceptions
and rounding modes; then end result of that was nothing in glibc and
such a sysdeps mechanism with a <bits/predefs.h> file in EGLIBC (an
architecture-specific version only provided for ARM).

It is however now clear that (contrary to the 2005 thread) glibc does
support configurations without the full exceptions / rounding modes
support, with various changes having gone into libc files and
testcases to handle such configurations better.  I have proposed a GCC
patch <http://gcc.gnu.org/ml/gcc-patches/2013-10/msg01131.html> to
predefine macros __GCC_IEC_559 and __GCC_IEC_559_COMPLEX to indicate
the intent of the GCC configuration and command-line options, with a
view to glibc avoiding defining these __STDC_* macros in cases where
exceptions / rounding modes support is lacking, or where options such
as -ffast-math unambiguously specify an intent contrary to Annex F
(or, as applicable, Annex G) - while still defining them for other
compilers or where the GCC macros indicate intent compatible with the
relevant Annex, in line with the principle of the macros describing
intent rather than completeness.

This is the corresponding glibc patch to use the new GCC macros,
proposed to go in subject to the GCC patch going in there.  Tested
x86_64.

2013-10-15  Joseph Myers  <joseph@codesourcery.com>

	* include/stdc-predef.h [__GCC_IEC_559] (__STDC_IEC_559__): Define
	depending on [__GCC_IEC_559 > 0].
	[__GCC_IEC_559_COMPLEX] (__STDC_IEC_559_COMPLEX__): Define
	depending on [__GCC_IEC_559_COMPLEX > 0].

diff --git a/include/stdc-predef.h b/include/stdc-predef.h
index b9c9967..f8cb2cb 100644
--- a/include/stdc-predef.h
+++ b/include/stdc-predef.h
@@ -26,9 +26,28 @@
    explicitly includes a system header.  GCC knows the name of this
    header in order to preinclude it.  */
 
-/* We do support the IEC 559 math functionality, real and complex.  */
-#define __STDC_IEC_559__		1
-#define __STDC_IEC_559_COMPLEX__	1
+/* glibc's intent is to support the IEC 559 math functionality, real
+   and complex.  If the GCC (4.9 and later) predefined macros
+   specifying compiler intent are available, use them to determine
+   whether the overall intent is to support these features; otherwise,
+   presume an older compiler has intent to support these features and
+   define these macros by default.  */
+
+#ifdef __GCC_IEC_559
+# if __GCC_IEC_559 > 0
+#  define __STDC_IEC_559__		1
+# endif
+#else
+# define __STDC_IEC_559__		1
+#endif
+
+#ifdef __GCC_IEC_559_COMPLEX
+# if __GCC_IEC_559_COMPLEX > 0
+#  define __STDC_IEC_559_COMPLEX__	1
+# endif
+#else
+# define __STDC_IEC_559_COMPLEX__	1
+#endif
 
 /* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /
    Unicode 6.0.  */

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]