[lkml]   [2000]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: if (CONFIG_FOO) Re: 2.4.0-test8-pre1 is quite bad / how about
Martin MaD Douda writes:
> On Tue, 5 Sep 2000, Alexander Viro wrote:
> > The _real_ problem is preprocessor abuse. BTW, could we schedule for
> > 2.5 the following?
> > * things like CONFIG_FOO are _always_ defined. As 0 or 1, that is.
> > * #ifdef CONFIG_FOO => if (CONFIG_FOO) in *.c. gcc will kill the unused
> > branches just fine.
> > * Yes, Virginia, it means that controlflow-affecting expansion has to
> > go. Good riddance, IMO.
> >
> > Goal: making sure that every bloody line of the files we choose to
> > compile goes through the parser. Will do wonders with test coverage and will
> > make analysis tools like tags viable. Then we can just use the gcc frontend
> > output as input for such beasts.
> I can understand advantages the if(CONFIG_FOO) approach has, but I'm not
> sure it is worth compilation slowdown.

In response to Al (I don't think I've got his mail, still got 150 emails
to look at since last night):

Been there, done that, maybe you'd like to look at the ARM code which contains
the machine_is_xxx()? These essentially reduce down to one of three possible

1. (0)
3. (__machine_type == MACH_TYPE_ASSABET)

The relevent definition is chosen by a set of pre-processor generated out of

Whilst it is good to remove redunant code, you still need #ifdefs...#endifs,
so I wouldn't recommend this style of configuration management for the
generic kernel.

Think about this:

struct bar foo_specific = {

struct bar *goo()
return &foo_specific;
return NULL;

Unfortunately, the compiler always generates dataspace for both structures,
even if CONFIG_FOO is 0. So, how do we get rid of them? Simple, surround
them with #if CONFIG_FOO...#endif. Oh dear, the symbol is now undefined.
I guess we must add #if CONFIG_FOO around the if (CONFIG_FOO) as well. Ug,
I suppose we might as well just do:

struct bar *goo()
return &foo_specific;
return NULL;

and be done with it.

Yes, I'd agree a good idea, and may apply to some small bits of code, but
not as a general kernel-wide thing. And converting the #ifdefs all to #ifs
is going to be a nightmarish large patch (before even thinking of making
configure produce the "define CONFIG_FOO as 0 or 1" you have first got to
make sure that there are no #ifdef CONFIG_FOO statements in existance.

(Note that the reason we do it on the ARM is NOT because we have a never
or always condition, but because we have never, maybe or always conditions,
and this is the easiest way to fix them up. But. We still need #ifdefs
|_____| ------------------------------------------------- ---+---+-
| | Russell King --- ---
| | | | / / |
| +-+-+ --- -+-
/ | THE developer of ARM Linux |+| /|\
/ | | | --- |
+-+-+ ------------------------------------------------- /\\\ |
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 12:38    [W:0.281 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site