Xen Test Framework
Macros
macro_magic.h File Reference

Varadic macro helpers - Here be many dragons. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define STR(x)   _STR(x)
 Stringise an expression, expanding preprocessor tokens. More...
 
#define VA_NARGS(...)   VA_NARGS_(X,##__VA_ARGS__, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
 Count the number of varadic arguments provided. More...
 
#define VAR_MACRO_C1(macro, c1, ...)   VAR_MACRO_C1_(macro, c1, VA_NARGS(__VA_ARGS__), ##__VA_ARGS__)
 Call a macro variation, based on the number of varadic arguments. More...
 
#define IS_DEFINED(x)   _IS_DEFINED(x)
 Evalute whether the CONFIG_ token x is defined. More...
 

Detailed Description

Varadic macro helpers - Here be many dragons.

Definition in file macro_magic.h.

Macro Definition Documentation

◆ STR

#define STR (   x)    _STR(x)

Stringise an expression, expanding preprocessor tokens.

Parameters
xExpression to stringise.

Definition at line 17 of file macro_magic.h.

◆ VA_NARGS

#define VA_NARGS (   ...)    VA_NARGS_(X,##__VA_ARGS__, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)

Count the number of varadic arguments provided.

  VA_NARGS()     => 0
  VA_NARGS(x)    => 1
  VA_NARGS(x, y) => 2

Currently functions for 0 to 11 arguments.

Definition at line 33 of file macro_magic.h.

◆ VAR_MACRO_C1

#define VAR_MACRO_C1 (   macro,
  c1,
  ... 
)    VAR_MACRO_C1_(macro, c1, VA_NARGS(__VA_ARGS__), ##__VA_ARGS__)

Call a macro variation, based on the number of varadic arguments.

Parameters
macroPartial token to call a variation of.
c1Constant parameter to pass through.
...Varadic arguments to pass through.

Tokenises 'macro' with the count of varadic arguments, passing 'c1' and the varadic arguments.

  VAR_MACRO_C1(m, c)          => m0(c)
  VAR_MACRO_C1(m, c, x)       => m1(c, x)
  VAR_MACRO_C1(m, c, x, y)    => m2(c, x, y)
  VAR_MACRO_C1(m, c, x, y, z) => m3(c, x, y, z)

Definition at line 58 of file macro_magic.h.

◆ IS_DEFINED

#define IS_DEFINED (   x)    _IS_DEFINED(x)

Evalute whether the CONFIG_ token x is defined.

Suitable for use in an if () condition, even if x is not defined. Will strictly evaluate to 0 or 1.

Definition at line 67 of file macro_magic.h.