From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKHvq-0008In-LI for qemu-devel@nongnu.org; Sun, 02 Mar 2014 20:44:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKHvk-0005Eo-QR for qemu-devel@nongnu.org; Sun, 02 Mar 2014 20:44:38 -0500 Received: from mail-pd0-x236.google.com ([2607:f8b0:400e:c02::236]:32901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKHvk-0005Eg-HF for qemu-devel@nongnu.org; Sun, 02 Mar 2014 20:44:32 -0500 Received: by mail-pd0-f182.google.com with SMTP id g10so3039784pdj.41 for ; Sun, 02 Mar 2014 17:44:31 -0800 (PST) From: Xuebing Wang Date: Mon, 3 Mar 2014 09:43:37 +0800 Message-Id: <1393811020-24881-5-git-send-email-xbing6@gmail.com> In-Reply-To: <1393811020-24881-1-git-send-email-xbing6@gmail.com> References: <1393811020-24881-1-git-send-email-xbing6@gmail.com> Subject: [Qemu-devel] [PULL 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, pbonzini@redhat.com, stefanha@redhat.com Cc: xbing6@gmail.com Signed-off-by: Xuebing Wang Reviewed-By: Alex Bligh --- 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