[PATCH v2 3/8] linux/kconfig.h: create two- and three-argument versions of CONFIG_IS_ENABLED

Bin Meng bmeng.cn at gmail.com
Tue Jul 7 09:19:00 CEST 2020


On Sat, Jul 4, 2020 at 12:38 AM Simon Glass <sjg at chromium.org> wrote:
>
> From: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
>
> This adds a bunch of preprocessor magic to extend the capabilities of
> CONFIG_IS_ENABLED. The existing semantics of
>
>   CONFIG_IS_ENABLED(FOO)
>
> expanding to a 1 or 0 (depending on build context and the defined-ness
> or not of the appropriate CONFIG_FOO/CONFIG_SPL_FOO/CONFIG_TPL_FOO)
> are of course preserved. With this, one is also allowed a two-argument
> form
>
>   CONFIG_IS_ENABLED(FOO, (something))
>
> which expands to something precisely when CONFIG_IS_ENABLED(FOO) would
> expand to 1, and expands to nothing otherwise. It is, in other words,
> completely equivalent to the three lines
>
>   #if CONFIG_IS_ENABLED(FOO)
>   something
>   #endif
>
> The second argument must be parenthesized in order to allow any
> tokens, including a trailing comma, to appear - one use case for this
> is precisely to make it a bit more ergonomic to build an array and
> only include certain items depending on .config. That should increase
> both readability and not least "git grep"ability.
>
> A third variant is also introduced,
>
>   CONFIG_IS_ENABLED(FOO, (xxx), (yyy))
>
> which corresponds to
>
>   #if CONFIG_IS_ENABLED(FOO)
>   xxx
>   #else
>   yyy
>   #endif
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
> Reviewed-by: Simon Glass <sjg at chromium.org>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> (no changes since v1)
>
>  include/linux/kconfig.h | 48 ++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 45 insertions(+), 3 deletions(-)
>

applied to u-boot-x86, thanks!


More information about the U-Boot mailing list