hv: add compile time assert for static checks

Add two files to do compile time assert.
One is arch specific, and put in hypervisor/arch/x86/.
The other one is common, and put in hypervisor/common/.

If the statement is not true, there will be error during compile time.
The file will not increase the size of HV binary.

Signed-off-by: Binbin Wu <binbin.wu@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Binbin Wu
2018-08-13 00:29:12 +08:00
committed by lijinxia
parent 69522dc861
commit a9151ff3fa
5 changed files with 75 additions and 76 deletions

View File

@@ -62,10 +62,6 @@ acrn_insert_request_wait(struct vcpu *vcpu, struct io_request *io_req)
struct vhm_request *vhm_req;
uint16_t cur;
ASSERT(sizeof(struct vhm_request) == (4096U/VHM_REQUEST_MAX),
"vhm_request page broken!");
if ((vcpu == NULL) || (io_req == NULL) ||
(vcpu->vm->sw.io_shared_page == NULL)) {
return -EINVAL;

View File

@@ -0,0 +1,12 @@
/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <acrn_common.h>
#define CAT_(A,B) A ## B
#define CTASSERT(expr) \
typedef int CAT_(CTA_DummyType,__LINE__)[(expr) ? 1 : -1]
CTASSERT(sizeof(struct vhm_request) == (4096U/VHM_REQUEST_MAX));