This is useful when preprocessing non-C code that lacks an if statement equivalent. For example, external device tree fragments can now specify: #include <linux/is_defined.h> __if_defined(bcm2711_rpi_4_dts, &emmc2, &sdhost) { instead of having to use the more verbose #ifdef: #ifdef bcm2711_rpi_4_dts &emmc2 { #else &sdhost { #endif Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- include/linux/is_defined.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/is_defined.h b/include/linux/is_defined.h index d68f8e877f9b..bfefca033f70 100644 --- a/include/linux/is_defined.h +++ b/include/linux/is_defined.h @@ -34,4 +34,10 @@ #define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val) #define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0) +#define __if_defined(x, a, b) ___if_defined(__is_defined(x), a, b) +#define ___if_defined(val, a, b) ____if_defined(val, a, b) +#define ____if_defined(val, a, b) ____if_defined_##val(a, b) +#define ____if_defined_1(a, b) a +#define ____if_defined_0(a, b) b + #endif -- 2.39.2