1 ?RCS: $Id: intsize.U,v 3.0.1.2 1997/02/28 15:55:26 ram Exp $
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
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.
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
17 ?RCS: Revision 3.0.1.1 1994/10/29 16:21:06 ram
18 ?RCS: patch36: added ?F: line for metalint file checking
20 ?RCS: Revision 3.0 1993/08/18 12:08:52 ram
21 ?RCS: Baseline for dist 3.0 netwide release.
23 ?MAKE:intsize longsize shortsize: \
24 Myread cat rm +cc +optimize +ccflags +ldflags +libs
25 ?MAKE: -pick add $@ %<
27 ?S: This variable contains the value of the INTSIZE symbol, which
28 ?S: indicates to the C program how many bytes there are in an int.
31 ?S: This variable contains the value of the LONGSIZE symbol, which
32 ?S: indicates to the C program how many bytes there are in a long.
35 ?S: This variable contains the value of the SHORTSIZE symbol which
36 ?S: indicates to the C program how many bytes there are in a short.
39 ?C: This symbol contains the value of sizeof(int) so that the C
40 ?C: preprocessor can make decisions based on it.
43 ?C: This symbol contains the value of sizeof(long) so that the C
44 ?C: preprocessor can make decisions based on it.
47 ?C: This symbol contains the value of sizeof(short) so that the C
48 ?C: preprocessor can make decisions based on it.
50 ?H:#define INTSIZE $intsize /**/
51 ?H:#define LONGSIZE $longsize /**/
52 ?H:#define SHORTSIZE $shortsize /**/
55 : check for lengths of integral types
59 echo "Checking to see how big your integers are..." >&4
60 $cat >intsize.c <<'EOCP'
64 @if INTSIZE || intsize
65 printf("intsize=%d;\n", sizeof(int));
67 @if LONGSIZE || longsize
68 printf("longsize=%d;\n", sizeof(long));
70 @if SHORTSIZE || shortsize
71 printf("shortsize=%d;\n", sizeof(short));
77 # If $libs contains -lsfio, and sfio is mis-configured, then it
78 # sometimes (apparently) runs and exits with a 0 status, but with no
79 # output!. Thus we check with test -s whether we actually got any
80 # output. I think it has to do with sfio's use of _exit vs. exit,
81 # but I don't know for sure. --Andy Dougherty 1/27/97.
82 if $cc $optimize $ccflags $ldflags -o intsize intsize.c $libs >/dev/null 2>&1 &&
83 ./intsize > intsize.out 2>/dev/null && test -s intsize.out ; then
84 eval `$cat intsize.out`
85 @if INTSIZE || intsize
86 echo "Your integers are $intsize bytes long."
88 @if LONGSIZE || longsize
89 echo "Your long integers are $longsize bytes long."
91 @if SHORTSIZE || shortsize
92 echo "Your short integers are $shortsize bytes long."
97 Help! I can't compile and run the intsize test program: please enlighten me!
98 (This is probably a misconfiguration in your system or libraries, and
99 you really ought to fix it. Still, I'll try anyway.)
102 @if INTSIZE || intsize
104 rp="What is the size of an integer (in bytes)?"
108 @if LONGSIZE || longsize
110 rp="What is the size of a long integer (in bytes)?"
114 @if SHORTSIZE || shortsize
116 rp="What is the size of a short integer (in bytes)?"
123 $rm -f intsize intsize.[co] intsize.out