This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Add predefined macros for library use in defining __STDC_IEC_559*
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Cc: <dje dot gcc at gmail dot com>
- Date: Tue, 15 Oct 2013 21:22:40 +0000
- Subject: Add predefined macros for library use in defining __STDC_IEC_559*
- Authentication-results: sourceware.org; auth=none
ISO C99 and C11 specify various predefined macros for implementation
properties that describe library features, or features of the
combination of the compiler and library implementations. In such
cases, GCC does not predefine the macros but provides a mechanism for
the library implementation to provide a stdc-predef.h header with
definitions of those macros, and implicitly preincludes that header in
compilations to meet the standard requirement for the macro
definitions to be constant throughout the translation unit.
Two such macros are __STDC_IEC_559__ and __STDC_IEC_559_COMPLEX__,
relating to IEEE 754 floating-point arithmetic support. Now, for
neither of those are the relevant features fully implemented in GCC
(or most other C99 compilers), but as with __STDC_VERSION__ it's
appropriate to treat these macros as indicating intent rather than
completeness, given that the GCC documentation specifically disclaims
completeness of C99 or C11 support.
Intent can be unclear in some cases, but it's reasonably clear that if
the user used -ffast-math, for example, that has specified an intent
to enable optimizations that conflict with the C99/C11 Annex F
requirements. And if the compiler configuration uses software
floating point without exceptions and rounding modes support (and
making software floating point support exceptions and rounding modes
depends on compiler and library cooperation, and likely isn't desired
for many configurations that use software floating point), that is
also prevents proper Annex F support.
<https://sourceware.org/ml/libc-alpha/2005-03/msg00196.html> suggested
a glibc sysdeps mechanism for controlling whether these macros are
defined, but that would only handle architecture-specific conditionals
for software floating point. There are various GCC options that
indicate intent contrary to Annex F, many of which do not predefine
macros that could be used to control the __STDC_* definitions
appropriately.
This patch adds new predefined macros __GCC_IEC_559 and
__GCC_IEC_559_COMPLEX, whose values specify the intent of the compiler
configuration and command-line options and so can be used by
stdc-predef.h to determine whether to define the __STDC_* macros. The
detailed semantics are given in the documentation changes;
distinguishing whether IEEE 754-2008 is supported is intended to allow
use in future to control the definition of __STDC_IEC_60559_BFP__ if
support for TS 18661-1 (latest draft: WG14 N1756) were to be added to
glibc (again, there are compiler features involved, quite complicated
to implement in the case of the static rounding direction pragmas, but
the macros are treated as being about intent rather than
completeness).
(It is quite likely there is *also* use for predefined macros for
various individual floating-point options that don't currently have
them, to facilitate optimization of library calls by indicating to the
library what the requirements are for accuracy, rounding mode
handling, exception handling etc. of library functions being called
from the current translatin unit, and so allow calls to be directed to
appropriate optimized function variants. But that's independent of
the new macros in support of __STDC_*; I don't think __STDC_* can
readily be computed from macros for individual options, given the
possibility of new options for new optimizations that may also
conflict with Annex F requirements.)
The default macro definitions are based on whether there is an adddf3
insn pattern - except on powerpc*-*-linux*, where a separate target
hook implementation is used because of software floating point support
in glibc handling exceptions and rounding modes - and on various
command-line options. (-ftrapping-math and -frounding-math are not
considered because in C99/C11 terms those relate to the default state
of the FENV_ACCESS pragma, which is permitted to be "off".)
There is a "???" comment regarding -ffp-contract, where logically
-ffp-contract=fast should be considered to conflict with Annex F but
options such as -std=c99 don't do anything to change the default to
-ffp-contract=on (= -ffp-contract=off at present). I looked back at
some of the discussion (Oct/Nov 2010) from when -ffp-contract was
added, but didn't find anything giving a reason why conformance
options don't do this, as I suggested in
<http://gcc.gnu.org/ml/gcc-patches/2010-10/msg01951.html> that they
should. So in the absence of someone coming up with such a reason I'd
be inclined to make such options enable -ffp-contract=on, just as they
enable -fexcess-precision=standard on 32-bit x86, and add a
corresponding check when setting the new macros.
Portable testcases for these macros are difficult, given the inherent
system-dependency of their values (which is part of the point of
adding them), but tests are added that various options force the
values of the macros to 0, along with a test enabled for i?86-*-linux*
x86_64-*-linux* powerpc*-*-linux* that the values are 2 on those
targets with -std=c11.
Bootstrapped with no regressions on x86_64-unknown-linux-gnu, and
tested with no regressions with cross to powerpc-linux-gnu
(soft-float). OK to commit (hook addition, rs6000/powerpc changes)?
2013-10-15 Joseph Myers <joseph@codesourcery.com>
* doc/cpp.texi (__GCC_IEC_559, __GCC_IEC_559_COMPLEX): Document
macros.
* target.def (float_exceptions_rounding_supported_p): New hook.
* targhooks.c (default_float_exceptions_rounding_supported_p): New
function.
* targhooks.h (default_float_exceptions_rounding_supported_p):
Declare.
* doc/tm.texi.in (TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P):
New @hook.
* doc/tm.texi: Regenerate.
* config.gcc (powerpc*-*-linux*): Set extra_objs.
* config/rs6000/rs6000-linux.c: New file.
* config/rs6000/rs6000-protos.h
(rs6000_linux_float_exceptions_rounding_supported_p): Declare.
* config/rs6000/linux.h
(TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P): New macro.
* config/rs6000/linux64.h
(TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P): Likewise.
* config/rs6000/t-linux (rs6000-linux.o): New rule.
* config/rs6000/t-linux64 (rs6000-linux.o): Likewise.
c-family:
2013-10-15 Joseph Myers <joseph@codesourcery.com>
* c-cppbuiltin.c (cpp_iec_559_value, cpp_iec_559_complex_value):
New functions.
(c_cpp_builtins): Define __GCC_IEC_559 and __GCC_IEC_559_COMPLEX.
testsuite:
2013-10-15 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/iec-559-macros-1.c, gcc.dg/iec-559-macros-2.c,
gcc.dg/iec-559-macros-3.c, gcc.dg/iec-559-macros-4.c,
gcc.dg/iec-559-macros-5.c, gcc.dg/iec-559-macros-6.c,
gcc.dg/iec-559-macros-7.c, gcc.dg/iec-559-macros-8.c,
gcc.dg/iec-559-macros-9.c: New tests.
Index: gcc/config/rs6000/t-linux64
===================================================================
--- gcc/config/rs6000/t-linux64 (revision 203606)
+++ gcc/config/rs6000/t-linux64 (working copy)
@@ -30,3 +30,7 @@ MULTILIB_DIRNAMES := 64 32
MULTILIB_EXTRA_OPTS :=
MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
+
+rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
Index: gcc/config/rs6000/linux.h
===================================================================
--- gcc/config/rs6000/linux.h (revision 203606)
+++ gcc/config/rs6000/linux.h (working copy)
@@ -145,3 +145,9 @@
/* Static stack checking is supported by means of probes. */
#define STACK_CHECK_STATIC_BUILTIN 1
+
+/* Software floating point support for exceptions and rounding modes
+ depends on the C library in use. */
+#undef TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P
+#define TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P \
+ rs6000_linux_float_exceptions_rounding_supported_p
Index: gcc/config/rs6000/rs6000-linux.c
===================================================================
--- gcc/config/rs6000/rs6000-linux.c (revision 0)
+++ gcc/config/rs6000/rs6000-linux.c (revision 0)
@@ -0,0 +1,38 @@
+/* Functions for Linux on PowerPC.
+ Copyright (C) 2013 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "rtl.h"
+#include "tm_p.h"
+
+/* Implement TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P. */
+
+bool
+rs6000_linux_float_exceptions_rounding_supported_p (void)
+{
+ /* glibc has support for exceptions and rounding modes for software
+ floating point. */
+ if (OPTION_GLIBC)
+ return true;
+ else
+ return TARGET_DF_INSN;
+}
Index: gcc/config/rs6000/linux64.h
===================================================================
--- gcc/config/rs6000/linux64.h (revision 203606)
+++ gcc/config/rs6000/linux64.h (working copy)
@@ -558,3 +558,9 @@ extern int dot_symbols;
/* The default value isn't sufficient in 64-bit mode. */
#define STACK_CHECK_PROTECT (TARGET_64BIT ? 16 * 1024 : 12 * 1024)
+
+/* Software floating point support for exceptions and rounding modes
+ depends on the C library in use. */
+#undef TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P
+#define TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P \
+ rs6000_linux_float_exceptions_rounding_supported_p
Index: gcc/config/rs6000/t-linux
===================================================================
--- gcc/config/rs6000/t-linux (revision 203606)
+++ gcc/config/rs6000/t-linux (working copy)
@@ -7,3 +7,7 @@ else
MULTIARCH_DIRNAME = powerpc-linux-gnu
endif
endif
+
+rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
Index: gcc/config/rs6000/rs6000-protos.h
===================================================================
--- gcc/config/rs6000/rs6000-protos.h (revision 203606)
+++ gcc/config/rs6000/rs6000-protos.h (working copy)
@@ -210,4 +210,6 @@ void rs6000_final_prescan_insn (rtx, rtx *operand,
extern bool rs6000_hard_regno_mode_ok_p[][FIRST_PSEUDO_REGISTER];
extern unsigned char rs6000_class_max_nregs[][LIM_REG_CLASSES];
extern unsigned char rs6000_hard_regno_nregs[][FIRST_PSEUDO_REGISTER];
+
+extern bool rs6000_linux_float_exceptions_rounding_supported_p (void);
#endif /* rs6000-protos.h */
Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi (revision 203606)
+++ gcc/doc/tm.texi (working copy)
@@ -768,6 +768,10 @@ Define this macro to 1 if your target needs this f
is 0.
@end defmac
+@deftypefn {Target Hook} bool TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P (void)
+Returns true if the target supports IEEE 754 floating-point exceptions and rounding modes, false otherwise. This is intended to relate to the @code{float} and @code{double} types, but not necessarily @code{long double}. By default, returns true if the @code{adddf3} instruction pattern is available and false otherwise, on the assumption that hardware floating point supports exceptions and rounding modes but software floating point does not.
+@end deftypefn
+
@node Per-Function Data
@section Defining data structures for per-function information.
@cindex per-function data
Index: gcc/doc/tm.texi.in
===================================================================
--- gcc/doc/tm.texi.in (revision 203606)
+++ gcc/doc/tm.texi.in (working copy)
@@ -744,6 +744,8 @@ Define this macro to 1 if your target needs this f
is 0.
@end defmac
+@hook TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P
+
@node Per-Function Data
@section Defining data structures for per-function information.
@cindex per-function data
Index: gcc/doc/cpp.texi
===================================================================
--- gcc/doc/cpp.texi (revision 203606)
+++ gcc/doc/cpp.texi (working copy)
@@ -2389,6 +2389,40 @@ These macros are defined with value 1 if the backe
the include file @file{math.h} can define the macros
@code{FP_FAST_FMA}, @code{FP_FAST_FMAF}, and @code{FP_FAST_FMAL}
for compatibility with the 1999 C standard.
+
+@item __GCC_IEC_559
+This macro is defined to indicate the intended level of support for
+IEEE 754 (IEC 60559) floating-point arithmetic. It expands to a
+nonnegative integer value. If 0, it indicates that the combination of
+the compiler configuration and the command-line options is not
+intended to support IEEE 754 arithmetic for @code{float} and
+@code{double} as defined in C99 and C11 Annex F (for example, that the
+standard rounding modes and exceptions are not supported, or that
+optimizations are enabled that conflict with IEEE 754 semantics). If
+1, it indicates that IEEE 754 arithmetic is intended to be supported;
+this does not mean that all relevant language features are supported
+by GCC. If 2 or more, it additionally indicates support for IEEE
+754-2008 (in particular, that the binary encodings for quiet and
+signaling NaNs are as specified in IEEE 754-2008).
+
+This macro does not indicate the default state of command-line options
+that control optimizations that C99 and C11 permit to be controlled by
+standard pragmas, where those standards do not require a particular
+default state. It does not indicate whether optimizations respect
+signaling NaN semantics (the macro for that is
+@code{__SUPPORT_SNAN__}). It does not indicate support for decimal
+floating point or the IEEE 754 binary16 and binary128 types.
+
+@item __GCC_IEC_559_COMPLEX
+This macro is defined to indicate the intended level of support for
+IEEE 754 (IEC 60559) floating-point arithmetic for complex numbers, as
+defined in C99 and C11 Annex G. It expands to a nonnegative integer
+value. If 0, it indicates that the combination of the compiler
+configuration and the command-line options is not intended to support
+Annex G requirements (for example, because @option{-fcx-limited-range}
+was used). If 1 or more, it indicates that it is intended to support
+those requirements; this does not mean that all relevant language
+features are supported by GCC.
@end table
@node System-specific Predefined Macros
Index: gcc/targhooks.c
===================================================================
--- gcc/targhooks.c (revision 203606)
+++ gcc/targhooks.c (working copy)
@@ -435,6 +435,19 @@ targhook_float_words_big_endian (void)
return !!FLOAT_WORDS_BIG_ENDIAN;
}
+/* True if the target supports floating-point exceptions and rounding
+ modes. */
+
+bool
+default_float_exceptions_rounding_supported_p (void)
+{
+#ifdef HAVE_adddf3
+ return HAVE_adddf3;
+#else
+ return false;
+#endif
+}
+
/* True if the target supports decimal floating point. */
bool
Index: gcc/targhooks.h
===================================================================
--- gcc/targhooks.h (revision 203606)
+++ gcc/targhooks.h (working copy)
@@ -69,6 +69,7 @@ extern tree default_mangle_assembler_name (const c
extern bool default_scalar_mode_supported_p (enum machine_mode);
extern bool targhook_words_big_endian (void);
extern bool targhook_float_words_big_endian (void);
+extern bool default_float_exceptions_rounding_supported_p (void);
extern bool default_decimal_float_supported_p (void);
extern bool default_fixed_point_supported_p (void);
Index: gcc/c-family/c-cppbuiltin.c
===================================================================
--- gcc/c-family/c-cppbuiltin.c (revision 203606)
+++ gcc/c-family/c-cppbuiltin.c (working copy)
@@ -683,6 +683,92 @@ cpp_atomic_builtins (cpp_reader *pfile)
(have_swap[psize]? 2 : 1));
}
+/* Return the value for __GCC_IEC_559. */
+static int
+cpp_iec_559_value (void)
+{
+ /* The default is support for IEEE 754-2008. */
+ int ret = 2;
+
+ /* float and double must be binary32 and binary64. If they are but
+ with reversed NaN convention, at most IEEE 754-1985 is
+ supported. */
+ const struct real_format *ffmt
+ = REAL_MODE_FORMAT (TYPE_MODE (float_type_node));
+ const struct real_format *dfmt
+ = REAL_MODE_FORMAT (TYPE_MODE (double_type_node));
+ if (!ffmt->qnan_msb_set || !dfmt->qnan_msb_set)
+ ret = 1;
+ if (ffmt->b != 2
+ || ffmt->p != 24
+ || ffmt->pnan != 24
+ || ffmt->emin != -125
+ || ffmt->emax != 128
+ || ffmt->signbit_rw != 31
+ || ffmt->round_towards_zero
+ || !ffmt->has_sign_dependent_rounding
+ || !ffmt->has_nans
+ || !ffmt->has_inf
+ || !ffmt->has_denorm
+ || !ffmt->has_signed_zero
+ || dfmt->b != 2
+ || dfmt->p != 53
+ || dfmt->pnan != 53
+ || dfmt->emin != -1021
+ || dfmt->emax != 1024
+ || dfmt->signbit_rw != 63
+ || dfmt->round_towards_zero
+ || !dfmt->has_sign_dependent_rounding
+ || !dfmt->has_nans
+ || !dfmt->has_inf
+ || !dfmt->has_denorm
+ || !dfmt->has_signed_zero)
+ ret = 0;
+
+ /* In strict C standards conformance mode, consider unpredictable
+ excess precision to mean lack of IEEE 754 support. ??? The same
+ should apply to unpredictable contraction, but at present
+ standards conformance options do not enable conforming
+ contraction. For C++, and outside strict conformance mode, do
+ not consider these options to mean lack of IEEE 754 support. */
+ if (flag_iso
+ && !c_dialect_cxx ()
+ && TARGET_FLT_EVAL_METHOD != 0
+ && flag_excess_precision != EXCESS_PRECISION_STANDARD)
+ ret = 0;
+
+ /* Various options are contrary to IEEE 754 semantics. */
+ if (flag_unsafe_math_optimizations
+ || flag_associative_math
+ || flag_reciprocal_math
+ || flag_finite_math_only
+ || !flag_signed_zeros
+ || flag_single_precision_constant)
+ ret = 0;
+
+ /* If the target does not support IEEE 754 exceptions and rounding
+ modes, consider IEEE 754 support to be absent. */
+ if (!targetm.float_exceptions_rounding_supported_p ())
+ ret = 0;
+
+ return ret;
+}
+
+/* Return the value for __GCC_IEC_559_COMPLEX. */
+static int
+cpp_iec_559_complex_value (void)
+{
+ /* The value is no bigger than that of __GCC_IEC_559. */
+ int ret = cpp_iec_559_value ();
+
+ /* Some options are contrary to the required default state of the
+ CX_LIMITED_RANGE pragma. */
+ if (flag_complex_method != 2)
+ ret = 0;
+
+ return ret;
+}
+
/* Hook that registers front end and target-specific built-ins. */
void
c_cpp_builtins (cpp_reader *pfile)
@@ -760,6 +846,13 @@ c_cpp_builtins (cpp_reader *pfile)
/* stdint.h and the testsuite need to know these. */
builtin_define_stdint_macros ();
+ /* Provide information for library headers to determine whether to
+ define macros such as __STDC_IEC_559__ and
+ __STDC_IEC_559_COMPLEX__. */
+ builtin_define_with_int_value ("__GCC_IEC_559", cpp_iec_559_value ());
+ builtin_define_with_int_value ("__GCC_IEC_559_COMPLEX",
+ cpp_iec_559_complex_value ());
+
/* float.h needs to know this. */
builtin_define_with_int_value ("__FLT_EVAL_METHOD__",
TARGET_FLT_EVAL_METHOD);
Index: gcc/target.def
===================================================================
--- gcc/target.def (revision 203606)
+++ gcc/target.def (working copy)
@@ -1935,6 +1935,18 @@ DEFHOOK_UNDOC
bool, (void),
targhook_float_words_big_endian)
+DEFHOOK
+(float_exceptions_rounding_supported_p,
+ "Returns true if the target supports IEEE 754 floating-point exceptions\
+ and rounding modes, false otherwise. This is intended to relate to the\
+ @code{float} and @code{double} types, but not necessarily @code{long double}.\
+ By default, returns true if the @code{adddf3} instruction pattern is\
+ available and false otherwise, on the assumption that hardware floating\
+ point supports exceptions and rounding modes but software floating point\
+ does not.",
+ bool, (void),
+ default_float_exceptions_rounding_supported_p)
+
/* True if the target supports decimal floating point. */
DEFHOOK
(decimal_float_supported_p,
Index: gcc/testsuite/gcc.dg/iec-559-macros-5.c
===================================================================
--- gcc/testsuite/gcc.dg/iec-559-macros-5.c (revision 0)
+++ gcc/testsuite/gcc.dg/iec-559-macros-5.c (revision 0)
@@ -0,0 +1,23 @@
+/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */
+/* { dg-do preprocess } */
+/* { dg-options "-fno-signed-zeros" } */
+
+#ifndef __GCC_IEC_559
+# error "__GCC_IEC_559 not defined"
+#endif
+#ifndef __GCC_IEC_559_COMPLEX
+# error "__GCC_IEC_559_COMPLEX not defined"
+#endif
+#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559
+# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559"
+#endif
+#if __GCC_IEC_559_COMPLEX < 0
+# error "__GCC_IEC_559_COMPLEX < 0"
+#endif
+
+#if __GCC_IEC_559 != 0
+# error "__GCC_IEC_559 != 0 with -fno-signed-zeros"
+#endif
+#if __GCC_IEC_559_COMPLEX != 0
+# error "__GCC_IEC_559_COMPLEX != 0 with -fno-signed-zeros"
+#endif
Index: gcc/testsuite/gcc.dg/iec-559-macros-9.c
===================================================================
--- gcc/testsuite/gcc.dg/iec-559-macros-9.c (revision 0)
+++ gcc/testsuite/gcc.dg/iec-559-macros-9.c (revision 0)
@@ -0,0 +1,23 @@
+/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */
+/* { dg-do preprocess { target i?86-*-linux* x86_64-*-linux* powerpc*-*-linux* } } */
+/* { dg-options "-std=c11" } */
+
+#ifndef __GCC_IEC_559
+# error "__GCC_IEC_559 not defined"
+#endif
+#ifndef __GCC_IEC_559_COMPLEX
+# error "__GCC_IEC_559_COMPLEX not defined"
+#endif
+#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559
+# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559"
+#endif
+#if __GCC_IEC_559_COMPLEX < 0
+# error "__GCC_IEC_559_COMPLEX < 0"
+#endif
+
+#if __GCC_IEC_559 < 2
+# error "__GCC_IEC_559 < 2"
+#endif
+#if __GCC_IEC_559_COMPLEX < 2
+# error "__GCC_IEC_559_COMPLEX < 2"
+#endif
Index: gcc/testsuite/gcc.dg/iec-559-macros-2.c
===================================================================
--- gcc/testsuite/gcc.dg/iec-559-macros-2.c (revision 0)
+++ gcc/testsuite/gcc.dg/iec-559-macros-2.c (revision 0)
@@ -0,0 +1,23 @@
+/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */
+/* { dg-do preprocess } */
+/* { dg-options "-funsafe-math-optimizations" } */
+
+#ifndef __GCC_IEC_559
+# error "__GCC_IEC_559 not defined"
+#endif
+#ifndef __GCC_IEC_559_COMPLEX
+# error "__GCC_IEC_559_COMPLEX not defined"
+#endif
+#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559
+# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559"
+#endif
+#if __GCC_IEC_559_COMPLEX < 0
+# error "__GCC_IEC_559_COMPLEX < 0"
+#endif
+
+#if __GCC_IEC_559 != 0
+# error "__GCC_IEC_559 != 0 with -funsafe-math-optimizations"
+#endif
+#if __GCC_IEC_559_COMPLEX != 0
+# error "__GCC_IEC_559_COMPLEX != 0 with -funsafe-math-optimizations"
+#endif
Index: gcc/testsuite/gcc.dg/iec-559-macros-6.c
===================================================================
--- gcc/testsuite/gcc.dg/iec-559-macros-6.c (revision 0)
+++ gcc/testsuite/gcc.dg/iec-559-macros-6.c (revision 0)
@@ -0,0 +1,23 @@
+/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */
+/* { dg-do preprocess } */
+/* { dg-options "-fsingle-precision-constant" } */
+
+#ifndef __GCC_IEC_559
+# error "__GCC_IEC_559 not defined"
+#endif
+#ifndef __GCC_IEC_559_COMPLEX
+# error "__GCC_IEC_559_COMPLEX not defined"
+#endif
+#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559
+# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559"
+#endif
+#if __GCC_IEC_559_COMPLEX < 0
+# error "__GCC_IEC_559_COMPLEX < 0"
+#endif
+
+#if __GCC_IEC_559 != 0
+# error "__GCC_IEC_559 != 0 with -fsingle-precision-constant"
+#endif
+#if __GCC_IEC_559_COMPLEX != 0
+# error "__GCC_IEC_559_COMPLEX != 0 with -fsingle-precision-constant"
+#endif
Index: gcc/testsuite/gcc.dg/iec-559-macros-3.c
===================================================================
--- gcc/testsuite/gcc.dg/iec-559-macros-3.c (revision 0)
+++ gcc/testsuite/gcc.dg/iec-559-macros-3.c (revision 0)
@@ -0,0 +1,23 @@
+/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */
+/* { dg-do preprocess } */
+/* { dg-options "-freciprocal-math" } */
+
+#ifndef __GCC_IEC_559
+# error "__GCC_IEC_559 not defined"
+#endif
+#ifndef __GCC_IEC_559_COMPLEX
+# error "__GCC_IEC_559_COMPLEX not defined"
+#endif
+#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559
+# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559"
+#endif
+#if __GCC_IEC_559_COMPLEX < 0
+# error "__GCC_IEC_559_COMPLEX < 0"
+#endif
+
+#if __GCC_IEC_559 != 0
+# error "__GCC_IEC_559 != 0 with -freciprocal-math"
+#endif
+#if __GCC_IEC_559_COMPLEX != 0
+# error "__GCC_IEC_559_COMPLEX != 0 with -freciprocal-math"
+#endif
Index: gcc/testsuite/gcc.dg/iec-559-macros-7.c
===================================================================
--- gcc/testsuite/gcc.dg/iec-559-macros-7.c (revision 0)
+++ gcc/testsuite/gcc.dg/iec-559-macros-7.c (revision 0)
@@ -0,0 +1,20 @@
+/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */
+/* { dg-do preprocess } */
+/* { dg-options "-fcx-limited-range" } */
+
+#ifndef __GCC_IEC_559
+# error "__GCC_IEC_559 not defined"
+#endif
+#ifndef __GCC_IEC_559_COMPLEX
+# error "__GCC_IEC_559_COMPLEX not defined"
+#endif
+#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559
+# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559"
+#endif
+#if __GCC_IEC_559_COMPLEX < 0
+# error "__GCC_IEC_559_COMPLEX < 0"
+#endif
+
+#if __GCC_IEC_559_COMPLEX != 0
+# error "__GCC_IEC_559_COMPLEX != 0 with -fcx-limited-range"
+#endif
Index: gcc/testsuite/gcc.dg/iec-559-macros-4.c
===================================================================
--- gcc/testsuite/gcc.dg/iec-559-macros-4.c (revision 0)
+++ gcc/testsuite/gcc.dg/iec-559-macros-4.c (revision 0)
@@ -0,0 +1,23 @@
+/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */
+/* { dg-do preprocess } */
+/* { dg-options "-ffinite-math-only" } */
+
+#ifndef __GCC_IEC_559
+# error "__GCC_IEC_559 not defined"
+#endif
+#ifndef __GCC_IEC_559_COMPLEX
+# error "__GCC_IEC_559_COMPLEX not defined"
+#endif
+#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559
+# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559"
+#endif
+#if __GCC_IEC_559_COMPLEX < 0
+# error "__GCC_IEC_559_COMPLEX < 0"
+#endif
+
+#if __GCC_IEC_559 != 0
+# error "__GCC_IEC_559 != 0 with -ffinite-math-only"
+#endif
+#if __GCC_IEC_559_COMPLEX != 0
+# error "__GCC_IEC_559_COMPLEX != 0 with -ffinite-math-only"
+#endif
Index: gcc/testsuite/gcc.dg/iec-559-macros-8.c
===================================================================
--- gcc/testsuite/gcc.dg/iec-559-macros-8.c (revision 0)
+++ gcc/testsuite/gcc.dg/iec-559-macros-8.c (revision 0)
@@ -0,0 +1,20 @@
+/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */
+/* { dg-do preprocess } */
+/* { dg-options "-fcx-fortran-rules" } */
+
+#ifndef __GCC_IEC_559
+# error "__GCC_IEC_559 not defined"
+#endif
+#ifndef __GCC_IEC_559_COMPLEX
+# error "__GCC_IEC_559_COMPLEX not defined"
+#endif
+#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559
+# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559"
+#endif
+#if __GCC_IEC_559_COMPLEX < 0
+# error "__GCC_IEC_559_COMPLEX < 0"
+#endif
+
+#if __GCC_IEC_559_COMPLEX != 0
+# error "__GCC_IEC_559_COMPLEX != 0 with -fcx-fortran-rules"
+#endif
Index: gcc/testsuite/gcc.dg/iec-559-macros-1.c
===================================================================
--- gcc/testsuite/gcc.dg/iec-559-macros-1.c (revision 0)
+++ gcc/testsuite/gcc.dg/iec-559-macros-1.c (revision 0)
@@ -0,0 +1,16 @@
+/* Test __GCC_IEC_559 and __GCC_IEC_559_COMPLEX macros values. */
+/* { dg-do preprocess } */
+/* { dg-options "" } */
+
+#ifndef __GCC_IEC_559
+# error "__GCC_IEC_559 not defined"
+#endif
+#ifndef __GCC_IEC_559_COMPLEX
+# error "__GCC_IEC_559_COMPLEX not defined"
+#endif
+#if __GCC_IEC_559_COMPLEX > __GCC_IEC_559
+# error "__GCC_IEC_559_COMPLEX > __GCC_IEC_559"
+#endif
+#if __GCC_IEC_559_COMPLEX < 0
+# error "__GCC_IEC_559_COMPLEX < 0"
+#endif
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc (revision 203606)
+++ gcc/config.gcc (working copy)
@@ -2198,6 +2198,7 @@ powerpc*-*-linux*)
tm_file="${tm_file} dbxelf.h elfos.h freebsd-spec.h rs6000/sysv4.h"
extra_options="${extra_options} rs6000/sysv4.opt"
tmake_file="rs6000/t-fprules rs6000/t-ppcos ${tmake_file} rs6000/t-ppccomm"
+ extra_objs="$extra_objs rs6000-linux.o"
case ${target} in
powerpc*le-*-*)
tm_file="${tm_file} rs6000/sysv4le.h" ;;
--
Joseph S. Myers
joseph@codesourcery.com