]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - include/linux/kconfig.h
kconfig.h: allow to use IS_{ENABLE,REACHABLE} in macro expansion
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Tue, 14 Jun 2016 05:58:57 +0000 (14:58 +0900)
committerMichal Marek <mmarek@suse.com>
Mon, 20 Jun 2016 20:42:32 +0000 (22:42 +0200)
commit5e8754fd80b0a594f720f44d32bf28c7b06ba5a6
treee1999ea36950a515194cb3874e54f7e657828d92
parent05a25c8e2c593914c18faf91dfb5ee471b79ce58
kconfig.h: allow to use IS_{ENABLE,REACHABLE} in macro expansion

The typical usage of IS_ENABLED() is

    if (IS_ENABLED(CONFIG_FOO)) {
            ...
    }

or

    #if IS_ENABLED(CONFIG_FOO)
            ...
    #endif

The current implementation of IS_ENABLED() includes "||" operator,
which works well in those expressions like above.

However, there is a case where we want to evaluate a config option
beyond those use cases.

For example, the OF_TABLE() in include/asm-generic/vmlinux.lds.h
needs to evaluate a config option in macro expansion:

  #define ___OF_TABLE(cfg, name)  _OF_TABLE_##cfg(name)
  #define __OF_TABLE(cfg, name)   ___OF_TABLE(cfg, name)
  #define OF_TABLE(cfg, name)     __OF_TABLE(config_enabled(cfg), name)
  #define _OF_TABLE_0(name)
  #define _OF_TABLE_1(name)  \
          ...

Here, we can not use IS_ENABLED() because of the "||" operator in
its define.  It is true config_enabled() works well, but it is a bit
ambiguous to be used against config options.

This commit makes IS_ENABLED() available in more generic context by
calculating "or" with macro expansion only.

Do likewise for IS_REACHABLE().

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
include/linux/kconfig.h