This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
metaconfig unit change for #18932.
[metaconfig.git] / U / a_dvisory / intsize.U
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
4 ?RCS: 
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:
23 ?MAKE:intsize longsize shortsize: Compile Myread cat rm run i_stdlib
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:.
53 : check for lengths of integral types
54 echo " "
55 case "$intsize" in
56 '')
57         echo "Checking to see how big your integers are..." >&4
58         $cat >try.c <<EOCP
59 #include <stdio.h>
60 #$i_stdlib I_STDLIB
61 #ifdef I_STDLIB
62 #include <stdlib.h>
63 #endif
64 int main()
65 {
66 @if INTSIZE || intsize
67         printf("intsize=%d;\n", (int)sizeof(int));
68 @end
69 @if LONGSIZE || longsize
70         printf("longsize=%d;\n", (int)sizeof(long));
71 @end
72 @if SHORTSIZE || shortsize
73         printf("shortsize=%d;\n", (int)sizeof(short));
74 @end
75         exit(0);
76 }
77 EOCP
78         set try
79         if eval $compile_ok && $run ./try > /dev/null; then
80                 eval `$run ./try`
81 @if INTSIZE || intsize
82                 echo "Your integers are $intsize bytes long."
83 @end
84 @if LONGSIZE || longsize
85                 echo "Your long integers are $longsize bytes long."
86 @end
87 @if SHORTSIZE || shortsize
88                 echo "Your short integers are $shortsize bytes long."
89 @end
90         else
91                 $cat >&4 <<EOM
92 !
93 Help! I can't compile and run the intsize test program: please enlighten me!
94 (This is probably a misconfiguration in your system or libraries, and
95 you really ought to fix it.  Still, I'll try anyway.)
96 !
97 EOM
98 @if INTSIZE || intsize
99                 dflt=4
100                 rp="What is the size of an integer (in bytes)?"
101                 . ./myread
102                 intsize="$ans"
103 @end
104 @if LONGSIZE || longsize
105                 dflt=$intsize
106                 rp="What is the size of a long integer (in bytes)?"
107                 . ./myread
108                 longsize="$ans"
109 @end
110 @if SHORTSIZE || shortsize
111                 dflt=2
112                 rp="What is the size of a short integer (in bytes)?"
113                 . ./myread
114                 shortsize="$ans"
115 @end
116         fi
117         ;;
118 esac
119 $rm -f try try.*
120