From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl3NJ-0005H8-Au for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tl3NG-0000bg-2M for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl3NF-0000an-Ql for qemu-devel@nongnu.org; Tue, 18 Dec 2012 15:02:45 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBIK2jvp010579 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Dec 2012 15:02:45 -0500 Received: from blackpad.lan.raisama.net (vpn1-6-125.gru2.redhat.com [10.97.6.125]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBIK2iHe023995 for ; Tue, 18 Dec 2012 15:02:44 -0500 From: Eduardo Habkost Date: Tue, 18 Dec 2012 18:03:55 -0200 Message-Id: <1355861053-11460-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1355861053-11460-1-git-send-email-ehabkost@redhat.com> References: <1355861053-11460-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [RFC 02/20] cpu: introduce CPU_GET_ENV macros List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This will help us gradually convert code based on CPUArchState to QOM-based code. The macro checks for NULL cpu value, so a NULL cpu safely becomes a NULL env pointer. Signed-off-by: Eduardo Habkost --- target-alpha/cpu-qom.h | 7 +++++++ target-arm/cpu-qom.h | 7 +++++++ target-cris/cpu-qom.h | 7 +++++++ target-i386/cpu-qom.h | 7 +++++++ target-lm32/cpu-qom.h | 7 +++++++ target-m68k/cpu-qom.h | 7 +++++++ target-microblaze/cpu-qom.h | 7 +++++++ target-mips/cpu-qom.h | 7 +++++++ target-openrisc/cpu.h | 7 +++++++ target-ppc/cpu-qom.h | 7 +++++++ target-s390x/cpu-qom.h | 7 +++++++ target-sh4/cpu-qom.h | 7 +++++++ target-sparc/cpu-qom.h | 7 +++++++ target-unicore32/cpu-qom.h | 7 +++++++ target-xtensa/cpu-qom.h | 7 +++++++ 15 files changed, 105 insertions(+) diff --git a/target-alpha/cpu-qom.h b/target-alpha/cpu-qom.h index 6b4ca6d..3c816a2 100644 --- a/target-alpha/cpu-qom.h +++ b/target-alpha/cpu-qom.h @@ -67,5 +67,12 @@ static inline AlphaCPU *alpha_env_get_cpu(CPUAlphaState *env) #define ENV_GET_CPU(e) CPU(alpha_env_get_cpu(e)) +static inline CPUAlphaState *alpha_cpu_get_env(AlphaCPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) alpha_cpu_get_env(ALPHA_CPU(cpu)) + #endif diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h index beabf9a..d7801f3 100644 --- a/target-arm/cpu-qom.h +++ b/target-arm/cpu-qom.h @@ -107,6 +107,13 @@ static inline ARMCPU *arm_env_get_cpu(CPUARMState *env) #define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e)) +static inline CPUARMState *arm_cpu_get_env(ARMCPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) arm_cpu_get_env(ARM_CPU(cpu)) + void arm_cpu_realize(ARMCPU *cpu); void register_cp_regs_for_features(ARMCPU *cpu); diff --git a/target-cris/cpu-qom.h b/target-cris/cpu-qom.h index d0e5f04..042dca4 100644 --- a/target-cris/cpu-qom.h +++ b/target-cris/cpu-qom.h @@ -66,5 +66,12 @@ static inline CRISCPU *cris_env_get_cpu(CPUCRISState *env) #define ENV_GET_CPU(e) CPU(cris_env_get_cpu(e)) +static inline CPUCRISState *cris_cpu_get_env(CRISCPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) cris_cpu_get_env(CRIS_CPU(cpu)) + #endif diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h index 5901140..19afe28 100644 --- a/target-i386/cpu-qom.h +++ b/target-i386/cpu-qom.h @@ -72,6 +72,13 @@ static inline X86CPU *x86_env_get_cpu(CPUX86State *env) #define ENV_GET_CPU(e) CPU(x86_env_get_cpu(e)) +static inline CPUX86State *x86_cpu_get_env(X86CPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) x86_cpu_get_env(X86_CPU(cpu)) + /* TODO Drop once ObjectClass::realize is available */ void x86_cpu_realize(Object *obj, Error **errp); diff --git a/target-lm32/cpu-qom.h b/target-lm32/cpu-qom.h index 4ae2edd..4b15192 100644 --- a/target-lm32/cpu-qom.h +++ b/target-lm32/cpu-qom.h @@ -67,5 +67,12 @@ static inline LM32CPU *lm32_env_get_cpu(CPULM32State *env) #define ENV_GET_CPU(e) CPU(lm32_env_get_cpu(e)) +static inline CPULM32State *lm32_cpu_get_env(LM32CPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) lm32_cpu_get_env(LM32_CPU(cpu)) + #endif diff --git a/target-m68k/cpu-qom.h b/target-m68k/cpu-qom.h index 805786b..fce1fe3 100644 --- a/target-m68k/cpu-qom.h +++ b/target-m68k/cpu-qom.h @@ -66,5 +66,12 @@ static inline M68kCPU *m68k_env_get_cpu(CPUM68KState *env) #define ENV_GET_CPU(e) CPU(m68k_env_get_cpu(e)) +static inline CPUM68KState *m68k_cpu_get_env(M68kCPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) m68k_cpu_get_env(M68K_CPU(cpu)) + #endif diff --git a/target-microblaze/cpu-qom.h b/target-microblaze/cpu-qom.h index 4b23303..38baa32 100644 --- a/target-microblaze/cpu-qom.h +++ b/target-microblaze/cpu-qom.h @@ -66,5 +66,12 @@ static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env) #define ENV_GET_CPU(e) CPU(mb_env_get_cpu(e)) +static inline CPUMBState *mb_cpu_get_env(MicroBlazeCPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) mb_cpu_get_env(MICROBLAZE_CPU(cpu)) + #endif diff --git a/target-mips/cpu-qom.h b/target-mips/cpu-qom.h index 6e22371..da8f187 100644 --- a/target-mips/cpu-qom.h +++ b/target-mips/cpu-qom.h @@ -70,5 +70,12 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env) #define ENV_GET_CPU(e) CPU(mips_env_get_cpu(e)) +static inline CPUMIPSState *mips_cpu_get_env(MIPSCPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) mips_cpu_get_env(MIPS_CPU(cpu)) + #endif diff --git a/target-openrisc/cpu.h b/target-openrisc/cpu.h index ebb5ad3..ca607b3 100644 --- a/target-openrisc/cpu.h +++ b/target-openrisc/cpu.h @@ -339,6 +339,13 @@ static inline OpenRISCCPU *openrisc_env_get_cpu(CPUOpenRISCState *env) #define ENV_GET_CPU(e) CPU(openrisc_env_get_cpu(e)) +static inline CPUOpenRISCState *openrisc_cpu_get_env(OpenRISCCPU *cpu) +{ + return &cpu->env;; +} + +#define CPU_GET_ENV(cpu) openrisc_cpu_get_env(OPENRISC_CPU(cpu)) + OpenRISCCPU *cpu_openrisc_init(const char *cpu_model); void openrisc_cpu_realize(Object *obj, Error **errp); diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h index fef6f95..d8a878e 100644 --- a/target-ppc/cpu-qom.h +++ b/target-ppc/cpu-qom.h @@ -73,5 +73,12 @@ static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env) #define ENV_GET_CPU(e) CPU(ppc_env_get_cpu(e)) +static inline CPUPPCState *ppc_cpu_get_env(PowerPCCPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) ppc_cpu_get_env(POWERPC_CPU(cpu)) + #endif diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h index 6fa55a8..7a51004 100644 --- a/target-s390x/cpu-qom.h +++ b/target-s390x/cpu-qom.h @@ -67,5 +67,12 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env) #define ENV_GET_CPU(e) CPU(s390_env_get_cpu(e)) +static inline CPUS390XState *s390_cpu_get_env(S390CPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) s390_cpu_get_env(S390_CPU(cpu)) + #endif diff --git a/target-sh4/cpu-qom.h b/target-sh4/cpu-qom.h index c41164a..b8cf70a 100644 --- a/target-sh4/cpu-qom.h +++ b/target-sh4/cpu-qom.h @@ -66,5 +66,12 @@ static inline SuperHCPU *sh_env_get_cpu(CPUSH4State *env) #define ENV_GET_CPU(e) CPU(sh_env_get_cpu(e)) +static inline CPUSH4State *sh_cpu_get_env(SuperHCPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) sh_cpu_get_env(SUPERH_CPU(cpu)) + #endif diff --git a/target-sparc/cpu-qom.h b/target-sparc/cpu-qom.h index 3d3ac0f..1ed4e11 100644 --- a/target-sparc/cpu-qom.h +++ b/target-sparc/cpu-qom.h @@ -71,5 +71,12 @@ static inline SPARCCPU *sparc_env_get_cpu(CPUSPARCState *env) #define ENV_GET_CPU(e) CPU(sparc_env_get_cpu(e)) +static inline CPUSPARCState *sparc_cpu_get_env(SPARCCPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) sparc_cpu_get_env(SPARC_CPU(cpu)) + #endif diff --git a/target-unicore32/cpu-qom.h b/target-unicore32/cpu-qom.h index 342d85e..0afe9b9 100644 --- a/target-unicore32/cpu-qom.h +++ b/target-unicore32/cpu-qom.h @@ -55,5 +55,12 @@ static inline UniCore32CPU *uc32_env_get_cpu(CPUUniCore32State *env) #define ENV_GET_CPU(e) CPU(uc32_env_get_cpu(e)) +static inline CPUUniCore32State *uc32_cpu_get_env(UniCore32CPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) uc32_cpu_get_env(UNICORE32_CPU(cpu)) + #endif diff --git a/target-xtensa/cpu-qom.h b/target-xtensa/cpu-qom.h index 1fd2f27..cfab791 100644 --- a/target-xtensa/cpu-qom.h +++ b/target-xtensa/cpu-qom.h @@ -76,5 +76,12 @@ static inline XtensaCPU *xtensa_env_get_cpu(const CPUXtensaState *env) #define ENV_GET_CPU(e) CPU(xtensa_env_get_cpu(e)) +static inline CPUXtensaState *xtensa_cpu_get_env(XtensaCPU *cpu) +{ + return cpu ? &cpu->env : NULL; +} + +#define CPU_GET_ENV(cpu) xtensa_cpu_get_env(XTENSA_CPU(cpu)) + #endif -- 1.7.11.7