1 /* 2 * Copyright (c) 2003 - 2010, Nils R. Weller 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * POSSIBILITY OF SUCH DAMAGE. 26 */ 27 #ifndef ATTRIBUTE_H 28 #define ATTRIBUTE_H 29 30 /* Function attributes */ 31 #define ATTRF_ALIAS 1 32 #define ATTRF_ALWAYS_INLINE 2 33 #define ATTRF_CDECL 3 34 #define ATTRF_CONST 4 35 #define ATTRF_CONSTRUCTOR 5 36 #define ATTRF_DEPRECATED 6 37 #define ATTRF_DESTRUCTOR 7 38 #define ATTRF_DLLIMPORT 8 39 #define ATTRF_DLLEXPORT 9 40 #define ATTRF_EIGHTBIT_DATA 10 41 #define ATTRF_FAR 11 42 #define ATTRF_FORMAT 12 43 44 #define ATTRF_FORMAT_IGNORED 0 45 #define ATTRF_FORMAT_PRINTF 1 46 #define ATTRF_FORMAT_SCANF 2 47 48 #define ATTRF_FORMAT_ARG 13 49 #define ATTRF_FUNCTION_VECTOR 14 50 #define ATTRF_INTERRUPT 15 51 #define ATTRF_INTERRUPT_HANDLER 16 52 #define ATTRF_LONGCALL 17 53 #define ATTRF_MALLOC 18 54 #define ATTRF_MODEL 19 55 #define ATTRF_NAKED 20 56 #define ATTRF_NEAR 21 57 #define ATTRF_NO_INSTRUMENT_FUNCTION 22 58 #define ATTRF_NOINLINE 23 59 #define ATTRF_NONNULL 24 60 #define ATTRF_NOTHROW 25 61 #define ATTRF_PURE 26 62 #define ATTRF_REGPARM 27 63 #define ATTRF_SECTION 28 64 #define ATTRF_SHORTCALL 29 65 #define ATTRF_SIGNAL 30 66 #define ATTRF_SP_SWITCH 31 67 #define ATTRF_STDCALL 32 68 #define ATTRF_TINY_DATA 33 69 #define ATTRF_TRAP_EXIT 34 70 #define ATTRF_UNUSED 35 71 #define ATTRF_USED 36 72 #define ATTRF_VISIBILITY 37 73 #define ATTRF_WEAK 38 74 #define ATTRF_EXCEPTION_HANDLER 39 75 #define ATTRF_EXTERNALLY_VISIBLE 40 76 #define ATTRF_FASTCALL 41 77 #define ATTRF_FLATTEN 42 78 #define ATTRF_FORCE_ALIGN_ARG_POINTER 43 79 #define ATTRF_LONG_CALL 44 80 #define ATTRF_GNU_INLINE 45 81 #define ATTRF_KSPISUSP 46 82 #define ATTRF_NESTING 47 83 #define ATTRF_NMI_HANDLER 48 84 #define ATTRF_NORETURN 49 85 #define ATTRF_RETURNS_TWICE 50 86 #define ATTRF_SENTINEL 51 87 #define ATTRF_SHORT_CALL 52 88 #define ATTRF_SSEREGPARAM 53 89 90 91 92 /* Structure / union / enum attributes */ 93 #define ATTRS_ALIGNED 60 94 #define ATTRS_DEPRECATED 61 95 #define ATTRS_MAY_ALIAS 62 96 #define ATTRS_PACKED 63 97 #define ATTRS_TRANSPARENT_UNION 64 98 #define ATTRS_UNUSED 65 99 100 101 /* Variable attributes */ 102 #define ATTRV_ALIGNED 90 103 #define ATTRV_CLEANUP 91 104 #define ATTRV_COMMON 92 105 #define ATTRV_DEPRECATED 93 106 #define ATTRV_DLLIMPORT 94 107 #define ATTRV_DLLEXPORT 95 108 #define ATTRV_MODE 96 109 110 #define ATTR_MODE_DI 1 111 #define ATTR_MODE_SI 2 112 113 #define ATTRV_MODEL 97 114 #define ATTRV_NOCOMMON 98 115 #define ATTRV_PACKED 99 116 #define ATTRV_SECTION 100 117 #define ATTRV_SHARED 101 118 #define ATTRV_TLS_MODEL 102 119 #define ATTRV_TRANSPARENT_UNION 103 120 #define ATTRV_UNUSED 104 121 #define ATTRV_VECTOR_SIZE 105 122 #define ATTRV_WEAK 106 123 #define ATTRV_BOUNDED 107 124 125 #define ATTR_ISFUNC(val) \ 126 ((val) >= ATTRF_NOINLINE && (val) <= ATTRF_DLLEXPORT) 127 128 #define ATTR_ISSTRUCT(val) \ 129 ((val) >= ATTRS_ALIGNED && (val) <= ATTRS_MAY_ALIAS) 130 131 #define ATTR_ISVAR(val) \ 132 ((val) >= ATTRV_ALIGNED && (val) <= ATTRV_DLLEXPORT) 133 134 /* 135 * Common attribute flags to quickly determine whether popular 136 * attributes are set 137 */ 138 #define CATTR_WEAK (1) 139 #define CATTR_PACKED (1 << 1) 140 #define CATTR_ALIGNED (1 << 2) 141 #define CATTR_ALIGN (1 << 3) 142 #define CATTR_FORMAT (1 << 4) 143 #define CATTR_MODE (1 << 5) 144 #define CATTR_TRANSPARENT_UNION (1 << 6) 145 #define CATTR_SECTION (1 << 7) 146 #define CATTR_PURE (1 << 7) 147 #define CATTR_USED (1 << 8) 148 #define CATTR_UNUSED (1 << 9) 149 150 151 #define ATTR_FUNC 1 152 #define ATTR_STRUCT 2 153 #define ATTR_VAR 3 154 155 struct attrib { 156 int type; /* function, structure or object */ 157 int code; /* actual value of attribute */ 158 int is_impl; /* is it implemented? */ 159 unsigned fastattrflag; 160 char *parg; /* pointer argument, if used */ 161 int iarg; /* integer argument, if used */ 162 int iarg2; /* 02/01/10: second integer argument, if used */ 163 int iarg3; /* 02/01/10: third integer argument, if used */ 164 struct token *tok; 165 struct attrib *next; /* next attribute */ 166 }; 167 168 struct token; 169 struct type; 170 struct decl; 171 172 extern int used_attribute_alias; 173 174 void merge_attr_with_type(struct type *); 175 void merge_attr_with_decl(struct decl *, struct attrib *); 176 struct attrib *lookup_attr(struct attrib *, int type); 177 struct attrib *dup_attr_list(struct attrib *); 178 void append_attribute(struct attrib **head, struct attrib *attr); 179 struct attrib *get_attribute(struct type *dest, struct token **tok); 180 struct token *ignore_attr(struct token *tok); 181 struct attrib *lookup_attr(struct attrib *, int); 182 void stupid_append_attr(struct attrib **, struct attrib *); 183 184 185 #endif 186 187