diff options
Diffstat (limited to 'U/d_casti32.U')
-rw-r--r-- | U/d_casti32.U | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/U/d_casti32.U b/U/d_casti32.U new file mode 100644 index 0000000000..efcfd07a3a --- /dev/null +++ b/U/d_casti32.U @@ -0,0 +1,86 @@ +?X: These units are based on the ones supplied with dist-3.0 +?X: patchlevel 22. They have been changed or enhanced to work with +?X: perl5alpha. I would appreciate hearing about any changes, +?X: corrections, or enhancements. +?X: Andy Dougherty doughera@lafcol.lafayette.edu +?X: Dept. of Physics +?X: Lafayette College +?X: Easton, PA 18042-1782 +?X: Sat Apr 2 15:45:17 EST 1994 +?RCS: $Id: d_casti32.U,v 3.0 1993/08/18 12:05:47 ram Exp $ +?RCS: +?RCS: Copyright (c) 1991-1993, Raphael Manfredi +?RCS: +?RCS: You may redistribute only under the terms of the Artistic Licence, +?RCS: as specified in the README file that comes with the distribution. +?RCS: You may reuse parts of this distribution only within the terms of +?RCS: that same Artistic Licence; a copy of which may be found at the root +?RCS: of the source tree for dist 3.0. +?RCS: +?RCS: $Log: d_casti32.U,v $ +?RCS: Revision 3.0 1993/08/18 12:05:47 ram +?RCS: Baseline for dist 3.0 netwide release. +?RCS: +?X: +?X: Can the compiler cast large floats to 32-bit integers? +?X: +?MAKE:d_casti32: cat cc ccflags rm intsize Setvar +?MAKE: -pick add $@ %< +?S:d_casti32: +?S: This variable conditionally defines CASTI32, which indicates +?S: wether the C compiler can cast large floats to 32-bit ints. +?S:. +?T:xxx yyy +?C:CASTI32: +?C: This symbol is defined if the C compiler can cast negative +?C: or large floating point numbers to 32-bit ints. +?C:. +?H:#$d_casti32 CASTI32 /**/ +?H:. +?LINT:set d_casti32 +: check for ability to cast large floats to 32-bit ints. +echo " " +echo 'Checking whether your C compiler can cast large floats to int32.' >&4 +if $test "$intsize" -ge 4; then + xxx=int +else + xxx=long +fi + +$cat >try.c <<EOCP +#include <sys/types.h> +#include <signal.h> +blech() { exit(3); } +main() +{ + $xxx i32; + double f; + int result = 0; + signal(SIGFPE, blech); + + f = (double) 0x7fffffff; + f = 10 * f; + i32 = ( $xxx )f; + + if (i32 != ( $xxx )f) + result |= 1; + exit(result); +} +EOCP +if $cc -o try $ccflags try.c >/dev/null 2>&1; then + ./try + yyy=$? +else + yyy=1 +fi +case "$yyy" in +0) val="$define" + echo "Yup, it can." + ;; +*) val="$undef" + echo "Nope, it can't." + ;; +esac +set d_casti32 +eval $setvar +$rm -f try.* |