diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2011-09-12 15:50:16 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2011-10-21 18:14:30 +0200 |
commit | dc2dfcf0002b4e6be494959a1ed2589dd109def0 (patch) | |
tree | 9710f4a6b64e4f449bbe1e0be348df5b281f20dc /qemu-timer.c | |
parent | f3fc6e2e9613d33e715624e6dd60f525f49446d1 (diff) | |
download | hqemu-dc2dfcf0002b4e6be494959a1ed2589dd109def0.zip hqemu-dc2dfcf0002b4e6be494959a1ed2589dd109def0.tar.gz |
qemu-timer: more clock functions
These will be used when moving icount accounting to cpus.c.
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qemu-timer.c')
-rw-r--r-- | qemu-timer.c | 25 |
1 files changed, 25 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) { |