From: jim.cromie@gmail.com
To: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: difference between DECLARE_* and DEFINE_* macro namespaces ?
Date: Wed, 21 Sep 2022 13:33:57 -0600 [thread overview]
Message-ID: <CAJfuBxxOMfkrwazP2Zz=WNK_c_ZmM5R3R6p3=F3EdkLJJsp7JA@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 1724 bytes --]
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 ?
[-- Attachment #1.2: Type: text/html, Size: 2898 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
next reply other threads:[~2022-09-21 19:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-21 19:33 jim.cromie [this message]
2022-09-26 14:29 ` difference between DECLARE_* and DEFINE_* macro namespaces ? Rik van Riel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJfuBxxOMfkrwazP2Zz=WNK_c_ZmM5R3R6p3=F3EdkLJJsp7JA@mail.gmail.com' \
--to=jim.cromie@gmail.com \
--cc=kernelnewbies@kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).