From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ull4d-00012n-HP for qemu-devel@nongnu.org; Sun, 09 Jun 2013 15:14:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ull4c-0000pw-0b for qemu-devel@nongnu.org; Sun, 09 Jun 2013 15:14:43 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44462 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ull4b-0000po-PR for qemu-devel@nongnu.org; Sun, 09 Jun 2013 15:14:41 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 607D0A51FF for ; Sun, 9 Jun 2013 21:14:41 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 9 Jun 2013 21:13:15 +0200 Message-Id: <1370805206-26574-49-git-send-email-afaerber@suse.de> In-Reply-To: <1370805206-26574-1-git-send-email-afaerber@suse.de> References: <1370805206-26574-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu 48/59] cpus: Abstract all_cpu_threads_idle() with qemu_for_each_cpu() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= Signed-off-by: Andreas F=C3=A4rber --- cpus.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/cpus.c b/cpus.c index 7428389..506a0c8 100644 --- a/cpus.c +++ b/cpus.c @@ -77,16 +77,24 @@ static bool cpu_thread_is_idle(CPUState *cpu) return true; } =20 -static bool all_cpu_threads_idle(void) +static void one_cpu_thread_idle(CPUState *cpu, void *data) { - CPUArchState *env; + bool *all_idle =3D data; =20 - for (env =3D first_cpu; env !=3D NULL; env =3D env->next_cpu) { - if (!cpu_thread_is_idle(ENV_GET_CPU(env))) { - return false; - } + if (!*all_idle) { + return; } - return true; + if (!cpu_thread_is_idle(cpu)) { + *all_idle =3D false; + } +} + +static bool all_cpu_threads_idle(void) +{ + bool ret =3D true; + + qemu_for_each_cpu(one_cpu_thread_idle, &ret); + return ret; } =20 /***********************************************************/ --=20 1.8.1.4