From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIICk-0003tJ-Jh for qemu-devel@nongnu.org; Tue, 25 Feb 2014 08:37:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WIICc-0004gH-6B for qemu-devel@nongnu.org; Tue, 25 Feb 2014 08:37:50 -0500 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]:32797) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIICb-0004g8-RB for qemu-devel@nongnu.org; Tue, 25 Feb 2014 08:37:41 -0500 Received: by mail-pa0-f42.google.com with SMTP id kl14so8086940pab.15 for ; Tue, 25 Feb 2014 05:37:40 -0800 (PST) From: Xuebing Wang Date: Tue, 25 Feb 2014 21:36:51 +0800 Message-Id: <1393335414-27589-5-git-send-email-xbing6@gmail.com> In-Reply-To: <1393335414-27589-1-git-send-email-xbing6@gmail.com> References: <1393335414-27589-1-git-send-email-xbing6@gmail.com> Subject: [Qemu-devel] [PATCH 4/7] timer: move QEMUTimerListGroup function to be below QEMUClockType List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, xbing6@gmail.com, stefanha@redhat.com, alex@alex.org.uk Signed-off-by: Xuebing Wang --- qemu-timer.c | 86 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/qemu-timer.c b/qemu-timer.c index 471150c..6f13a76 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -456,6 +456,51 @@ bool qemu_clock_run_all_timers(void) return progress; } +/* + * QEMUTimerListGroup + */ + +void timerlistgroup_init(QEMUTimerListGroup *tlg, + QEMUTimerListNotifyCB *cb, void *opaque) +{ + QEMUClockType type; + for (type = 0; type < QEMU_CLOCK_MAX; type++) { + tlg->tl[type] = timerlist_new(type, cb, opaque); + } +} + +void timerlistgroup_deinit(QEMUTimerListGroup *tlg) +{ + QEMUClockType type; + for (type = 0; type < QEMU_CLOCK_MAX; type++) { + timerlist_free(tlg->tl[type]); + } +} + +bool timerlistgroup_run_timers(QEMUTimerListGroup *tlg) +{ + QEMUClockType type; + bool progress = false; + for (type = 0; type < QEMU_CLOCK_MAX; type++) { + progress |= timerlist_run_timers(tlg->tl[type]); + } + return progress; +} + +int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg) +{ + int64_t deadline = -1; + QEMUClockType type; + for (type = 0; type < QEMU_CLOCK_MAX; type++) { + if (qemu_clock_use_for_deadline(tlg->tl[type]->clock->type)) { + deadline = qemu_soonest_timeout(deadline, + timerlist_deadline_ns( + tlg->tl[type])); + } + } + return deadline; +} + /* Transition function to convert a nanosecond timeout to ms * This is used where a system does not support ppoll */ @@ -630,47 +675,6 @@ bool timer_expired(QEMUTimer *timer_head, int64_t current_time) return timer_expired_ns(timer_head, current_time * timer_head->scale); } -void timerlistgroup_init(QEMUTimerListGroup *tlg, - QEMUTimerListNotifyCB *cb, void *opaque) -{ - QEMUClockType type; - for (type = 0; type < QEMU_CLOCK_MAX; type++) { - tlg->tl[type] = timerlist_new(type, cb, opaque); - } -} - -void timerlistgroup_deinit(QEMUTimerListGroup *tlg) -{ - QEMUClockType type; - for (type = 0; type < QEMU_CLOCK_MAX; type++) { - timerlist_free(tlg->tl[type]); - } -} - -bool timerlistgroup_run_timers(QEMUTimerListGroup *tlg) -{ - QEMUClockType type; - bool progress = false; - for (type = 0; type < QEMU_CLOCK_MAX; type++) { - progress |= timerlist_run_timers(tlg->tl[type]); - } - return progress; -} - -int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg) -{ - int64_t deadline = -1; - QEMUClockType type; - for (type = 0; type < QEMU_CLOCK_MAX; type++) { - if (qemu_clock_use_for_deadline(tlg->tl[type]->clock->type)) { - deadline = qemu_soonest_timeout(deadline, - timerlist_deadline_ns( - tlg->tl[type])); - } - } - return deadline; -} - void init_clocks(void) { QEMUClockType type; -- 1.7.9.5