@@ -113,12 +113,13 @@ tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
tests-static = test-fpucw-static test-fpucw-ieee-static
# We do the `long double' tests only if this data type is available and
# distinct from `double'.
-test-longdouble-yes = test-ldouble test-ildoubl
+test-longdouble-yes = test-ldouble test-ildoubl test-ldouble-finite
ifneq (no,$(PERL))
libm-vec-tests = $(addprefix test-,$(libmvec-tests))
libm-tests = test-float test-double $(test-longdouble-$(long-double-fcts)) \
- test-ifloat test-idouble $(libm-vec-tests)
+ test-ifloat test-idouble test-float-finite test-double-finite \
+ $(libm-vec-tests)
libm-tests.o = $(addsuffix .o,$(libm-tests))
tests += $(libm-tests)
@@ -141,10 +142,13 @@ $(objpfx)libm-test.stmp: $(ulps-file) libm-test.inc gen-libm-test.pl \
$(objpfx)test-float.o: $(objpfx)libm-test.stmp
$(objpfx)test-ifloat.o: $(objpfx)libm-test.stmp
+$(objpfx)test-float-finite.o: $(objpfx)libm-test.stmp
$(objpfx)test-double.o: $(objpfx)libm-test.stmp
$(objpfx)test-idouble.o: $(objpfx)libm-test.stmp
+$(objpfx)test-double-finite.o: $(objpfx)libm-test.stmp
$(objpfx)test-ldouble.o: $(objpfx)libm-test.stmp
$(objpfx)test-ildoubl.o: $(objpfx)libm-test.stmp
+$(objpfx)test-ldouble-finite.o: $(objpfx)libm-test.stmp
endif
libm-test-fast-math-cflags = -fno-builtin -D__FAST_MATH__ -DTEST_FAST_MATH
@@ -167,9 +171,15 @@ CFLAGS-test-float-vlen8-wrappers.c = $(float-vlen8-arch-ext-cflags)
CFLAGS-test-float-vlen16.c = $(libm-test-vec-cflags)
CFLAGS-test-float-vlen16-wrappers.c = $(float-vlen16-arch-ext-cflags)
-CFLAGS-test-float.c = -fno-inline -ffloat-store -fno-builtin
-CFLAGS-test-double.c = -fno-inline -ffloat-store -fno-builtin
-CFLAGS-test-ldouble.c = -fno-inline -ffloat-store -fno-builtin
+libm-test-no-inline-cflags = -fno-inline -ffloat-store -fno-builtin
+libm-test-finite-cflags = $(libm-test-no-inline-cflags) \
+ -U__FINITE_MATH_ONLY__ -D__FINITE_MATH_ONLY__=1
+CFLAGS-test-float.c = $(libm-test-no-inline-cflags)
+CFLAGS-test-float-finite.c = $(libm-test-finite-cflags)
+CFLAGS-test-double.c = $(libm-test-no-inline-cflags)
+CFLAGS-test-double-finite.c = $(libm-test-finite-cflags)
+CFLAGS-test-ldouble.c = $(libm-test-no-inline-cflags)
+CFLAGS-test-ldouble-finite.c = $(libm-test-finite-cflags)
CFLAGS-test-tgmath.c = -fno-builtin
# The following testcase uses very long lines (>3 million), so it may take a
# while to compile it. See: http://llvm.org/bugs/show_bug.cgi?id=14106 and
@@ -141,12 +141,13 @@ sub build_complex_beautify {
# Return the text to put in an initializer for a test's exception
# information.
sub show_exceptions {
- my ($ignore_result, $exception) = @_;
+ my ($ignore_result, $non_finite, $exception) = @_;
$ignore_result = ($ignore_result ? "IGNORE_RESULT|" : "");
+ $non_finite = ($non_finite ? "NON_FINITE|" : "");
if (defined $exception) {
- return ", ${ignore_result}$exception";
+ return ", ${ignore_result}${non_finite}$exception";
} else {
- return ", ${ignore_result}0";
+ return ", ${ignore_result}${non_finite}0";
}
}
@@ -162,6 +163,7 @@ sub parse_args {
my (@plus_oflow, @minus_oflow, @plus_uflow, @minus_uflow);
my (@errno_plus_oflow, @errno_minus_oflow);
my (@errno_plus_uflow, @errno_minus_uflow);
+ my ($non_finite);
($descr_args, $descr_res) = split /_/,$descr, 2;
@@ -306,8 +308,12 @@ sub parse_args {
if ($ignore_result_any && !$ignore_result_all) {
die ("some but not all function results ignored\n");
}
+ # Determine whether any arguments or results, for any rounding
+ # mode, are non-finite.
+ $non_finite = ($args =~ /qnan_value|plus_infty|minus_infty/);
# Add exceptions.
$cline_res .= show_exceptions ($ignore_result_any,
+ $non_finite,
($current_arg <= $#args_res)
? $args_res[$current_arg]
: undef);
@@ -182,6 +182,7 @@ struct ulp_data
#define ERRNO_ERANGE 0x10000
/* Flags generated by gen-libm-test.pl, not entered here manually. */
#define IGNORE_RESULT 0x20000
+#define NON_FINITE 0x40000
/* Values underflowing only for float. */
#ifdef TEST_FLOAT
@@ -1041,6 +1042,8 @@ enable_test (int exceptions)
return 0;
if (TEST_INLINE && (exceptions & NO_TEST_INLINE))
return 0;
+ if (TEST_FINITE && (exceptions & NON_FINITE) != 0)
+ return 0;
return 1;
}
new file mode 100644
@@ -0,0 +1,26 @@
+/* Copyright (C) 1997-2015 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 "test-double.h"
+#include "test-math-finite.h"
+#include "test-math-no-inline.h"
+#include "test-math-scalar.h"
+
+#define TEST_MSG "testing double (finite-math-only)\n"
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cdouble
+
+#include "libm-test.c"
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#include "test-double.h"
+#include "test-math-no-finite.h"
#include "test-math-no-inline.h"
#include "test-math-errno.h"
#include "test-math-scalar.h"
new file mode 100644
@@ -0,0 +1,26 @@
+/* Copyright (C) 1997-2015 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 "test-float.h"
+#include "test-math-finite.h"
+#include "test-math-no-inline.h"
+#include "test-math-scalar.h"
+
+#define TEST_MSG "testing float (finite-math-only)\n"
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Cfloat
+
+#include "libm-test.c"
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#include "test-float.h"
+#include "test-math-no-finite.h"
#include "test-math-no-inline.h"
#include "test-math-errno.h"
#include "test-math-scalar.h"
new file mode 100644
@@ -0,0 +1,26 @@
+/* Copyright (C) 1997-2015 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 "test-ldouble.h"
+#include "test-math-finite.h"
+#include "test-math-no-inline.h"
+#include "test-math-scalar.h"
+
+#define TEST_MSG "testing long double (finite-math-only)\n"
+#define CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat) Clongdouble
+
+#include "libm-test.c"
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#include "test-ldouble.h"
+#include "test-math-no-finite.h"
#include "test-math-no-inline.h"
#include "test-math-errno.h"
#include "test-math-scalar.h"
new file mode 100644
@@ -0,0 +1,20 @@
+/* Common definitions for libm tests for finite-math-only.
+ Copyright (C) 2015 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/>. */
+
+#define TEST_FINITE 1
+#define TEST_ERRNO 0
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#define TEST_INLINE 1
+#define TEST_FINITE 0
#define TEST_ERRNO 0
#define TEST_EXCEPTIONS 0
new file mode 100644
@@ -0,0 +1,19 @@
+/* Common definitions for libm tests for no-finite-math-only.
+ Copyright (C) 2015 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/>. */
+
+#define TEST_FINITE 0
@@ -17,6 +17,7 @@
<http://www.gnu.org/licenses/>. */
#define TEST_MATHVEC 1
+#define TEST_FINITE 0
#define TEST_ERRNO 0
#define CNCT(x, y) x ## y