Commit 4e588a4d0e1683488282658c057d4b44976d77d8
1 parent
a368741b
negative decr fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1510 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
6 additions
and
3 deletions
hw/ppc.c
@@ -107,13 +107,16 @@ uint32_t cpu_ppc_load_decr (CPUState *env) | @@ -107,13 +107,16 @@ uint32_t cpu_ppc_load_decr (CPUState *env) | ||
107 | { | 107 | { |
108 | ppc_tb_t *tb_env = env->tb_env; | 108 | ppc_tb_t *tb_env = env->tb_env; |
109 | uint32_t decr; | 109 | uint32_t decr; |
110 | + int64_t diff; | ||
110 | 111 | ||
111 | - decr = muldiv64(tb_env->decr_next - qemu_get_clock(vm_clock), | ||
112 | - tb_env->tb_freq, ticks_per_sec); | 112 | + diff = tb_env->decr_next - qemu_get_clock(vm_clock); |
113 | + if (diff >= 0) | ||
114 | + decr = muldiv64(diff, tb_env->tb_freq, ticks_per_sec); | ||
115 | + else | ||
116 | + decr = -muldiv64(-diff, tb_env->tb_freq, ticks_per_sec); | ||
113 | #if defined(DEBUG_TB) | 117 | #if defined(DEBUG_TB) |
114 | printf("%s: 0x%08x\n", __func__, decr); | 118 | printf("%s: 0x%08x\n", __func__, decr); |
115 | #endif | 119 | #endif |
116 | - | ||
117 | return decr; | 120 | return decr; |
118 | } | 121 | } |
119 | 122 |