summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien Jarno <aurelien@aurel32.net>2009-10-15 23:08:46 +0200
committerAurelien Jarno <aurelien@aurel32.net>2009-10-23 00:05:17 +0200
commit686eeb93d5738c84c59395b2ec6f8181c2b7cbed (patch)
tree13b0a3533034804c14ed2e51c401f02de5302a45
parenttarget-arm: use clz32() instead of a for loop (diff)
downloadqemu-kvm-686eeb93d5738c84c59395b2ec6f8181c2b7cbed.tar.gz
qemu-kvm-686eeb93d5738c84c59395b2ec6f8181c2b7cbed.tar.bz2
qemu-kvm-686eeb93d5738c84c59395b2ec6f8181c2b7cbed.zip
target-arm: fix sdiv helper
(INT32_MIN / -1) triggers an overflow, and the result depends on the host architecture (INT32_MIN on arm, -1 on ppc, SIGFPE on x86). Use a test to output the correct value. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Acked-by: Laurent Desnogues <laurent.desnogues@gmail.com>
-rw-r--r--target-arm/helper.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 656b5df9e..021d121df 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -402,6 +402,8 @@ int32_t HELPER(sdiv)(int32_t num, int32_t den)
{
if (den == 0)
return 0;
+ if (num == INT_MIN && den == -1)
+ return INT_MIN;
return num / den;
}