From ac176ccb387881490c17de39e18ee49b3bee3172 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 12 Jun 2019 12:14:38 -0400 Subject: [PATCH] cpu: Move ENV_OFFSET to exec/gen-icount.h Now that we have ArchCPU, we can define this generically, in the one place that needs it. Backports commit 677c4d69ac21961e76a386f9bfc892a44923acc0 from qemu --- qemu/include/exec/gen-icount.h | 2 ++ qemu/target/arm/cpu.h | 2 -- qemu/target/i386/cpu.h | 2 -- qemu/target/m68k/cpu.h | 2 -- qemu/target/mips/cpu.h | 2 -- qemu/target/riscv/cpu.h | 2 -- qemu/target/sparc/cpu.h | 2 -- qemu/tcg/tcg-op.c | 3 +++ 8 files changed, 5 insertions(+), 12 deletions(-) diff --git a/qemu/include/exec/gen-icount.h b/qemu/include/exec/gen-icount.h index d8d49b49..c28b5bfd 100644 --- a/qemu/include/exec/gen-icount.h +++ b/qemu/include/exec/gen-icount.h @@ -5,6 +5,8 @@ /* Helpers for instruction counting code generation. */ +#define ENV_OFFSET offsetof(ArchCPU, env) + //static TCGOp *icount_start_insn; static inline void gen_tb_start(TCGContext *tcg_ctx, TranslationBlock *tb) diff --git a/qemu/target/arm/cpu.h b/qemu/target/arm/cpu.h index 79d80bc7..6ba79bb9 100644 --- a/qemu/target/arm/cpu.h +++ b/qemu/target/arm/cpu.h @@ -887,8 +887,6 @@ struct ARMCPU { uint32_t sve_max_vq; }; -#define ENV_OFFSET offsetof(ARMCPU, env) - #ifndef CONFIG_USER_ONLY extern const struct VMStateDescription vmstate_arm_cpu; #endif diff --git a/qemu/target/i386/cpu.h b/qemu/target/i386/cpu.h index c964b01e..4bea4bd3 100644 --- a/qemu/target/i386/cpu.h +++ b/qemu/target/i386/cpu.h @@ -1398,8 +1398,6 @@ struct X86CPU { bool cpu_globals_initialized; }; -#define ENV_OFFSET offsetof(X86CPU, env) - #ifndef CONFIG_USER_ONLY extern struct VMStateDescription vmstate_x86_cpu; #endif diff --git a/qemu/target/m68k/cpu.h b/qemu/target/m68k/cpu.h index f230930e..f43edb4a 100644 --- a/qemu/target/m68k/cpu.h +++ b/qemu/target/m68k/cpu.h @@ -167,8 +167,6 @@ struct M68kCPU { CPUM68KState env; }; -#define ENV_OFFSET offsetof(M68kCPU, env) - void m68k_cpu_do_interrupt(CPUState *cpu); bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req); void m68k_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, diff --git a/qemu/target/mips/cpu.h b/qemu/target/mips/cpu.h index 4ebc07c3..aa0b5e81 100644 --- a/qemu/target/mips/cpu.h +++ b/qemu/target/mips/cpu.h @@ -1069,8 +1069,6 @@ struct MIPSCPU { CPUMIPSState env; }; -#define ENV_OFFSET offsetof(MIPSCPU, env) - void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf); #define cpu_signal_handler cpu_mips_signal_handler diff --git a/qemu/target/riscv/cpu.h b/qemu/target/riscv/cpu.h index 95a60754..2520ab25 100644 --- a/qemu/target/riscv/cpu.h +++ b/qemu/target/riscv/cpu.h @@ -236,8 +236,6 @@ extern const char * const riscv_fpr_regnames[]; extern const char * const riscv_excp_names[]; extern const char * const riscv_intr_names[]; -#define ENV_OFFSET offsetof(RISCVCPU, env) - void riscv_cpu_do_interrupt(CPUState *cpu); int riscv_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int riscv_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/qemu/target/sparc/cpu.h b/qemu/target/sparc/cpu.h index 967f2f13..6f0b38a8 100644 --- a/qemu/target/sparc/cpu.h +++ b/qemu/target/sparc/cpu.h @@ -528,8 +528,6 @@ struct SPARCCPU { CPUSPARCState env; }; -#define ENV_OFFSET offsetof(SPARCCPU, env) - void sparc_cpu_do_interrupt(CPUState *cpu); void sparc_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags); diff --git a/qemu/tcg/tcg-op.c b/qemu/tcg/tcg-op.c index 2b5c68a9..57d2501d 100644 --- a/qemu/tcg/tcg-op.c +++ b/qemu/tcg/tcg-op.c @@ -30,6 +30,9 @@ #include "tcg-op.h" #include "tcg-mo.h" +/* Unicorn: Necessary for check_exit_request */ +#include "exec/gen-icount.h" + /* Reduce the number of ifdefs below. This assumes that all uses of TCGV_HIGH and TCGV_LOW are properly protected by a conditional that the compiler can eliminate. */