Re: RFC: cleaning up the in-kernel headers





On Tue, 11 Jul 2006, H. Peter Anvin wrote:

#1 I doubt the time taken to look at include files that are #ifndef'd in their
entirety is significant (I think there is special code in gcc to handle this
case fast.)

Correct. Don't worry about multiple includes.

HOWEVER. If you can avoid the include entirely, that can be an absolutely
huge timesaver. Much of the compile time is from just parsing the things
the first time around (rather than parsing it over and over), and if you
don't strictly need a header, avoiding parsing it in the first place is a
big big issue.

For example, if a header only needs a structure to be declared because it
uses a pointer to it, then rather than including the header file that
declares that structure fully, just doing a

struct task_struct;

to say that "there is such a thing as a 'struct task_struct'" can be a
huge time-saver.

Of course, anything that actually needs to look past the pointer will need
to get the full declaration..

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: string
    ... >bitset but declares a function called 'header' that takes ... error C2061: syntax ...
    (microsoft.public.vc.stl)
  • Re: C Interview Questions
    ... Each library function is declared in a header, ... header declares a set of related functions, ... external identifiers that begin with an underscore are reserved. ... define standard library functions in standard headers, ...
    (comp.lang.c)
  • Re: Is using namespace std; valid without namespace std {}; first?
    ... > declares those items in that you need. ... both ANSI C++ compliant compilers, ... but the header files do not use the std namespace. ...
    (comp.lang.cpp)
  • Re: Flat-File to Xml Query...
    ... special character resulting in corrupting the remaining data in that ... While parsing I get error: ... Line number 2885 has the special characters and when replaced/removed ... type at the same level as Header and Detail records, ...
    (microsoft.public.biztalk.general)
  • Re: Flat-File to Xml Query...
    ... While parsing I get error: ... Line number 2885 has the special characters and when replaced/removed ... type at the same level as Header and Detail records, ... <GroupRecord> ...
    (microsoft.public.biztalk.general)