aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog32
-rw-r--r--math/Makefile20
-rwxr-xr-xmath/gen-libm-test.pl12
-rw-r--r--math/libm-test.inc3
-rw-r--r--math/test-double-finite.c26
-rw-r--r--math/test-double.c1
-rw-r--r--math/test-float-finite.c26
-rw-r--r--math/test-float.c1
-rw-r--r--math/test-ldouble-finite.c26
-rw-r--r--math/test-ldouble.c1
-rw-r--r--math/test-math-finite.h20
-rw-r--r--math/test-math-inline.h1
-rw-r--r--math/test-math-no-finite.h19
-rw-r--r--math/test-math-vector.h1
14 files changed, 181 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 26cde5b1ce..8cf5b0cc9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2015-11-05 Joseph Myers <joseph@codesourcery.com>
+
+ * math/libm-test.inc (NON_FINITE): New macro.
+ (enable_test): Do not run tests flagged NON_FINITE if TEST_FINITE.
+ * math/gen-libm-test.pl (show_exceptions): Add argument
+ $non_finite.
+ (parse_args): Update call to show_exceptions.
+ * math/test-math-finite.h: New file.
+ * math/test-math-no-finite.h: Likewise.
+ * math/test-double-finite.c: Likewise.
+ * math/test-float-finite.c: Likewise.
+ * math/test-ldouble-finite.c: Likewise.
+ * math/test-double.c: Include "test-math-no-finite.h".
+ * math/test-float.c: Include "test-math-no-finite.h".
+ * math/test-ldouble.c: Include "test-math-no-finite.h".
+ * math/test-math-inline.h (TEST_FINITE): New macro.
+ * math/test-math-vector.h (TEST_FINITE): Likewise.
+ * math/Makefile (test-longdouble-yes): Add test-ldouble-finite.
+ (libm-tests): Add test-float-finite and test-double-finite.
+ ($(objpfx)test-float-finite.o): New dependency on
+ $(objpfx)libm-test.stmp.
+ ($(objpfx)test-double-finite.o): Likewise.
+ ($(objpfx)test-ldouble-finite.o): Likewise.
+ (libm-test-no-inline-cflags): New variable.
+ (libm-test-finite-cflags): Likewise.
+ (CFLAGS-test-float-finite.c): Likewise.
+ (CFLAGS-test-double-finite.c): Likewise.
+ (CFLAGS-test-ldouble-finite.c): Likewise.
+ (CFLAGS-test-float.c): Use $(libm-test-no-inline-cflags).
+ (CFLAGS-test-double.c): Likewise.
+ (CFLAGS-test-ldouble.c): Likewise.
+
2015-11-05 Roland McGrath <roland@hack.frob.com>
* io/fcntl.c (__fcntl): Add ... to prototype.
diff --git a/math/Makefile b/math/Makefile
index adeb806e3f..ec9e6b29d1 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -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
diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl
index 9a0ada0f6f..e1ed0b7297 100755
--- a/math/gen-libm-test.pl
+++ b/math/gen-libm-test.pl
@@ -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);
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 2f0d6d95f0..669b060dc9 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -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;
}
diff --git a/math/test-double-finite.c b/math/test-double-finite.c
new file mode 100644
index 0000000000..52c3fd919c
--- /dev/null
+++ b/math/test-double-finite.c
@@ -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"
diff --git a/math/test-double.c b/math/test-double.c
index caffe20b2c..594c9969c3 100644
--- a/math/test-double.c
+++ b/math/test-double.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"
diff --git a/math/test-float-finite.c b/math/test-float-finite.c
new file mode 100644
index 0000000000..3587d66e58
--- /dev/null
+++ b/math/test-float-finite.c
@@ -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"
diff --git a/math/test-float.c b/math/test-float.c
index cb6b22d05e..4ca81f7b13 100644
--- a/math/test-float.c
+++ b/math/test-float.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"
diff --git a/math/test-ldouble-finite.c b/math/test-ldouble-finite.c
new file mode 100644
index 0000000000..ca252839e9
--- /dev/null
+++ b/math/test-ldouble-finite.c
@@ -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"
diff --git a/math/test-ldouble.c b/math/test-ldouble.c
index 4da4a4f9fc..2450dfbe9a 100644
--- a/math/test-ldouble.c
+++ b/math/test-ldouble.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"
diff --git a/math/test-math-finite.h b/math/test-math-finite.h
new file mode 100644
index 0000000000..52e87e24c0
--- /dev/null
+++ b/math/test-math-finite.h
@@ -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
diff --git a/math/test-math-inline.h b/math/test-math-inline.h
index 4083f703e3..0d35005875 100644
--- a/math/test-math-inline.h
+++ b/math/test-math-inline.h
@@ -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
diff --git a/math/test-math-no-finite.h b/math/test-math-no-finite.h
new file mode 100644
index 0000000000..d74a15830e
--- /dev/null
+++ b/math/test-math-no-finite.h
@@ -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
diff --git a/math/test-math-vector.h b/math/test-math-vector.h
index ec4c533fe6..a1290168fa 100644
--- a/math/test-math-vector.h
+++ b/math/test-math-vector.h
@@ -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