mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
tools: lift BUILD_BUG_ON to a tools header file
Only define BUILD_BUG_ON when there isn't one already, because mini-os currently leaks that. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
1 parent
1ef5056bd6
commit
3a7f872ae4
13 files changed
+46
-38
No files matched your search
@@ -31,6 +31,7 @@
|
||||
#include "option_rom.h"
|
||||
|
||||
#include <xen/hvm/params.h>
|
||||
#include <xen-tools/libs.h>
|
||||
|
||||
#define ROM_INCLUDE_ROMBIOS
|
||||
#define ROM_INCLUDE_VGABIOS
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "util.h"
|
||||
#include "hypercall.h"
|
||||
#include <xen/hvm/hvm_xs_strings.h>
|
||||
#include <xen-tools/libs.h>
|
||||
|
||||
/* SBMIOS handle base values */
|
||||
#define SMBIOS_HANDLE_TYPE0 0x0000
|
||||
|
||||
@@ -41,7 +41,6 @@ void __assert_failed(char *assertion, char *file, int line)
|
||||
void __bug(char *file, int line) __attribute__((noreturn));
|
||||
#define BUG() __bug(__FILE__, __LINE__)
|
||||
#define BUG_ON(p) do { if (p) BUG(); } while (0)
|
||||
#define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)]))
|
||||
|
||||
#define min_t(type,x,y) \
|
||||
({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef __XEN_TOOLS_LIBS__
|
||||
|
||||
#ifndef BUILD_BUG_ON
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
#define BUILD_BUG_ON(p) ({ _Static_assert(!(p), "!(" #p ")"); })
|
||||
#else
|
||||
#define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)]))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __XEN_TOOLS_LIBS__ */
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "xg_private.h"
|
||||
#include "xc_core.h"
|
||||
|
||||
#include <xen-tools/libs.h>
|
||||
|
||||
int
|
||||
xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt,
|
||||
unsigned long pfn)
|
||||
@@ -101,7 +103,7 @@ xc_core_arch_get_scratch_gpfn(xc_interface *xch, domid_t domid,
|
||||
* The Grant Table region space is not used until the guest is
|
||||
* booting. Use the first page for the scratch pfn.
|
||||
*/
|
||||
XC_BUILD_BUG_ON(GUEST_GNTTAB_SIZE < XC_PAGE_SIZE);
|
||||
BUILD_BUG_ON(GUEST_GNTTAB_SIZE < XC_PAGE_SIZE);
|
||||
|
||||
*gpfn = GUEST_GNTTAB_BASE >> XC_PAGE_SHIFT;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "xc_private.h"
|
||||
#include "xc_bitops.h"
|
||||
#include <xen/hvm/params.h>
|
||||
#include <xen-tools/libs.h>
|
||||
|
||||
enum {
|
||||
#define XEN_CPUFEATURE(name, value) X86_FEATURE_##name = value,
|
||||
@@ -98,12 +99,12 @@ const uint32_t *xc_get_static_cpu_featuremask(
|
||||
hvm_hap[FEATURESET_NR_ENTRIES] = INIT_HVM_HAP_FEATURES,
|
||||
deep_features[FEATURESET_NR_ENTRIES] = INIT_DEEP_FEATURES;
|
||||
|
||||
XC_BUILD_BUG_ON(ARRAY_SIZE(known) != FEATURESET_NR_ENTRIES);
|
||||
XC_BUILD_BUG_ON(ARRAY_SIZE(special) != FEATURESET_NR_ENTRIES);
|
||||
XC_BUILD_BUG_ON(ARRAY_SIZE(pv) != FEATURESET_NR_ENTRIES);
|
||||
XC_BUILD_BUG_ON(ARRAY_SIZE(hvm_shadow) != FEATURESET_NR_ENTRIES);
|
||||
XC_BUILD_BUG_ON(ARRAY_SIZE(hvm_hap) != FEATURESET_NR_ENTRIES);
|
||||
XC_BUILD_BUG_ON(ARRAY_SIZE(deep_features) != FEATURESET_NR_ENTRIES);
|
||||
BUILD_BUG_ON(ARRAY_SIZE(known) != FEATURESET_NR_ENTRIES);
|
||||
BUILD_BUG_ON(ARRAY_SIZE(special) != FEATURESET_NR_ENTRIES);
|
||||
BUILD_BUG_ON(ARRAY_SIZE(pv) != FEATURESET_NR_ENTRIES);
|
||||
BUILD_BUG_ON(ARRAY_SIZE(hvm_shadow) != FEATURESET_NR_ENTRIES);
|
||||
BUILD_BUG_ON(ARRAY_SIZE(hvm_hap) != FEATURESET_NR_ENTRIES);
|
||||
BUILD_BUG_ON(ARRAY_SIZE(deep_features) != FEATURESET_NR_ENTRIES);
|
||||
|
||||
switch ( mask )
|
||||
{
|
||||
@@ -139,7 +140,7 @@ const uint32_t *xc_get_feature_deep_deps(uint32_t feature)
|
||||
|
||||
unsigned int start = 0, end = ARRAY_SIZE(deep_deps);
|
||||
|
||||
XC_BUILD_BUG_ON(ARRAY_SIZE(deep_deps) != NR_DEEP_DEPS);
|
||||
BUILD_BUG_ON(ARRAY_SIZE(deep_deps) != NR_DEEP_DEPS);
|
||||
|
||||
/* deep_deps[] is sorted. Perform a binary search. */
|
||||
while ( start < end )
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <xen/xen.h>
|
||||
#include <xen/io/protocols.h>
|
||||
#include <xen-tools/libs.h>
|
||||
|
||||
#include "xg_private.h"
|
||||
#include "xc_dom.h"
|
||||
@@ -69,7 +70,7 @@ static int alloc_magic_pages(struct xc_dom_image *dom)
|
||||
const xen_pfn_t base = GUEST_MAGIC_BASE >> XC_PAGE_SHIFT;
|
||||
xen_pfn_t p2m[NR_MAGIC_PAGES];
|
||||
|
||||
XC_BUILD_BUG_ON(NR_MAGIC_PAGES > GUEST_MAGIC_SIZE >> XC_PAGE_SHIFT);
|
||||
BUILD_BUG_ON(NR_MAGIC_PAGES > GUEST_MAGIC_SIZE >> XC_PAGE_SHIFT);
|
||||
|
||||
DOMPRINTF_CALLED(dom->xch);
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "xg_private.h"
|
||||
#include "xc_dom_decompress.h"
|
||||
|
||||
#include <xen-tools/libs.h>
|
||||
|
||||
#ifndef __MINIOS__
|
||||
|
||||
#if defined(HAVE_BZLIB)
|
||||
@@ -418,7 +420,7 @@ static int xc_try_lzo1x_decode(
|
||||
* lzo_uint should match size_t. Check that this is the case to be
|
||||
* sure we won't overflow various lzo_uint fields.
|
||||
*/
|
||||
XC_BUILD_BUG_ON(sizeof(lzo_uint) != sizeof(size_t));
|
||||
BUILD_BUG_ON(sizeof(lzo_uint) != sizeof(size_t));
|
||||
|
||||
ret = lzo_init();
|
||||
if ( ret != LZO_E_OK )
|
||||
|
||||
+4
-2
@@ -21,6 +21,8 @@
|
||||
#include <stdbool.h>
|
||||
#include "xc_private.h"
|
||||
|
||||
#include <xen-tools/libs.h>
|
||||
|
||||
/*
|
||||
* Get PM statistic info
|
||||
*/
|
||||
@@ -274,8 +276,8 @@ int xc_get_cpufreq_para(xc_interface *xch, int cpuid,
|
||||
sys_para->scaling_governor, CPUFREQ_NAME_LEN);
|
||||
|
||||
/* copy to user_para no matter what cpufreq governor */
|
||||
XC_BUILD_BUG_ON(sizeof(((struct xc_get_cpufreq_para *)0)->u) !=
|
||||
sizeof(((struct xen_get_cpufreq_para *)0)->u));
|
||||
BUILD_BUG_ON(sizeof(((struct xc_get_cpufreq_para *)0)->u) !=
|
||||
sizeof(((struct xen_get_cpufreq_para *)0)->u));
|
||||
|
||||
memcpy(&user_para->u, &sys_para->u, sizeof(sys_para->u));
|
||||
}
|
||||
|
||||
@@ -72,13 +72,6 @@ struct iovec {
|
||||
#define PAGE_SIZE XC_PAGE_SIZE
|
||||
#define PAGE_MASK XC_PAGE_MASK
|
||||
|
||||
/* Force a compilation error if condition is true */
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
#define XC_BUILD_BUG_ON(p) ({ _Static_assert(!(p), "!(" #p ")"); })
|
||||
#else
|
||||
#define XC_BUILD_BUG_ON(p) ((void)sizeof(struct { int:-!!(p); }))
|
||||
#endif
|
||||
|
||||
#ifndef ARRAY_SIZE /* MiniOS leaks ARRAY_SIZE into our namespace as part of a
|
||||
* stubdom build. It shouldn't... */
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
+12
-10
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "xc_sr_common.h"
|
||||
|
||||
#include <xen-tools/libs.h>
|
||||
|
||||
static const char *dhdr_types[] =
|
||||
{
|
||||
[DHDR_TYPE_X86_PV] = "x86 PV",
|
||||
@@ -140,17 +142,17 @@ int read_record(struct xc_sr_context *ctx, int fd, struct xc_sr_record *rec)
|
||||
|
||||
static void __attribute__((unused)) build_assertions(void)
|
||||
{
|
||||
XC_BUILD_BUG_ON(sizeof(struct xc_sr_ihdr) != 24);
|
||||
XC_BUILD_BUG_ON(sizeof(struct xc_sr_dhdr) != 16);
|
||||
XC_BUILD_BUG_ON(sizeof(struct xc_sr_rhdr) != 8);
|
||||
BUILD_BUG_ON(sizeof(struct xc_sr_ihdr) != 24);
|
||||
BUILD_BUG_ON(sizeof(struct xc_sr_dhdr) != 16);
|
||||
BUILD_BUG_ON(sizeof(struct xc_sr_rhdr) != 8);
|
||||
|
||||
XC_BUILD_BUG_ON(sizeof(struct xc_sr_rec_page_data_header) != 8);
|
||||
XC_BUILD_BUG_ON(sizeof(struct xc_sr_rec_x86_pv_info) != 8);
|
||||
XC_BUILD_BUG_ON(sizeof(struct xc_sr_rec_x86_pv_p2m_frames) != 8);
|
||||
XC_BUILD_BUG_ON(sizeof(struct xc_sr_rec_x86_pv_vcpu_hdr) != 8);
|
||||
XC_BUILD_BUG_ON(sizeof(struct xc_sr_rec_tsc_info) != 24);
|
||||
XC_BUILD_BUG_ON(sizeof(struct xc_sr_rec_hvm_params_entry) != 16);
|
||||
XC_BUILD_BUG_ON(sizeof(struct xc_sr_rec_hvm_params) != 8);
|
||||
BUILD_BUG_ON(sizeof(struct xc_sr_rec_page_data_header) != 8);
|
||||
BUILD_BUG_ON(sizeof(struct xc_sr_rec_x86_pv_info) != 8);
|
||||
BUILD_BUG_ON(sizeof(struct xc_sr_rec_x86_pv_p2m_frames) != 8);
|
||||
BUILD_BUG_ON(sizeof(struct xc_sr_rec_x86_pv_vcpu_hdr) != 8);
|
||||
BUILD_BUG_ON(sizeof(struct xc_sr_rec_tsc_info) != 24);
|
||||
BUILD_BUG_ON(sizeof(struct xc_sr_rec_hvm_params_entry) != 16);
|
||||
BUILD_BUG_ON(sizeof(struct xc_sr_rec_hvm_params) != 8);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -4148,14 +4148,6 @@ int libxl__string_parse_json(libxl__gc *gc, const libxl__json_object *o,
|
||||
|
||||
int libxl__random_bytes(libxl__gc *gc, uint8_t *buf, size_t len);
|
||||
|
||||
/*
|
||||
* Compile time assertion
|
||||
*/
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
#define BUILD_BUG_ON(p) ({ _Static_assert(!(p), "!(" #p ")"); })
|
||||
#else
|
||||
#define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)]))
|
||||
#endif
|
||||
#include "_libxl_types_private.h"
|
||||
#include "_libxl_types_internal_private.h"
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "libxl_osdeps.h" /* must come before any other headers */
|
||||
#include "libxl_internal.h"
|
||||
|
||||
#include <xen-tools/libs.h>
|
||||
|
||||
#define IA32_QM_CTR_ERROR_MASK (0x3ul << 62)
|
||||
|
||||
|
||||