From: Andrew Cooper Date: Wed, 9 Mar 2016 19:41:59 +0000 (+0000) Subject: Introduce IS_DEFINED() for use in C code X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=ce29b29438d24f6ac645da07f037df42794b6e0a;p=people%2Froyger%2Fxen-test-framework.git Introduce IS_DEFINED() for use in C code Alter CONFIG_{PV,HVM} to be explicitly defined as 1. Signed-off-by: Andrew Cooper --- diff --git a/include/arch/x86/config.h b/include/arch/x86/config.h index 490405d..7ee7010 100644 --- a/include/arch/x86/config.h +++ b/include/arch/x86/config.h @@ -11,9 +11,11 @@ #ifndef XTF_X86_CONFIG_H #define XTF_X86_CONFIG_H +#include + #if defined(CONFIG_ENV_pv64) -#define CONFIG_PV +#define CONFIG_PV 1 #define CONFIG_PAGING_LEVELS 4 #define ENVIRONMENT_DESCRIPTION "PV 64bit (Long mode 4 levels)" @@ -21,7 +23,7 @@ #elif defined(CONFIG_ENV_pv32pae) -#define CONFIG_PV +#define CONFIG_PV 1 #define CONFIG_PAGING_LEVELS 3 #define ENVIRONMENT_DESCRIPTION "PV 32bit (PAE 3 levels)" @@ -29,7 +31,7 @@ #elif defined(CONFIG_ENV_hvm64) -#define CONFIG_HVM +#define CONFIG_HVM 1 #define CONFIG_PAGING_LEVELS 4 #define ENVIRONMENT_DESCRIPTION "HVM 64bit (Long mode 4 levels)" @@ -37,7 +39,7 @@ #elif defined(CONFIG_ENV_hvm32pae) -#define CONFIG_HVM +#define CONFIG_HVM 1 #define CONFIG_PAGING_LEVELS 3 #define ENVIRONMENT_DESCRIPTION "HVM 32bit (PAE 3 levels)" @@ -45,7 +47,7 @@ #elif defined(CONFIG_ENV_hvm32pse) -#define CONFIG_HVM +#define CONFIG_HVM 1 #define CONFIG_PAGING_LEVELS 2 #define ENVIRONMENT_DESCRIPTION "HVM 32bit (PSE 2 levels)" @@ -53,7 +55,7 @@ #elif defined(CONFIG_ENV_hvm32) -#define CONFIG_HVM +#define CONFIG_HVM 1 #define CONFIG_PAGING_LEVELS 0 #define ENVIRONMENT_DESCRIPTION "HVM 32bit (No paging)" diff --git a/include/xtf/macro_magic.h b/include/xtf/macro_magic.h index b63c047..c2a1143 100644 --- a/include/xtf/macro_magic.h +++ b/include/xtf/macro_magic.h @@ -48,6 +48,20 @@ #define VAR_MACRO_C1(macro, c1, ...) \ VAR_MACRO_C1_(macro, c1, VA_NARGS(__VA_ARGS__), ##__VA_ARGS__) +/** + * Evalute whether the CONFIG_ token @p x is defined + * + * Suitable for use in an `if ()` condition, even if @p x is not defined. + * Will strictly evaluate to 0 or 1. + */ +#define IS_DEFINED(x) _IS_DEFINED(x) +/** @cond */ +#define _IS_DEFINED_PARTIAL_1 0, +#define _IS_DEFINED(x) __IS_DEFINED(_IS_DEFINED_PARTIAL_ ## x) +#define __IS_DEFINED(y) ___IS_DEFINED(y 1, 0) +#define ___IS_DEFINED(maybe, val, ...) val +/** @endcond */ + #endif /* XTF_MACRO_MAGIC_H */ /*