difference between DECLARE_* and DEFINE_* macro namespaces ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



difference between DECLARE_* and DEFINE_* macro namespaces ?




heres some quantitative observations

1st , raw usage counts

[jimc@frodo wk-test]$ ack DECLARE_\\w+ | wc
  12541   30583 1030008
[jimc@frodo wk-test]$ ack \\bDECLARE_\\w+ | wc
  11293   25240  897730

[jimc@frodo wk-test]$ ack \\bDEFINE_\\w+ | wc
  14746   42085 1222994
[jimc@frodo wk-test]$ ack DEFINE_\\w+ | wc
  16714   48172 1386881

used quite a lot. worth seeing the patterns...


this one seems telling it counts indent=0 lines,
ie Header lines, file-scope vars, global declarations etc.

]$ ack ^DEFINE_\\w+ | wc
   7392   19578  661324


[jimc@frodo wk-test]$ ack 'static DECLARE_\w+'  | wc
    920    3025   80318

so about 1/12 of the DECLAREs have static outside them.









#defines determine how many PATTERN uses there are.
lets count them.

[jimc@frodo wk-test]$ ack '#define DECLARE_\w+' | wc
    314    1384   27393
[jimc@frodo wk-test]$ ack '#define DEFINE_\w+' | wc
    695    2734   55559

so, 2.3x DEFINE_/DECLARE_ definitions,
and 1.15x uses of those defns

interesting, not suggestive of anything..




lets look at one case

include/linux/spinlock_types_raw.h
71:#define DEFINE_RAW_SPINLOCK(x)  raw_spinlock_t x = __RAW_SPIN_LOCK_UNLOCKED(x)

its a variable declaration, expecting ';' in caller to close it.

[jimc@frodo wk-test]$ ack DEFINE_RAW_SPINLOCK | wc
    140     293   10455
[jimc@frodo wk-test]$ ack 'static DEFINE_RAW_SPINLOCK' | wc
    116     258    8705
[jimc@frodo wk-test]$ ack '^static DEFINE_RAW_SPINLOCK' | wc
    107     231    8009

140 uses, most with static, most of those at file-scope













so, all that said, I havent gleaned any heuristics

does anyone want to offer a more qualitative review ?


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux