aboutsummaryrefslogtreecommitdiff
path: root/math/gen-libm-test.pl
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-05-26 16:38:04 +0000
committerJoseph Myers <joseph@codesourcery.com>2016-05-26 16:38:04 +0000
commit262112840ca3807d2e5c7227a476be88be5740a7 (patch)
tree819898673e9c173d0f0d81dd6e180c9684451e70 /math/gen-libm-test.pl
parent2f0dc39029ae08cbed2f65d21501b3e329895e7d (diff)
downloadglibc-262112840ca3807d2e5c7227a476be88be5740a7.zip
glibc-262112840ca3807d2e5c7227a476be88be5740a7.tar.gz
glibc-262112840ca3807d2e5c7227a476be88be5740a7.tar.bz2
Support sNaN testing in libm-test.inc.
This patch adds support in libm-test.inc for tests with signaling NaN arguments. gen-libm-test.pl is made to set a flag TEST_SNAN for such tests, so that they can be disabled automatically when sNaN testing isn't supported for a given type (at present, for float and double on 32-bit x86 because it's unpredictable when a value might be loaded into a floating-point register and so automatically converted to long double with sNaNs converted to quiet NaNs). -fsignaling-nans is used where needed. Tests are added for classification macros, as a starting point; this is deliberately more conservative than Thomas's patch <https://sourceware.org/ml/libc-ports/2013-04/msg00008.html>, to allow more tests to be added, and issues exposed fixed, bit by bit. Tested for x86_64 and x86. * math/libm-test.inc: Update comment about NaN testing. (TEST_SNAN): New macro. (snan_value): Likewise. (enable_test): Disable tests of sNaNs when SNAN_TESTS fails. (fpclassify_test_data): Add sNaN tests. (isfinite_test_data): Likewise. (isinf_test_data): Likewise. (isnan_test_data): Likewise. (isnormal_test_data): Likewise. (issignaling_test_data): Likewise. (signbit_test_data): Likewise. * math/gen-libm-test.pl (%beautify): Add snan_value. (show_exceptions): Add argument $test_snan. (parse_args): Handle snan_value as non-finite. Update call to show_exceptions. * math/Makefile (libm-test-no-inline-cflags): Add -fsignaling-nans.
Diffstat (limited to 'math/gen-libm-test.pl')
-rwxr-xr-xmath/gen-libm-test.pl14
1 files changed, 9 insertions, 5 deletions
diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl
index 17f17f7..c42a53b 100755
--- a/math/gen-libm-test.pl
+++ b/math/gen-libm-test.pl
@@ -59,6 +59,7 @@ use vars qw (%auto_tests);
"minus_infty" => "-inf",
"plus_infty" => "inf",
"qnan_value" => "qNaN",
+ "snan_value" => "sNaN",
);
@@ -141,13 +142,14 @@ sub build_complex_beautify {
# Return the text to put in an initializer for a test's exception
# information.
sub show_exceptions {
- my ($ignore_result, $non_finite, $exception) = @_;
+ my ($ignore_result, $non_finite, $test_snan, $exception) = @_;
$ignore_result = ($ignore_result ? "IGNORE_RESULT|" : "");
$non_finite = ($non_finite ? "NON_FINITE|" : "");
+ $test_snan = ($test_snan ? "TEST_SNAN|" : "");
if (defined $exception) {
- return ", ${ignore_result}${non_finite}$exception";
+ return ", ${ignore_result}${non_finite}${test_snan}$exception";
} else {
- return ", ${ignore_result}${non_finite}0";
+ return ", ${ignore_result}${non_finite}${test_snan}0";
}
}
@@ -163,7 +165,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);
+ my ($non_finite, $test_snan);
($descr_args, $descr_res) = split /_/,$descr, 2;
@@ -310,10 +312,12 @@ sub parse_args {
}
# Determine whether any arguments or results, for any rounding
# mode, are non-finite.
- $non_finite = ($args =~ /qnan_value|plus_infty|minus_infty/);
+ $non_finite = ($args =~ /qnan_value|snan_value|plus_infty|minus_infty/);
+ $test_snan = ($args =~ /snan_value/);
# Add exceptions.
$cline_res .= show_exceptions ($ignore_result_any,
$non_finite,
+ $test_snan,
($current_arg <= $#args_res)
? $args_res[$current_arg]
: undef);