Re: RFC: cleaning up the in-kernel headers

Dave Jones
2006-07-11T17:08:40Z

On Tue, Jul 11, 2006 at 06:06:39PM +0200, Adrian Bunk wrote:
> I'd like to cleanup the mess of the in-kernel headers, based on the
> following rules:
> - every header should #include everything it uses
> - remove unneeded #include's from headers
>
> This would also remove all the implicit rules "before #include'ing
> header foo.h, you must #include header bar.h" you usually only see when
> the compilation fails.

You may want to add as a secondary goal, splitting up some of the
huge 3-headed monster include files like sched.h
(It's better than it used to be, but it still sucks, and that thing
#include's the world). Worst, iirc module.h pulls it in, which means
everything built as a module is pulling in hundreds of includes
even though most of the time, it'll never use anything from the
indirect ones.

ghviz & hviz from http://www.kernel.org/pub/linux/kernel/people/acme/
are invaluable for eyeballing include dependancies btw.
They need graphviz installed, and run like so..

ghviz include/linux/sched.h 10

to produce a pretty graph.

> There might be exceptions (e.g. for avoiding circular #include's) but
> these would be special cases.

In many cases, adding forward references is a lot cleaner than
adding dozens of indirect include dependancies.

Dave

--