Patchwork [4/7] target-alpha: Let cpu_alpha_init() return AlphaCPU

login
register
mail settings
Submitter Andreas Färber
Date Oct. 31, 2012, 3:04 a.m.
Message ID <1351652644-18687-5-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/195720/
State New
Headers show

Comments

Andreas Färber - Oct. 31, 2012, 3:04 a.m.
Replace cpu_init() macro with inline function for backwards
compatibility.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-alpha/cpu.h       |   13 +++++++++++--
 target-alpha/translate.c |    4 ++--
 2 Dateien geändert, 13 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
Richard Henderson - Oct. 31, 2012, 5:02 a.m.
On 2012-10-31 14:04, Andreas Färber wrote:
> Replace cpu_init() macro with inline function for backwards
> compatibility.
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  target-alpha/cpu.h       |   13 +++++++++++--
>  target-alpha/translate.c |    4 ++--

Acked-by: Richard Henderson <rth@twiddle.net>


r~

Patch

diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h
index 28999ab..2bbde9c 100644
--- a/target-alpha/cpu.h
+++ b/target-alpha/cpu.h
@@ -297,7 +297,6 @@  struct CPUAlphaState {
     int implver;
 };
 
-#define cpu_init cpu_alpha_init
 #define cpu_list alpha_cpu_list
 #define cpu_exec cpu_alpha_exec
 #define cpu_gen_code cpu_alpha_gen_code
@@ -435,7 +434,17 @@  enum {
     IR_ZERO = 31,
 };
 
-CPUAlphaState *cpu_alpha_init(const char *cpu_model);
+AlphaCPU *cpu_alpha_init(const char *cpu_model);
+
+static inline CPUAlphaState *cpu_init(const char *cpu_model)
+{
+    AlphaCPU *cpu = cpu_alpha_init(cpu_model);
+    if (cpu == NULL) {
+        return NULL;
+    }
+    return &cpu->env;
+}
+
 void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 int cpu_alpha_exec(CPUAlphaState *s);
 /* you can call this signal handler from your SIGBUS and SIGSEGV
diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index 6ee031d..5419df1 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -3493,7 +3493,7 @@  void gen_intermediate_code_pc (CPUAlphaState *env, struct TranslationBlock *tb)
     gen_intermediate_code_internal(env, tb, 1);
 }
 
-CPUAlphaState *cpu_alpha_init(const char *cpu_model)
+AlphaCPU *cpu_alpha_init(const char *cpu_model)
 {
     AlphaCPU *cpu;
     CPUAlphaState *env;
@@ -3511,7 +3511,7 @@  CPUAlphaState *cpu_alpha_init(const char *cpu_model)
     env->cpu_model_str = cpu_model;
 
     qemu_init_vcpu(env);
-    return env;
+    return cpu;
 }
 
 void restore_state_to_opc(CPUAlphaState *env, TranslationBlock *tb, int pc_pos)