[BACK]Return to lint.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.bin / xlint / common

Annotation of src/usr.bin/xlint/common/lint.h, Revision 1.26

1.26    ! rillig      1: /*     $NetBSD: lint.h,v 1.25 2021/01/16 02:40:02 rillig Exp $ */
1.1       thorpej     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:
1.7       lukem      34: #if HAVE_NBTOOL_CONFIG_H
                     35: #include "nbtool_config.h"
1.2       tv         36: #else
                     37: #define HAVE_DECL_SYS_SIGNAME 1
                     38: #endif
                     39:
1.1       thorpej    40: #include <sys/types.h>
1.25      rillig     41: #include <ctype.h>
1.3       tv         42: #include <err.h>
1.6       tv         43: #include <inttypes.h>
1.21      rillig     44: #include <stdbool.h>
                     45: #include <stddef.h>
1.5       tv         46: #include <stdio.h>
1.1       thorpej    47:
                     48: #include "param.h"
                     49:
                     50: /*
1.17      rillig     51:  * Type specifiers, used in type structures (type_t) and elsewhere.
1.1       thorpej    52:  */
                     53: typedef enum {
                     54:        NOTSPEC = 0,
                     55:        SIGNED,         /* keyword "signed", only used in the parser */
                     56:        UNSIGN,         /* keyword "unsigned", only used in the parser */
1.8       yamt       57:        BOOL,           /* _Bool */
1.1       thorpej    58:        CHAR,           /* char */
                     59:        SCHAR,          /* signed char */
                     60:        UCHAR,          /* unsigned char */
                     61:        SHORT,          /* (signed) short */
                     62:        USHORT,         /* unsigned short */
                     63:        INT,            /* (signed) int */
                     64:        UINT,           /* unsigned int */
                     65:        LONG,           /* (signed) long */
                     66:        ULONG,          /* unsigned long */
                     67:        QUAD,           /* (signed) long long */
                     68:        UQUAD,          /* unsigned long long */
1.14      christos   69: #ifdef INT128_SIZE
                     70:        INT128,         /* (signed) __int128_t */
                     71:        UINT128,        /* __uint128_t */
                     72: #endif
1.1       thorpej    73:        FLOAT,          /* float */
                     74:        DOUBLE,         /* double or, with tflag, long float */
                     75:        LDOUBLE,        /* long double */
                     76:        VOID,           /* void */
                     77:        STRUCT,         /* structure tag */
                     78:        UNION,          /* union tag */
                     79:        ENUM,           /* enum tag */
                     80:        PTR,            /* pointer */
                     81:        ARRAY,          /* array */
                     82:        FUNC,           /* function */
1.12      matt       83:        COMPLEX,        /* _Complex */
1.11      christos   84:        FCOMPLEX,       /* float _Complex */
                     85:        DCOMPLEX,       /* double _Complex */
1.19      rillig     86:        LCOMPLEX        /* long double _Complex */
                     87: #define NTSPEC (LCOMPLEX + 1)
1.1       thorpej    88: } tspec_t;
                     89:
1.19      rillig     90:
1.1       thorpej    91: /*
                     92:  * size of types, name and classification
                     93:  */
                     94: typedef        struct {
1.26    ! rillig     95:        size_t  tt_size_in_bits;
        !            96:        size_t  tt_portable_size_in_bits; /* different from tt_size_in_bits
        !            97:                                         * if pflag is set */
1.20      rillig     98:        tspec_t tt_signed_counterpart;
                     99:        tspec_t tt_unsigned_counterpart;
1.24      rillig    100:        bool    tt_is_integer : 1;      /* integer type */
                    101:        bool    tt_is_uinteger : 1;     /* unsigned integer type */
                    102:        bool    tt_is_floating : 1;     /* floating point type */
                    103:        bool    tt_is_arithmetic : 1;   /* arithmetic type */
1.21      rillig    104:        bool    tt_is_scalar : 1;       /* scalar type */
                    105:        bool    tt_is_complex : 1;      /* complex type */
1.15      rillig    106:        const char *tt_name;            /* name of the type */
1.1       thorpej   107: } ttab_t;
                    108:
1.26    ! rillig    109: #define size_in_bits(t)                (ttab[t].tt_size_in_bits)
        !           110: #define portable_size_in_bits(t) (ttab[t].tt_portable_size_in_bits)
1.20      rillig    111: #define signed_type(t)         (ttab[t].tt_signed_counterpart)
                    112: #define unsigned_type(t)       (ttab[t].tt_unsigned_counterpart)
1.24      rillig    113: #define is_integer(t)          (ttab[t].tt_is_integer)
                    114: #define is_uinteger(t)         (ttab[t].tt_is_uinteger)
                    115: #define is_floating(t)         (ttab[t].tt_is_floating)
                    116: #define is_arithmetic(t)       (ttab[t].tt_is_arithmetic)
                    117: #define is_complex(t)          (ttab[t].tt_is_complex)
                    118: #define is_scalar(t)           (ttab[t].tt_is_scalar)
1.1       thorpej   119:
                    120: extern ttab_t  ttab[];
                    121:
                    122:
                    123: typedef        enum {
1.19      rillig    124:        NODECL,                 /* not declared until now */
1.1       thorpej   125:        DECL,                   /* declared */
                    126:        TDEF,                   /* tentative defined */
                    127:        DEF                     /* defined */
                    128: } def_t;
                    129:
1.19      rillig    130: /* Some data used for the output buffer. */
1.1       thorpej   131: typedef        struct  ob {
                    132:        char    *o_buf;         /* buffer */
                    133:        char    *o_end;         /* first byte after buffer */
                    134:        size_t  o_len;          /* length of buffer */
1.18      rillig    135:        char    *o_next;        /* next free byte in buffer */
1.1       thorpej   136: } ob_t;
                    137:
1.9       christos  138: typedef struct type type_t;
                    139:
1.1       thorpej   140: #include "externs.h"
1.25      rillig    141:
                    142: static inline bool
                    143: ch_isalnum(char ch) { return isalnum((unsigned char)ch) != 0; }
                    144: static inline bool
                    145: ch_isdigit(char ch) { return isdigit((unsigned char)ch) != 0; }
                    146: static inline bool
                    147: ch_isprint(char ch) { return isprint((unsigned char)ch) != 0; }
                    148: static inline bool
                    149: ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; }

CVSweb <webmaster@jp.NetBSD.org>