From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b097U-0003F0-1C for qemu-devel@nongnu.org; Tue, 10 May 2016 10:58:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b097O-0002rw-Q8 for qemu-devel@nongnu.org; Tue, 10 May 2016 10:58:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b097O-0002rH-Jm for qemu-devel@nongnu.org; Tue, 10 May 2016 10:58:38 -0400 Date: Tue, 10 May 2016 16:58:31 +0200 From: Igor Mammedov Message-ID: <20160510165831.40d0033a@nial.brq.redhat.com> In-Reply-To: <1462558292-2126-2-git-send-email-ehabkost@redhat.com> References: <1462558292-2126-1-git-send-email-ehabkost@redhat.com> <1462558292-2126-2-git-send-email-ehabkost@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/9] target-i386: Move TCG initialization check to tcg_x86_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: qemu-devel@nongnu.org, Jiri Denemark , Andreas =?UTF-8?B?RsOkcmJlcg==?= , libvir-list@redhat.com On Fri, 6 May 2016 15:11:24 -0300 Eduardo Habkost wrote: > Instead of requiring cpu.c to check if TCG was already initialized, > simply let the function be called multiple times. > > Suggested-by: Igor Mammedov > Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov > --- > 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 4856cd4..a689fec 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -3087,7 +3087,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); > @@ -3138,8 +3137,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 1a1214d..92570b4 100644 > --- a/target-i386/translate.c > +++ b/target-i386/translate.c > @@ -8133,6 +8133,12 @@ void tcg_x86_init(void) > "bnd0_ub", "bnd1_ub", "bnd2_ub", "bnd3_ub" > }; > 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(cpu_env,