]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
Introduce IS_DEFINED() for use in C code
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 9 Mar 2016 19:41:59 +0000 (19:41 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 11 May 2016 12:48:35 +0000 (13:48 +0100)
Alter CONFIG_{PV,HVM} to be explicitly defined as 1.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
include/arch/x86/config.h
include/xtf/macro_magic.h

index 490405d09cb8c7e70d90984ee0a210f0a7654d62..7ee701010b928add12fe2d7d7e55042a00c4d47c 100644 (file)
 #ifndef XTF_X86_CONFIG_H
 #define XTF_X86_CONFIG_H
 
+#include <xtf/macro_magic.h>
+
 #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)"
 
index b63c047df4a04c905a89afe99dfb9482a5f98dd8..c2a1143ceb7471bffe72dcbd1bf3c251db626095 100644 (file)
 #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 */
 
 /*