From patchwork Wed May 23 03:07:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 160772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5C488B6F13 for ; Wed, 23 May 2012 13:09:23 +1000 (EST) Received: from localhost ([::1]:60858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX1wu-0000Ko-B1 for incoming@patchwork.ozlabs.org; Tue, 22 May 2012 23:09:20 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX1we-0000KC-Sw for qemu-devel@nongnu.org; Tue, 22 May 2012 23:09:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SX1wc-0005aS-JJ for qemu-devel@nongnu.org; Tue, 22 May 2012 23:09:04 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35561 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX1wc-0005Zb-9Z for qemu-devel@nongnu.org; Tue, 22 May 2012 23:09:02 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 34D6D98060 for ; Wed, 23 May 2012 05:09:01 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Wed, 23 May 2012 05:07:34 +0200 Message-Id: <1337742502-28565-12-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1337742502-28565-1-git-send-email-afaerber@suse.de> References: <1337742502-28565-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH qom-next 11/59] cpu: Move created field to CPUState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Change its type to bool. Signed-off-by: Andreas Färber --- cpu-defs.h | 1 - cpus.c | 13 +++++++------ include/qemu/cpu.h | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cpu-defs.h b/cpu-defs.h index 4018b88..ae95158 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -205,7 +205,6 @@ typedef struct CPUWatchpoint { /* user data */ \ void *opaque; \ \ - uint32_t created; \ uint32_t stop; /* Stop request */ \ uint32_t stopped; /* Artificially stopped */ \ struct QemuCond *halt_cond; \ diff --git a/cpus.c b/cpus.c index 7d30e55..8ad4949 100644 --- a/cpus.c +++ b/cpus.c @@ -748,7 +748,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) qemu_kvm_init_cpu_signals(env); /* signal CPU creation */ - env->created = 1; + cpu->created = true; qemu_cond_signal(&qemu_cpu_cond); while (1) { @@ -783,7 +783,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) sigaddset(&waitset, SIG_IPI); /* signal CPU creation */ - env->created = 1; + cpu->created = true; qemu_cond_signal(&qemu_cpu_cond); cpu_single_env = env; @@ -820,8 +820,9 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) /* signal CPU creation */ qemu_mutex_lock(&qemu_global_mutex); for (env = first_cpu; env != NULL; env = env->next_cpu) { + cpu = ENV_GET_CPU(env); env->thread_id = qemu_get_thread_id(); - env->created = 1; + cpu->created = true; } qemu_cond_signal(&qemu_cpu_cond); @@ -993,7 +994,7 @@ static void qemu_tcg_init_vcpu(void *_env) #ifdef _WIN32 cpu->hThread = qemu_thread_get_handle(cpu->thread); #endif - while (env->created == 0) { + while (!cpu->created) { qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); } tcg_cpu_thread = cpu->thread; @@ -1012,7 +1013,7 @@ static void qemu_kvm_start_vcpu(CPUArchState *env) qemu_cond_init(env->halt_cond); qemu_thread_create(cpu->thread, qemu_kvm_cpu_thread_fn, env, QEMU_THREAD_JOINABLE); - while (env->created == 0) { + while (!cpu->created) { qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); } } @@ -1026,7 +1027,7 @@ static void qemu_dummy_start_vcpu(CPUArchState *env) qemu_cond_init(env->halt_cond); qemu_thread_create(cpu->thread, qemu_dummy_cpu_thread_fn, env, QEMU_THREAD_JOINABLE); - while (env->created == 0) { + while (!cpu->created) { qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex); } } diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h index 7be983d..3ab2e25 100644 --- a/include/qemu/cpu.h +++ b/include/qemu/cpu.h @@ -54,6 +54,7 @@ typedef struct CPUClass { /** * CPUState: + * @created: Indicates whether the CPU thread has been successfully created. * * State of one CPU core or thread. */ @@ -67,6 +68,7 @@ struct CPUState { HANDLE hThread; #endif bool thread_kicked; + bool created; /* TODO Move common fields from CPUArchState here. */ };