mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-24 02:08:04 +00:00
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:
@@ -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;
|
||||
|
12
hypervisor/common/static_checks.c
Normal file
12
hypervisor/common/static_checks.c
Normal 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));
|
Reference in New Issue
Block a user