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