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 /* Build time sanity checks to make sure hard-coded offset
* is matching the actual offset! * is matching the actual offset!
*/ */
STATIC_ASSERT(offsetof(struct cpu_regs, rax) == _Static_assert(offsetof(struct cpu_regs, rax) ==
VMX_MACHINE_T_GUEST_RAX_OFFSET); VMX_MACHINE_T_GUEST_RAX_OFFSET,
STATIC_ASSERT(offsetof(struct cpu_regs, rbx) == "cpu_regs rax offset not match");
VMX_MACHINE_T_GUEST_RBX_OFFSET); _Static_assert(offsetof(struct cpu_regs, rbx) ==
STATIC_ASSERT(offsetof(struct cpu_regs, rcx) == VMX_MACHINE_T_GUEST_RBX_OFFSET,
VMX_MACHINE_T_GUEST_RCX_OFFSET); "cpu_regs rbx offset not match");
STATIC_ASSERT(offsetof(struct cpu_regs, rdx) == _Static_assert(offsetof(struct cpu_regs, rcx) ==
VMX_MACHINE_T_GUEST_RDX_OFFSET); VMX_MACHINE_T_GUEST_RCX_OFFSET,
STATIC_ASSERT(offsetof(struct cpu_regs, rbp) == "cpu_regs rcx offset not match");
VMX_MACHINE_T_GUEST_RBP_OFFSET); _Static_assert(offsetof(struct cpu_regs, rdx) ==
STATIC_ASSERT(offsetof(struct cpu_regs, rsi) == VMX_MACHINE_T_GUEST_RDX_OFFSET,
VMX_MACHINE_T_GUEST_RSI_OFFSET); "cpu_regs rdx offset not match");
STATIC_ASSERT(offsetof(struct cpu_regs, rdi) == _Static_assert(offsetof(struct cpu_regs, rbp) ==
VMX_MACHINE_T_GUEST_RDI_OFFSET); VMX_MACHINE_T_GUEST_RBP_OFFSET,
STATIC_ASSERT(offsetof(struct cpu_regs, r8) == "cpu_regs rbp offset not match");
VMX_MACHINE_T_GUEST_R8_OFFSET); _Static_assert(offsetof(struct cpu_regs, rsi) ==
STATIC_ASSERT(offsetof(struct cpu_regs, r9) == VMX_MACHINE_T_GUEST_RSI_OFFSET,
VMX_MACHINE_T_GUEST_R9_OFFSET); "cpu_regs rsi offset not match");
STATIC_ASSERT(offsetof(struct cpu_regs, r10) == _Static_assert(offsetof(struct cpu_regs, rdi) ==
VMX_MACHINE_T_GUEST_R10_OFFSET); VMX_MACHINE_T_GUEST_RDI_OFFSET,
STATIC_ASSERT(offsetof(struct cpu_regs, r11) == "cpu_regs rdi offset not match");
VMX_MACHINE_T_GUEST_R11_OFFSET); _Static_assert(offsetof(struct cpu_regs, r8) ==
STATIC_ASSERT(offsetof(struct cpu_regs, r12) == VMX_MACHINE_T_GUEST_R8_OFFSET,
VMX_MACHINE_T_GUEST_R12_OFFSET); "cpu_regs r8 offset not match");
STATIC_ASSERT(offsetof(struct cpu_regs, r13) == _Static_assert(offsetof(struct cpu_regs, r9) ==
VMX_MACHINE_T_GUEST_R13_OFFSET); VMX_MACHINE_T_GUEST_R9_OFFSET,
STATIC_ASSERT(offsetof(struct cpu_regs, r14) == "cpu_regs r9 offset not match");
VMX_MACHINE_T_GUEST_R14_OFFSET); _Static_assert(offsetof(struct cpu_regs, r10) ==
STATIC_ASSERT(offsetof(struct cpu_regs, r15) == VMX_MACHINE_T_GUEST_R10_OFFSET,
VMX_MACHINE_T_GUEST_R15_OFFSET); "cpu_regs r10 offset not match");
STATIC_ASSERT(offsetof(struct run_context, cr2) == _Static_assert(offsetof(struct cpu_regs, r11) ==
VMX_MACHINE_T_GUEST_CR2_OFFSET); VMX_MACHINE_T_GUEST_R11_OFFSET,
STATIC_ASSERT(offsetof(struct run_context, ia32_spec_ctrl) == "cpu_regs r11 offset not match");
VMX_MACHINE_T_GUEST_SPEC_CTRL_OFFSET); _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 */ /* Initialize the hypervisor paging */
init_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) #define ASSERT(x, ...) do { } while(0)
#endif #endif
/* Force a compilation error if condition is false */
#define STATIC_ASSERT(condition) ((void)sizeof(char[(condition) ? 1 : -1]))
#endif /* ASSERT_H */ #endif /* ASSERT_H */