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