summaryrefslogtreecommitdiff
path: root/target-arm
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2012-05-10 12:56:09 +0000
committerPeter Maydell <peter.maydell@linaro.org>2012-05-10 12:56:09 +0000
commitad37ad5b25592d2829989111b8386b8007ea0d83 (patch)
tree44dcb9c5689e3d21a49b8a5125df0f5d13ebccec /target-arm
parent7e598de023e4f3f612be7f16acea2ec5dac010ec (diff)
downloadqemu-ad37ad5b25592d2829989111b8386b8007ea0d83.tar.gz
target-arm/cpu.h: Make cpu_init("nonexistent cpu") return NULL
The macro definition of cpu_init meant that if cpu_arm_init() returned NULL this wouldn't result in cpu_init() itself returning NULL. This had the effect that "-cpu foo" for some unknown CPU name 'foo' would cause ARM targets to segfault rather than generating a useful error message. Fix this by making cpu_init a simple inline function. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Acked-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'target-arm')
-rw-r--r--target-arm/cpu.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 5eac070379..d01285fd57 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -458,7 +458,15 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,
#define TARGET_PHYS_ADDR_SPACE_BITS 32
#define TARGET_VIRT_ADDR_SPACE_BITS 32
-#define cpu_init(model) (&cpu_arm_init(model)->env)
+static inline CPUARMState *cpu_init(const char *cpu_model)
+{
+ ARMCPU *cpu = cpu_arm_init(cpu_model);
+ if (cpu) {
+ return &cpu->env;
+ }
+ return NULL;
+}
+
#define cpu_exec cpu_arm_exec
#define cpu_gen_code cpu_arm_gen_code
#define cpu_signal_handler cpu_arm_signal_handler