[PATCH 15/16] kconfig: implement IF_ENABLED helper

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Apr 1 03:48:05 PDT 2025


For situations where ternary operations are not allowed like
compile-time string concatenation, introduce a helper that checks if the
first argument is enabled and expands to the rest of the arguments only
if it is.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 include/linux/kconfig.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 4e9c77b964a7..971f4260725c 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -33,6 +33,12 @@
  */
 #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option))
 
+#define IF_ENABLED__0(args...)
+#define IF_ENABLED__1(args...)		args
+#define IF_ENABLED__(optval, args...)	IF_ENABLED__##optval(args)
+#define IF_ENABLED_(optval, args...)	IF_ENABLED__(optval, args)
+#define IF_ENABLED(option, args...)	IF_ENABLED_(IS_ENABLED(option), args)
+
 #ifdef __PBL__
 #define IN_PBL		1
 #define IN_PROPER	0
-- 
2.39.5




More information about the barebox mailing list