Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kconfig.h: explain IS_MODULE(), IS_ENABLED()

Extend IS_MODULE() and IS_ENABLED comments to explain why one might use
"#if IS_ENABLED(CONFIG_FOO)" instead of "#ifdef CONFIG_FOO".

To wit, "#ifdef CONFIG_FOO" is true only for CONFIG_FOO=y, while
"#if IS_ENABLED(CONFIG_FOO)" is true for both CONFIG_FOO=y and
CONFIG_FOO=m.

This is because "CONFIG_FOO=m" in .config does not result in "CONFIG_FOO"
being defined. The actual definitions are in autoconf.h, where:

CONFIG_FOO=y results in #define CONFIG_FOO 1
CONFIG_FOO=m results in #define CONFIG_FOO_MODULE 1

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Bjorn Helgaas and committed by
Masahiro Yamada
c7c90e12 43ac7110

+4 -2
+4 -2
include/linux/kconfig.h
··· 51 51 52 52 /* 53 53 * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0 54 - * otherwise. 54 + * otherwise. CONFIG_FOO=m results in "#define CONFIG_FOO_MODULE 1" in 55 + * autoconf.h. 55 56 */ 56 57 #define IS_MODULE(option) __is_defined(option##_MODULE) 57 58 ··· 67 66 68 67 /* 69 68 * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm', 70 - * 0 otherwise. 69 + * 0 otherwise. Note that CONFIG_FOO=y results in "#define CONFIG_FOO 1" in 70 + * autoconf.h, while CONFIG_FOO=m results in "#define CONFIG_FOO_MODULE 1". 71 71 */ 72 72 #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) 73 73