Home | History | Annotate | Line # | Download | only in common
lint.h revision 1.21
      1  1.21    rillig /*	$NetBSD: lint.h,v 1.21 2021/01/02 01:06:15 rillig Exp $	*/
      2   1.1   thorpej 
      3   1.1   thorpej /*
      4   1.1   thorpej  * Copyright (c) 1994, 1995 Jochen Pohl
      5   1.1   thorpej  * All Rights Reserved.
      6   1.1   thorpej  *
      7   1.1   thorpej  * Redistribution and use in source and binary forms, with or without
      8   1.1   thorpej  * modification, are permitted provided that the following conditions
      9   1.1   thorpej  * are met:
     10   1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     11   1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     12   1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     14   1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     15   1.1   thorpej  * 3. All advertising materials mentioning features or use of this software
     16   1.1   thorpej  *    must display the following acknowledgement:
     17   1.1   thorpej  *      This product includes software developed by Jochen Pohl for
     18   1.1   thorpej  *	The NetBSD Project.
     19   1.1   thorpej  * 4. The name of the author may not be used to endorse or promote products
     20   1.1   thorpej  *    derived from this software without specific prior written permission.
     21   1.1   thorpej  *
     22   1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23   1.1   thorpej  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24   1.1   thorpej  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25   1.1   thorpej  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26   1.1   thorpej  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27   1.1   thorpej  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28   1.1   thorpej  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29   1.1   thorpej  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30   1.1   thorpej  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31   1.1   thorpej  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32   1.1   thorpej  */
     33   1.1   thorpej 
     34   1.7     lukem #if HAVE_NBTOOL_CONFIG_H
     35   1.7     lukem #include "nbtool_config.h"
     36   1.2        tv #else
     37   1.2        tv #define HAVE_DECL_SYS_SIGNAME 1
     38   1.2        tv #endif
     39   1.2        tv 
     40   1.1   thorpej #include <sys/types.h>
     41   1.3        tv #include <err.h>
     42   1.6        tv #include <inttypes.h>
     43  1.21    rillig #include <stdbool.h>
     44  1.21    rillig #include <stddef.h>
     45   1.5        tv #include <stdio.h>
     46   1.1   thorpej 
     47   1.1   thorpej #include "param.h"
     48   1.1   thorpej 
     49   1.1   thorpej /*
     50  1.17    rillig  * Type specifiers, used in type structures (type_t) and elsewhere.
     51   1.1   thorpej  */
     52   1.1   thorpej typedef enum {
     53   1.1   thorpej 	NOTSPEC = 0,
     54   1.1   thorpej 	SIGNED,		/* keyword "signed", only used in the parser */
     55   1.1   thorpej 	UNSIGN,		/* keyword "unsigned", only used in the parser */
     56   1.8      yamt 	BOOL,		/* _Bool */
     57   1.1   thorpej 	CHAR,		/* char */
     58   1.1   thorpej 	SCHAR,		/* signed char */
     59   1.1   thorpej 	UCHAR,		/* unsigned char */
     60   1.1   thorpej 	SHORT,		/* (signed) short */
     61   1.1   thorpej 	USHORT,		/* unsigned short */
     62   1.1   thorpej 	INT,		/* (signed) int */
     63   1.1   thorpej 	UINT,		/* unsigned int */
     64   1.1   thorpej 	LONG,		/* (signed) long */
     65   1.1   thorpej 	ULONG,		/* unsigned long */
     66   1.1   thorpej 	QUAD,		/* (signed) long long */
     67   1.1   thorpej 	UQUAD,		/* unsigned long long */
     68  1.14  christos #ifdef INT128_SIZE
     69  1.14  christos 	INT128,		/* (signed) __int128_t */
     70  1.14  christos 	UINT128,	/* __uint128_t */
     71  1.14  christos #endif
     72   1.1   thorpej 	FLOAT,		/* float */
     73   1.1   thorpej 	DOUBLE,		/* double or, with tflag, long float */
     74   1.1   thorpej 	LDOUBLE,	/* long double */
     75   1.1   thorpej 	VOID,		/* void */
     76   1.1   thorpej 	STRUCT,		/* structure tag */
     77   1.1   thorpej 	UNION,		/* union tag */
     78   1.1   thorpej 	ENUM,		/* enum tag */
     79   1.1   thorpej 	PTR,		/* pointer */
     80   1.1   thorpej 	ARRAY,		/* array */
     81   1.1   thorpej 	FUNC,		/* function */
     82  1.12      matt 	COMPLEX,	/* _Complex */
     83  1.11  christos 	FCOMPLEX,	/* float _Complex */
     84  1.11  christos 	DCOMPLEX,	/* double _Complex */
     85  1.19    rillig 	LCOMPLEX	/* long double _Complex */
     86  1.19    rillig #define NTSPEC (LCOMPLEX + 1)
     87   1.1   thorpej } tspec_t;
     88   1.1   thorpej 
     89  1.19    rillig 
     90   1.1   thorpej /*
     91   1.1   thorpej  * size of types, name and classification
     92   1.1   thorpej  */
     93   1.1   thorpej typedef	struct {
     94  1.13  christos 	size_t	tt_sz;			/* size in bits */
     95  1.13  christos 	size_t	tt_psz;			/* size, different from tt_sz
     96   1.1   thorpej 					   if pflag is set */
     97  1.20    rillig 	tspec_t	tt_signed_counterpart;
     98  1.20    rillig 	tspec_t	tt_unsigned_counterpart;
     99  1.21    rillig 	bool	tt_is_int : 1;		/* integer type */
    100  1.21    rillig 	bool	tt_is_uint : 1;		/* unsigned integer type */
    101  1.21    rillig 	bool	tt_is_float : 1;	/* floating point type */
    102  1.21    rillig 	bool	tt_is_arith : 1;	/* arithmetic type */
    103  1.21    rillig 	bool	tt_is_scalar : 1;	/* scalar type */
    104  1.21    rillig 	bool	tt_is_complex : 1;	/* complex type */
    105  1.15    rillig 	const char *tt_name;		/* name of the type */
    106   1.1   thorpej } ttab_t;
    107   1.1   thorpej 
    108  1.16    rillig #define size(t)			(ttab[t].tt_sz)
    109  1.16    rillig #define psize(t)		(ttab[t].tt_psz)
    110  1.20    rillig #define signed_type(t)		(ttab[t].tt_signed_counterpart)
    111  1.20    rillig #define unsigned_type(t)	(ttab[t].tt_unsigned_counterpart)
    112  1.16    rillig #define tspec_is_int(t)		(ttab[t].tt_is_int)
    113  1.16    rillig #define tspec_is_uint(t)	(ttab[t].tt_is_uint)
    114  1.16    rillig #define tspec_is_float(t)	(ttab[t].tt_is_float)
    115  1.16    rillig #define tspec_is_arith(t)	(ttab[t].tt_is_arith)
    116  1.16    rillig #define tspec_is_complex(t)	(ttab[t].tt_is_complex)
    117  1.16    rillig #define tspec_is_scalar(t)	(ttab[t].tt_is_scalar)
    118   1.1   thorpej 
    119   1.1   thorpej extern	ttab_t	ttab[];
    120   1.1   thorpej 
    121   1.1   thorpej 
    122   1.1   thorpej typedef	enum {
    123  1.19    rillig 	NODECL,			/* not declared until now */
    124   1.1   thorpej 	DECL,			/* declared */
    125   1.1   thorpej 	TDEF,			/* tentative defined */
    126   1.1   thorpej 	DEF			/* defined */
    127   1.1   thorpej } def_t;
    128   1.1   thorpej 
    129  1.19    rillig /* Some data used for the output buffer. */
    130   1.1   thorpej typedef	struct	ob {
    131   1.1   thorpej 	char	*o_buf;		/* buffer */
    132   1.1   thorpej 	char	*o_end;		/* first byte after buffer */
    133   1.1   thorpej 	size_t	o_len;		/* length of buffer */
    134  1.18    rillig 	char	*o_next;	/* next free byte in buffer */
    135   1.1   thorpej } ob_t;
    136   1.1   thorpej 
    137   1.9  christos typedef struct type type_t;
    138   1.9  christos 
    139   1.1   thorpej #include "externs.h"
    140