From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KCKk7-0003Iv-9V for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:40:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KCKk6-0003Hm-Hs for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:40:26 -0400 Received: from [199.232.76.173] (port=51165 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KCKk6-0003Ha-Bi for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:40:26 -0400 Received: from mx1.redhat.com ([66.187.233.31]:55986) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KCKk6-00082Y-KA for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:40:26 -0400 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m5RKePbG014669 for ; Fri, 27 Jun 2008 16:40:25 -0400 Received: from pobox-2.corp.redhat.com (pobox-2.corp.redhat.com [10.11.255.15]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m5RKePDX006121 for ; Fri, 27 Jun 2008 16:40:25 -0400 Received: from localhost.localdomain (vpn-4-80.str.redhat.com [10.32.4.80]) by pobox-2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m5RKdads004563 for ; Fri, 27 Jun 2008 16:40:23 -0400 From: Glauber Costa Date: Fri, 27 Jun 2008 17:38:23 -0300 Message-Id: <1214599103-13846-21-git-send-email-gcosta@redhat.com> In-Reply-To: <1214599103-13846-20-git-send-email-gcosta@redhat.com> References: <1214599103-13846-1-git-send-email-gcosta@redhat.com> <1214599103-13846-2-git-send-email-gcosta@redhat.com> <1214599103-13846-3-git-send-email-gcosta@redhat.com> <1214599103-13846-4-git-send-email-gcosta@redhat.com> <1214599103-13846-5-git-send-email-gcosta@redhat.com> <1214599103-13846-6-git-send-email-gcosta@redhat.com> <1214599103-13846-7-git-send-email-gcosta@redhat.com> <1214599103-13846-8-git-send-email-gcosta@redhat.com> <1214599103-13846-9-git-send-email-gcosta@redhat.com> <1214599103-13846-10-git-send-email-gcosta@redhat.com> <1214599103-13846-11-git-send-email-gcosta@redhat.com> <1214599103-13846-12-git-send-email-gcosta@redhat.com> <1214599103-13846-13-git-send-email-gcosta@redhat.com> <1214599103-13846-14-git-send-email-gcosta@redhat.com> <1214599103-13846-15-git-send-email-gcosta@redhat.com> <1214599103-13846-16-git-send-email-gcosta@redhat.com> <1214599103-13846-17-git-send-email-gcosta@redhat.com> <1214599103-13846-18-git-send-email-gcosta@redhat.com> <1214599103-13846-19-git-send-email-gcosta@redhat.com> <1214599103-13846-20-git-send-email-gcosta@redhat.com> Subject: [Qemu-devel] [PATCH 20/20] add next_cpu_index Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org separate the logic for calculating the next cpu index from cpu creation. It will allow others to query what's the next cpu index to be created before cpu creation. Signed-off-by: Glauber Costa --- exec.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index d6490ba..3a17a7c 100644 --- a/exec.c +++ b/exec.c @@ -438,21 +438,27 @@ void cpu_exec_init_all(unsigned long tb_size) accel_start(); } -void cpu_exec_init(CPUState *env) +int next_cpu_index() { CPUState **penv; - int cpu_index; + int cpu_index = 0; - env->next_cpu = NULL; penv = &first_cpu; - cpu_index = 0; + while (*penv != NULL) { penv = (CPUState **)&(*penv)->next_cpu; cpu_index++; } - env->cpu_index = cpu_index; + return cpu_index; +} + +void cpu_exec_init(CPUState *env) +{ + env->next_cpu = NULL; + env->cpu_index = next_cpu_index(); + if (env->cpu_index == 0) + first_cpu = env; env->nb_watchpoints = 0; - *penv = env; } static inline void invalidate_page_bitmap(PageDesc *p) -- 1.5.5.1