Re: dealing with excessive includes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Oct 22, 2006 at 07:58:53PM +0200, Geert Uytterhoeven wrote:
> On Fri, 20 Oct 2006, Randy Dunlap wrote:
> > Yes, we have lots of header include indirection going on.
> > I don't know of a good tool to detect/fix it.
> 
> BTW, what about making sure all header files are self-contained (i.e. all
> header files include all stuff they need)? This would make it easier for the
> users to know which files to include.

I was wondering about putting in some tags in comments in the headers and
using scripts to parse them out.  Something like:

/*+
 * Provides: struct sched
 * Provides: total_forks, nr_threads, process_counts, nr_processes()
 * Provides: nr_running(), nr_uninterruptible(), nr_active(), nr_iowait(), weighted_cpuload()
 */

(you should be able to have multiple /*+ blocks in the file, multiple
Provides: lines and multiple things provided on a line.  Functions are
tagged with a trailing (), structs with the leading 'struct' and
everything else is a variable.)

Not only does that tell a script unambiguously which header needs to
be included for what function, struct definition and variable, it also
tells the programmer what header to include for what function.

This would have the benefit over automated analysis that you can put
Provides: irq_canonicalize() in <linux/interrupt.h> despite it being
actually defined in <asm/irq.h> (there's probably better examples
than this).

The script could warn for both unnecessary headers included and warn for
headers which weren't included but should be.  The warnings would start
out fairly useful and improve as we added more Provides: lines.

Anyone want to code this, or just pick holes in it?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux