diff mbox series

[RFC,03/15] accel/hax: Simplify #ifdef'ry

Message ID 20210517115525.1088693-4-f4bug@amsat.org (mailing list archive)
State New, archived
Headers show
Series softmmu: Make various objects target agnostic | expand

Commit Message

Philippe Mathieu-Daudé May 17, 2021, 11:55 a.m. UTC
hax_enabled() is called from:

- qemu_init_board() in softmmu/vl.c
- qemu_wait_io_event() in softmmu/cpus.c
- apic_common_realize() in hw/intc/apic_common.c

By converting macros to a function, we can remove the
NEED_CPU_H dependency and build softmmu/cpus.c once
for all targets.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/sysemu/hax.h      | 14 +-------------
 accel/stubs/hax-stub.c    |  5 +++++
 target/i386/hax/hax-all.c |  2 +-
 3 files changed, 7 insertions(+), 14 deletions(-)

Comments

Richard Henderson May 26, 2021, 6:49 p.m. UTC | #1
On 5/17/21 4:55 AM, Philippe Mathieu-Daudé wrote:
> -#ifdef NEED_CPU_H
> -
> -#ifdef CONFIG_HAX
> -
> -int hax_enabled(void);
> -
> -#else /* CONFIG_HAX */
> -
> -#define hax_enabled() (0)
> -
> -#endif /* CONFIG_HAX */
> -
> -#endif /* NEED_CPU_H */
> +bool hax_enabled(void);

Similarly with CONFIG_HAX_IS_POSSIBLE.


r~
diff mbox series

Patch

diff --git a/include/sysemu/hax.h b/include/sysemu/hax.h
index 247f0661d12..bc165b23ae6 100644
--- a/include/sysemu/hax.h
+++ b/include/sysemu/hax.h
@@ -24,18 +24,6 @@ 
 
 int hax_sync_vcpus(void);
 
-#ifdef NEED_CPU_H
-
-#ifdef CONFIG_HAX
-
-int hax_enabled(void);
-
-#else /* CONFIG_HAX */
-
-#define hax_enabled() (0)
-
-#endif /* CONFIG_HAX */
-
-#endif /* NEED_CPU_H */
+bool hax_enabled(void);
 
 #endif /* QEMU_HAX_H */
diff --git a/accel/stubs/hax-stub.c b/accel/stubs/hax-stub.c
index 49077f88e3c..1a0370a4362 100644
--- a/accel/stubs/hax-stub.c
+++ b/accel/stubs/hax-stub.c
@@ -16,6 +16,11 @@ 
 #include "qemu/osdep.h"
 #include "sysemu/hax.h"
 
+bool hax_enabled(void)
+{
+    return false;
+}
+
 int hax_sync_vcpus(void)
 {
     return 0;
diff --git a/target/i386/hax/hax-all.c b/target/i386/hax/hax-all.c
index bf65ed6fa92..d99feef21d4 100644
--- a/target/i386/hax/hax-all.c
+++ b/target/i386/hax/hax-all.c
@@ -56,7 +56,7 @@  struct hax_state hax_global;
 static void hax_vcpu_sync_state(CPUArchState *env, int modified);
 static int hax_arch_get_registers(CPUArchState *env);
 
-int hax_enabled(void)
+bool hax_enabled(void)
 {
     return hax_allowed;
 }