diff options
author | Yuval Peress <peress@chromium.org> | 2021-02-02 10:58:29 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-02 23:15:29 +0000 |
commit | 4f352e3880581952aa15c945fc635e2142fd7c93 (patch) | |
tree | 68b9abf1edcf26e69b5188490ed6b3d497b7c366 /include/common.h | |
parent | c15e3c7be204a74b21d2f3b589e0d864231bd357 (diff) | |
download | chrome-ec-4f352e3880581952aa15c945fc635e2142fd7c93.tar.gz |
zephyr: add STATIC_IF* that work with Kconfig
This change adds implementations of STATIC_IF and
STATIC_IF_NOT that work with Zephyr's Kconfig values.
Note that when using COND_CODE_1 both extern and static
have to be wrapped with parenthesis since COND_CODE_1
requires them and will strip them.
BRANCH=none
BUG=b:176828988, b:174481378
TEST=zmake testall
TEST=make runhosttests
Signed-off-by: Yuval Peress <peress@chromium.org>
Change-Id: Ib7f61758fc34acf2f609cb395cfa33ce7c71d759
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2668869
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'include/common.h')
-rw-r--r-- | include/common.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h index da3af6dc21..ee01db37d8 100644 --- a/include/common.h +++ b/include/common.h @@ -472,8 +472,19 @@ enum ec_error_list { * This follows the same constraints as IS_ENABLED, the config option * should be defined to nothing or undefined. */ +#ifndef CONFIG_ZEPHYR #define STATIC_IF(option) \ __cfg_select_build_assert(#option, option, static, extern) +#else +/* + * Version of STATIC_IF for Zephyr, with similar considerations to IS_ENABLED. + * + * Note, if __cfg_select fails, then we check using Zephyr's COND_CODE_1 macro + * to determine if the config option is enabled by Zephyr's definition. + */ +#define STATIC_IF(option) \ + __cfg_select(option, static, COND_CODE_1(option, (static), (extern))) +#endif /* CONFIG_ZEPHYR */ /** * STATIC_IF_NOT is just like STATIC_IF, but makes the variable static @@ -482,7 +493,16 @@ enum ec_error_list { * This is to assert that a variable will go unused with a certain * config option. */ +#ifndef CONFIG_ZEPHYR #define STATIC_IF_NOT(option) \ __cfg_select_build_assert(#option, option, extern, static) +#else +/* + * Version of STATIC_IF_NOT for Zephyr, with similar considerations to STATIC_IF + * and IS_ENABLED. + */ +#define STATIC_IF_NOT(option) \ + __cfg_select(option, extern, COND_CODE_1(option, (extern), (static))) +#endif /* CONFIG_ZEPHYR */ #endif /* __CROS_EC_COMMON_H */ |