qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [RFC PATCH 1/5] add more helper functions with explicit milli/nanosecond resolution
Date: Sat, 12 Mar 2011 18:04:16 +0100	[thread overview]
Message-ID: <1299949460-4387-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1299949460-4387-1-git-send-email-pbonzini@redhat.com>

The code doesn't make much sense right now, but it will as
soon as timers will be able to scale their resolution arbitrarily.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-timer.h |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/qemu-timer.h b/qemu-timer.h
index 8cd8f83..345feea 100644
--- a/qemu-timer.h
+++ b/qemu-timer.h
@@ -12,6 +12,10 @@
 
 /* timers */
 
+#define SCALE_MS 1000000
+#define SCALE_US 1000
+#define SCALE_NS 1
+
 typedef struct QEMUClock QEMUClock;
 typedef void QEMUTimerCB(void *opaque);
 
@@ -54,6 +58,25 @@ void init_clocks(void);
 int init_timer_alarm(void);
 void quit_timers(void);
 
+static inline QEMUTimer *qemu_new_timer_ns(QEMUClock *clock, QEMUTimerCB *cb,
+                                           void *opaque)
+{
+    assert(clock != rt_clock);
+    return qemu_new_timer(clock, cb, opaque);
+}
+
+static inline QEMUTimer *qemu_new_timer_ms(QEMUClock *clock, QEMUTimerCB *cb,
+                                           void *opaque)
+{
+    assert(clock == rt_clock);
+    return qemu_new_timer(clock, cb, opaque);
+}
+
+static inline int64_t qemu_get_clock_ms(QEMUClock *clock)
+{
+    return qemu_get_clock_ns(clock) / SCALE_MS;
+}
+
 static inline int64_t get_ticks_per_sec(void)
 {
     return 1000000000LL;
-- 
1.7.4

  reply	other threads:[~2011-03-12 17:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-12 17:04 [Qemu-devel] [RFC PATCH 0/5] allow arbitrary scaling of timers Paolo Bonzini
2011-03-12 17:04 ` Paolo Bonzini [this message]
2011-03-12 17:04 ` [Qemu-devel] [RFC PATCH 2/5] change all rt_clock references to use millisecond resolution accessors Paolo Bonzini
2011-03-12 17:04 ` [Qemu-devel] [RFC PATCH 3/5] change all other clock references to use nanosecond " Paolo Bonzini
2011-03-12 17:04 ` [Qemu-devel] [RFC PATCH 4/5] add a generic scaling mechanism for timers Paolo Bonzini
2011-03-12 17:04 ` [Qemu-devel] [RFC PATCH 5/5] remove qemu_get_clock Paolo Bonzini
2011-03-12 23:33 ` [Qemu-devel] [RFC PATCH 0/5] allow arbitrary scaling of timers Anthony Liguori
2011-03-14  7:14   ` Paolo Bonzini
2011-03-21 13:35     ` [Qemu-devel] [PULL] " Paolo Bonzini
2011-03-21 20:44       ` Aurelien Jarno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1299949460-4387-2-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).