From 686eeb93d5738c84c59395b2ec6f8181c2b7cbed Mon Sep 17 00:00:00 2001 From: Aurelien Jarno Date: Thu, 15 Oct 2009 23:08:46 +0200 Subject: [PATCH] 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 Acked-by: Laurent Desnogues --- target-arm/helper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target-arm/helper.c b/target-arm/helper.c index 656b5df..021d121 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; } -- 2.7.4