1
0

config.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _TOOLS_CONFIG_H
  3. #define _TOOLS_CONFIG_H
  4. /* Subset of include/linux/kconfig.h */
  5. #define __ARG_PLACEHOLDER_1 0,
  6. #define __take_second_arg(__ignored, val, ...) val
  7. /*
  8. * Helper macros to use CONFIG_ options in C/CPP expressions. Note that
  9. * these only work with boolean and tristate options.
  10. */
  11. /*
  12. * Getting something that works in C and CPP for an arg that may or may
  13. * not be defined is tricky. Here, if we have "#define CONFIG_BOOGER 1"
  14. * we match on the placeholder define, insert the "0," for arg1 and generate
  15. * the triplet (0, 1, 0). Then the last step cherry picks the 2nd arg (a one).
  16. * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
  17. * the last step cherry picks the 2nd arg, we get a zero.
  18. */
  19. #define __is_defined(x) ___is_defined(x)
  20. #define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val)
  21. #define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0)
  22. /*
  23. * IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
  24. * otherwise. For boolean options, this is equivalent to
  25. * IS_ENABLED(CONFIG_FOO).
  26. */
  27. #define IS_BUILTIN(option) __is_defined(option)
  28. #endif /* _TOOLS_CONFIG_H */