Xen Test Framework
macro_magic.h
Go to the documentation of this file.
1 
6 #ifndef XTF_MACRO_MAGIC_H
7 #define XTF_MACRO_MAGIC_H
8 
15 #define _STR(x) #x
16 
17 #define STR(x) _STR(x)
18 
31 #define VA_NARGS_(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, N, ...) N
32 
33 #define VA_NARGS(...) \
34  VA_NARGS_(X,##__VA_ARGS__, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
35 
54 #define VAR_MACRO_C1__(macro, c1, count, ...) macro##count(c1, ##__VA_ARGS__)
55 #define VAR_MACRO_C1_(macro, c1, count, ...) \
56  VAR_MACRO_C1__(macro, c1, count, ##__VA_ARGS__)
57 
58 #define VAR_MACRO_C1(macro, c1, ...) \
59  VAR_MACRO_C1_(macro, c1, VA_NARGS(__VA_ARGS__), ##__VA_ARGS__)
60 
67 #define IS_DEFINED(x) _IS_DEFINED(x)
68 
69 #define _IS_DEFINED_PARTIAL_1 0,
70 #define _IS_DEFINED(x) __IS_DEFINED(_IS_DEFINED_PARTIAL_ ## x)
71 #define __IS_DEFINED(y) ___IS_DEFINED(y 1, 0)
72 #define ___IS_DEFINED(maybe, val, ...) val
73 
75 #endif /* XTF_MACRO_MAGIC_H */
76 
77 /*
78  * Local variables:
79  * mode: C
80  * c-file-style: "BSD"
81  * c-basic-offset: 4
82  * tab-width: 4
83  * indent-tabs-mode: nil
84  * End:
85  */