Patchwork [next,v2,52/74] target-cris: Let cpu_cris_init() return CRISCPU

login
register
mail settings
Submitter Andreas Färber
Date May 10, 2012, 12:14 a.m.
Message ID <1336608892-30501-53-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/158124/
State New
Headers show

Comments

Andreas Färber - May 10, 2012, 12:14 a.m.
Turn cpu_init macro into a static inline function returning CPUCRISState
for backwards compatibility.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-cris/cpu.h       |   12 ++++++++++--
 target-cris/translate.c |    8 ++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

Patch

diff --git a/target-cris/cpu.h b/target-cris/cpu.h
index 5449cc4..a760367 100644
--- a/target-cris/cpu.h
+++ b/target-cris/cpu.h
@@ -171,7 +171,7 @@  typedef struct CPUCRISState {
 
 #include "cpu-qom.h"
 
-CPUCRISState *cpu_cris_init(const char *cpu_model);
+CRISCPU *cpu_cris_init(const char *cpu_model);
 int cpu_cris_exec(CPUCRISState *s);
 void cpu_cris_close(CPUCRISState *s);
 void do_interrupt(CPUCRISState *env);
@@ -216,7 +216,15 @@  enum {
 #define TARGET_PHYS_ADDR_SPACE_BITS 32
 #define TARGET_VIRT_ADDR_SPACE_BITS 32
 
-#define cpu_init cpu_cris_init
+static inline CPUCRISState *cpu_init(const char *cpu_model)
+{
+    CRISCPU *cpu = cpu_cris_init(cpu_model);
+    if (cpu == NULL) {
+        return NULL;
+    }
+    return &cpu->env;
+}
+
 #define cpu_exec cpu_cris_exec
 #define cpu_gen_code cpu_cris_gen_code
 #define cpu_signal_handler cpu_cris_signal_handler
diff --git a/target-cris/translate.c b/target-cris/translate.c
index a398057..eed03d3 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -3503,7 +3503,7 @@  static uint32_t vr_by_name(const char *name)
     return 32;
 }
 
-CPUCRISState *cpu_cris_init (const char *cpu_model)
+CRISCPU *cpu_cris_init(const char *cpu_model)
 {
     CRISCPU *cpu;
     CPUCRISState *env;
@@ -3519,7 +3519,7 @@  CPUCRISState *cpu_cris_init (const char *cpu_model)
     qemu_init_vcpu(env);
 
     if (tcg_initialized) {
-        return env;
+        return cpu;
     }
 
     tcg_initialized = 1;
@@ -3529,7 +3529,7 @@  CPUCRISState *cpu_cris_init (const char *cpu_model)
 
     if (env->pregs[PR_VR] < 32) {
         cpu_crisv10_init(env);
-        return env;
+        return cpu;
     }
 
 
@@ -3573,7 +3573,7 @@  CPUCRISState *cpu_cris_init (const char *cpu_model)
                                        pregnames[i]);
     }
 
-    return env;
+    return cpu;
 }
 
 void cpu_state_reset(CPUCRISState *env)