@@ -632,13 +632,7 @@ struct hvm_msr {
uint32_t index;
uint32_t _rsvd;
uint64_t val;
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- } msr[];
-#elif defined(__GNUC__)
- } msr[0];
-#else
- } msr[1 /* variable size */];
-#endif
+ } msr[XEN_FLEX_ARRAY_DIM];
};
#define CPU_MSR_CODE 20
@@ -35,11 +35,7 @@ struct xen_pmu_amd_ctxt {
uint32_t ctrls;
/* Counter MSRs */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- uint64_t regs[];
-#elif defined(__GNUC__)
- uint64_t regs[0];
-#endif
+ uint64_t regs[XEN_FLEX_ARRAY_DIM];
};
typedef struct xen_pmu_amd_ctxt xen_pmu_amd_ctxt_t;
DEFINE_XEN_GUEST_HANDLE(xen_pmu_amd_ctxt_t);
@@ -71,11 +67,7 @@ struct xen_pmu_intel_ctxt {
uint64_t debugctl;
/* Fixed and architectural counter MSRs */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- uint64_t regs[];
-#elif defined(__GNUC__)
- uint64_t regs[0];
-#endif
+ uint64_t regs[XEN_FLEX_ARRAY_DIM];
};
typedef struct xen_pmu_intel_ctxt xen_pmu_intel_ctxt_t;
DEFINE_XEN_GUEST_HANDLE(xen_pmu_intel_ctxt_t);
@@ -82,11 +82,7 @@ typedef struct xen_argo_ring
* multiple of the message slot size.
*/
uint8_t reserved[56];
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- uint8_t ring[];
-#elif defined(__GNUC__)
- uint8_t ring[0];
-#endif
+ uint8_t ring[XEN_FLEX_ARRAY_DIM];
} xen_argo_ring_t;
typedef struct xen_argo_register_ring
@@ -136,11 +132,7 @@ typedef struct xen_argo_ring_data
{
uint32_t nent;
uint32_t pad;
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- struct xen_argo_ring_data_ent data[];
-#elif defined(__GNUC__)
- struct xen_argo_ring_data_ent data[0];
-#endif
+ struct xen_argo_ring_data_ent data[XEN_FLEX_ARRAY_DIM];
} xen_argo_ring_data_t;
struct xen_argo_ring_message_header
@@ -148,11 +140,7 @@ struct xen_argo_ring_message_header
uint32_t len;
struct xen_argo_addr source;
uint32_t message_type;
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- uint8_t data[];
-#elif defined(__GNUC__)
- uint8_t data[0];
-#endif
+ uint8_t data[XEN_FLEX_ARRAY_DIM];
};
/*
@@ -300,11 +300,7 @@ struct physdev_pci_device_add {
* First element ([0]) is PXM domain associated with the device (if
* XEN_PCI_DEV_PXM is set)
*/
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- uint32_t optarr[];
-#elif defined(__GNUC__)
- uint32_t optarr[0];
-#endif
+ uint32_t optarr[XEN_FLEX_ARRAY_DIM];
};
typedef struct physdev_pci_device_add physdev_pci_device_add_t;
DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_add_t);
@@ -95,11 +95,8 @@ typedef char xen_commandline_t[1024];
#define XENVER_build_id 10
struct xen_build_id {
uint32_t len; /* IN: size of buf[]. */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- unsigned char buf[];
-#elif defined(__GNUC__)
- unsigned char buf[1]; /* OUT: Variable length buffer with build_id. */
-#endif
+ unsigned char buf[XEN_FLEX_ARRAY_DIM];
+ /* OUT: Variable length buffer with build_id. */
};
typedef struct xen_build_id xen_build_id_t;
@@ -41,4 +41,6 @@
#error "These header files do not support the requested interface version."
#endif
+#define COMPAT_FLEX_ARRAY_DIM XEN_FLEX_ARRAY_DIM
+
#endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */
@@ -53,6 +53,15 @@ DEFINE_XEN_GUEST_HANDLE(uint64_t);
DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
+/* Define a variable length array (depends on compiler). */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define XEN_FLEX_ARRAY_DIM
+#elif defined(__GNUC__)
+#define XEN_FLEX_ARRAY_DIM 0
+#else
+#define XEN_FLEX_ARRAY_DIM 1 /* variable size */
+#endif
+
/* Turn a plain number into a C unsigned (long (long)) constant. */
#define __xen_mk_uint(x) x ## U
#define __xen_mk_ulong(x) x ## UL
Several public headers of the hypervisor contain structures with variable length arrays. In order to be usable with different compilers those definitions are depending on the compiler type and the standard supported by the compiler. In order to avoid open coding the different variants in each header add a common macro for that purpose in xen.h. This at once corrects most of the definitions which miss one case leading to not defining the array at all. Signed-off-by: Juergen Gross <jgross@suse.com> --- V2: - rename macro (Jan Beulich) --- xen/include/public/arch-x86/hvm/save.h | 8 +------- xen/include/public/arch-x86/pmu.h | 12 ++---------- xen/include/public/argo.h | 18 +++--------------- xen/include/public/physdev.h | 6 +----- xen/include/public/version.h | 7 ++----- xen/include/public/xen-compat.h | 2 ++ xen/include/public/xen.h | 9 +++++++++ 7 files changed, 20 insertions(+), 42 deletions(-)