Commit | Line | Data |
---|---|---|
d8875586 MBT |
1 | ?RCS: $Id$ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 1991-1997, 2004-2006, 2012 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 4.0. | |
10 | ?RCS: | |
11 | ?MAKE:intsize longsize shortsize: Assert Myread cat rm +cc +ccflags echo n c | |
12 | ?MAKE: -pick add $@ %< | |
13 | ?S:intsize: | |
14 | ?S: This variable contains the value of the INTSIZE symbol, which | |
15 | ?S: indicates to the C program how many bytes there are in an int. | |
16 | ?S:. | |
17 | ?S:longsize: | |
18 | ?S: This variable contains the value of the LONGSIZE symbol, which | |
19 | ?S: indicates to the C program how many bytes there are in a long. | |
20 | ?S:. | |
21 | ?S:shortsize: | |
22 | ?S: This variable contains the value of the SHORTSIZE symbol which | |
23 | ?S: indicates to the C program how many bytes there are in a short. | |
24 | ?S:. | |
25 | ?C:INTSIZE: | |
26 | ?C: This symbol contains the value of sizeof(int) so that the C | |
27 | ?C: preprocessor can make decisions based on it. | |
28 | ?C:. | |
29 | ?C:LONGSIZE: | |
30 | ?C: This symbol contains the value of sizeof(long) so that the C | |
31 | ?C: preprocessor can make decisions based on it. | |
32 | ?C:. | |
33 | ?C:SHORTSIZE: | |
34 | ?C: This symbol contains the value of sizeof(short) so that the C | |
35 | ?C: preprocessor can make decisions based on it. | |
36 | ?C:. | |
37 | ?H:#define INTSIZE $intsize | |
38 | ?H:#define LONGSIZE $longsize | |
39 | ?H:#define SHORTSIZE $shortsize | |
40 | ?H:. | |
41 | ?T:types t size var | |
42 | ?LINT: set shortsize intsize longsize | |
43 | : check for lengths of integral types | |
44 | echo " " | |
45 | types='' | |
46 | @if SHORTSIZE || shortsize | |
47 | types="$types short" | |
48 | @end | |
49 | @if INTSIZE || intsize | |
50 | types="$types int" | |
51 | @end | |
52 | @if LONGSIZE || longsize | |
53 | types="$types long" | |
54 | @end | |
55 | for t in $types; do | |
56 | $echo $n "Checking to see how big your ${t}s are...$c" >&4 | |
57 | for size in 2 4 8 16 error; do | |
58 | $cat >try.c <<EOCP | |
59 | #include "static_assert.h" | |
60 | $t foo; | |
61 | int main() | |
62 | { | |
63 | STATIC_ASSERT($size == sizeof(foo)); | |
64 | return 0; | |
65 | } | |
66 | EOCP | |
67 | if $cc -c $ccflags try.c >/dev/null 2>&1; then break; fi | |
68 | done | |
69 | var=${t}size | |
70 | case "$size" in | |
71 | error) | |
72 | echo " cannot compute it." >&4 | |
73 | case $t in | |
74 | short) dflt=2;; | |
75 | int) dflt=4;; | |
76 | long) dflt=4;; | |
77 | esac | |
78 | rp="What is the size of the \"$t\" type (in bytes)?" | |
79 | . ./myread | |
80 | eval $var="$ans" | |
81 | ;; | |
82 | *) | |
83 | echo " $size bytes." >&4 | |
84 | eval $var=$size | |
85 | ;; | |
86 | esac | |
87 | done | |
88 | $rm -f try.* | |
89 |