Message ID | 20250318045125.759259-5-pierrick.bouvier@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | single-binary: start make hw/arm/ common (boot.c) | expand |
On 3/17/25 21:51, Pierrick Bouvier wrote: > Including "cpu.h" from code that is not compiled per target is ambiguous > by definition. Thus we introduce a conditional include, to allow every > architecture to set this, to point to the correct definition. > > hw/X or target/X will now include directly "target/X/cpu.h", and > "target/X/cpu.h" will define CPU_INCLUDE to itself. > We already do this change for arm cpu as part of this commit. > > Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> > --- > include/exec/cpu-all.h | 4 ++++ > target/arm/cpu.h | 2 ++ > 2 files changed, 6 insertions(+) > > diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h > index 7c6c47c43ed..1a756c0cfb3 100644 > --- a/include/exec/cpu-all.h > +++ b/include/exec/cpu-all.h > @@ -46,7 +46,11 @@ > > CPUArchState *cpu_copy(CPUArchState *env); > > +#ifdef CPU_INCLUDE > +#include CPU_INCLUDE > +#else > #include "cpu.h" > +#endif > > #ifdef CONFIG_USER_ONLY > > diff --git a/target/arm/cpu.h b/target/arm/cpu.h > index a8177c6c2e8..7aeb012428c 100644 > --- a/target/arm/cpu.h > +++ b/target/arm/cpu.h > @@ -31,6 +31,8 @@ > #include "target/arm/multiprocessing.h" > #include "target/arm/gtimer.h" > > +#define CPU_INCLUDE "target/arm/cpu.h" > + > #ifdef TARGET_AARCH64 > #define KVM_HAVE_MCE_INJECTION 1 > #endif This doesn't make any sense to me. CPU_INCLUDE is defined within the very file that you're trying to include by avoiding "cpu.h". r~
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 7c6c47c43ed..1a756c0cfb3 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -46,7 +46,11 @@ CPUArchState *cpu_copy(CPUArchState *env); +#ifdef CPU_INCLUDE +#include CPU_INCLUDE +#else #include "cpu.h" +#endif #ifdef CONFIG_USER_ONLY diff --git a/target/arm/cpu.h b/target/arm/cpu.h index a8177c6c2e8..7aeb012428c 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -31,6 +31,8 @@ #include "target/arm/multiprocessing.h" #include "target/arm/gtimer.h" +#define CPU_INCLUDE "target/arm/cpu.h" + #ifdef TARGET_AARCH64 #define KVM_HAVE_MCE_INJECTION 1 #endif
Including "cpu.h" from code that is not compiled per target is ambiguous by definition. Thus we introduce a conditional include, to allow every architecture to set this, to point to the correct definition. hw/X or target/X will now include directly "target/X/cpu.h", and "target/X/cpu.h" will define CPU_INCLUDE to itself. We already do this change for arm cpu as part of this commit. Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> --- include/exec/cpu-all.h | 4 ++++ target/arm/cpu.h | 2 ++ 2 files changed, 6 insertions(+)