[coreboot] [PATCH] Make RAM check configurable via Kconfig
Uwe Hermann
uwe at hermann-uwe.de
Sat Mar 8 20:39:16 CET 2008
On Fri, Mar 07, 2008 at 09:11:24PM -0800, ron minnich wrote:
> I'm being foolish, forgetting a lesson from Plan 9 style.
>
> This will work fine:
> if (RAMTEST) {
> ram_test(0, 640*1024);
> ram_test(whatever);
> }
>
> The compiler will optimize out the whole block if RAMTEST is 0.
Nice trick, but it won't work in this case. Kconfig variables are
#defined to 1 if they're selected in menuconfig, but they're not
defined at all otherwise.
So 'if (CONFIG_RAMTEST)' will not compile if you don't select it via
Kconfig.
I still prefer the version in my patch because it makes the majority of
the code look clean and short (no #ifdefs). We could add a '_maybe'
prefix/suffix to function names which are conditionally compiled like
that (I think some Linux code does that).
E.g. ram_check_maybe(0, 640 * 1024), which should make it clear to
readers that the function may or may not have any effect depending
on kconfig variables.
Uwe.
--
http://www.hermann-uwe.de | http://www.holsham-traders.de
http://www.crazy-hacks.org | http://www.unmaintained-free-software.org
More information about the coreboot
mailing list