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