qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v2 2/4] target-i386: Move TCG initialization check t


From: Eduardo Habkost
Subject: [Qemu-devel] [PATCH v2 2/4] target-i386: Move TCG initialization check to tcg_x86_init()
Date: Fri, 18 Sep 2015 16:38:14 -0300

Instead of requiring cpu.c to check if TCG was already initialized,
simply let the function be called multiple times.

Suggested-by: Igor Mammedov <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
 target-i386/cpu.c       | 4 +---
 target-i386/translate.c | 6 ++++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 22c0f5b..f054a69 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -3021,7 +3021,6 @@ static void x86_cpu_initfn(Object *obj)
     X86CPUClass *xcc = X86_CPU_GET_CLASS(obj);
     CPUX86State *env = &cpu->env;
     FeatureWord w;
-    static int inited;
 
     cs->env_ptr = env;
     cpu_exec_init(cs, &error_abort);
@@ -3072,8 +3071,7 @@ static void x86_cpu_initfn(Object *obj)
     x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort);
 
     /* init various static tables used in TCG mode */
-    if (tcg_enabled() && !inited) {
-        inited = 1;
+    if (tcg_enabled()) {
         tcg_x86_init();
     }
 }
diff --git a/target-i386/translate.c b/target-i386/translate.c
index e6e60e5..8ed3902 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -7821,6 +7821,12 @@ void tcg_x86_init(void)
 #endif
     };
     int i;
+    static bool initialized = false;
+
+    if (initialized) {
+        return;
+    }
+    initialized = true;
 
     cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
     cpu_cc_op = tcg_global_mem_new_i32(TCG_AREG0,
-- 
2.1.0




reply via email to

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