--- "Eric W. Biederman" <[EMAIL PROTECTED]> wrote:
> Konstantin Zhidkov <[EMAIL PROTECTED]> writes:
>
> > --- Ronald G Minnich <[EMAIL PROTECTED]> wrote:
> > >
> >
> > > I'm going through the code and hope to produce a table of
> #if
> > > and #ifdef
> > > used in linuxbios and what they mean soon. Also (this is
> my
> > > fault) we
> > > really do need to rename config variables for linuxbios
> to
> > > CONFIG_LINUXBIOS_ to avoid confusion between linuxbios
> config
> > > variables
> > > and other variable (e.g. i586). This I will do slowly,
> along
> > > with
> > > correcting cases where people used
> > > #ifdef x
> > > (old style) instead of
> > > #if (x == 1)
> > > (new style)
> > >
> >
> > There also are some functions that can be conditionally(!)
> > defined as do{}while(0). This makes code beautiful but
> > misleading. Could there be a naming covention for such
> > functions? For exapmle, to start names with i_lie_again_:)
>
> Maybe. I suspect better access to the configuration
> variables
> would be good. Before we had that the code was totally
> unreadable.
> ifdefs cluttered up hardwaremain horribly.
>
> Now looking at the code you can see what would maximally
> happen. You
> just can't trivially tell if it has been configured not to.
> From
> a coding perspecitive you can just assmume everything will
> happen.
>
While reading such code one have to look at definition of
*each* function, because there's no other way to distinguish
between conditional and generic functions. Simple naming
convention can overcome this nightmare: cond__<name>
like this: cond__i8259_setup();
Use of mirage functions have one big advantage -- incapsulation
of preprocessor directives. This reduces use of complex/nested
preprocessor directives, which sometimes are hard to predict.
Look at interrupts_on() in i386_subr.c: what will happen if
both I686 and APIC are undefined? This is what I mean.
There's also need to distinguish between configuration options
and configuration parameters. While option can only exist or
not exist, parameter can have any value, including zero, and
can also not exist. Currently, one have to add both option and
parameter to avoid use of #ifndef, for example:
config:
# We have to slowdown io by output to nonexistent port.
# Port 0x80 isn't nonexistent in our system.
option CONFIG_LINUXBIOS_USE_CUSTOM_NONEXISTENT_PORT=1
option CONFIG_LINUXBIOS_NONEXISTENT_PORT=0
changes to io.h:
#if ((CONFIG_LINUXBIOS_USE_CUSTOM_NONEXISTENT_PORT) == 1)
#define NONEXISTENT_PORT CONFIG_LINUXBIOS_NONEXISTENT_PORT
#else
#define NONEXISTENT_PORT 0x80
#endif
.
.
.
Konstantin
__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/