[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 29/34] arm: cpu: Multi-define guard deep CPU spe
From: |
Peter Crosthwaite |
Subject: |
[Qemu-devel] [RFC PATCH 29/34] arm: cpu: Multi-define guard deep CPU specifics |
Date: |
Sun, 10 May 2015 23:29:32 -0700 |
If MMU_USER_IDX or ENV_OFFSET is already defined, undefine it.
The undef will cause a compile error on the ambiguous case where
multiple cpu.h's are included yet either of these defs
is needed. This shouldn't happen, as the multi-include should only
happen in device-land system level code that need CPU defs from
multiple arches - e.g. a machine model with two different arch CPUs.
Such device code has no bussiness using MMU_USER_IDX or ENV_OFFSET.
ENV_GET_CPU s also multi-guarded to perform no action on second define.
This is for multi-arch where target-multi provides a working
implementation already
Signed-off-by: Peter Crosthwaite <address@hidden>
---
target-arm/cpu-qom.h | 7 +++++++
target-arm/cpu.h | 5 +++++
2 files changed, 12 insertions(+)
diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h
index ed5a644..ad742ed 100644
--- a/target-arm/cpu-qom.h
+++ b/target-arm/cpu-qom.h
@@ -188,9 +188,16 @@ static inline ARMCPU *arm_env_get_cpu(CPUARMState *env)
return container_of(env, ARMCPU, env);
}
+#ifndef ENV_GET_CPU
#define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e))
+#endif
+#ifndef ENV_OFFSET
#define ENV_OFFSET offsetof(ARMCPU, env)
+#else
+/* Try and cause a compile bug on any (invalid) users of the multiple def */
+#undef ENV_OFFSET
+#endif
#ifndef CONFIG_USER_ONLY
extern const struct VMStateDescription vmstate_arm_cpu;
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index e0363a2..53a8051 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -1627,7 +1627,12 @@ typedef enum ARMMMUIdx {
ARMMMUIdx_S1NSE1 = 8,
} ARMMMUIdx;
+#ifdef MMU_USER_IDX
+/* Try and cause a compile bug on any (invalid) users of the multiple def */
+#undef MMU_USER_IDX
+#else
#define MMU_USER_IDX 0
+#endif
/* Return the exception level we're running at if this is our mmu_idx */
static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
--
1.9.1
- [Qemu-devel] [RFC PATCH 00/34] Multi Architecture System Emulation, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 33/34] HACK: mb: boot: Assume using -firmware for mb software, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 34/34] HACK: mb: boot: Disable dtb load in multi-arch, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 32/34] arm: xilinx_zynq: Add a microblaze, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 31/34] arm: boot: Don't assume all CPUs are ARM, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 29/34] arm: cpu: Multi-define guard deep CPU specifics,
Peter Crosthwaite <=
- [Qemu-devel] [RFC PATCH 30/34] arm: Enable multi-arch, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 28/34] arm: cpu: Guard cpu_init definition for user mode, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 27/34] hw: arm: Explicitly include cpu.h for consumers, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 25/34] arm: cpu: Move CPU_COMMON to front of env, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 26/34] arm: Use qomified tcg defintions, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 22/34] arm: Remove ELF_MACHINE from cpu.h, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 24/34] arm: delete dummy prototypes, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 23/34] arm: cpu.h: Move cpu-all include, Peter Crosthwaite, 2015/05/11