qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-arm: fix sdiv helper
@ 2009-10-15 21:08 Aurelien Jarno
  2009-10-18 14:29 ` Laurent Desnogues
  0 siblings, 1 reply; 2+ messages in thread
From: Aurelien Jarno @ 2009-10-15 21:08 UTC (permalink / raw)
  To: qemu-devel

(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>
---
 target-arm/helper.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/target-arm/helper.c b/target-arm/helper.c
index 701629a..b3d6198 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -404,6 +404,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;
 }
 
-- 
1.6.1.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-18 14:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-15 21:08 [Qemu-devel] [PATCH] target-arm: fix sdiv helper Aurelien Jarno
2009-10-18 14:29 ` Laurent Desnogues

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).