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