[ppc-dev] Re: Restructuring Efforts

Bill Davidsen davidsen at prodigy.com
Wed Feb 17 23:50:25 EST 1999


Troy Benjegerdes <hozer at drgw.net> noted:

> ifdefs are evil ;) 
> OTOH, I don't know if I like a ton of 'if _machine' from a readability
> standpoint. I would like something similiar to the Alpha's and Corey
> Minyards rework with a structure for various machines with any code that
> would have been inside an #ifdef , switch(_machine) if _machine. 

Well, you can preserve readability if you are willing to put the
machine types in an enum and make use of "pointer to function
returning" arrays. So instead of doing something like init_mem() you
would use (*init_mem[_machine])() instead.

Another trick is to have a set if defines which you provide for each
machine type, and then call. Either of these provide easy extensibility
without ifdefs.

-- 
   -bill davidsen (davidsen at prodigy.com)
"The secret to procrastination is to put things off until the
 last possible moment - but no longer"  -me


[[ This message was sent via the linuxppc-dev mailing list. Replies are ]]
[[ not forced back to the list, so be sure to  Cc linuxppc-dev  if your ]]
[[ reply is of general interest. To unsubscribe from linuxppc-dev, send ]]
[[ the message 'unsubscribe' to linuxppc-dev-request at lists.linuxppc.org ]]




More information about the Linuxppc-dev mailing list