This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport 7eb35c035978bf0530591a57244b6922682a3344
[metaconfig.git] / U / a_dvisory / intsize.U
CommitLineData
959f3c4c
JH
1?RCS: $Id: intsize.U,v 3.0.1.2 1997/02/28 15:55:26 ram Exp $
2?RCS:
3?RCS: Copyright (c) 1991-1993, Raphael Manfredi
0065f4af 4?RCS:
959f3c4c
JH
5?RCS: You may redistribute only under the terms of the Artistic Licence,
6?RCS: as specified in the README file that comes with the distribution.
7?RCS: You may reuse parts of this distribution only within the terms of
8?RCS: that same Artistic Licence; a copy of which may be found at the root
9?RCS: of the source tree for dist 3.0.
10?RCS:
11?RCS: $Log: intsize.U,v $
12?RCS: Revision 3.0.1.2 1997/02/28 15:55:26 ram
13?RCS: patch61: avoid prompting the user if the test runs ok
14?RCS: patch61: moved code from longsize.U into there
15?RCS: patch61: new tests for shortsize as well
16?RCS:
17?RCS: Revision 3.0.1.1 1994/10/29 16:21:06 ram
18?RCS: patch36: added ?F: line for metalint file checking
19?RCS:
20?RCS: Revision 3.0 1993/08/18 12:08:52 ram
21?RCS: Baseline for dist 3.0 netwide release.
22?RCS:
2cb64bf6 23?MAKE:intsize longsize shortsize: Compile Myread cat run i_stdlib rm_try
959f3c4c
JH
24?MAKE: -pick add $@ %<
25?S:intsize:
26?S: This variable contains the value of the INTSIZE symbol, which
27?S: indicates to the C program how many bytes there are in an int.
28?S:.
29?S:longsize:
30?S: This variable contains the value of the LONGSIZE symbol, which
31?S: indicates to the C program how many bytes there are in a long.
32?S:.
33?S:shortsize:
34?S: This variable contains the value of the SHORTSIZE symbol which
35?S: indicates to the C program how many bytes there are in a short.
36?S:.
37?C:INTSIZE:
38?C: This symbol contains the value of sizeof(int) so that the C
39?C: preprocessor can make decisions based on it.
40?C:.
41?C:LONGSIZE:
42?C: This symbol contains the value of sizeof(long) so that the C
43?C: preprocessor can make decisions based on it.
44?C:.
45?C:SHORTSIZE:
46?C: This symbol contains the value of sizeof(short) so that the C
47?C: preprocessor can make decisions based on it.
48?C:.
49?H:#define INTSIZE $intsize /**/
50?H:#define LONGSIZE $longsize /**/
51?H:#define SHORTSIZE $shortsize /**/
52?H:.
0065f4af 53?F:!try
959f3c4c
JH
54: check for lengths of integral types
55echo " "
56case "$intsize" in
57'')
58 echo "Checking to see how big your integers are..." >&4
d687b8cb 59 $cat >try.c <<EOCP
959f3c4c 60#include <stdio.h>
3b148aa9
JH
61#$i_stdlib I_STDLIB
62#ifdef I_STDLIB
63#include <stdlib.h>
64#endif
959f3c4c
JH
65int main()
66{
67@if INTSIZE || intsize
37a56d0d 68 printf("intsize=%d;\n", (int)sizeof(int));
959f3c4c
JH
69@end
70@if LONGSIZE || longsize
37a56d0d 71 printf("longsize=%d;\n", (int)sizeof(long));
959f3c4c
JH
72@end
73@if SHORTSIZE || shortsize
37a56d0d 74 printf("shortsize=%d;\n", (int)sizeof(short));
959f3c4c
JH
75@end
76 exit(0);
77}
78EOCP
0f00356b
JH
79 set try
80 if eval $compile_ok && $run ./try > /dev/null; then
81 eval `$run ./try`
959f3c4c
JH
82@if INTSIZE || intsize
83 echo "Your integers are $intsize bytes long."
84@end
85@if LONGSIZE || longsize
86 echo "Your long integers are $longsize bytes long."
87@end
88@if SHORTSIZE || shortsize
89 echo "Your short integers are $shortsize bytes long."
90@end
91 else
92 $cat >&4 <<EOM
93!
94Help! I can't compile and run the intsize test program: please enlighten me!
95(This is probably a misconfiguration in your system or libraries, and
96you really ought to fix it. Still, I'll try anyway.)
97!
98EOM
99@if INTSIZE || intsize
100 dflt=4
101 rp="What is the size of an integer (in bytes)?"
102 . ./myread
103 intsize="$ans"
104@end
105@if LONGSIZE || longsize
106 dflt=$intsize
107 rp="What is the size of a long integer (in bytes)?"
108 . ./myread
109 longsize="$ans"
110@end
111@if SHORTSIZE || shortsize
112 dflt=2
113 rp="What is the size of a short integer (in bytes)?"
114 . ./myread
115 shortsize="$ans"
116@end
117 fi
118 ;;
119esac
2cb64bf6 120$rm_try
959f3c4c 121