From patchwork Wed Sep 9 15:11:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 33195 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id B25AFB7079 for ; Thu, 10 Sep 2009 01:39:49 +1000 (EST) Received: from localhost ([127.0.0.1]:48200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlPGs-0007Ka-ML for incoming@patchwork.ozlabs.org; Wed, 09 Sep 2009 11:39:46 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlOuv-0006mS-Cm for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:17:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlOuq-0006k9-Oz for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:17:04 -0400 Received: from [199.232.76.173] (port=35722 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlOup-0006jm-HE for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:16:59 -0400 Received: from goliath.siemens.de ([192.35.17.28]:21243) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MlOuo-00029A-Oq for qemu-devel@nongnu.org; Wed, 09 Sep 2009 11:16:59 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id n89FGujS005683; Wed, 9 Sep 2009 17:16:56 +0200 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail1.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id n89FGtv2011415; Wed, 9 Sep 2009 17:16:55 +0200 Resent-From: Jan Kiszka Resent-To: Anthony Liguori Resent-Cc: qemu-devel , Glauber Costa , Blue Swirl , Dor Laor Resent-Date: Wed, 9 Sep 2009 17:17:13 +0200 Resent-Message-Id: <4AA7C6F9.7010708@siemens.com> Resent-User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 From: Jan Kiszka To: Anthony Liguori Date: Wed, 09 Sep 2009 17:11:12 +0200 Message-ID: <20090909151112.26816.10925.stgit@mchn012c.ww002.siemens.net> In-Reply-To: <20090909151111.26816.49862.stgit@mchn012c.ww002.siemens.net> References: <20090909151111.26816.49862.stgit@mchn012c.ww002.siemens.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Resent-Date: Wed, 09 Sep 2009 11:17:04 -0400 Cc: Blue Swirl , Glauber Costa , Dor Laor , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 1/5] Rename QEMU_TIMER_* to QEMU_CLOCK_* X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org These constants select clocks, not timers. And init_timers initializes clocks. Signed-off-by: Jan Kiszka --- vl.c | 54 +++++++++++++++++++++++++++--------------------------- 1 files changed, 27 insertions(+), 27 deletions(-) diff --git a/vl.c b/vl.c index 098daaa..872083d 100644 --- a/vl.c +++ b/vl.c @@ -529,7 +529,7 @@ uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) /***********************************************************/ /* real time host monotonic timer */ -#define QEMU_TIMER_BASE 1000000000LL +#define QEMU_CLOCK_BASE 1000000000LL #ifdef WIN32 @@ -551,7 +551,7 @@ static int64_t get_clock(void) { LARGE_INTEGER ti; QueryPerformanceCounter(&ti); - return muldiv64(ti.QuadPart, QEMU_TIMER_BASE, clock_freq); + return muldiv64(ti.QuadPart, QEMU_CLOCK_BASE, clock_freq); } #else @@ -671,8 +671,8 @@ void cpu_disable_ticks(void) /***********************************************************/ /* timers */ -#define QEMU_TIMER_REALTIME 0 -#define QEMU_TIMER_VIRTUAL 1 +#define QEMU_CLOCK_REALTIME 0 +#define QEMU_CLOCK_VIRTUAL 1 struct QEMUClock { int type; @@ -754,7 +754,7 @@ static void rtc_stop_timer(struct qemu_alarm_timer *t); fairly approximate, so ignore small variation. When the guest is idle real and virtual time will be aligned in the IO wait loop. */ -#define ICOUNT_WOBBLE (QEMU_TIMER_BASE / 10) +#define ICOUNT_WOBBLE (QEMU_CLOCK_BASE / 10) static void icount_adjust(void) { @@ -796,7 +796,7 @@ static void icount_adjust_rt(void * opaque) static void icount_adjust_vm(void * opaque) { qemu_mod_timer(icount_vm_timer, - qemu_get_clock(vm_clock) + QEMU_TIMER_BASE / 10); + qemu_get_clock(vm_clock) + QEMU_CLOCK_BASE / 10); icount_adjust(); } @@ -812,7 +812,7 @@ static void init_icount_adjust(void) qemu_get_clock(rt_clock) + 1000); icount_vm_timer = qemu_new_timer(vm_clock, icount_adjust_vm, NULL); qemu_mod_timer(icount_vm_timer, - qemu_get_clock(vm_clock) + QEMU_TIMER_BASE / 10); + qemu_get_clock(vm_clock) + QEMU_CLOCK_BASE / 10); } static struct qemu_alarm_timer alarm_timers[] = { @@ -1020,10 +1020,10 @@ static void qemu_run_timers(QEMUTimer **ptimer_head, int64_t current_time) int64_t qemu_get_clock(QEMUClock *clock) { switch(clock->type) { - case QEMU_TIMER_REALTIME: + case QEMU_CLOCK_REALTIME: return get_clock() / 1000000; default: - case QEMU_TIMER_VIRTUAL: + case QEMU_CLOCK_VIRTUAL: if (use_icount) { return cpu_get_icount(); } else { @@ -1032,12 +1032,12 @@ int64_t qemu_get_clock(QEMUClock *clock) } } -static void init_timers(void) +static void init_clocks(void) { init_get_clock(); - ticks_per_sec = QEMU_TIMER_BASE; - rt_clock = qemu_new_clock(QEMU_TIMER_REALTIME); - vm_clock = qemu_new_clock(QEMU_TIMER_VIRTUAL); + ticks_per_sec = QEMU_CLOCK_BASE; + rt_clock = qemu_new_clock(QEMU_CLOCK_REALTIME); + vm_clock = qemu_new_clock(QEMU_CLOCK_VIRTUAL); } /* save a timer */ @@ -1131,9 +1131,9 @@ static void host_alarm_handler(int host_signum) #endif if (alarm_has_dynticks(alarm_timer) || (!use_icount && - qemu_timer_expired(active_timers[QEMU_TIMER_VIRTUAL], + qemu_timer_expired(active_timers[QEMU_CLOCK_VIRTUAL], qemu_get_clock(vm_clock))) || - qemu_timer_expired(active_timers[QEMU_TIMER_REALTIME], + qemu_timer_expired(active_timers[QEMU_CLOCK_REALTIME], qemu_get_clock(rt_clock))) { qemu_event_increment(); if (alarm_timer) alarm_timer->flags |= ALARM_FLAG_EXPIRED; @@ -1153,8 +1153,8 @@ static int64_t qemu_next_deadline(void) { int64_t delta; - if (active_timers[QEMU_TIMER_VIRTUAL]) { - delta = active_timers[QEMU_TIMER_VIRTUAL]->expire_time - + if (active_timers[QEMU_CLOCK_VIRTUAL]) { + delta = active_timers[QEMU_CLOCK_VIRTUAL]->expire_time - qemu_get_clock(vm_clock); } else { /* To avoid problems with overflow limit this to 2^32. */ @@ -1178,8 +1178,8 @@ static uint64_t qemu_next_deadline_dyntick(void) else delta = (qemu_next_deadline() + 999) / 1000; - if (active_timers[QEMU_TIMER_REALTIME]) { - rtdelta = (active_timers[QEMU_TIMER_REALTIME]->expire_time - + if (active_timers[QEMU_CLOCK_REALTIME]) { + rtdelta = (active_timers[QEMU_CLOCK_REALTIME]->expire_time - qemu_get_clock(rt_clock))*1000; if (rtdelta < delta) delta = rtdelta; @@ -1361,8 +1361,8 @@ static void dynticks_rearm_timer(struct qemu_alarm_timer *t) int64_t nearest_delta_us = INT64_MAX; int64_t current_us; - if (!active_timers[QEMU_TIMER_REALTIME] && - !active_timers[QEMU_TIMER_VIRTUAL]) + if (!active_timers[QEMU_CLOCK_REALTIME] && + !active_timers[QEMU_CLOCK_VIRTUAL]) return; nearest_delta_us = qemu_next_deadline_dyntick(); @@ -1477,8 +1477,8 @@ static void win32_rearm_timer(struct qemu_alarm_timer *t) struct qemu_alarm_win32 *data = t->priv; uint64_t nearest_delta_us; - if (!active_timers[QEMU_TIMER_REALTIME] && - !active_timers[QEMU_TIMER_VIRTUAL]) + if (!active_timers[QEMU_CLOCK_REALTIME] && + !active_timers[QEMU_CLOCK_VIRTUAL]) return; nearest_delta_us = qemu_next_deadline_dyntick(); @@ -4124,12 +4124,12 @@ void main_loop_wait(int timeout) /* vm time timers */ if (vm_running) { if (!cur_cpu || likely(!(cur_cpu->singlestep_enabled & SSTEP_NOTIMER))) - qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL], - qemu_get_clock(vm_clock)); + qemu_run_timers(&active_timers[QEMU_CLOCK_VIRTUAL], + qemu_get_clock(vm_clock)); } /* real time timers */ - qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME], + qemu_run_timers(&active_timers[QEMU_CLOCK_REALTIME], qemu_get_clock(rt_clock)); /* Check bottom-halves last in case any of the earlier events triggered @@ -5757,7 +5757,7 @@ int main(int argc, char **argv, char **envp) setvbuf(stdout, NULL, _IOLBF, 0); #endif - init_timers(); + init_clocks(); if (init_timer_alarm() < 0) { fprintf(stderr, "could not initialize alarm timer\n"); exit(1);