Message ID | 1361556605-21963-3-git-send-email-peter.maydell@linaro.org |
---|---|
State | Accepted |
Commit | fadf982584b040527aeee0ede270a4d01463d293 |
Headers | show |
Am 22.02.2013 19:10, schrieb Peter Maydell: > From: Andreas Färber <afaerber@suse.de> > > Introduce ENV_OFFSET macros which can be used in non-target-specific > code that needs to generate TCG instructions which reference CPUState > fields given the cpu_env register that TCG targets set up with a > pointer to the CPUArchState struct. > > Signed-off-by: Andreas Färber <afaerber@suse.de> > Signed-off-by: Peter Maydell <peter.maydell@linaro.org> > --- > target-alpha/cpu-qom.h | 1 + > target-arm/cpu-qom.h | 2 ++ > target-cris/cpu-qom.h | 1 + > target-i386/cpu-qom.h | 1 + > target-lm32/cpu-qom.h | 1 + > target-m68k/cpu-qom.h | 1 + > target-microblaze/cpu-qom.h | 1 + > target-mips/cpu-qom.h | 1 + > target-openrisc/cpu.h | 2 ++ > target-ppc/cpu-qom.h | 3 ++- > target-s390x/cpu-qom.h | 1 + > target-sh4/cpu-qom.h | 1 + > target-sparc/cpu-qom.h | 1 + > target-unicore32/cpu-qom.h | 1 + > target-xtensa/cpu-qom.h | 1 + > 15 files changed, 18 insertions(+), 1 deletion(-) > > diff --git a/target-alpha/cpu-qom.h b/target-alpha/cpu-qom.h > index c0f6c6d..252bd14 100644 > --- a/target-alpha/cpu-qom.h > +++ b/target-alpha/cpu-qom.h > @@ -72,5 +72,6 @@ static inline AlphaCPU *alpha_env_get_cpu(CPUAlphaState *env) > > #define ENV_GET_CPU(e) CPU(alpha_env_get_cpu(e)) > > +#define ENV_OFFSET offsetof(AlphaCPU, env) > > #endif [snip] Compared to my rebased copy of this patch on qom-cpu-10 yours is dropping a white line per target. I've intentionally used two lines spacing for grouping and a line between definitions. Matter of taste. Andreas
On 22 February 2013 18:20, Andreas Färber <afaerber@suse.de> wrote: > Am 22.02.2013 19:10, schrieb Peter Maydell: >> From: Andreas Färber <afaerber@suse.de> >> index c0f6c6d..252bd14 100644 >> --- a/target-alpha/cpu-qom.h >> +++ b/target-alpha/cpu-qom.h >> @@ -72,5 +72,6 @@ static inline AlphaCPU *alpha_env_get_cpu(CPUAlphaState *env) >> >> #define ENV_GET_CPU(e) CPU(alpha_env_get_cpu(e)) >> >> +#define ENV_OFFSET offsetof(AlphaCPU, env) >> >> #endif > [snip] > > Compared to my rebased copy of this patch on qom-cpu-10 yours is > dropping a white line per target. I've intentionally used two lines > spacing for grouping and a line between definitions. Matter of taste. Yeah, I deliberately dropped a bunch of what I felt were extraneous blank lines :-) -- PMM
Am 22.02.2013 19:22, schrieb Peter Maydell: > On 22 February 2013 18:20, Andreas Färber <afaerber@suse.de> wrote: >> Am 22.02.2013 19:10, schrieb Peter Maydell: >>> From: Andreas Färber <afaerber@suse.de> >>> index c0f6c6d..252bd14 100644 >>> --- a/target-alpha/cpu-qom.h >>> +++ b/target-alpha/cpu-qom.h >>> @@ -72,5 +72,6 @@ static inline AlphaCPU *alpha_env_get_cpu(CPUAlphaState *env) >>> >>> #define ENV_GET_CPU(e) CPU(alpha_env_get_cpu(e)) >>> >>> +#define ENV_OFFSET offsetof(AlphaCPU, env) >>> >>> #endif >> [snip] >> >> Compared to my rebased copy of this patch on qom-cpu-10 yours is >> dropping a white line per target. I've intentionally used two lines >> spacing for grouping and a line between definitions. Matter of taste. > > Yeah, I deliberately dropped a bunch of what I felt were > extraneous blank lines :-) I've applied it to qom-cpu since it conflicts with my additions of vmstate_..._cpu fields and ..._do_interrupt() functions. https://github.com/afaerber/qemu-cpu/commits/qom-cpu But I will remind you of you messing with my coding style next time you ask me to redo any ifs to your liking. May Markus be my witness. Either we respect each other's style in cross-target refactorings or we don't. Andreas
On 24 February 2013 11:27, Andreas Färber <afaerber@suse.de> wrote: > Am 22.02.2013 19:22, schrieb Peter Maydell: >> Yeah, I deliberately dropped a bunch of what I felt were >> extraneous blank lines :-) > > I've applied it to qom-cpu since it conflicts with my additions of > vmstate_..._cpu fields and ..._do_interrupt() functions. > > https://github.com/afaerber/qemu-cpu/commits/qom-cpu > > But I will remind you of you messing with my coding style next time you > ask me to redo any ifs to your liking. May Markus be my witness. Either > we respect each other's style in cross-target refactorings or we don't. In this case I actually kind of 50% thought they were the result of conflicts/merge process rather than intentional, which is why I cleaned them up. I don't actually care one way or the other, so you can reinstate them if you prefer. -- PMM
Am 24.02.2013 12:31, schrieb Peter Maydell: > On 24 February 2013 11:27, Andreas Färber <afaerber@suse.de> wrote: >> Am 22.02.2013 19:22, schrieb Peter Maydell: >>> Yeah, I deliberately dropped a bunch of what I felt were >>> extraneous blank lines :-) >> >> I've applied it to qom-cpu since it conflicts with my additions of >> vmstate_..._cpu fields and ..._do_interrupt() functions. >> >> https://github.com/afaerber/qemu-cpu/commits/qom-cpu >> >> But I will remind you of you messing with my coding style next time you >> ask me to redo any ifs to your liking. May Markus be my witness. Either >> we respect each other's style in cross-target refactorings or we don't. > > In this case I actually kind of 50% thought they were the > result of conflicts/merge process rather than intentional, > which is why I cleaned them up. I don't actually care one > way or the other, so you can reinstate them if you prefer. My reasoning was to differenciate between the header guard and any in-file #ifdef CONFIG_USER_ONLY or TARGET_FOO, which for functions I usually separate by one line. I don't really care too much though, it's just the principle that angers me that you made me go through hoops, propagating adopt-the-author's-style when it comes to target-arm files, while now violating your own paradigm and apparently even finding that funny. Andreas
On 24 February 2013 11:42, Andreas Färber <afaerber@suse.de> wrote: > Am 24.02.2013 12:31, schrieb Peter Maydell: >> In this case I actually kind of 50% thought they were the >> result of conflicts/merge process rather than intentional, >> which is why I cleaned them up. I don't actually care one >> way or the other, so you can reinstate them if you prefer. > > My reasoning was to differenciate between the header guard and any > in-file #ifdef CONFIG_USER_ONLY or TARGET_FOO, which for functions I > usually separate by one line. > > I don't really care too much though, it's just the principle that angers > me that you made me go through hoops, propagating > adopt-the-author's-style when it comes to target-arm files, while now > violating your own paradigm and apparently even finding that funny. I'm sorry; that smiley was perhaps misplaced. I dropped the blank lines because I didn't understand their purpose and part of my process before sending patches out is "read patch and fix anything I would comment on if it were code review of somebody else's patch". You've explained the rationale for them, so I will reinstate them. V2 coming up later today or tomorrow. -- PMM
Am 24.02.2013 15:07, schrieb Peter Maydell: > On 24 February 2013 11:42, Andreas Färber <afaerber@suse.de> wrote: >> Am 24.02.2013 12:31, schrieb Peter Maydell: >>> In this case I actually kind of 50% thought they were the >>> result of conflicts/merge process rather than intentional, >>> which is why I cleaned them up. I don't actually care one >>> way or the other, so you can reinstate them if you prefer. >> >> My reasoning was to differenciate between the header guard and any >> in-file #ifdef CONFIG_USER_ONLY or TARGET_FOO, which for functions I >> usually separate by one line. >> >> I don't really care too much though, it's just the principle that angers >> me that you made me go through hoops, propagating >> adopt-the-author's-style when it comes to target-arm files, while now >> violating your own paradigm and apparently even finding that funny. > > I'm sorry; that smiley was perhaps misplaced. I dropped the > blank lines because I didn't understand their purpose and > part of my process before sending patches out is "read patch > and fix anything I would comment on if it were code review > of somebody else's patch". You've explained the rationale for > them, so I will reinstate them. V2 coming up later today or > tomorrow. Please don't. It's on qom-cpu as is, and I've had to rebase four follow-up branches that all add something to the bottom of those files, so having to go through that again is no improvement. Rather try to be more relaxed when I add something to my cpu.c or cpu-qom.h files next time, the audio code is already big enough an exception-from-the-rule for cross-target changes. ;) Andreas
diff --git a/target-alpha/cpu-qom.h b/target-alpha/cpu-qom.h index c0f6c6d..252bd14 100644 --- a/target-alpha/cpu-qom.h +++ b/target-alpha/cpu-qom.h @@ -72,5 +72,6 @@ static inline AlphaCPU *alpha_env_get_cpu(CPUAlphaState *env) #define ENV_GET_CPU(e) CPU(alpha_env_get_cpu(e)) +#define ENV_OFFSET offsetof(AlphaCPU, env) #endif diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h index aff7bf3..7539727 100644 --- a/target-arm/cpu-qom.h +++ b/target-arm/cpu-qom.h @@ -109,6 +109,8 @@ static inline ARMCPU *arm_env_get_cpu(CPUARMState *env) #define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e)) +#define ENV_OFFSET offsetof(ARMCPU, env) + void register_cp_regs_for_features(ARMCPU *cpu); #endif diff --git a/target-cris/cpu-qom.h b/target-cris/cpu-qom.h index 2bac71f..11e5286 100644 --- a/target-cris/cpu-qom.h +++ b/target-cris/cpu-qom.h @@ -71,5 +71,6 @@ static inline CRISCPU *cris_env_get_cpu(CPUCRISState *env) #define ENV_GET_CPU(e) CPU(cris_env_get_cpu(e)) +#define ENV_OFFSET offsetof(CRISCPU, env) #endif diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h index 48e6b54..b7bdcb6 100644 --- a/target-i386/cpu-qom.h +++ b/target-i386/cpu-qom.h @@ -74,5 +74,6 @@ static inline X86CPU *x86_env_get_cpu(CPUX86State *env) #define ENV_GET_CPU(e) CPU(x86_env_get_cpu(e)) +#define ENV_OFFSET offsetof(X86CPU, env) #endif diff --git a/target-lm32/cpu-qom.h b/target-lm32/cpu-qom.h index d7525b3..c0b6ce5 100644 --- a/target-lm32/cpu-qom.h +++ b/target-lm32/cpu-qom.h @@ -69,5 +69,6 @@ static inline LM32CPU *lm32_env_get_cpu(CPULM32State *env) #define ENV_GET_CPU(e) CPU(lm32_env_get_cpu(e)) +#define ENV_OFFSET offsetof(LM32CPU, env) #endif diff --git a/target-m68k/cpu-qom.h b/target-m68k/cpu-qom.h index 20e5684..f4c33b2 100644 --- a/target-m68k/cpu-qom.h +++ b/target-m68k/cpu-qom.h @@ -68,5 +68,6 @@ static inline M68kCPU *m68k_env_get_cpu(CPUM68KState *env) #define ENV_GET_CPU(e) CPU(m68k_env_get_cpu(e)) +#define ENV_OFFSET offsetof(M68kCPU, env) #endif diff --git a/target-microblaze/cpu-qom.h b/target-microblaze/cpu-qom.h index 5ea911c..a0248a5 100644 --- a/target-microblaze/cpu-qom.h +++ b/target-microblaze/cpu-qom.h @@ -68,5 +68,6 @@ static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env) #define ENV_GET_CPU(e) CPU(mb_env_get_cpu(e)) +#define ENV_OFFSET offsetof(MicroBlazeCPU, env) #endif diff --git a/target-mips/cpu-qom.h b/target-mips/cpu-qom.h index 55aa692..c6bcddf 100644 --- a/target-mips/cpu-qom.h +++ b/target-mips/cpu-qom.h @@ -72,5 +72,6 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env) #define ENV_GET_CPU(e) CPU(mips_env_get_cpu(e)) +#define ENV_OFFSET offsetof(MIPSCPU, env) #endif diff --git a/target-openrisc/cpu.h b/target-openrisc/cpu.h index 419f007..4cfd1c7 100644 --- a/target-openrisc/cpu.h +++ b/target-openrisc/cpu.h @@ -340,6 +340,8 @@ static inline OpenRISCCPU *openrisc_env_get_cpu(CPUOpenRISCState *env) #define ENV_GET_CPU(e) CPU(openrisc_env_get_cpu(e)) +#define ENV_OFFSET offsetof(OpenRISCCPU, env) + OpenRISCCPU *cpu_openrisc_init(const char *cpu_model); void cpu_openrisc_list(FILE *f, fprintf_function cpu_fprintf); diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h index 2b82cdb..4e8ceca 100644 --- a/target-ppc/cpu-qom.h +++ b/target-ppc/cpu-qom.h @@ -78,7 +78,8 @@ static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env) #define ENV_GET_CPU(e) CPU(ppc_env_get_cpu(e)) -PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr); +#define ENV_OFFSET offsetof(PowerPCCPU, env) +PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr); #endif diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h index 237184f..f6e5145 100644 --- a/target-s390x/cpu-qom.h +++ b/target-s390x/cpu-qom.h @@ -69,5 +69,6 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env) #define ENV_GET_CPU(e) CPU(s390_env_get_cpu(e)) +#define ENV_OFFSET offsetof(S390CPU, env) #endif diff --git a/target-sh4/cpu-qom.h b/target-sh4/cpu-qom.h index d368db1..f4e8976 100644 --- a/target-sh4/cpu-qom.h +++ b/target-sh4/cpu-qom.h @@ -68,5 +68,6 @@ static inline SuperHCPU *sh_env_get_cpu(CPUSH4State *env) #define ENV_GET_CPU(e) CPU(sh_env_get_cpu(e)) +#define ENV_OFFSET offsetof(SuperHCPU, env) #endif diff --git a/target-sparc/cpu-qom.h b/target-sparc/cpu-qom.h index 89cd1cf..efeeca0 100644 --- a/target-sparc/cpu-qom.h +++ b/target-sparc/cpu-qom.h @@ -73,5 +73,6 @@ static inline SPARCCPU *sparc_env_get_cpu(CPUSPARCState *env) #define ENV_GET_CPU(e) CPU(sparc_env_get_cpu(e)) +#define ENV_OFFSET offsetof(SPARCCPU, env) #endif diff --git a/target-unicore32/cpu-qom.h b/target-unicore32/cpu-qom.h index 625c614..c6590bd 100644 --- a/target-unicore32/cpu-qom.h +++ b/target-unicore32/cpu-qom.h @@ -58,5 +58,6 @@ static inline UniCore32CPU *uc32_env_get_cpu(CPUUniCore32State *env) #define ENV_GET_CPU(e) CPU(uc32_env_get_cpu(e)) +#define ENV_OFFSET offsetof(UniCore32CPU, env) #endif diff --git a/target-xtensa/cpu-qom.h b/target-xtensa/cpu-qom.h index 270de16..c78136b 100644 --- a/target-xtensa/cpu-qom.h +++ b/target-xtensa/cpu-qom.h @@ -78,5 +78,6 @@ static inline XtensaCPU *xtensa_env_get_cpu(const CPUXtensaState *env) #define ENV_GET_CPU(e) CPU(xtensa_env_get_cpu(e)) +#define ENV_OFFSET offsetof(XtensaCPU, env) #endif