aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2011-03-11 16:46:02 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2011-03-21 09:23:23 +0100
commit0ce1b9480ee52b037b99deeffbdac4ae48641d63 (patch)
tree3f59d33648f0c0bb649414447fa47e5b95c7b8bd
parente0efb993b817564ef84e462ac1fe35f89b57ad7b (diff)
add more helper functions with explicit milli/nanosecond resolution
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>
-rw-r--r--qemu-timer.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/qemu-timer.h b/qemu-timer.h
index 8cd8f8368a..345feeabc0 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;