inittyp.c revision 1.1 1 /* $NetBSD: inittyp.c,v 1.1 2002/01/18 21:01:38 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Jochen Pohl for
18 * The NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include <sys/cdefs.h>
35 #ifndef lint
36 __RCSID("$NetBSD: inittyp.c,v 1.1 2002/01/18 21:01:38 thorpej Exp $");
37 #endif
38
39 #include <stdlib.h>
40 #include <ctype.h>
41 #include <limits.h>
42 #include <err.h>
43
44 #include "lint.h"
45
46 /* various type information */
47 ttab_t ttab[NTSPEC];
48
49 void
50 inittyp(void)
51 {
52 int i;
53 static const struct {
54 tspec_t it_tspec;
55 ttab_t it_ttab;
56 } ittab[NTSPEC] = {
57 { SIGNED, { 0, 0,
58 SIGNED, UNSIGN,
59 0, 0, 0, 0, 0, "signed" } },
60 { UNSIGN, { 0, 0,
61 SIGNED, UNSIGN,
62 0, 0, 0, 0, 0, "unsigned" } },
63 { CHAR, { CHAR_SIZE, CHAR_BIT,
64 SCHAR, UCHAR,
65 1, 0, 0, 1, 1, "char" } },
66 { SCHAR, { CHAR_SIZE, CHAR_BIT,
67 SCHAR, UCHAR,
68 1, 0, 0, 1, 1, "signed char" } },
69 { UCHAR, { CHAR_SIZE, CHAR_BIT,
70 SCHAR, UCHAR,
71 1, 1, 0, 1, 1, "unsigned char" } },
72 { SHORT, { SHORT_SIZE, 2 * CHAR_BIT,
73 SHORT, USHORT,
74 1, 0, 0, 1, 1, "short" } },
75 { USHORT, { SHORT_SIZE, 2 * CHAR_BIT,
76 SHORT, USHORT,
77 1, 1, 0, 1, 1, "unsigned short" } },
78 { INT, { INT_SIZE, 3 * CHAR_BIT,
79 INT, UINT,
80 1, 0, 0, 1, 1, "int" } },
81 { UINT, { INT_SIZE, 3 * CHAR_BIT,
82 INT, UINT,
83 1, 1, 0, 1, 1, "unsigned int" } },
84 { LONG, { LONG_SIZE, 4 * CHAR_BIT,
85 LONG, ULONG,
86 1, 0, 0, 1, 1, "long" } },
87 { ULONG, { LONG_SIZE, 4 * CHAR_BIT,
88 LONG, ULONG,
89 1, 1, 0, 1, 1, "unsigned long" } },
90 { QUAD, { QUAD_SIZE, 8 * CHAR_BIT,
91 QUAD, UQUAD,
92 1, 0, 0, 1, 1, "long long" } },
93 { UQUAD, { QUAD_SIZE, 8 * CHAR_BIT,
94 QUAD, UQUAD,
95 1, 1, 0, 1, 1, "unsigned long long" } },
96 { FLOAT, { sizeof (float) * CHAR_BIT, 4 * CHAR_BIT,
97 FLOAT, FLOAT,
98 0, 0, 1, 1, 1, "float" } },
99 { DOUBLE, { sizeof (double) * CHAR_BIT, 8 * CHAR_BIT,
100 DOUBLE, DOUBLE,
101 0, 0, 1, 1, 1, "double" } },
102 { LDOUBLE, { sizeof (ldbl_t) * CHAR_BIT, 10 * CHAR_BIT,
103 LDOUBLE, LDOUBLE,
104 0, 0, 1, 1, 1, "long double" } },
105 { VOID, { -1, -1,
106 VOID, VOID,
107 0, 0, 0, 0, 0, "void" } },
108 { STRUCT, { -1, -1,
109 STRUCT, STRUCT,
110 0, 0, 0, 0, 0, "struct" } },
111 { UNION, { -1, -1,
112 UNION, UNION,
113 0, 0, 0, 0, 0, "union" } },
114 { ENUM, { sizeof (int) * CHAR_BIT, 3 * CHAR_BIT,
115 ENUM, ENUM,
116 1, 0, 0, 1, 1, "enum" } },
117 { PTR, { PTR_SIZE, 4 * CHAR_BIT,
118 PTR, PTR,
119 0, 1, 0, 0, 1, "pointer" } },
120 { ARRAY, { -1, -1,
121 ARRAY, ARRAY,
122 0, 0, 0, 0, 0, "array" } },
123 { FUNC, { -1, -1,
124 FUNC, FUNC,
125 0, 0, 0, 0, 0, "function" } },
126 };
127
128 for (i = 0; i < sizeof (ittab) / sizeof (ittab[0]); i++)
129 STRUCT_ASSIGN(ttab[ittab[i].it_tspec], ittab[i].it_ttab);
130 if (!pflag) {
131 for (i = 0; i < NTSPEC; i++)
132 ttab[i].tt_psz = ttab[i].tt_sz;
133 }
134 }
135