develooper Front page | perl.perl5.porters | Postings from November 2000

[PATCH] Re: NV preserving UV (wasRe: [ID 20001007.002] Not OK: perl v5.7.0 +DEVEL7158 on armv4l-linux-64int 2.2.17-rmk1 (UNINSTALLED))

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
November 8, 2000 07:14
Subject:
[PATCH] Re: NV preserving UV (wasRe: [ID 20001007.002] Not OK: perl v5.7.0 +DEVEL7158 on armv4l-linux-64int 2.2.17-rmk1 (UNINSTALLED))
Message ID:
20001108151412.B98736@plum.flirble.org
On Sat, Oct 07, 2000 at 11:01:37PM +0100, Nicholas Clark wrote:
> On Sat, Oct 07, 2000 at 03:48:02PM -0500, Jarkko Hietaniemi wrote:
> > > Checking how many bits of your UVs your NVs can preserve...
> > > Floating point exception - core dumped

No core dumps now
 
> > Whoa.  We cannot have Configure saying things like this, such messages
> > scare people.
> 
> It scares me!
> I meant to mean "My patch isn't finished yet because it goes bang for some
> architectures"
> It surprises me that FreeBSD doesn't seem to be able to cast
> long double 0x10000000000000000 to max unsigned long long
> 0xFFFFFFFFFFFFFFFF without going SIGFPE
> Two of the other tests use a SIGFPE handler so I will experiment.
> I think I can stop it coredumping and return a correct answer.

Following patch should work reliably. Tested on FreeBSD and Linux (x86 and
arm). It gives sensible results:

Choosing the C types to be used for Perl's internal types...
(IV will be long long, 8 bytes)
(UV will be unsigned long long, 8 bytes)
(NV will be double, 8 bytes)
Checking how many bits of your UVs your NVs can preserve...
Your NVs can preserve 53 bits of your UVs.

and doesn't fall into the trap that the current tests fail to spot where
0xFFFFFFFFFFFFFFFF casts to the float 2**64, which casts back to the
long long 0xFFFFFFFFFFFFFFFF

Nicholas Clark

--- Configure.orig	Tue Nov  7 23:38:14 2000
+++ Configure	Wed Nov  8 14:58:48 2000
@@ -10274,67 +10274,62 @@
 	;;
 esac
 
-$echo "Checking whether your NVs can preserve your UVs..." >&4
+$echo "Checking how many bits of your UVs your NVs can preserve..." >&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>
-int main() {
-    $uvtype k = ($uvtype)~0, l;
-    $nvtype d;
-    l = k;
-    d = ($nvtype)l;
-    l = ($uvtype)d;
-    if (l == k)
-       printf("preserve\n");
-    exit(0);
-}
-EOP
-set try
-if eval $compile; then
-	case "`./try$exe_ext`" in
-	preserve) d_nv_preserves_uv="$define" ;;
-	esac
-fi	
-case "$d_nv_preserves_uv" in
-$define) $echo "Yes, they can."  2>&1 ;;
-*)	 $echo "No, they can't." 2>&1
-	 d_nv_preserves_uv="$undef"
-	 ;;
-esac
-
-$rm -f try.* try
-
-case "$d_nv_preserves_uv" in
-"$define") d_nv_preserves_uv_bits=`expr $uvsize \* 8` ;;
-*)	$echo "Checking how many bits of your UVs your NVs can preserve..." >&4
-	$cat <<EOP >try.c
-#include <stdio.h>
+#include <sys/types.h>
+#include <signal.h>
+$volatile int bletched = 0;
+$signal_t blech(s) int s; { bletched = 1; }
 int main() {
     $uvtype u = 0;
+    $nvtype d;
     int     n = 8 * $uvsize;
     int     i;
+    signal(SIGFPE, blech);
+
     for (i = 0; i < n; i++) {
       u = u << 1 | ($uvtype)1;
-      if (($uvtype)($nvtype)u != u)
+      d = ($nvtype)u;
+      if (($uvtype)d != u)
         break;
+      if (d <= 0)
+	break;
+      d = ($nvtype)(u - 1);
+      if (($uvtype)d != (u - 1))
+        break;
+      if (bletched) {
+	break;
+      }	
     }
-    printf("%d\n", i);
+    printf("%d\n", ((i == n) ? -n : i), u);
     exit(0);
 }
 EOP
-	set try
-	if eval $compile; then
-		d_nv_preserves_uv_bits="`./try$exe_ext`"
-	fi
-	case "$d_nv_preserves_uv_bits" in
-	[1-9]*)	$echo "Your NVs can preserve $d_nv_preserves_uv_bits bits of your UVs."  2>&1 ;;
-	*)	$echo "Can't figure out how many bits your NVs preserve." 2>&1
-		d_nv_preserves_uv_bits="$undef"
-		;;
-	esac
-	$rm -f try.* try
+set try
+
+d_nv_preserves_uv="$undef"
+if eval $compile; then
+	d_nv_preserves_uv_bits="`./try$exe_ext`"
+fi
+case "$d_nv_preserves_uv_bits" in
+\-[1-9]*)	
+	d_nv_preserves_uv_bits=`expr 0 - $d_nv_preserves_uv_bits`
+	$echo "Your NVs can preserve all $d_nv_preserves_uv_bits bits of your UVs."  2>&1
+	d_nv_preserves_uv="$define"
 	;;
+[1-9]*)	$echo "Your NVs can preserve $d_nv_preserves_uv_bits bits of your UVs."  2>&1
+	d_nv_preserves_uv="$undef" ;;
+*)	$echo "Can't figure out how many bits your NVs preserve." 2>&1
+	d_nv_preserves_uv_bits="$undef" ;;
 esac
 
+$rm -f try.* try
+
 
 : check for off64_t
 echo " "

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About