lint.h revision 1.2 1 /* $NetBSD: lint.h,v 1.2 2002/01/21 19:49:51 tv 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_CONFIG_H
35 #include "config.h"
36 #else
37 #define HAVE_ERR_H 1
38 #define HAVE_DECL_SYS_SIGNAME 1
39 #endif
40
41 #include <sys/types.h>
42 #include <stddef.h>
43 #include <stdio.h>
44
45 #if HAVE_ERR_H
46 #include <err.h>
47 #endif
48
49 #include "param.h"
50
51 /*
52 * Type specifiers, used in type structures (type_t) and otherwere.
53 */
54 typedef enum {
55 NOTSPEC = 0,
56 SIGNED, /* keyword "signed", only used in the parser */
57 UNSIGN, /* keyword "unsigned", only used in the parser */
58 CHAR, /* char */
59 SCHAR, /* signed char */
60 UCHAR, /* unsigned char */
61 SHORT, /* (signed) short */
62 USHORT, /* unsigned short */
63 INT, /* (signed) int */
64 UINT, /* unsigned int */
65 LONG, /* (signed) long */
66 ULONG, /* unsigned long */
67 QUAD, /* (signed) long long */
68 UQUAD, /* unsigned long long */
69 FLOAT, /* float */
70 DOUBLE, /* double or, with tflag, long float */
71 LDOUBLE, /* long double */
72 VOID, /* void */
73 STRUCT, /* structure tag */
74 UNION, /* union tag */
75 ENUM, /* enum tag */
76 PTR, /* pointer */
77 ARRAY, /* array */
78 FUNC, /* function */
79 NTSPEC
80 } tspec_t;
81
82 /*
83 * size of types, name and classification
84 */
85 typedef struct {
86 int tt_sz; /* size in bits */
87 int tt_psz; /* size, different from tt_sz
88 if pflag is set */
89 tspec_t tt_styp; /* signed counterpart */
90 tspec_t tt_utyp; /* unsigned counterpart */
91 u_int tt_isityp : 1; /* 1 if integer type */
92 u_int tt_isutyp : 1; /* 1 if unsigned integer type */
93 u_int tt_isftyp : 1; /* 1 if floating point type */
94 u_int tt_isatyp : 1; /* 1 if arithmetic type */
95 u_int tt_issclt : 1; /* 1 if scalar type */
96 char *tt_name; /* Bezeichnung des Typs */
97 } ttab_t;
98
99 #define size(t) (ttab[t].tt_sz)
100 #define psize(t) (ttab[t].tt_psz)
101 #define styp(t) (ttab[t].tt_styp)
102 #define utyp(t) (ttab[t].tt_utyp)
103 #define isityp(t) (ttab[t].tt_isityp)
104 #define isutyp(t) (ttab[t].tt_isutyp)
105 #define isftyp(t) (ttab[t].tt_isftyp)
106 #define isatyp(t) (ttab[t].tt_isatyp)
107 #define issclt(t) (ttab[t].tt_issclt)
108
109 extern ttab_t ttab[];
110
111
112 typedef enum {
113 NODECL, /* until now not declared */
114 DECL, /* declared */
115 TDEF, /* tentative defined */
116 DEF /* defined */
117 } def_t;
118
119 /*
120 * Following structure contains some data used for the output buffer.
121 */
122 typedef struct ob {
123 char *o_buf; /* buffer */
124 char *o_end; /* first byte after buffer */
125 size_t o_len; /* length of buffer */
126 char *o_nxt; /* next free byte in buffer */
127 } ob_t;
128
129 #include "externs.h"
130