[kvm-unit-tests RFC 03/16] x86 UEFI: Move setjmp.h out of desc.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Previous desc.h includes setjmp.h, and this causes duplicate definition
when compiling with UEFI header efi.h. This is because setjmp() function
is defined both in KVM-Unit-Tests and UEFI. When including both desc.h
and efi.h, the setjmp() is found in both headers and causes this error.

The easy solution is to move setjmp.h from desc.h to desc.c, so
including desc.h does not bring in setjmp.h, so that we can include
both desc.h and efi.h in lib/x86/setup.c.

This commit also includes setjmp.h in x86/vmx.c, because this test case
previously assumed setjmp.h is included by desc.h and did not include
setjmp.h explicitly.

This commit does not change any test case behavior.

Signed-off-by: Zixuan Wang <zixuanwang@xxxxxxxxxx>
---
 lib/x86/desc.c | 4 ++++
 lib/x86/desc.h | 5 -----
 x86/vmx.c      | 1 +
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/x86/desc.c b/lib/x86/desc.c
index e7378c1..eb4d2bc 100644
--- a/lib/x86/desc.c
+++ b/lib/x86/desc.c
@@ -3,6 +3,10 @@
 #include "processor.h"
 #include <setjmp.h>
 
+void __set_exception_jmpbuf(jmp_buf *addr);
+#define set_exception_jmpbuf(jmpbuf) \
+	(setjmp(jmpbuf) ? : (__set_exception_jmpbuf(&(jmpbuf)), 0))
+
 #ifndef __x86_64__
 __attribute__((regparm(1)))
 #endif
diff --git a/lib/x86/desc.h b/lib/x86/desc.h
index a6ffb38..9fda20d 100644
--- a/lib/x86/desc.h
+++ b/lib/x86/desc.h
@@ -1,8 +1,6 @@
 #ifndef _X86_DESC_H_
 #define _X86_DESC_H_
 
-#include <setjmp.h>
-
 void setup_idt(void);
 void setup_alt_stack(void);
 
@@ -226,9 +224,6 @@ void unhandled_exception(struct ex_regs *regs, bool cpu);
 
 bool test_for_exception(unsigned int ex, void (*trigger_func)(void *data),
 			void *data);
-void __set_exception_jmpbuf(jmp_buf *addr);
-#define set_exception_jmpbuf(jmpbuf) \
-	(setjmp(jmpbuf) ? : (__set_exception_jmpbuf(&(jmpbuf)), 0))
 
 static inline void *get_idt_addr(idt_entry_t *entry)
 {
diff --git a/x86/vmx.c b/x86/vmx.c
index f0b853a..4469b31 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -38,6 +38,7 @@
 #include "msr.h"
 #include "smp.h"
 #include "apic.h"
+#include "setjmp.h"
 
 u64 *bsp_vmxon_region;
 struct vmcs *vmcs_root;
-- 
2.33.0.rc1.237.g0d66db33f3-goog




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux