Remove STATIC_ASSERT Macro and replace with standard _Static_assert

Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Jason Chen CJ 2018-03-27 21:07:56 +08:00 committed by lijinxia
parent 6d8029f3da
commit 15d2d91de6
2 changed files with 51 additions and 37 deletions

View File

@ -292,40 +292,57 @@ void bsp_boot_init(void)
/* Build time sanity checks to make sure hard-coded offset
* is matching the actual offset!
*/
STATIC_ASSERT(offsetof(struct cpu_regs, rax) ==
VMX_MACHINE_T_GUEST_RAX_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, rbx) ==
VMX_MACHINE_T_GUEST_RBX_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, rcx) ==
VMX_MACHINE_T_GUEST_RCX_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, rdx) ==
VMX_MACHINE_T_GUEST_RDX_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, rbp) ==
VMX_MACHINE_T_GUEST_RBP_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, rsi) ==
VMX_MACHINE_T_GUEST_RSI_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, rdi) ==
VMX_MACHINE_T_GUEST_RDI_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, r8) ==
VMX_MACHINE_T_GUEST_R8_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, r9) ==
VMX_MACHINE_T_GUEST_R9_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, r10) ==
VMX_MACHINE_T_GUEST_R10_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, r11) ==
VMX_MACHINE_T_GUEST_R11_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, r12) ==
VMX_MACHINE_T_GUEST_R12_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, r13) ==
VMX_MACHINE_T_GUEST_R13_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, r14) ==
VMX_MACHINE_T_GUEST_R14_OFFSET);
STATIC_ASSERT(offsetof(struct cpu_regs, r15) ==
VMX_MACHINE_T_GUEST_R15_OFFSET);
STATIC_ASSERT(offsetof(struct run_context, cr2) ==
VMX_MACHINE_T_GUEST_CR2_OFFSET);
STATIC_ASSERT(offsetof(struct run_context, ia32_spec_ctrl) ==
VMX_MACHINE_T_GUEST_SPEC_CTRL_OFFSET);
_Static_assert(offsetof(struct cpu_regs, rax) ==
VMX_MACHINE_T_GUEST_RAX_OFFSET,
"cpu_regs rax offset not match");
_Static_assert(offsetof(struct cpu_regs, rbx) ==
VMX_MACHINE_T_GUEST_RBX_OFFSET,
"cpu_regs rbx offset not match");
_Static_assert(offsetof(struct cpu_regs, rcx) ==
VMX_MACHINE_T_GUEST_RCX_OFFSET,
"cpu_regs rcx offset not match");
_Static_assert(offsetof(struct cpu_regs, rdx) ==
VMX_MACHINE_T_GUEST_RDX_OFFSET,
"cpu_regs rdx offset not match");
_Static_assert(offsetof(struct cpu_regs, rbp) ==
VMX_MACHINE_T_GUEST_RBP_OFFSET,
"cpu_regs rbp offset not match");
_Static_assert(offsetof(struct cpu_regs, rsi) ==
VMX_MACHINE_T_GUEST_RSI_OFFSET,
"cpu_regs rsi offset not match");
_Static_assert(offsetof(struct cpu_regs, rdi) ==
VMX_MACHINE_T_GUEST_RDI_OFFSET,
"cpu_regs rdi offset not match");
_Static_assert(offsetof(struct cpu_regs, r8) ==
VMX_MACHINE_T_GUEST_R8_OFFSET,
"cpu_regs r8 offset not match");
_Static_assert(offsetof(struct cpu_regs, r9) ==
VMX_MACHINE_T_GUEST_R9_OFFSET,
"cpu_regs r9 offset not match");
_Static_assert(offsetof(struct cpu_regs, r10) ==
VMX_MACHINE_T_GUEST_R10_OFFSET,
"cpu_regs r10 offset not match");
_Static_assert(offsetof(struct cpu_regs, r11) ==
VMX_MACHINE_T_GUEST_R11_OFFSET,
"cpu_regs r11 offset not match");
_Static_assert(offsetof(struct cpu_regs, r12) ==
VMX_MACHINE_T_GUEST_R12_OFFSET,
"cpu_regs r12 offset not match");
_Static_assert(offsetof(struct cpu_regs, r13) ==
VMX_MACHINE_T_GUEST_R13_OFFSET,
"cpu_regs r13 offset not match");
_Static_assert(offsetof(struct cpu_regs, r14) ==
VMX_MACHINE_T_GUEST_R14_OFFSET,
"cpu_regs r14 offset not match");
_Static_assert(offsetof(struct cpu_regs, r15) ==
VMX_MACHINE_T_GUEST_R15_OFFSET,
"cpu_regs r15 offset not match");
_Static_assert(offsetof(struct run_context, cr2) ==
VMX_MACHINE_T_GUEST_CR2_OFFSET,
"run_context cr2 offset not match");
_Static_assert(offsetof(struct run_context, ia32_spec_ctrl) ==
VMX_MACHINE_T_GUEST_SPEC_CTRL_OFFSET,
"run_context ia32_spec_ctrl offset not match");
/* Initialize the hypervisor paging */
init_paging();

View File

@ -43,7 +43,4 @@ void __assert(uint32_t line, const char *file, char *txt);
#define ASSERT(x, ...) do { } while(0)
#endif
/* Force a compilation error if condition is false */
#define STATIC_ASSERT(condition) ((void)sizeof(char[(condition) ? 1 : -1]))
#endif /* ASSERT_H */