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