From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:49523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFtDZ-0005HT-7P for qemu-devel@nongnu.org; Mon, 17 Oct 2011 15:51:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RFtDY-0005S5-41 for qemu-devel@nongnu.org; Mon, 17 Oct 2011 15:51:25 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:50356) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFtDY-0005Px-0J for qemu-devel@nongnu.org; Mon, 17 Oct 2011 15:51:24 -0400 Received: by mail-yx0-f174.google.com with SMTP id 4so4361806yxp.5 for ; Mon, 17 Oct 2011 12:51:23 -0700 (PDT) Message-ID: <4E9C8739.7050907@codemonkey.ws> Date: Mon, 17 Oct 2011 14:51:21 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1318332930-16217-1-git-send-email-pbonzini@redhat.com> <1318332930-16217-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1318332930-16217-5-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 04/13] qemu-timer: more clock functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On 10/11/2011 06:35 AM, Paolo Bonzini wrote: > These will be used when moving icount accounting to cpus.c. > > Signed-off-by: Paolo Bonzini Reviewed-by: Anthony Liguori Regards, Anthony Liguori > --- > qemu-timer.c | 25 +++++++++++++++++++++++++ > qemu-timer.h | 3 +++ > 2 files changed, 28 insertions(+), 0 deletions(-) > > diff --git a/qemu-timer.c b/qemu-timer.c > index e2551f3..ebb5089 100644 > --- a/qemu-timer.c > +++ b/qemu-timer.c > @@ -495,6 +495,31 @@ void qemu_clock_warp(QEMUClock *clock) > } > } > > +int64_t qemu_clock_has_timers(QEMUClock *clock) > +{ > + return !!clock->active_timers; > +} > + > +int64_t qemu_clock_expired(QEMUClock *clock) > +{ > + return (clock->active_timers&& > + clock->active_timers->expire_time< qemu_get_clock_ns(clock)); > +} > + > +int64_t qemu_clock_deadline(QEMUClock *clock) > +{ > + /* To avoid problems with overflow limit this to 2^32. */ > + int64_t delta = INT32_MAX; > + > + if (clock->active_timers) { > + delta = clock->active_timers->expire_time - qemu_get_clock_ns(clock); > + } > + if (delta< 0) { > + delta = 0; > + } > + return delta; > +} > + > QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale, > QEMUTimerCB *cb, void *opaque) > { > diff --git a/qemu-timer.h b/qemu-timer.h > index 0a43469..4578075 100644 > --- a/qemu-timer.h > +++ b/qemu-timer.h > @@ -38,6 +38,9 @@ extern QEMUClock *vm_clock; > extern QEMUClock *host_clock; > > int64_t qemu_get_clock_ns(QEMUClock *clock); > +int64_t qemu_clock_has_timers(QEMUClock *clock); > +int64_t qemu_clock_expired(QEMUClock *clock); > +int64_t qemu_clock_deadline(QEMUClock *clock); > void qemu_clock_enable(QEMUClock *clock, int enabled); > void qemu_clock_warp(QEMUClock *clock); >