1 /*	$OpenBSD: lint.h,v 1.7 2010/07/24 22:17:03 guenther Exp $	*/
2 /*	$NetBSD: lint.h,v 1.2 1995/07/03 21:24:18 cgd Exp $	*/
3 
4 /*
5  * Copyright (c) 1994, 1995 Jochen Pohl
6  * All Rights Reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by Jochen Pohl for
19  *	The NetBSD Project.
20  * 4. The name of the author may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #include <sys/types.h>
36 #include <stdio.h>
37 #include <stddef.h>
38 
39 #include "param.h"
40 
41 /*
42  * Type specifiers, used in type structures (type_t) and elsewhere.
43  */
44 typedef enum {
45 	NOTSPEC,
46 	SIGNED,		/* keyword "signed", only used in the parser */
47 	UNSIGN,		/* keyword "unsigned", only used in the parser */
48 	BOOL,		/* _Bool */
49 	CHAR,		/* char */
50 	SCHAR,		/* signed char */
51 	UCHAR,		/* unsigned char */
52 	SHORT,		/* (signed) short */
53 	USHORT,		/* unsigned short */
54 	INT,		/* (signed) int */
55 	UINT,		/* unsigned int */
56 	LONG,		/* (signed) long */
57 	ULONG,		/* unsigned long */
58 	QUAD,		/* (signed) long long */
59 	UQUAD,		/* unsigned long long */
60 	FLOAT,		/* float */
61 	DOUBLE,		/* double */
62 	LDOUBLE,	/* long double */
63 	COMPLEX,	/* float _Complex */
64 	DCOMPLEX,	/* double _Complex */
65 	LDCOMPLEX,	/* long double _Complex */
66 	IMAGINARY,	/* float _Imaginary */
67 	DIMAGINARY,	/* double _Imaginary */
68 	LDIMAGINARY,	/* long double _Imaginary */
69 	VOID,		/* void */
70 	STRUCT,		/* structure tag */
71 	UNION,		/* union tag */
72 	ENUM,		/* enum tag */
73 	PTR,		/* pointer */
74 	ARRAY,		/* array */
75 	FUNC		/* function */
76 #define	NTSPEC		((int)FUNC + 1)
77 } tspec_t;
78 
79 /*
80  * size of types, name and classification
81  */
82 typedef	struct {
83 	int	tt_sz;			/* size in bits */
84 	int	tt_psz;			/* size, different from tt_sz
85 					   if pflag is set */
86 	int	tt_rank;		/* rank (C99), similar to tt_psz */
87 	tspec_t	tt_styp;		/* signed counterpart */
88 	tspec_t	tt_utyp;		/* unsigned counterpart */
89 	u_int	tt_isityp : 1;		/* 1 if integer type */
90 	u_int	tt_isutyp : 1;		/* 1 if unsigned integer type */
91 	u_int	tt_isftyp : 1;		/* 1 if floating point type */
92 	u_int	tt_isatyp : 1;		/* 1 if arithmetic type */
93 	u_int	tt_domain : 2;		/* 0 if non-scalar, 1 if real,
94 					   2 if imaginary, 3 if complex */
95 	char	*tt_name;		/* type name */
96 } ttab_t;
97 
98 #define size(t)		(ttab[t].tt_sz)
99 #define psize(t)	(ttab[t].tt_psz)
100 #define rank(t)		(ttab[t].tt_rank)
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_domain != 0)
108 #define iscomplex(t)	(ttab[t].tt_domain == 3)
109 #define isimag(t)	(ttab[t].tt_domain == 2)
110 
111 extern	ttab_t	ttab[];
112 
113 
114 typedef	enum {
115 	NODECL,			/* until now not declared */
116 	DECL,			/* declared */
117 	TDEF,			/* tentative defined */
118 	DEF			/* defined */
119 } def_t;
120 
121 /*
122  * Following structure contains some data used for the output buffer.
123  */
124 typedef	struct	ob {
125 	char	*o_buf;		/* buffer */
126 	char	*o_end;		/* first byte after buffer */
127 	size_t	o_len;		/* length of buffer */
128 	char	*o_nxt;		/* next free byte in buffer */
129 } ob_t;
130 
131 #include "externs.h"
132