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