aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2010-03-10 11:38:49 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-03-17 11:14:53 -0500
commite2a7bb4b156aff7c7bc1da111dd8bcc0931dede8 (patch)
tree23075ce9d75b4ca6df03b4905f06799e88b9d94e
parent4e3de9e954b2674543b3b5c99890c20a7f324a9d (diff)
add qemu_icount_round
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--vl.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/vl.c b/vl.c
index 7938328564..a520b814d2 100644
--- a/vl.c
+++ b/vl.c
@@ -731,6 +731,11 @@ static void configure_icount(const char *option)
qemu_get_clock(vm_clock) + get_ticks_per_sec() / 10);
}
+static int64_t qemu_icount_round(int64_t count)
+{
+ return (count + (1 << icount_time_shift) - 1) >> icount_time_shift;
+}
+
static struct qemu_alarm_timer alarm_timers[] = {
#ifndef _WIN32
#ifdef __linux__
@@ -3960,9 +3965,7 @@ static int qemu_cpu_exec(CPUState *env)
qemu_icount -= (env->icount_decr.u16.low + env->icount_extra);
env->icount_decr.u16.low = 0;
env->icount_extra = 0;
- count = qemu_next_deadline();
- count = (count + (1 << icount_time_shift) - 1)
- >> icount_time_shift;
+ count = qemu_icount_round (qemu_next_deadline());
qemu_icount += count;
decr = (count > 0xffff) ? 0xffff : count;
count -= decr;
@@ -4072,9 +4075,7 @@ static int qemu_calculate_timeout(void)
if (add > 10000000)
add = 10000000;
delta += add;
- add = (add + (1 << icount_time_shift) - 1)
- >> icount_time_shift;
- qemu_icount += add;
+ qemu_icount += qemu_icount_round (add);
timeout = delta / 1000000;
if (timeout < 0)
timeout = 0;