Commit | Line | Data |
---|---|---|
34e49164 | 1 | // **************************************************************************** |
708f4980 | 2 | // Prelude, this file is used with -macro_file_builtins option of the C parser |
34e49164 C |
3 | // **************************************************************************** |
4 | ||
5 | /* This file contains: | |
6 | * - macros found in <.h> | |
708f4980 C |
7 | * - macros found in ".h" |
8 | * but where we cant detect that it will be a "bad macro" | |
9 | * - hints, cf below. | |
10 | * | |
11 | * A "bad macro" is a macro using free variables or when expanded | |
12 | * that influence the control-flow of the code. In those cases it | |
13 | * is preferable to expand the macro so that the coccinelle engine | |
14 | * has a more accurate representation of what is going on. | |
15 | * | |
16 | * | |
17 | * | |
18 | * | |
19 | * old: this file was also containing what is below but now we | |
20 | * try to expand on demand the macro found in the c file, so those cases | |
21 | * are not needed any more: | |
34e49164 C |
22 | * - macros found in .c; macros that cannot be parsed. |
23 | * In the future should be autodetected | |
24 | * (not so easy to do same for macros in .h cos require to access .h file) | |
34e49164 C |
25 | * - macros found in .c; macros correctly parsed |
26 | * but where we cant detect that it will be a "bad macro" | |
27 | * | |
28 | * Some of those macros could be deleted and the C code rewritten because | |
29 | * they are "bad" macros. | |
30 | * | |
31 | * todo? perhaps better if could enable/disable some of those expansions | |
32 | * as different software may use conflicting macros. | |
33 | * | |
34 | * | |
35 | * can maybe have a look in sparse/lib.c to see a list of default #define | |
36 | * handled builtin apparently by gcc. | |
37 | */ | |
38 | ||
b1b2de81 C |
39 | // **************************************************************************** |
40 | // Hints | |
41 | // **************************************************************************** | |
42 | ||
43 | /* Cooperation with parsing_hack.ml: some body of macros in this file, such | |
44 | * as MACROSTATEMENT, are considered as magic strings. | |
45 | * I can't just expand those macros into some 'whatever();' because I need | |
46 | * to generate a TMacroStmt for solving some ambiguities in the grammar | |
47 | * for the toplevel stuff I think. | |
48 | * Right now a set of special strings are used as "hints" to the parser | |
49 | * to help it parse code. Those hints are specified in parsing_hack.ml: | |
50 | * | |
51 | * - YACFE_ITERATOR | |
52 | * - YACFE_DECLARATOR | |
53 | * - YACFE_STRING | |
54 | * - YACFE_STATEMENT, or MACROSTATEMENT | |
55 | * - YACFE_ATTRIBUTE | |
56 | * - YACFE_IDENT_BUILDER | |
57 | */ | |
58 | ||
34e49164 C |
59 | // **************************************************************************** |
60 | // Test macros | |
61 | // **************************************************************************** | |
62 | ||
63 | // #define FOO(a, OP, b) a OP b | |
64 | // #define FOO(a,b) fn(a,b) | |
b1b2de81 | 65 | #define FOO_METH_TEST(a) YACFE_IDENT_BUILDER |
34e49164 | 66 | |
708f4980 | 67 | //#define FOO YACFE_DECLARATOR |
34e49164 C |
68 | |
69 | // **************************************************************************** | |
708f4980 | 70 | // Generic macros |
34e49164 C |
71 | // **************************************************************************** |
72 | ||
708f4980 C |
73 | // this is defined by windows compiler, and so can not be found via a macro |
74 | // after a -extract_macros | |
978fd7e5 C |
75 | // update: now handled in lexer, simplify stuff |
76 | //#define __stdcall /*could: YACFE_ATTRIBUTE*/ | |
77 | //#define __declspec(a) | |
34e49164 | 78 | |
978fd7e5 C |
79 | //#define WINAPI |
80 | //#define CALLBACK | |
34e49164 C |
81 | |
82 | ||
83 | // **************************************************************************** | |
84 | // Linux macros | |
85 | // **************************************************************************** | |
86 | ||
87 | // ---------------------------------------------------------------------------- | |
88 | // Attributes. could perhaps generalize via "__.*" | |
89 | // ---------------------------------------------------------------------------- | |
90 | #define __init | |
91 | #define __exit | |
92 | #define __user | |
93 | #define __iomem | |
94 | #define __initdata | |
95 | #define __exitdata | |
96 | #define __devinit | |
97 | #define __devexit | |
98 | #define __devinitdata | |
99 | #define __cpuinit | |
100 | #define __cpuinitdata | |
101 | #define __init_or_module | |
102 | #define __initdata_or_module | |
103 | #define __pminit | |
104 | #define __pminitdata | |
105 | ||
106 | #define __cacheline_aligned | |
107 | #define ____cacheline_aligned | |
108 | #define __cacheline_aligned_in_smp | |
109 | #define ____cacheline_aligned_in_smp | |
110 | #define ____cacheline_internodealigned_in_smp | |
111 | ||
112 | #define __ALIGNED__ | |
113 | #define __3xp_aligned | |
114 | ||
115 | #define __pmac | |
116 | #define __force | |
117 | #define __nocast | |
118 | #define __read_mostly | |
119 | ||
120 | #define __must_check | |
121 | // pb | |
122 | #define __unused | |
123 | #define __maybe_unused | |
124 | ||
125 | ||
126 | #define __attribute_used__ | |
127 | #define __attribute_pure__ | |
128 | #define __attribute_const__ | |
129 | // #define _attribute__const __attribute__((const)) | |
130 | ||
131 | #define __always_inline | |
132 | ||
133 | #define __xipram | |
134 | ||
135 | // in the other part of the kernel, in arch/, mm/, etc | |
136 | #define __sched | |
137 | #define __initmv | |
138 | #define __exception | |
139 | #define __cpuexit | |
140 | #define __kprobes | |
141 | #define __meminit | |
142 | #define __meminitdata | |
143 | #define __nosavedata | |
144 | #define __kernel | |
145 | #define __nomods_init | |
146 | #define __apicdebuginit | |
147 | #define __ipc_init | |
148 | #define __modinit | |
149 | #define __lockfunc | |
150 | #define __weak | |
151 | #define __tlb_handler_align | |
152 | #define __lock_aligned | |
153 | #define __force_data | |
154 | #define __nongprelbss | |
155 | #define __nongpreldata | |
156 | #define __noreturn | |
157 | ||
158 | #define __section_jiffies | |
159 | #define __vsyscall_fn | |
160 | #define __section_vgetcpu_mode | |
161 | #define __section_vsyscall_gtod_data | |
162 | ||
163 | // in header files | |
164 | #define __bitwise | |
165 | #define __bitwise__ | |
166 | #define __deprecated | |
167 | ||
168 | ||
169 | // last found | |
170 | #define __init_refok | |
171 | ||
172 | ||
173 | // maybe only in old kernel | |
174 | #define __openfirmware | |
175 | ||
978fd7e5 C |
176 | // now in lexer |
177 | //#define __extension__ | |
34e49164 C |
178 | |
179 | #define __thread | |
180 | #define __used | |
181 | #define __pure | |
182 | ||
183 | #define __ref | |
184 | #define __refdata | |
185 | ||
186 | #define __uses_jump_to_uncached | |
187 | ||
708f4980 C |
188 | |
189 | // last last | |
190 | #define __net_init | |
191 | #define __net_exit | |
192 | #define __net_initdata | |
193 | ||
194 | #define __paginginit // in mm | |
195 | ||
34e49164 C |
196 | // ---------------------------------------------------------------------------- |
197 | // String macros | |
198 | // ---------------------------------------------------------------------------- | |
199 | ||
200 | /* string macro. normally handle quite well by mu lalr(k), but | |
201 | * sometimes not enough, if have for instance the XX YY case, could | |
202 | * be considered as a declaration with XX being a typedef, so would | |
203 | * Have ambiguity. So at least by adding this special case, we can | |
204 | * catch more correct string-macro, no more a XX YY but now a good | |
205 | * "XX" YY | |
206 | * | |
207 | * cf include/linux/kernel.h | |
208 | * | |
209 | * For stringification I need to have at least a witness, a string, | |
210 | * and sometimes have just printk(KERN_WARNING MYSTR) and it could | |
211 | * be transformed in a typedef later, so better to at least | |
212 | * transform in string already the string-macro we know. | |
213 | * | |
214 | * Perhaps better to apply also as soon as possible the | |
215 | * correct macro-annotation tagging (__init & co) to be able to | |
216 | * filter them as soon as possible so that they will not polluate | |
217 | * our pattern-matching that come later. | |
218 | */ | |
219 | ||
220 | #define KERN_EMERG "KERN_EMERG" | |
221 | #define KERN_ALERT "KERN_ALERT" | |
222 | #define KERN_CRIT "KERN_CRIT" | |
223 | #define KERN_ERR "KERN_ERR" | |
224 | #define KERN_WARNING "KERN_WARNING" | |
225 | #define KERN_NOTICE "KERN_NOTICE" | |
226 | #define KERN_INFO "KERN_INFO" | |
227 | #define KERN_DEBUG "KERN_DEBUG" | |
228 | ||
229 | ||
230 | /* EX_TABLE & co. | |
231 | * | |
232 | * Replaced by a string. We can't put everything as comment | |
233 | * because it can be part of an expression where we wait for | |
234 | * something, where we wait for a string. So at least we | |
235 | * must keep the EX_TABLE token and transform it as a string. | |
236 | * | |
237 | * normally not needed if have good stringification of macro | |
238 | * but those macros are sometimes used multiple times | |
239 | * as in EX_TABLE(0b) EX_TABLE(1b) and we don't detect | |
240 | * it well yet. | |
241 | */ | |
242 | ||
243 | // TODO don't use x :( | |
244 | #define EX_TABLE(x) "TOTO" | |
245 | #define ASM_EXCEPTIONTABLE_ENTRY(x) "TOTO" | |
246 | #define DCACHE_CLEAR(x) "TOTO" | |
247 | #define PPC405_ERR77(x) "TOTO" | |
248 | ||
249 | ||
250 | ||
251 | ||
252 | // ---------------------------------------------------------------------------- | |
253 | // Alias keywords | |
254 | // ---------------------------------------------------------------------------- | |
255 | // pb, false positive, can also be a #define cst and use as 'case CONST:' | |
256 | //#define CONST const | |
257 | ||
258 | ||
259 | #define STATIC static | |
260 | #define _static static | |
261 | ||
262 | #define noinline | |
263 | ||
264 | #define __CS4231_INLINE__ inline | |
265 | #define CCIO_INLINE inline | |
266 | #define SBA_INLINE inline | |
267 | ||
268 | #define STATIC_INLINE static inline | |
269 | #define __EXTERN_INLINE extern inline | |
270 | ||
271 | #define AGPEXTERN extern | |
272 | ||
273 | #define PNMI_STATIC static | |
274 | #define RLMT_STATIC static | |
275 | #define SISINITSTATIC static | |
276 | #define SCTP_STATIC static | |
277 | ||
278 | #define BUGLVL if | |
279 | #define IFDEBUG if | |
280 | ||
281 | #define TRACE_EXIT return | |
282 | ||
708f4980 C |
283 | #define notrace |
284 | ||
285 | #define noinline_for_stack // in fs | |
286 | #define debug_noinline // in net | |
34e49164 C |
287 | |
288 | // ---------------------------------------------------------------------------- | |
289 | // linkage | |
290 | // ---------------------------------------------------------------------------- | |
291 | ||
292 | #define fastcall | |
293 | #define asmlinkage | |
294 | ||
295 | #define far | |
296 | #define SK_FAR | |
297 | ||
298 | // pb | |
299 | //#define near | |
300 | ||
301 | ||
302 | // ---------------------------------------------------------------------------- | |
303 | // ---------------------------------------------------------------------------- | |
304 | ||
305 | #define INITSECTION | |
306 | ||
307 | #define NORET_TYPE | |
308 | ||
309 | #define compat_init_data | |
310 | ||
311 | #define DIVA_EXIT_FUNCTION | |
312 | #define DIVA_INIT_FUNCTION | |
313 | #define ACPI_SYSTEM_XFACE | |
314 | ||
315 | #define ASC_INITDATA | |
316 | #define in2000__INITDATA | |
317 | #define PACKED | |
318 | ||
319 | #define WPMINFO | |
320 | #define CPMINFO | |
321 | #define PMINFO | |
322 | ||
323 | #define ACPI_INTERNAL_VAR_XFACE | |
324 | ||
325 | #define SISIOMEMTYPE | |
326 | ||
327 | #define ACPI_STATE_COMMON | |
328 | #define ACPI_PARSE_COMMON | |
329 | #define ACPI_COMMON_DEBUG_MEM_HEADER | |
330 | ||
331 | ||
332 | #define nabi_no_regargs | |
333 | ||
334 | ||
335 | #define ATTRIB_NORET | |
336 | #define ATTRIBUTE_UNUSED | |
337 | #define BTEXT | |
338 | #define BTDATA | |
339 | #define PAGE_ALIGNED | |
340 | ||
341 | #define EARLY_INIT_SECTION_ATTR | |
342 | ||
343 | // pb | |
344 | //#define INIT | |
345 | ||
346 | #define IDI_CALL_ENTITY_T | |
347 | #define IDI_CALL_LINK_T | |
348 | ||
349 | /* cf gcc-linux.h | |
350 | * A trick to suppress uninitialized variable warning without generating any | |
351 | * code | |
352 | */ | |
353 | #define uninitialized_var(x) x = x | |
354 | // as in u16 uninitialized_var(ioboard_type); /* GCC be quiet */ | |
355 | ||
356 | // ---------------------------------------------------------------------------- | |
357 | // ---------------------------------------------------------------------------- | |
358 | ||
359 | #define __releases(x) | |
360 | #define __acquires(x) | |
978fd7e5 C |
361 | |
362 | //now in lexer | |
363 | //#define __declspec(x) | |
364 | ||
34e49164 C |
365 | #define __page_aligned(x) |
366 | #define __vsyscall(x) | |
367 | ||
368 | // ---------------------------------------------------------------------------- | |
369 | // ---------------------------------------------------------------------------- | |
370 | ||
371 | ||
372 | //conflict with a macro of firefox | |
373 | //#define FASTCALL(x) x | |
374 | #define PARAMS(x) x | |
375 | ||
376 | ||
377 | ||
378 | // ---------------------------------------------------------------------------- | |
379 | // ---------------------------------------------------------------------------- | |
380 | ||
381 | // include/asm-arm/mach/arch.h | |
382 | // #define MACHINE_START(x) struct foo { x } | |
383 | #define MACHINE_START(_type,_name) \ | |
384 | static const struct machine_desc __mach_desc_##_type \ | |
385 | /* __used*/ \ | |
386 | __attribute__((__section__(".arch.info.init"))) = { \ | |
387 | .nr = MACH_TYPE_##_type, \ | |
388 | .name = _name, | |
389 | ||
390 | #define MACHINE_END \ | |
391 | }; | |
392 | ||
393 | // include/asm-powerpc/machdep.h | |
394 | #define define_machine(name) \ | |
395 | extern struct machdep_calls mach_##name; \ | |
396 | EXPORT_SYMBOL(mach_##name); \ | |
397 | struct machdep_calls mach_##name /*__machine_desc*/ = | |
398 | ||
399 | ||
400 | // ---------------------------------------------------------------------------- | |
401 | // Declare like macros (in structure def), or tricky Declare macros | |
402 | // ---------------------------------------------------------------------------- | |
403 | ||
404 | // include/asm-i386/pci.h | |
405 | // the DECLARE are detected by parsing_hack but not when they are | |
406 | // inside a struct def. | |
407 | #define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) | |
408 | #define DECLARE_PCI_UNMAP_LEN(LEN_NAME) | |
409 | ||
410 | // defined in drivers/infiniband/hw/mthca/mthca_doorbell.h | |
411 | #define MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock) | |
412 | ||
413 | // include/linux/types.h | |
414 | //#define BITS_TO_LONGS(bits) \ | |
415 | // (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) | |
3a314143 C |
416 | #define DECLARE_BITMAP(name,bits) |
417 | // /*unsigned*/ long name[BITS_TO_LONGS(bits)] | |
34e49164 C |
418 | |
419 | ||
420 | // include/asm-i386/percpu.h | |
421 | // interesting macro where we see the need of __typeof__(type) with | |
422 | // for example DECLARE_PER_CPU(char[256], iucv_dbf_txt_buf); | |
423 | #define DEFINE_PER_CPU(type, name) \ | |
424 | __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name | |
425 | #define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name | |
426 | ||
427 | ||
428 | ||
429 | // include/linux/kobject.h | |
430 | #define decl_subsys(_name,_type,_uevent_ops) \ | |
431 | struct subsystem _name##_subsys = { \ | |
432 | .kset = { \ | |
433 | .kobj = { .name = __stringify(_name) }, \ | |
434 | .ktype = _type, \ | |
435 | .uevent_ops =_uevent_ops, \ | |
436 | } \ | |
437 | } | |
438 | ||
439 | // ---------------------------------------------------------------------------- | |
440 | // ---------------------------------------------------------------------------- | |
441 | ||
442 | // pb: if use this macro then we will not transform the argument of CS_CHECK | |
443 | // in some rules. | |
444 | //#define CS_CHECK(fn, ret) \ | |
445 | // do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | |
446 | ||
447 | ||
448 | // bt2/hci_bcsp.c | |
449 | #define BCSP_CRC_INIT(x) x = 0xffff | |
450 | ||
451 | ||
452 | // sound/oss/cs46xx_wrapper-24.h | |
453 | #define CS_OWNER .owner = | |
454 | #define CS_THIS_MODULE THIS_MODULE, | |
455 | ||
456 | ||
457 | // sound/sparc/dbri.c | |
458 | // "bad macro", have a ',' at the end | |
459 | #define CS4215_SINGLE(xname, entry, shift, mask, invert) \ | |
460 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | |
461 | .info = snd_cs4215_info_single, \ | |
462 | .get = snd_cs4215_get_single, .put = snd_cs4215_put_single, \ | |
463 | .private_value = entry | (shift << 8) | (mask << 16) | (invert << 24) }, | |
464 | ||
465 | // drivers/media/video/sn9c102/sn9c102_sensor.h | |
466 | //#define sn9c102_write_const_regs(sn9c102_device, data...) \ | |
467 | // ({ const static u8 _valreg[][2] = {data}; \ | |
468 | // sn9c102_write_regs(sn9c102_device, _valreg, ARRAY_SIZE(_valreg)); }) | |
469 | ||
470 | ||
471 | ||
472 | ||
473 | ||
474 | // drivers/s390/cio/qdio.h | |
475 | #define SYNC_MEMORY if (unlikely(q->siga_sync)) qdio_siga_sync_q(q) | |
476 | #define SYNC_MEMORY_ALL if (unlikely(q->siga_sync)) \ | |
477 | qdio_siga_sync(q,~0U,~0U) | |
478 | #define SYNC_MEMORY_ALL_OUTB if (unlikely(q->siga_sync)) \ | |
479 | qdio_siga_sync(q,~0U,0) | |
480 | ||
481 | // drivers/scsi/g_NCR5380.c | |
482 | #define ANDP , | |
483 | ||
484 | ||
485 | // drivers/scsi/ncr53c8xx.c | |
486 | // generate lots of errors because error en cascade car dans l'initialiseur | |
487 | // il y'a des '}' dans la premiere colonne | |
488 | #define PREFETCH_FLUSH SCR_CALL, PADDRH (wait_dma), | |
489 | ||
490 | // drivers/net/e100.c | |
491 | // pbs false positive, defined in another manner in some files | |
492 | //#define X(a,b) a,b | |
493 | ||
494 | ||
495 | // net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c | |
496 | // also used in other.c that don't do any include :( | |
497 | // but locally redefined in drivers/net/bnx2.c :( with a | |
498 | // #define FNAME 0x8 | |
499 | #define FNAME(name) name, | |
500 | ||
501 | ||
502 | // drivers/net/tulip/de4x5.c | |
503 | #define DESC_ALIGN | |
504 | ||
505 | ||
506 | // in .h | |
507 | #define MPI_POINTER * | |
508 | ||
509 | // mega4/soc.c mega4/socal.c | |
510 | // cause false typedef inference if let soc_printk | |
511 | #define soc_printk printk | |
512 | #define socal_printk printk | |
513 | ||
514 | ||
515 | // ---------------------------------------------------------------------------- | |
516 | // Initializer array macros | |
517 | // ---------------------------------------------------------------------------- | |
518 | ||
519 | // drivers/net/wireless/bcm43xx/bcm43xx_wx.c | |
520 | // defined in similar way multiple times, in the same file and in another one | |
521 | #define WX(ioctl) [(ioctl) - SIOCSIWCOMMIT] | |
522 | // #define WX(x) [(x)-SIOCIWFIRST] | |
523 | ||
524 | // drivers/net/wireless/ipw2200.c | |
525 | #define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] | |
526 | ||
527 | // drivers/net/wireless/zd1211rw/zd_netdev.c | |
528 | #define PRIV_OFFSET(x) [(x)-SIOCIWFIRSTPRIV] | |
529 | ||
530 | // drivers/net/wireless/zd1211rw/zd_rf.h | |
531 | #define RF_CHANNEL(ch) [(ch)-1] | |
532 | ||
533 | // drivers/net/wireless/zd1211rw/zd_rf_uw2453.c | |
534 | #define RF_CHANPAIR(a,b) [CHAN_TO_PAIRIDX(a)] | |
535 | ||
536 | // drivers/net/wireless/arlan-proc.c | |
537 | // incomplete macro, the real macro is quite complex and use other macros | |
538 | #define ARLAN_SYSCTL_TABLE_TOTAL(x) | |
539 | ||
540 | ||
541 | // ---------------------------------------------------------------------------- | |
542 | // ---------------------------------------------------------------------------- | |
543 | ||
544 | // drivers/net/cxgb3/t3_hw.c | |
545 | #define VPD_ENTRY(name, len) \ | |
546 | u8 name##_kword[2]; u8 name##_len; u8 name##_data[len] | |
547 | ||
548 | ||
549 | // #define rtrc(i) {} | |
550 | ||
551 | // ---------------------------------------------------------------------------- | |
552 | // ---------------------------------------------------------------------------- | |
553 | ||
554 | // drivers/video/nvidia/nv_type.h | |
555 | // use: SetBitField(h_blank_e, 5: 5, 7:7) | |
556 | //#define BITMASK(t,b) (((unsigned)(1U << (((t)-(b)+1)))-1) << (b)) | |
557 | //#define MASKEXPAND(mask) BITMASK(1?mask,0?mask) | |
558 | //#define SetBF(mask,value) ((value) << (0?mask)) | |
559 | //#define GetBF(var,mask) (((unsigned)((var) & MASKEXPAND(mask))) >> (0?mask) ) | |
560 | //#define SetBitField(value,from,to) SetBF(to, GetBF(value,from)) | |
561 | //#define SetBit(n) (1<<(n)) | |
562 | //#define Set8Bits(value) ((value)&0xff) | |
563 | ||
564 | ||
565 | // drivers/video/sis/init.c | |
566 | // use: GETBITSTR((SiS_Pr->CVTotal -2), 10:10, 0:0) | |
567 | //#define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l)) | |
568 | //#define GENMASK(mask) BITMASK(1?mask,0?mask) | |
569 | //#define GETBITS(var,mask) (((var) & GENMASK(mask)) >> (0?mask)) | |
570 | //#define GETBITSTR(val,from,to) ((GETBITS(val,from)) << (0?to)) | |
571 | ||
572 | ||
573 | // fs/afs/internal.h | |
574 | #define ASSERTCMP(X, OP, Y) \ | |
575 | do { \ | |
576 | if (unlikely(!((X) OP (Y)))) { \ | |
577 | printk(KERN_ERR "\n"); \ | |
578 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
579 | printk(KERN_ERR "%lu " /*#OP*/ " %lu is false\n", \ | |
580 | (unsigned long)(X), (unsigned long)(Y)); \ | |
581 | printk(KERN_ERR "0x%lx " /*#OP*/ " 0x%lx is false\n", \ | |
582 | (unsigned long)(X), (unsigned long)(Y)); \ | |
583 | BUG(); \ | |
584 | } \ | |
585 | } while(0) | |
586 | ||
587 | #define ASSERTIFCMP(C, X, OP, Y) \ | |
588 | do { \ | |
589 | if (unlikely((C) && !((X) OP (Y)))) { \ | |
590 | printk(KERN_ERR "\n"); \ | |
591 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
592 | printk(KERN_ERR "%lu " /*#OP*/ " %lu is false\n", \ | |
593 | (unsigned long)(X), (unsigned long)(Y)); \ | |
594 | printk(KERN_ERR "0x%lx " /*#OP*/ " 0x%lx is false\n", \ | |
595 | (unsigned long)(X), (unsigned long)(Y)); \ | |
596 | BUG(); \ | |
597 | } \ | |
598 | } while(0) | |
599 | ||
600 | ||
601 | #define ASSERTRANGE(L, OP1, N, OP2, H) \ | |
602 | do { \ | |
603 | if (unlikely(!((L) OP1 (N)) || !((N) OP2 (H)))) { \ | |
604 | printk(KERN_ERR "\n"); \ | |
605 | printk(KERN_ERR "AFS: Assertion failed\n"); \ | |
606 | printk(KERN_ERR "%lu "/*#OP1*/" %lu "/*#OP2*/" %lu is false\n", \ | |
607 | (unsigned long)(L), (unsigned long)(N), \ | |
608 | (unsigned long)(H)); \ | |
609 | printk(KERN_ERR "0x%lx "/*#OP1*/" 0x%lx "/*#OP2*/" 0x%lx is false\n", \ | |
610 | (unsigned long)(L), (unsigned long)(N), \ | |
611 | (unsigned long)(H)); \ | |
612 | BUG(); \ | |
613 | } \ | |
614 | } while(0) | |
615 | ||
616 | ||
617 | ||
618 | ||
619 | // loop, macro without ';', single macro. ex: DEBUG() | |
620 | ||
621 | // TODO should find the definition because we don't use 'x' and so | |
622 | // may lose code sites with coccinelle. If expand correctly, will | |
623 | // still don't transform correctly but at least will detect the place. | |
624 | ||
625 | ||
626 | ||
627 | ||
34e49164 C |
628 | #define ASSERT(x) MACROSTATEMENT |
629 | #define IRDA_ASSERT(x) MACROSTATEMENT | |
630 | ||
631 | #define CHECK_NULL(x) MACROSTATEMENT | |
632 | ||
633 | //#define DEBUG(x) MACROSTATEMENT | |
634 | #define DEBUG0(x) MACROSTATEMENT | |
635 | #define DEBUG1(x) MACROSTATEMENT | |
636 | #define DEBUG2(x) MACROSTATEMENT | |
637 | #define DEBUG3(x) MACROSTATEMENT | |
638 | ||
639 | ||
640 | #define DBG(x) MACROSTATEMENT | |
641 | #define DEB(x) MACROSTATEMENT | |
642 | #define PARSEDEBUG(x) MACROSTATEMENT | |
643 | #define DEBC(x) MACROSTATEMENT | |
644 | #define DBG_TRC(x) MACROSTATEMENT | |
645 | #define DBG_ERR(x) MACROSTATEMENT | |
646 | #define DBG_FTL(x) MACROSTATEMENT | |
647 | ||
648 | #define DBGINFO(x) MACROSTATEMENT | |
649 | #define DFLOW(x) MACROSTATEMENT | |
650 | #define DFLIP(x) MACROSTATEMENT | |
651 | #define DLOG_INT_TRIG(x) MACROSTATEMENT | |
652 | ||
653 | #define D3(x) MACROSTATEMENT | |
654 | #define D1(x) MACROSTATEMENT | |
655 | #define DB(x) MACROSTATEMENT | |
656 | #define DCBDEBUG(x) MACROSTATEMENT | |
657 | #define SCSI_LOG_MLQUEUE(x) MACROSTATEMENT | |
658 | ||
659 | #define PLND(x) MACROSTATEMENT | |
660 | #define FCALND(x) MACROSTATEMENT | |
661 | #define FCALD(x) MACROSTATEMENT | |
662 | ||
663 | #define DEBUGRECURSION(x) MACROSTATEMENT | |
664 | ||
665 | #define DEBUGPIO(x) MACROSTATEMENT | |
666 | #define VDEB(x) MACROSTATEMENT | |
667 | ||
668 | #define READ_UNLOCK_IRQRESTORE(x) MACROSTATEMENT | |
669 | ||
670 | #define TRACE_CATCH(x) MACROSTATEMENT | |
671 | ||
672 | #define PDBGG(x) MACROSTATEMENT | |
673 | ||
674 | #define IF_ABR(x) MACROSTATEMENT | |
675 | #define IF_EVENT(x) MACROSTATEMENT | |
676 | #define IF_ERR(x) MACROSTATEMENT | |
677 | #define IF_CBR(x) MACROSTATEMENT | |
678 | #define IF_INIT(x) MACROSTATEMENT | |
679 | #define IF_RX(x) MACROSTATEMENT | |
680 | ||
681 | #define SOD(x) MACROSTATEMENT | |
682 | ||
683 | #define KDBG(x) MACROSTATEMENT | |
684 | ||
685 | #define IRDA_ASSERT_LABEL(x) MACROSTATEMENT | |
686 | ||
687 | ||
688 | ||
689 | ||
690 | ||
691 | // ---------------------------------------------------------------------------- | |
692 | // Difficult foreach | |
693 | // ---------------------------------------------------------------------------- | |
694 | ||
695 | // include/linux/sched.h | |
696 | #define while_each_thread(g, t) \ | |
697 | while ((t = next_thread(t)) != g) | |
698 | ||
699 | ||
700 | ||
701 | // net/decnet/dn_fib.c | |
702 | #define for_fib_info() { struct dn_fib_info *fi;\ | |
703 | for(fi = dn_fib_info_list; fi; fi = fi->fib_next) | |
704 | #define endfor_fib_info() } | |
705 | ||
706 | #define for_nexthops(fi) { int nhsel; const struct dn_fib_nh *nh;\ | |
707 | for(nhsel = 0, nh = (fi)->fib_nh; nhsel < (fi)->fib_nhs; nh++, nhsel++) | |
708 | ||
709 | #define change_nexthops(fi) { int nhsel; struct dn_fib_nh *nh;\ | |
710 | for(nhsel = 0, nh = (struct dn_fib_nh *)((fi)->fib_nh); nhsel < (fi)->fib_nhs; nh++, nhsel++) | |
711 | ||
712 | #define endfor_nexthops(fi) } | |
713 | ||
714 | ||
715 | // ---------------------------------------------------------------------------- | |
716 | // Macros around function prototype | |
717 | // ---------------------------------------------------------------------------- | |
718 | ||
719 | ||
720 | // net/sched/em_meta.c | |
721 | #define META_COLLECTOR(FUNC) static void meta_##FUNC(struct sk_buff *skb, \ | |
722 | struct tcf_pkt_info *info, struct meta_value *v, \ | |
723 | struct meta_obj *dst, int *err) | |
724 | ||
725 | ||
726 | #define GDTH_INITFUNC(x,y) x y | |
727 | #define ASC_INITFUNC(x,y) x y | |
728 | ||
729 | ||
730 | // ---------------------------------------------------------------------------- | |
731 | // If-like macros | |
732 | // ---------------------------------------------------------------------------- | |
733 | ||
734 | // include/linux/lockd/debug.h | |
735 | // include/linux/nfs_fs.h | |
736 | // include/linux/nfsd/debug.h | |
737 | // include/linux/sunrpc/debug.h | |
738 | //#define ifdebug(flag) if (unlikely(nlm_debug & NLMDBG_##flag)) | |
739 | #define ifdebug(flag) if (0) | |
740 | ||
741 | ||
742 | ||
743 | // ---------------------------------------------------------------------------- | |
744 | //#define __PROM_O32 | |
745 | ||
746 | // ---------------------------------------------------------------------------- | |
747 | // for tests-big/ macros, may be obsolete now cos fixed in latest kernel | |
748 | // ---------------------------------------------------------------------------- | |
749 | ||
750 | // rule10 | |
751 | //#define ACPI_MODULE_NAME(x) |