Skip to content

RFC CONFIG_IS_ENABLED magic

Tom Rini u-boot 1 version New

Get series with b4
b4 am 20200619175738.GO27801@bill-the-cat

Versions newest first

  1. v1 RFC Latest2 of 4 patches 0 repliesNew

2 of 4 patches are in this archive. The cover letter announces 4.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4common/image.c: image_decomp: put IH_COMP_XXX cases inside ifndef USE_HOSTCC+0 -00 replies
4/4linux/kconfig.h: create two- and three-argument versions of CONFIG_IS_ENABLED+0 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/4] CONFIG_IS_ENABLED magic
Quoted 39 lines · Rasmus Villemoes

The first patch is just something I suggested to allow zstd support to move forward. The remaining ones aim to make it more ergonomic to use CONFIG_IS_ENABLED to exclude things from the build.

While it currently works just fine in C code that one can do

  if (CONFIG_IS_ENABLED(FOO)) {

  }

and have the compiler throw the whole block away, and then later the linker throw away any functions and/or data that turns out not be used anyway, it's currently somewhat uglier to exclude items from an array initializer - it requires three lines to do

  #if CONFIG_IS_ENABLED(FOO)
  { some array item },
  #endif

and grepping for the FOO symbol doesn't really show what it is used for including/excluding.

With the last patch, one can instead do

CONFIG_IS_ENABLED(FOO, ({ some array item },))

It's just an RFC; I think this can be useful to reduce the size of SPL/TPL without too much cluttering of the source, others can disagree.

Rasmus Villemoes (4):
common/image.c: image_decomp: put IH_COMP_XXX cases inside ifndef
USE_HOSTCC
linux/kconfig.h: simplify logic for choosing CONFIG_{SPL_,TPL_,}* linux/kconfig.h: remove unused helper macros linux/kconfig.h: create two- and three-argument versions of
CONFIG_IS_ENABLED

Quoted 4 lines
 common/image.c               |   2 +
 include/linux/kconfig.h      | 103 ++++++++++++++++++-----------------
 scripts/config_whitelist.txt |   2 -
 3 files changed, 54 insertions(+), 53 deletions(-)

This is I believe a good step forward and should let us clean up our code in a few areas. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200619/2d3791db/attachment.sig>