summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2016-10-27 07:46:22 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2016-10-28 22:04:48 -0400
commit85272d315820be85a9069783ae2be8878e1e42a4 (patch)
tree35bdaf1813054f56cbefb0fa9f3c4e8dd7768860
parent4cb05021f1602b1c29295f791d76ba4b38426f2a (diff)
downloadperl-85272d315820be85a9069783ae2be8878e1e42a4.tar.gz
Use the new metalevel definitions for fp inf/nan/range
There are still hacks (in a good sense) of detecting "vax float" in the cpan/ modules (patches submitted upstream, customized moves done), but that is fine since the new Config symbols will be available only in the future.
-rw-r--r--ext/POSIX/Makefile.PL10
-rw-r--r--ext/POSIX/t/math.t28
-rw-r--r--t/lib/warnings/9uninit9
-rw-r--r--t/lib/warnings/pp_sys13
-rw-r--r--t/op/hexfp.t3
-rw-r--r--t/op/inc.t8
-rw-r--r--t/op/infnan.t4
-rw-r--r--t/op/pack.t8
-rw-r--r--t/op/sprintf2.t12
-rw-r--r--t/opbasic/arith.t7
-rw-r--r--t/porting/globvar.t8
11 files changed, 48 insertions, 62 deletions
diff --git a/ext/POSIX/Makefile.PL b/ext/POSIX/Makefile.PL
index 56b8e5345a..bdaa4b6747 100644
--- a/ext/POSIX/Makefile.PL
+++ b/ext/POSIX/Makefile.PL
@@ -92,13 +92,15 @@ END
#endif
'});
-unless ($Config{doublekind} == 9 ||
- $Config{doublekind} == 10 ||
- $Config{doublekind} == 11) {
+if ($Config{d_double_has_inf}) {
push @names,
{name=>"INFINITY", type=>"NV", value=>"NV_INF", not_constant=>1},
- {name=>"NAN", type=>"NV", value=>"NV_NAN", not_constant=>1},
{name=>"Inf", type=>"NV", value=>"NV_INF", not_constant=>1},
+}
+
+if ($Config{d_double_has_nan}) {
+ push @names,
+ {name=>"NAN", type=>"NV", value=>"NV_NAN", not_constant=>1},
{name=>"NaN", type=>"NV", value=>"NV_NAN", not_constant=>1};
}
diff --git a/ext/POSIX/t/math.t b/ext/POSIX/t/math.t
index adb5de524e..0426e03ae1 100644
--- a/ext/POSIX/t/math.t
+++ b/ext/POSIX/t/math.t
@@ -55,17 +55,18 @@ between(0.76, tanh(1), 0.77, 'tanh(1)');
between(-0.77, tanh(-1), -0.76, 'tanh(-1)');
cmp_ok(tanh(1), '==', -tanh(-1), 'tanh(1) == -tanh(-1)');
-my $non_ieee_fp = ($Config{doublekind} == 9 ||
- $Config{doublekind} == 10 ||
- $Config{doublekind} == 11);
-
SKIP: {
skip "no fpclassify", 4 unless $Config{d_fpclassify};
is(fpclassify(1), FP_NORMAL, "fpclassify 1");
is(fpclassify(0), FP_ZERO, "fpclassify 0");
- skip("no inf/nan", 2) if $non_ieee_fp;
- is(fpclassify(INFINITY), FP_INFINITE, "fpclassify INFINITY");
- is(fpclassify(NAN), FP_NAN, "fpclassify NAN");
+ SKIP: {
+ skip("no inf", 1) unless $Config{d_double_has_inf};
+ is(fpclassify(INFINITY), FP_INFINITE, "fpclassify INFINITY");
+ }
+ SKIP: {
+ skip("no nan", 1) unless $Config{d_double_has_nan};
+ is(fpclassify(NAN), FP_NAN, "fpclassify NAN");
+ }
}
sub near {
@@ -104,15 +105,18 @@ SKIP: {
ok(!isinf(42), "isinf 42");
ok(!isnan(42), "isnan Inf");
SKIP: {
- skip("no inf/nan", 9) if $non_ieee_fp;
+ skip("no inf", 4) unless $Config{d_double_has_inf};
ok(!isfinite(Inf), "isfinite Inf");
- ok(!isfinite(NaN), "isfinite NaN");
ok(isinf(INFINITY), "isinf INFINITY");
ok(isinf(Inf), "isinf Inf");
+ ok(!isnan(Inf), "isnan Inf");
+ }
+ SKIP: {
+ skip("no nan", 5) unless $Config{d_double_has_nan};
+ ok(!isfinite(NaN), "isfinite NaN");
ok(!isinf(NaN), "isinf NaN");
ok(isnan(NAN), "isnan NAN");
ok(isnan(NaN), "isnan NaN");
- ok(!isnan(Inf), "isnan Inf");
cmp_ok(nan(), '!=', nan(), 'nan');
}
near(log1p(2), 1.09861228866811, "log1p", 1e-9);
@@ -147,7 +151,7 @@ SKIP: {
ok(islessequal(1, 1), "islessequal 1 1");
SKIP: {
- skip("no inf/nan", 2) if $non_ieee_fp;
+ skip("no nan", 2) unless $Config{d_double_has_nan};
ok(!isless(1, NaN), "isless 1 NaN");
ok(isunordered(1, NaN), "isunordered 1 NaN");
}
@@ -169,7 +173,7 @@ SKIP: {
near(lgamma(9), 10.6046029027452, "lgamma 9", 1.5e-7);
SKIP: {
- skip("no inf/nan", 19) if $non_ieee_fp;
+ skip("no inf/nan", 19) unless $Config{d_double_has_inf} && $Config{d_double_has_nan};
# These don't work on old mips/hppa platforms
# because nan with payload zero == Inf (or == -Inf).
diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit
index aa50b58735..c8b843f09a 100644
--- a/t/lib/warnings/9uninit
+++ b/t/lib/warnings/9uninit
@@ -669,10 +669,7 @@ Use of uninitialized value in sort at - line 21.
Use of uninitialized value in sort at - line 22.
########
use Config;
-my $non_ieee_fp = ($Config{doublekind} == 9 ||
- $Config{doublekind} == 10 ||
- $Config{doublekind} == 11);
-if ($non_ieee_fp) {
+unless ($Config{d_double_has_inf} && $Config{d_double_has_nan}) {
print <<EOM ;
SKIPPED
# No inf/nan support
@@ -692,8 +689,8 @@ use warnings 'uninitialized';
@sort = sort { ($a)[0] <=> $b } 1, $nan;
@sort = sort { $a <=> $b } 1, $nan;
EXPECT
-Use of uninitialized value in sort at - line 22.
-Use of uninitialized value in sort at - line 23.
+Use of uninitialized value in sort at - line 19.
+Use of uninitialized value in sort at - line 20.
########
use warnings 'uninitialized';
my ($m1, $m2, $v);
diff --git a/t/lib/warnings/pp_sys b/t/lib/warnings/pp_sys
index 6349b7b040..56e2da55b2 100644
--- a/t/lib/warnings/pp_sys
+++ b/t/lib/warnings/pp_sys
@@ -912,10 +912,7 @@ closedir() attempted on invalid dirhandle $foo at - line 23.
# pp_sys.c [pp_gmtime]
use Config;
-my $non_ieee_fp = ($Config{doublekind} == 9 ||
- $Config{doublekind} == 10 ||
- $Config{doublekind} == 11);
-if ($non_ieee_fp) {
+unless ($Config{d_double_has_nan}) {
print <<EOM ;
SKIPPED
# No nan support
@@ -929,10 +926,10 @@ gmtime("NaN");
localtime("NaN");
EXPECT
-gmtime(NaN) too large at - line 17.
-gmtime(NaN) failed at - line 17.
-localtime(NaN) too large at - line 18.
-localtime(NaN) failed at - line 18.
+gmtime(NaN) too large at - line 14.
+gmtime(NaN) failed at - line 14.
+localtime(NaN) too large at - line 15.
+localtime(NaN) failed at - line 15.
########
# pp_sys.c [pp_alarm]
diff --git a/t/op/hexfp.t b/t/op/hexfp.t
index bdf1e95d8d..29378f29af 100644
--- a/t/op/hexfp.t
+++ b/t/op/hexfp.t
@@ -248,8 +248,7 @@ SKIP: {
skip("non-80-bit-long-double", 4)
unless ($Config{uselongdouble} &&
($Config{nvsize} == 16 || $Config{nvsize} == 12) &&
- ($Config{longdblkind} == 3 ||
- $Config{longdblkind} == 4));
+ ($Config{long_double_style_ieee_extended}));
is(0x1p-1074, 4.94065645841246544e-324);
is(0x1p-1075, 2.47032822920623272e-324, '[perl #128919]');
is(0x1p-1076, 1.23516411460311636e-324);
diff --git a/t/op/inc.t b/t/op/inc.t
index 20d4769657..c685a70ce2 100644
--- a/t/op/inc.t
+++ b/t/op/inc.t
@@ -188,13 +188,11 @@ cmp_ok($a, '==', 2147483647, "postdecrement properly downgrades from double");
SKIP: {
if ($Config{uselongdouble} &&
- ($Config{longdblkind} == 6 || $Config{longdblkind} == 5)) {
+ ($Config{long_double_style_ieee_doubledouble})) {
skip "the double-double format is weird", 1;
}
- if ($Config{doublekind} == 9 ||
- $Config{doublekind} == 10 ||
- $Config{doublekind} == 11) {
- skip "the VAX format is not IEEE", 1;
+ unless ($Config{double_style_ieee}) {
+ skip "the doublekind $Config{doublekind} is not IEEE", 1;
}
# I'm sure that there's an IBM format with a 48 bit mantissa
diff --git a/t/op/infnan.t b/t/op/infnan.t
index b50d6e68d5..1f68cff8c1 100644
--- a/t/op/infnan.t
+++ b/t/op/infnan.t
@@ -16,9 +16,7 @@ BEGIN {
# but Inf is completely broken (e.g. Inf + 0 -> NaN).
skip_all "$^O with long doubles does not have sane inf/nan";
}
- if ($Config{doublekind} == 9 ||
- $Config{doublekind} == 10 ||
- $Config{doublekind} == 11) {
+ unless ($Config{d_double_has_inf} && $Config{d_double_has_nan}) {
skip_all "the doublekind $Config{doublekind} does not have inf/nan";
}
}
diff --git a/t/op/pack.t b/t/op/pack.t
index 014fbc55ac..3fc12e4241 100644
--- a/t/op/pack.t
+++ b/t/op/pack.t
@@ -50,8 +50,6 @@ for my $size ( 16, 32, 64 ) {
my $IsTwosComplement = pack('i', -1) eq "\xFF" x $Config{intsize};
print "# \$IsTwosComplement = $IsTwosComplement\n";
-my $vax_float = (pack("d", 1) =~ /^[\x80\x10]\x40/);
-
sub is_valid_error
{
my $err = shift;
@@ -297,7 +295,7 @@ sub list_eq ($$) {
# Is this a stupid thing to do on VMS, VOS and other unusual platforms?
skip("-- the IEEE infinity model is unavailable in this configuration.", 1)
- if (($^O eq 'VMS') && !defined($Config{useieee}) || $vax_float);
+ if (($^O eq 'VMS') && !defined($Config{useieee}) || !$Config{d_double_has_inf});
skip("-- $^O has serious fp indigestion on w-packed infinities", 1)
if (
@@ -322,7 +320,7 @@ sub list_eq ($$) {
SKIP: {
skip("-- the full range of an IEEE double may not be available in this configuration.", 3)
- if (($^O eq 'VMS') && !defined($Config{useieee}) || $vax_float);
+ if (($^O eq 'VMS') && !defined($Config{useieee}) || !$Config{d_double_style_ieee});
skip("-- $^O does not like 2**1023", 3)
if (($^O eq 'ultrix'));
@@ -1534,7 +1532,7 @@ is(unpack('c'), 65, "one-arg unpack (change #18751)"); # defaulting to $_
is($x[1], $y[1], "checksum advance ok");
SKIP: {
- skip("-- VAX float", 1) if $vax_float;
+ skip("-- non-IEEE float", 1) if !$Config{d_double_style_ieee};
# verify that the checksum is not overflowed with C0
is(unpack("C0%128U", "abcd"), unpack("U0%128U", "abcd"), "checksum not overflowed");
}
diff --git a/t/op/sprintf2.t b/t/op/sprintf2.t
index 8b9931fae3..56ef3e27c0 100644
--- a/t/op/sprintf2.t
+++ b/t/op/sprintf2.t
@@ -528,10 +528,8 @@ for my $num (0, -1, 1) {
}
}
-my $vax_float = (pack("d", 1) =~ /^[\x80\x10]\x40/);
-
SKIP: {
- if ($vax_float) { skip "VAX float has no Inf or NaN", 3 }
+ unless ($Config{d_double_has_inf} && $Config{d_double_has_nan}) { skip "no Inf or NaN in doublekind $Config{doublekind}", 3 }
# test that %f doesn't panic with +Inf, -Inf, NaN [perl #45383]
foreach my $n ('2**1e100', '-2**1e100', '2**1e100/2**1e100') { # +Inf, -Inf, NaN
eval { my $f = sprintf("%f", eval $n); };
@@ -600,7 +598,7 @@ is $o::count, 0, 'sprintf %d string overload count is 0';
is $o::numcount, 1, 'sprintf %d number overload count is 1';
SKIP: { # hexfp
- if ($vax_float) { skip "VAX float no hexfp", scalar @hexfloat }
+ unless ($Config{d_double_style_ieee}) { skip "no IEEE, no hexfp", scalar @hexfloat }
my $ppc_linux = $Config{archname} =~ /^(?:ppc|power(?:pc)?)(?:64)?-linux/;
my $irix_ld = $Config{archname} =~ /^IP\d+-irix-ld$/;
@@ -696,8 +694,7 @@ SKIP: {
skip("uselongdouble=" . ($Config{uselongdouble} ? 'define' : 'undef')
. " longdblkind=$Config{longdblkind} os=$^O", 6)
unless ($Config{uselongdouble} &&
- ($Config{longdblkind} == 5 ||
- $Config{longdblkind} == 6)
+ ($Config{long_double_style_ieee_doubledouble})
# Gating on 'linux' (ppc) here is due to the differing
# double-double implementations: other (also big-endian)
# double-double platforms (e.g. AIX on ppc or IRIX on mips)
@@ -862,8 +859,7 @@ SKIP: {
skip("non-80-bit-long-double", 17)
unless ($Config{uselongdouble} &&
($Config{nvsize} == 16 || $Config{nvsize} == 12) &&
- ($Config{longdblkind} == 3 ||
- $Config{longdblkind} == 4));
+ ($Config{long_double_style_ieee_extended}));
{
# The last normal for this format.
diff --git a/t/opbasic/arith.t b/t/opbasic/arith.t
index 81f272a7a8..75dc56e134 100644
--- a/t/opbasic/arith.t
+++ b/t/opbasic/arith.t
@@ -427,12 +427,11 @@ if ($^O eq 'VMS') {
eval {require Config; import Config};
$vms_no_ieee = 1 unless defined($Config{useieee});
}
-my $vax_float = (pack("d",1) =~ /^[\x80\x10]\x40/);
if ($^O eq 'vos') {
print "not ok ", $T++, " # TODO VOS raises SIGFPE instead of producing infinity.\n";
}
-elsif ($vms_no_ieee || $vax_float) {
+elsif ($vms_no_ieee || !$Config{d_double_has_inf}) {
print "ok ", $T++, " # SKIP -- the IEEE infinity model is unavailable in this configuration.\n"
}
elsif ($^O eq 'ultrix') {
@@ -462,8 +461,8 @@ else {
# [perl #120426]
# small numbers shouldn't round to zero if they have extra floating digits
-if ($vax_float) {
-for (1..8) { print "ok ", $T++, " # SKIP -- VAX not IEEE\n" }
+unless ($Config{d_double_style_ieee}) {
+for (1..8) { print "ok ", $T++, " # SKIP -- not IEEE\n" }
} else {
try $T++, 0.153e-305 != 0.0, '0.153e-305';
try $T++, 0.1530e-305 != 0.0, '0.1530e-305';
diff --git a/t/porting/globvar.t b/t/porting/globvar.t
index f917fd8324..8dd45ba34e 100644
--- a/t/porting/globvar.t
+++ b/t/porting/globvar.t
@@ -61,12 +61,10 @@ foreach my $file (map {$_ . $Config{_o}} qw(globals regcomp)) {
close $fh or die "Problem running nm $file";
}
-my $non_ieee_fp = ($Config{doublekind} == 9 ||
- $Config{doublekind} == 10 ||
- $Config{doublekind} == 11);
-
-if ($non_ieee_fp) {
+unless ($Config{d_double_has_inf}) {
$skip{PL_inf}++;
+}
+unless ($Config{d_double_has_nan}) {
$skip{PL_nan}++;
}