diff options
author | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-12-25 03:18:19 +0000 |
---|---|---|
committer | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-12-25 03:18:19 +0000 |
commit | 306ab3e86a94b7547883ca9dac0c86122bb8622c (patch) | |
tree | 83ce8aaab791759b954fbd3786db326622672cb3 /target-mips | |
parent | 6d35524c40a7c884462b852ae697f16f7c90ee9e (diff) |
Avoid host FPE for overflowing division on MIPS, by Richard Sandiford.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3856 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'target-mips')
-rw-r--r-- | target-mips/op_helper.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c index 0323021611..36c4b73f93 100644 --- a/target-mips/op_helper.c +++ b/target-mips/op_helper.c @@ -230,9 +230,16 @@ void do_div (void) void do_ddiv (void) { if (T1 != 0) { - lldiv_t res = lldiv((int64_t)T0, (int64_t)T1); - env->LO[0][env->current_tc] = res.quot; - env->HI[0][env->current_tc] = res.rem; + int64_t arg0 = (int64_t)T0; + int64_t arg1 = (int64_t)T1; + if (arg0 == ((int64_t)-1 << 63) && arg1 == (int64_t)-1) { + env->LO[0][env->current_tc] = arg0; + env->HI[0][env->current_tc] = 0; + } else { + lldiv_t res = lldiv(arg0, arg1); + env->LO[0][env->current_tc] = res.quot; + env->HI[0][env->current_tc] = res.rem; + } } } |