difference between DECLARE_* and DEFINE_* macro namespaces ?
jim.cromie at gmail.com
jim.cromie at gmail.com
Wed Sep 21 15:33:57 EDT 2022
difference between DECLARE_* and DEFINE_* macro namespaces ?
heres some quantitative observations
1st , raw usage counts
[jimc at frodo wk-test]$ ack DECLARE_\\w+ | wc
12541 30583 1030008
[jimc at frodo wk-test]$ ack \\bDECLARE_\\w+ | wc
11293 25240 897730
[jimc at frodo wk-test]$ ack \\bDEFINE_\\w+ | wc
14746 42085 1222994
[jimc at 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 at 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 at frodo wk-test]$ ack '#define DECLARE_\w+' | wc
314 1384 27393
[jimc at 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 at frodo wk-test]$ ack DEFINE_RAW_SPINLOCK | wc
140 293 10455
[jimc at frodo wk-test]$ ack 'static DEFINE_RAW_SPINLOCK' | wc
116 258 8705
[jimc at 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 ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20220921/da6f9a22/attachment.html>
More information about the Kernelnewbies
mailing list