On Thu, Jul 23, 2015 at 08:31:56PM +0900, Masahiro Yamada wrote: > The previous commit introduced a useful macro used in makefiles, > which references to different variables (CONFIG_ or CONFIG_SPL_ > prefixed), in order to enable/disable features independently > for each of images. > > Per-image config option control is a PITA in C sources, too. > So, introduce some macros useful in C/CPP expressions. > > CONFIG_IS_ENABLED(FOO) is a shorthand for > > (!defined(CONFIG_SPL_BUILD) && defined(CONFIG_FOO)) || \ > (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_FOO)) > > For example, it is useful to describe C code as follows, > > #if CONFIG_IS_ENABLED(OF_CONTROL) > (device tree code) > #else > (board file code) > #endif > > The ifdef conditional above is switched by CONFIG_OF_CONTROL during > the U-Boot proper building (CONFIG_SPL_BUILD is not defined), and by > CONFIG_SPL_OF_CONTROL during SPL building (CONFIG_SPL_BUILD is > defined). > > The macro can be used in C context as well, so you can also write the > equivalent code as follows: > > if (CONFIG_IS_ENABLED(OF_CONTROL)) { > (device tree code) > } else { > (board file code) > } > > Another useful macro is CONFIG_VALUE(). > CONFIG_VALUE(FOO) is expanded into CONFIG_FOO during the main build, > and into CONFIG_SPL_FOO during SPL build. > > You can write as follows: > > text_base = CONFIG_VALUE(TEXT_BASE); > > instead of: > > #ifdef CONFIG_SPL_BUILD > text_base = CONFIG_SPL_TEXT_BASE; > #else > text_base = CONFIG_TEXT_BASE; > #endif > > Signed-off-by: Masahiro Yamada <yamada.masah...@socionext.com>
Reviewed-by: Tom Rini <tr...@konsulko.com> -- Tom
signature.asc
Description: Digital signature
_______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot