Print this page
12257 resync smatch to 0.6.1-rc1-il-4
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/smatch/src/lib.h
+++ new/usr/src/tools/smatch/src/lib.h
1 1 #ifndef LIB_H
2 2 #define LIB_H
3 3
4 4 #include <stdbool.h>
5 5 #include <stdlib.h>
6 6 #include <stddef.h>
7 7
8 8 /*
9 9 * Basic helper routine descriptions for 'sparse'.
10 10 *
11 11 * Copyright (C) 2003 Transmeta Corp.
12 12 * 2003 Linus Torvalds
13 13 * 2004 Christopher Li
14 14 *
15 15 * Permission is hereby granted, free of charge, to any person obtaining a copy
16 16 * of this software and associated documentation files (the "Software"), to deal
17 17 * in the Software without restriction, including without limitation the rights
18 18 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19 19 * copies of the Software, and to permit persons to whom the Software is
20 20 * furnished to do so, subject to the following conditions:
21 21 *
22 22 * The above copyright notice and this permission notice shall be included in
23 23 * all copies or substantial portions of the Software.
24 24 *
25 25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 28 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 29 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 30 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 31 * THE SOFTWARE.
32 32 */
33 33
34 34 #include "compat.h"
35 35 #include "ptrlist.h"
36 36 #include "utils.h"
37 37 #include "bits.h"
38 38
39 39 #define DO_STRINGIFY(x) #x
40 40 #define STRINGIFY(x) DO_STRINGIFY(x)
41 41
42 42 #ifndef ARRAY_SIZE
43 43 #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
44 44 #endif
45 45
46 46 extern int verbose, optimize_level, optimize_size, preprocessing;
47 47 extern int die_if_error;
48 48 extern int parse_error;
49 49 extern int repeat_phase;
50 50 extern int do_output;
51 51 extern int gcc_major, gcc_minor, gcc_patchlevel;
52 52
53 53 extern const char *base_filename;
54 54
55 55 extern unsigned int hexval(unsigned int c);
56 56
57 57 struct position {
58 58 unsigned int type:6,
59 59 stream:14,
60 60 newline:1,
61 61 whitespace:1,
62 62 pos:10;
63 63 unsigned int line:31,
64 64 noexpand:1;
65 65 };
66 66
67 67 struct ident;
68 68 struct token;
69 69 struct symbol;
70 70 struct statement;
71 71 struct expression;
72 72 struct basic_block;
73 73 struct entrypoint;
74 74 struct instruction;
75 75 struct multijmp;
76 76 struct pseudo;
77 77
78 78 DECLARE_PTR_LIST(symbol_list, struct symbol);
79 79 DECLARE_PTR_LIST(statement_list, struct statement);
80 80 DECLARE_PTR_LIST(expression_list, struct expression);
81 81 DECLARE_PTR_LIST(basic_block_list, struct basic_block);
82 82 DECLARE_PTR_LIST(instruction_list, struct instruction);
83 83 DECLARE_PTR_LIST(multijmp_list, struct multijmp);
84 84 DECLARE_PTR_LIST(pseudo_list, struct pseudo);
85 85 DECLARE_PTR_LIST(ident_list, struct ident);
86 86 DECLARE_PTR_LIST(string_list, char);
87 87
88 88 typedef struct pseudo *pseudo_t;
89 89
90 90 struct token *skip_to(struct token *, int);
91 91 struct token *expect(struct token *, int, const char *);
92 92 void unexpected(struct token *, const char *errmsg);
93 93
94 94 #ifdef __GNUC__
95 95 #define FORMAT_ATTR(pos) __attribute__ ((__format__ (__printf__, pos, pos+1)))
96 96 #define NORETURN_ATTR __attribute__ ((__noreturn__))
97 97 #define SENTINEL_ATTR __attribute__ ((__sentinel__))
98 98 #else
99 99 #define FORMAT_ATTR(pos)
100 100 #define NORETURN_ATTR
101 101 #define SENTINEL_ATTR
102 102 #endif
103 103
104 104 FORMAT_ATTR(1) NORETURN_ATTR
105 105 extern void die(const char *, ...);
106 106
107 107 FORMAT_ATTR(2) NORETURN_ATTR
108 108 extern void error_die(struct position, const char *, ...);
109 109
110 110 extern void info(struct position, const char *, ...) FORMAT_ATTR(2);
111 111 extern void warning(struct position, const char *, ...) FORMAT_ATTR(2);
112 112 extern void sparse_error(struct position, const char *, ...) FORMAT_ATTR(2);
113 113 extern void expression_error(struct expression *, const char *, ...) FORMAT_ATTR(2);
114 114
115 115 #define ERROR_CURR_PHASE (1 << 0)
116 116 #define ERROR_PREV_PHASE (1 << 1)
117 117 extern int has_error;
118 118
119 119
120 120 enum phase {
121 121 PASS__PARSE,
122 122 PASS__LINEARIZE,
123 123 PASS__MEM2REG,
124 124 PASS__OPTIM,
125 125 PASS__FINAL,
126 126 };
↓ open down ↓ |
126 lines elided |
↑ open up ↑ |
127 127
128 128 #define PASS_PARSE (1UL << PASS__PARSE)
129 129 #define PASS_LINEARIZE (1UL << PASS__LINEARIZE)
130 130 #define PASS_MEM2REG (1UL << PASS__MEM2REG)
131 131 #define PASS_OPTIM (1UL << PASS__OPTIM)
132 132 #define PASS_FINAL (1UL << PASS__FINAL)
133 133
134 134
135 135 extern void add_pre_buffer(const char *fmt, ...) FORMAT_ATTR(1);
136 136 extern void predefine(const char *name, int weak, const char *fmt, ...) FORMAT_ATTR(3);
137 +extern void predefine_nostd(const char *name);
137 138
138 139 extern int preprocess_only;
139 140
140 141 extern int Waddress;
141 142 extern int Waddress_space;
142 143 extern int Wbitwise;
143 144 extern int Wbitwise_pointer;
144 145 extern int Wcast_from_as;
145 146 extern int Wcast_to_as;
146 147 extern int Wcast_truncate;
147 148 extern int Wconstant_suffix;
148 149 extern int Wconstexpr_not_const;
149 150 extern int Wcontext;
150 151 extern int Wdecl;
151 152 extern int Wdeclarationafterstatement;
152 153 extern int Wdefault_bitfield_sign;
153 154 extern int Wdesignated_init;
154 155 extern int Wdo_while;
155 156 extern int Wenum_mismatch;
156 157 extern int Wexternal_function_has_definition;
157 158 extern int Wsparse_error;
158 159 extern int Wimplicit_int;
159 160 extern int Winit_cstring;
160 161 extern int Wint_to_pointer_cast;
161 162 extern int Wmemcpy_max_count;
162 163 extern int Wnon_pointer_null;
163 164 extern int Wold_initializer;
164 165 extern int Wold_style_definition;
165 166 extern int Wone_bit_signed_bitfield;
166 167 extern int Woverride_init;
167 168 extern int Woverride_init_all;
168 169 extern int Woverride_init_whole_range;
169 170 extern int Wparen_string;
170 171 extern int Wpointer_arith;
171 172 extern int Wpointer_to_int_cast;
172 173 extern int Wptr_subtraction_blows;
173 174 extern int Wreturn_void;
174 175 extern int Wshadow;
175 176 extern int Wshift_count_negative;
176 177 extern int Wshift_count_overflow;
177 178 extern int Wsizeof_bool;
178 179 extern int Wstrict_prototypes;
179 180 extern int Wtautological_compare;
180 181 extern int Wtransparent_union;
181 182 extern int Wtypesign;
182 183 extern int Wundef;
183 184 extern int Wuninitialized;
184 185 extern int Wunknown_attribute;
185 186 extern int Wvla;
186 187
187 188 extern int dump_macro_defs;
188 189 extern int dump_macros_only;
189 190
190 191 extern int dbg_compound;
191 192 extern int dbg_dead;
192 193 extern int dbg_domtree;
193 194 extern int dbg_entry;
194 195 extern int dbg_ir;
195 196 extern int dbg_postorder;
196 197
197 198 extern unsigned int fmax_warnings;
198 199 extern int fmem_report;
↓ open down ↓ |
52 lines elided |
↑ open up ↑ |
199 200 extern unsigned long fdump_ir;
200 201 extern unsigned long long fmemcpy_max_count;
201 202 extern unsigned long fpasses;
202 203 extern int funsigned_char;
203 204
204 205 extern int arch_m64;
205 206 extern int arch_msize_long;
206 207 extern int arch_big_endian;
207 208 extern int arch_mach;
208 209
210 +enum standard {
211 + STANDARD_NONE,
212 + STANDARD_GNU,
213 + STANDARD_C89,
214 + STANDARD_GNU89 = STANDARD_C89 | STANDARD_GNU,
215 + STANDARD_C94,
216 + STANDARD_GNU94 = STANDARD_C94 | STANDARD_GNU,
217 + STANDARD_C99,
218 + STANDARD_GNU99 = STANDARD_C99 | STANDARD_GNU,
219 + STANDARD_C11,
220 + STANDARD_GNU11 = STANDARD_C11 | STANDARD_GNU,
221 +};
222 +extern enum standard standard;
223 +
209 224 extern void dump_macro_definitions(void);
210 225 extern struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list **files);
211 226 extern struct symbol_list *__sparse(char *filename);
212 227 extern struct symbol_list *sparse_keep_tokens(char *filename);
213 228 extern struct symbol_list *sparse(char *filename);
214 229 extern void report_stats(void);
215 230
216 231 static inline int symbol_list_size(struct symbol_list *list)
217 232 {
218 233 return ptr_list_size((struct ptr_list *)(list));
219 234 }
220 235
221 236 static inline int statement_list_size(struct statement_list *list)
222 237 {
223 238 return ptr_list_size((struct ptr_list *)(list));
224 239 }
225 240
226 241 static inline int expression_list_size(struct expression_list *list)
227 242 {
228 243 return ptr_list_size((struct ptr_list *)(list));
229 244 }
230 245
231 246 static inline int instruction_list_size(struct instruction_list *list)
232 247 {
233 248 return ptr_list_size((struct ptr_list *)(list));
234 249 }
235 250
236 251 static inline int pseudo_list_size(struct pseudo_list *list)
237 252 {
238 253 return ptr_list_size((struct ptr_list *)(list));
239 254 }
240 255
241 256 static inline int bb_list_size(struct basic_block_list *list)
242 257 {
243 258 return ptr_list_size((struct ptr_list *)(list));
244 259 }
245 260
246 261 static inline void free_instruction_list(struct instruction_list **head)
247 262 {
248 263 free_ptr_list(head);
249 264 }
250 265
251 266 static inline struct instruction * delete_last_instruction(struct instruction_list **head)
252 267 {
253 268 return undo_ptr_list_last((struct ptr_list **)head);
254 269 }
255 270
256 271 static inline struct basic_block *first_basic_block(struct basic_block_list *head)
257 272 {
258 273 return first_ptr_list((struct ptr_list *)head);
259 274 }
260 275 static inline struct instruction *last_instruction(struct instruction_list *head)
261 276 {
262 277 return last_ptr_list((struct ptr_list *)head);
263 278 }
264 279
265 280 static inline struct instruction *first_instruction(struct instruction_list *head)
266 281 {
267 282 return first_ptr_list((struct ptr_list *)head);
268 283 }
269 284
270 285 static inline struct expression *first_expression(struct expression_list *head)
271 286 {
272 287 return first_ptr_list((struct ptr_list *)head);
273 288 }
274 289
275 290 static inline pseudo_t first_pseudo(struct pseudo_list *head)
276 291 {
277 292 return first_ptr_list((struct ptr_list *)head);
278 293 }
279 294
280 295 static inline void concat_symbol_list(struct symbol_list *from, struct symbol_list **to)
281 296 {
282 297 concat_ptr_list((struct ptr_list *)from, (struct ptr_list **)to);
283 298 }
284 299
285 300 static inline void concat_basic_block_list(struct basic_block_list *from, struct basic_block_list **to)
286 301 {
287 302 concat_ptr_list((struct ptr_list *)from, (struct ptr_list **)to);
288 303 }
289 304
290 305 static inline void concat_instruction_list(struct instruction_list *from, struct instruction_list **to)
291 306 {
292 307 concat_ptr_list((struct ptr_list *)from, (struct ptr_list **)to);
293 308 }
294 309
295 310 static inline void add_symbol(struct symbol_list **list, struct symbol *sym)
296 311 {
297 312 add_ptr_list(list, sym);
298 313 }
299 314
300 315 static inline void add_statement(struct statement_list **list, struct statement *stmt)
301 316 {
302 317 add_ptr_list(list, stmt);
303 318 }
304 319
305 320 static inline void add_expression(struct expression_list **list, struct expression *expr)
306 321 {
307 322 add_ptr_list(list, expr);
308 323 }
309 324
310 325 static inline void add_ident(struct ident_list **list, struct ident *ident)
311 326 {
312 327 add_ptr_list(list, ident);
313 328 }
314 329
315 330 #define hashval(x) ((unsigned long)(x))
316 331
317 332 #endif
↓ open down ↓ |
99 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX