Skip to content

Commit c7c90e1

Browse files
bjorn-helgaasmasahir0y
authored andcommitted
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 <[email protected]> Acked-by: Randy Dunlap <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 43ac711 commit c7c90e1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/linux/kconfig.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151

5252
/*
5353
* 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.
5556
*/
5657
#define IS_MODULE(option) __is_defined(option##_MODULE)
5758

@@ -66,7 +67,8 @@
6667

6768
/*
6869
* IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
69-
* 0 otherwise.
70+
* 0 otherwise. Note that CONFIG_FOO=y results in "#define CONFIG_FOO 1" in
71+
* autoconf.h, while CONFIG_FOO=m results in "#define CONFIG_FOO_MODULE 1".
7072
*/
7173
#define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option))
7274

0 commit comments

Comments
 (0)