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>
This commit is contained in:
Aurelien Jarno 2009-10-15 23:08:46 +02:00
parent 7bbcb0afe7
commit 686eeb93d5
1 changed files with 2 additions and 0 deletions

View File

@ -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;
}