From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Michal Marek <mmarek@suse.cz>
Cc: linux-kbuild@vger.kernel.org
Subject: Re: include guard weirdness
Date: Sat, 12 Jul 2014 13:11:28 +0200 [thread overview]
Message-ID: <87y4vyzva7.fsf@rasmusvillemoes.dk> (raw)
In-Reply-To: <53BFD6A8.5080803@suse.cz> (Michal Marek's message of "Fri, 11 Jul 2014 14:20:56 +0200")
Michal Marek <mmarek@suse.cz> writes:
> On 2014-07-11 13:51, Rasmus Villemoes wrote:
>> Hi,
>>
>> gcc/cpp claims to be smart enough to recognize the include guard idiom,
>> and most of the time this works very well: the second and subsequent
>> #includes do not even cause the file to be opened (thus saving at least
>> open+fstat+read+close). Except in a few cases, which are so common that
>> it might be worth investigating.
>>
>> For example, linux/mm.h often shows up exactly twice in strace output;
>> another very common header such as linux/types.h always occurs only
>> once.
>
> My guess is that <linux/mm.h> includes a header which at some point
> includes <linux/mm.h> again.
Indeed. I naively thought that the kernel didn't have any cyclic
includes, but if ever I was wrong about something...
The cycle is very short (mm.h and vmstat.h include each
other). Including vmstat.h before mm.h breaks the build.
Thanks for enlightening me,
Rasmus
prev parent reply other threads:[~2014-07-12 11:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-11 11:51 include guard weirdness Rasmus Villemoes
2014-07-11 12:20 ` Michal Marek
2014-07-12 11:11 ` Rasmus Villemoes [this message]
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=87y4vyzva7.fsf@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=linux-kbuild@vger.kernel.org \
--cc=mmarek@suse.cz \
/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