+2016-12-16 Joseph Myers <joseph@codesourcery.com>
+
+ * math/fenv.h
+ [__GLIBC_USE (IEC_60559_BFP_EXT) && FE_INVALID && __SUPPORT_SNAN__]
+ (FE_SNANS_ALWAYS_SIGNAL): New macro.
+ * math/test-fe-snans-always-signal.c: New file.
+ * math/Makefile (tests): Add test-fe-snans-always-signal.
+ (CFLAGS-test-fe-snans-always-signal.c): New variable.
+ * manual/arith.texi (Infinity and NaN): Document
+ FE_SNANS_ALWAYS_SIGNAL.
+
2016-12-16 Adhemerval Zanella <adhemerval.zanella@linaro.org>
* string/test-memchr.c (do_test): Typo on ‘byte’ and missing closing
problem.
* New <fenv.h> features from TS 18661-1:2014 are added to libm: the
- fesetexcept, fetestexceptflag, fegetmode and fesetmode functions,
- the femode_t type and the FE_DFL_MODE macro.
+ fesetexcept, fetestexceptflag, fegetmode and fesetmode functions, the
+ femode_t type and the FE_DFL_MODE and FE_SNANS_ALWAYS_SIGNAL macros.
* Integer width macros from TS 18661-1:2014 are added to <limits.h>:
CHAR_WIDTH, SCHAR_WIDTH, UCHAR_WIDTH, SHRT_WIDTH, USHRT_WIDTH, INT_WIDTH,
signaling NaNs.
@end deftypevr
+@comment fenv.h
+@comment ISO
+@deftypevr Macro int FE_SNANS_ALWAYS_SIGNAL
+This macro, defined by TS 18661-1:2014, is defined to @code{1} in
+@file{fenv.h} to indicate that functions and operations with signaling
+NaN inputs and floating-point results always raise the invalid
+exception and return a quiet NaN, even in cases (such as @code{fmax},
+@code{hypot} and @code{pow}) where a quiet NaN input can produce a
+non-NaN result. Because some compiler optimizations may not handle
+signaling NaNs correctly, this macro is only defined if compiler
+support for signaling NaNs is enabled. That support can be enabled
+with the GCC option @option{-fsignaling-nans}.
+@end deftypevr
+
@w{IEEE 754} also allows for another unusual value: negative zero. This
value is produced when you divide a positive number by negative
infinity, or when a negative result is smaller than the limits of
test-fesetexcept-traps test-fetestexceptflag test-femode \
test-femode-traps test-iszero-excess-precision \
test-iseqsig-excess-precision test-flt-eval-method \
- test-fp-ilogb-constants test-fp-llogb-constants $(tests-static)
+ test-fp-ilogb-constants test-fp-llogb-constants \
+ test-fe-snans-always-signal $(tests-static)
tests-static = test-fpucw-static test-fpucw-ieee-static \
test-signgam-uchar-static test-signgam-uchar-init-static \
test-signgam-uint-static test-signgam-uint-init-static \
CFLAGS-test-iseqsig-excess-precision.c = -fexcess-precision=standard
CFLAGS-test-flt-eval-method.c = -fexcess-precision=standard
+CFLAGS-test-fe-snans-always-signal.c = -fsignaling-nans
+
# The -lieee module sets the _LIB_VERSION_ switch to IEEE mode
# for error handling in the -lm functions.
install-lib += libieee.a
# include <bits/fenvinline.h>
#endif
+/* NaN support. */
+
+#if (__GLIBC_USE (IEC_60559_BFP_EXT) \
+ && defined FE_INVALID \
+ && defined __SUPPORT_SNAN__)
+# define FE_SNANS_ALWAYS_SIGNAL 1
+#endif
+
#ifdef __USE_GNU
/* Enable individual exceptions. Will not enable more exceptions than
--- /dev/null
+/* Test FE_SNANS_ALWAYS_SIGNAL definition.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+
+#ifdef FE_INVALID
+# ifndef FE_SNANS_ALWAYS_SIGNAL
+# error "FE_SNANS_ALWAYS_SIGNAL not defined"
+# endif
+#else
+# ifdef FE_SNANS_ALWAYS_SIGNAL
+# error "FE_SNANS_ALWAYS_SIGNAL defined, but no FE_INVALID support"
+# endif
+#endif
+
+int
+do_test (void)
+{
+ /* This is a compilation test. */
+ return 0;
+}
+
+#include <support/test-driver.c>