diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-01-23 09:18:41 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-01-23 09:18:41 +0000 |
commit | b68c599a1231c4d11ec0b0a667ce0c407c357eab (patch) | |
tree | d5ae12e45397be6d6266d7a947752951af4a968f /Configure | |
parent | d2aeed1648166d254ac68525c35b77dec4ba8772 (diff) | |
download | perl-b68c599a1231c4d11ec0b0a667ce0c407c357eab.tar.gz |
Fix the misplaced warnings and failing tests caused by the precision
loss warning on ++ and -- by moving the check to Configure time,
creating a new config.sh variable nv_overflows_integers_at which
contains an constant expression for the value of the NV which can't
be incremented by 1.0
p4raw-id: //depot/perl@33049
Diffstat (limited to 'Configure')
-rwxr-xr-x | Configure | 85 |
1 files changed, 85 insertions, 0 deletions
@@ -1058,6 +1058,7 @@ i8type='' ivsize='' ivtype='' nv_preserves_uv_bits='' +nv_overflows_integers_at='' nvsize='' nvtype='' u16size='' @@ -15468,6 +15469,89 @@ case "$nv_preserves_uv_bits" in esac $rm_try +$echo "Checking to find the largest integer value your NVs can hold..." >&4 +: volatile so that the compiler has to store it out to memory. +if test X"$d_volatile" = X"$define"; then + volatile=volatile +fi +$cat <<EOP >try.c +#include <stdio.h> + +typedef $nvtype NV; + +int +main() { + NV value = 2; + int count = 1; + + while(count < 256) { + $volatile NV up = value + 1.0; + $volatile NV negated = -value; + $volatile NV down = negated - 1.0; + $volatile NV got_up = up - value; + int up_good = got_up == 1.0; + int got_down = down - negated; + int down_good = got_down == -1.0; + + if (down_good != up_good) { + fprintf(stderr, + "Inconsistency - up %d %f; down %d %f; for 2**%d (%.20f)\n", + up_good, (double) got_up, down_good, (double) got_down, + count, (double) value); + return 1; + } + if (!up_good) { + while (1) { + if (count > 8) { + count -= 8; + fputs("256.0", stdout); + } else { + count--; + fputs("2.0", stdout); + } + if (!count) { + puts(""); + return 0; + } + fputs("*", stdout); + } + } + value *= 2; + ++count; + } + fprintf(stderr, "Cannot overflow integer range, even at 2**%d (%.20f)\n", + count, (double) value); + return 1; +} +EOP +set try + +nv_overflows_integers_at='0' +if eval $compile; then + xxx="`$run ./try`" + case "$?" in + 0) + case "$xxx" in + 2*) cat >&4 <<EOM +The largest integer your NVs can preserve is equal to $xxx +EOM + nv_overflows_integers_at="$xxx" + ;; + *) cat >&4 <<EOM +Cannot determine the largest integer value your NVs can hold, unexpected output +'$xxx' +EOM + ;; + esac + ;; + *) cat >&4 <<EOM +Cannot determine the largest integer value your NVs can hold +EOM + ;; + esac +fi +$rm_try + $echo "Checking whether NV 0.0 is all bits zero in memory..." >&4 : volatile so that the compiler has to store it out to memory. if test X"$d_volatile" = X"$define"; then @@ -22420,6 +22504,7 @@ nroff='$nroff' nvEUformat='$nvEUformat' nvFUformat='$nvFUformat' nvGUformat='$nvGUformat' +nv_overflows_integers_at='$nv_overflows_integers_at' nv_preserves_uv_bits='$nv_preserves_uv_bits' nveformat='$nveformat' nvfformat='$nvfformat' |