perl 5.0 alpha 8
[p5sagit/p5-mst-13.2.git] / U / d_casti32.U
CommitLineData
2304df62 1?X: These units are based on the ones supplied with dist-3.0
2?X: patchlevel 22. They have been changed or enhanced to work with
3?X: perl5alpha. I would appreciate hearing about any changes,
4?X: corrections, or enhancements.
5?X: Andy Dougherty doughera@lafcol.lafayette.edu
6?X: Dept. of Physics
7?X: Lafayette College
8?X: Easton, PA 18042-1782
9?X: Sat Apr 2 15:45:17 EST 1994
10?RCS: $Id: d_casti32.U,v 3.0 1993/08/18 12:05:47 ram Exp $
11?RCS:
12?RCS: Copyright (c) 1991-1993, Raphael Manfredi
13?RCS:
14?RCS: You may redistribute only under the terms of the Artistic Licence,
15?RCS: as specified in the README file that comes with the distribution.
16?RCS: You may reuse parts of this distribution only within the terms of
17?RCS: that same Artistic Licence; a copy of which may be found at the root
18?RCS: of the source tree for dist 3.0.
19?RCS:
20?RCS: $Log: d_casti32.U,v $
21?RCS: Revision 3.0 1993/08/18 12:05:47 ram
22?RCS: Baseline for dist 3.0 netwide release.
23?RCS:
24?X:
25?X: Can the compiler cast large floats to 32-bit integers?
26?X:
27?MAKE:d_casti32: cat cc ccflags rm intsize Setvar
28?MAKE: -pick add $@ %<
29?S:d_casti32:
30?S: This variable conditionally defines CASTI32, which indicates
31?S: wether the C compiler can cast large floats to 32-bit ints.
32?S:.
33?T:xxx yyy
34?C:CASTI32:
35?C: This symbol is defined if the C compiler can cast negative
36?C: or large floating point numbers to 32-bit ints.
37?C:.
38?H:#$d_casti32 CASTI32 /**/
39?H:.
40?LINT:set d_casti32
41: check for ability to cast large floats to 32-bit ints.
42echo " "
43echo 'Checking whether your C compiler can cast large floats to int32.' >&4
44if $test "$intsize" -ge 4; then
45 xxx=int
46else
47 xxx=long
48fi
49
50$cat >try.c <<EOCP
51#include <sys/types.h>
52#include <signal.h>
53blech() { exit(3); }
54main()
55{
56 $xxx i32;
57 double f;
58 int result = 0;
59 signal(SIGFPE, blech);
60
61 f = (double) 0x7fffffff;
62 f = 10 * f;
63 i32 = ( $xxx )f;
64
65 if (i32 != ( $xxx )f)
66 result |= 1;
67 exit(result);
68}
69EOCP
70if $cc -o try $ccflags try.c >/dev/null 2>&1; then
71 ./try
72 yyy=$?
73else
74 yyy=1
75fi
76case "$yyy" in
770) val="$define"
78 echo "Yup, it can."
79 ;;
80*) val="$undef"
81 echo "Nope, it can't."
82 ;;
83esac
84set d_casti32
85eval $setvar
86$rm -f try.*