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