diff options
Diffstat (limited to 'include/linux/kconfig.h')
-rw-r--r-- | include/linux/kconfig.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h index 52586a7557b..d20da615b96 100644 --- a/include/linux/kconfig.h +++ b/include/linux/kconfig.h @@ -58,6 +58,30 @@ #define CONFIG_VAL(option) config_val(option) /* + * This uses a similar mechanism to config_enabled() above. If cfg is enabled, + * it resolves to the value of opt_cfg, otherwise it resolves to def_val + */ +#define config_opt_enabled(cfg, opt_cfg, def_val) _config_opt_enabled(cfg, opt_cfg, def_val) +#define _config_opt_enabled(cfg_val, opt_value, def_val) \ + __config_opt_enabled(__ARG_PLACEHOLDER_##cfg_val, opt_value, def_val) +#define __config_opt_enabled(arg1_or_junk, arg2, def_val) \ + ___config_opt_enabled(arg1_or_junk arg2, def_val) +#define ___config_opt_enabled(__ignored, val, ...) val + +#ifndef __ASSEMBLY__ +/* + * Detect usage of a the value when the conditional is not enabled. When used + * in assembly context, this likely produces a assembly error, or hopefully at + * least something recognisable. + */ +long invalid_use_of_IF_ENABLED_INT(void); +#endif + +/* Evaluates to int_option if option is defined, otherwise a build error */ +#define IF_ENABLED_INT(option, int_option) \ + config_opt_enabled(option, int_option, invalid_use_of_IF_ENABLED_INT()) + +/* * Count number of arguments to a variadic macro. Currently only need * it for 1, 2 or 3 arguments. */ @@ -111,5 +135,21 @@ #define CONFIG_IS_ENABLED(option, ...) \ __concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) (option, ##__VA_ARGS__) +#ifndef __ASSEMBLY__ +/* + * Detect usage of a the value when the conditional is not enabled. When used + * in assembly context, this likely produces a assembly error, or hopefully at + * least something recognisable. + */ +long invalid_use_of_CONFIG_IF_ENABLED_INT(void); +#endif + +/* + * Evaluates to SPL_/TPL_int_option if SPL_/TPL_/option is not defined, + * otherwise build error + */ +#define CONFIG_IF_ENABLED_INT(option, int_option) \ + CONFIG_IS_ENABLED(option, (CONFIG_VAL(int_option)), \ + (invalid_use_of_CONFIG_IF_ENABLED_INT())) #endif /* __LINUX_KCONFIG_H */ |