diff options
author | Craig A. Berry <craigberry@mac.com> | 2005-06-18 13:23:59 -0500 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-06-19 15:11:06 +0000 |
commit | f607920a165f3c14b9c61dc74e535bdc6aa1904c (patch) | |
tree | 9036f388507340c1b9d3931c0a9098bc1d7d9be7 /Configure | |
parent | dd69047874984d0e0233a4ed2eb67c2fe4ea1617 (diff) | |
download | perl-f607920a165f3c14b9c61dc74e535bdc6aa1904c.tar.gz |
Add a Configure test to see if NV 0.0 is stored as all bits zero, and
#define NV_ZERO_IS_ALLBITS_ZERO if so. This is always true on VMS:
Subject: Re: Configure check for whether 0.0 is stored as all bits zero
From: "Craig A. Berry" <craigberry@mac.com>
Message-Id: <p06210214beda5bf31c4c@[172.16.52.1]>
Date: Sat, 18 Jun 2005 18:23:59 -0500
p4raw-id: //depot/perl@24898
Diffstat (limited to 'Configure')
-rwxr-xr-x | Configure | 124 |
1 files changed, 124 insertions, 0 deletions
@@ -1002,6 +1002,7 @@ perl5='' perladmin='' perlpath='' d_nv_preserves_uv='' +d_nv_zero_is_allbits_zero='' i16size='' i16type='' i32size='' @@ -14833,6 +14834,128 @@ esac $rm -f try.* 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 + volatile=volatile +fi +$cat <<EOP >try.c +#include <stdio.h> +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include <stdlib.h> +#endif +#$i_string I_STRING +#ifdef I_STRING +# include <string.h> +#else +# include <strings.h> +#endif +#include <sys/types.h> +#include <signal.h> +#ifdef SIGFPE +$volatile int bletched = 0; +$signal_t blech(s) int s; { bletched = 1; } +#endif + +int checkit($nvtype d, char *where) { + unsigned char *p = (char *)&d; + unsigned char *end = p + sizeof(d); + int fail = 0; + + while (p < end) + fail += *p++; + + if (!fail) + return 0; + + p = (char *)&d; + printf("No - %s: 0x", where); + while (p < end) + printf ("%02X", *p++); + printf("\n"); + return 1; +} + +int main(int argc, char **argv) { + $nvtype d = 0.0; + int fail = 0; + fail += checkit(d, "0.0"); + + /* The compiler shouldn't be assuming that bletched is 0 */ + d = bletched; + + fail += checkit(d, "bleched"); + +#ifdef SIGFPE + signal(SIGFPE, blech); +#endif + + /* Paranoia - the compiler should have no way of knowing that ANSI says + that argv[argc] will always be NULL. Actually, if it did assume this it + would be buggy, as this is C and main() can be called from elsewhere in + the program. */ + d = argv[argc] ? 1 : 0; + + if (d) { + printf("Odd argv[argc]=%p, d=%g\n", argv[argc], d); + } + + fail += checkit(d, "ternary"); + + memset(&d, sizeof(d), argv[argc] ? 1 : 0); + + if (d != 0.0) { + printf("No - memset doesn't give 0.0\n"); + /* This might just blow up: */ + printf("(gives %g)\n", d); + return 1; + } + +#ifdef SIGFPE + if (bletched) { + printf("No - something bleched\n"); + return 1; + } +#endif + if (fail) { + printf("No - %d fail(s)\n", fail); + return 1; + } + printf("Yes\n"); + return 0; +} +EOP +set try + +d_nv_zero_is_allbits_zero="$undef" +if eval $compile; then + xxx="`$run ./try`" + case "$?" in + 0) + case "$xxx" in + Yes) cat >&4 <<EOM +0.0 is represented as all bits zero in memory +EOM + d_nv_zero_is_allbits_zero="$define" + ;; + *) cat >&4 <<EOM +0.0 is not represented as all bits zero in memory +EOM + d_nv_zero_is_allbits_zero="$undef" + ;; + esac + ;; + *) cat >&4 <<EOM +0.0 is not represented as all bits zero in memory +EOM + d_nv_zero_is_allbits_zero="$undef" + ;; + esac +fi + +$rm -f try.* try + : check for off64_t echo " " @@ -21012,6 +21135,7 @@ d_mymalloc='$d_mymalloc' d_nice='$d_nice' d_nl_langinfo='$d_nl_langinfo' d_nv_preserves_uv='$d_nv_preserves_uv' +d_nv_zero_is_allbits_zero='$d_nv_zero_is_allbits_zero' d_off64_t='$d_off64_t' d_old_pthread_create_joinable='$d_old_pthread_create_joinable' d_oldpthreads='$d_oldpthreads' |