lint.h revision 1.17 1 /* $NetBSD: lint.h,v 1.17 2020/12/28 21:24:55 rillig 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 #if HAVE_NBTOOL_CONFIG_H
35 #include "nbtool_config.h"
36 #else
37 #define HAVE_DECL_SYS_SIGNAME 1
38 #endif
39
40 #include <sys/types.h>
41 #include <stddef.h>
42 #include <err.h>
43 #include <inttypes.h>
44 #include <stdio.h>
45
46 #include "param.h"
47
48 /*
49 * Type specifiers, used in type structures (type_t) and elsewhere.
50 */
51 typedef enum {
52 NOTSPEC = 0,
53 SIGNED, /* keyword "signed", only used in the parser */
54 UNSIGN, /* keyword "unsigned", only used in the parser */
55 BOOL, /* _Bool */
56 CHAR, /* char */
57 SCHAR, /* signed char */
58 UCHAR, /* unsigned char */
59 SHORT, /* (signed) short */
60 USHORT, /* unsigned short */
61 INT, /* (signed) int */
62 UINT, /* unsigned int */
63 LONG, /* (signed) long */
64 ULONG, /* unsigned long */
65 QUAD, /* (signed) long long */
66 UQUAD, /* unsigned long long */
67 #ifdef INT128_SIZE
68 INT128, /* (signed) __int128_t */
69 UINT128, /* __uint128_t */
70 #endif
71 FLOAT, /* float */
72 DOUBLE, /* double or, with tflag, long float */
73 LDOUBLE, /* long double */
74 VOID, /* void */
75 STRUCT, /* structure tag */
76 UNION, /* union tag */
77 ENUM, /* enum tag */
78 PTR, /* pointer */
79 ARRAY, /* array */
80 FUNC, /* function */
81 COMPLEX, /* _Complex */
82 FCOMPLEX, /* float _Complex */
83 DCOMPLEX, /* double _Complex */
84 LCOMPLEX, /* long double _Complex */
85 NTSPEC
86 } tspec_t;
87
88 /*
89 * size of types, name and classification
90 */
91 typedef struct {
92 size_t tt_sz; /* size in bits */
93 size_t tt_psz; /* size, different from tt_sz
94 if pflag is set */
95 tspec_t tt_styp; /* signed counterpart */
96 tspec_t tt_utyp; /* unsigned counterpart */
97 u_int tt_is_int : 1; /* 1 if integer type */
98 u_int tt_is_uint : 1; /* 1 if unsigned integer type */
99 u_int tt_is_float : 1; /* 1 if floating point type */
100 u_int tt_is_arith : 1; /* 1 if arithmetic type */
101 u_int tt_is_scalar : 1; /* 1 if scalar type */
102 u_int tt_is_complex : 1; /* 1 if complex type */
103 const char *tt_name; /* name of the type */
104 } ttab_t;
105
106 #define size(t) (ttab[t].tt_sz)
107 #define psize(t) (ttab[t].tt_psz)
108 #define styp(t) (ttab[t].tt_styp)
109 #define utyp(t) (ttab[t].tt_utyp)
110 #define tspec_is_int(t) (ttab[t].tt_is_int)
111 #define tspec_is_uint(t) (ttab[t].tt_is_uint)
112 #define tspec_is_float(t) (ttab[t].tt_is_float)
113 #define tspec_is_arith(t) (ttab[t].tt_is_arith)
114 #define tspec_is_complex(t) (ttab[t].tt_is_complex)
115 #define tspec_is_scalar(t) (ttab[t].tt_is_scalar)
116
117 extern ttab_t ttab[];
118
119
120 typedef enum {
121 NODECL, /* until now not declared */
122 DECL, /* declared */
123 TDEF, /* tentative defined */
124 DEF /* defined */
125 } def_t;
126
127 /*
128 * Following structure contains some data used for the output buffer.
129 */
130 typedef struct ob {
131 char *o_buf; /* buffer */
132 char *o_end; /* first byte after buffer */
133 size_t o_len; /* length of buffer */
134 char *o_nxt; /* next free byte in buffer */
135 } ob_t;
136
137 typedef struct type type_t;
138
139 #include "externs.h"
140