qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH 17/34] mb: cpu: Multi-define guard deep CPU spec


From: Peter Crosthwaite
Subject: [Qemu-devel] [RFC PATCH 17/34] mb: cpu: Multi-define guard deep CPU specifics
Date: Sun, 10 May 2015 23:29:20 -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-microblaze/cpu-qom.h | 7 +++++++
 target-microblaze/cpu.h     | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/target-microblaze/cpu-qom.h b/target-microblaze/cpu-qom.h
index e3e0701..f3960ac 100644
--- a/target-microblaze/cpu-qom.h
+++ b/target-microblaze/cpu-qom.h
@@ -67,9 +67,16 @@ static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env)
     return container_of(env, MicroBlazeCPU, env);
 }
 
+#ifndef ENV_GET_CPU
 #define ENV_GET_CPU(e) CPU(mb_env_get_cpu(e))
+#endif
 
+#ifndef ENV_OFFSET
 #define ENV_OFFSET offsetof(MicroBlazeCPU, env)
+#else
+/* Try and cause a compile bug on any (invalid) users of the multiple def */
+#undef ENV_OFFSET
+#endif
 
 void mb_cpu_do_interrupt(CPUState *cs);
 bool mb_cpu_exec_interrupt(CPUState *cs, int int_req);
diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h
index da42483..5f15ca9 100644
--- a/target-microblaze/cpu.h
+++ b/target-microblaze/cpu.h
@@ -288,7 +288,13 @@ MicroBlazeCPU *cpu_mb_init(const char *cpu_model);
 /* MMU modes definitions */
 #define MMU_NOMMU_IDX   0
 #define MMU_KERNEL_IDX  1
+
+#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    2
+#endif
 /* See NB_MMU_MODES further up the file.  */
 
 int mb_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]