From patchwork Thu Oct 15 21:08:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 36149 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8CBA0B7B91 for ; Fri, 16 Oct 2009 08:09:45 +1100 (EST) Received: from localhost ([127.0.0.1]:48749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyXZu-0002mD-KR for incoming@patchwork.ozlabs.org; Thu, 15 Oct 2009 17:09:42 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MyXZ7-0002S0-8d for qemu-devel@nongnu.org; Thu, 15 Oct 2009 17:08:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MyXZ5-0002Pe-Nb for qemu-devel@nongnu.org; Thu, 15 Oct 2009 17:08:52 -0400 Received: from [199.232.76.173] (port=52284 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyXZ5-0002PS-Bg for qemu-devel@nongnu.org; Thu, 15 Oct 2009 17:08:51 -0400 Received: from hall.aurel32.net ([88.191.82.174]:33511) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MyXZ4-00048S-T1 for qemu-devel@nongnu.org; Thu, 15 Oct 2009 17:08:51 -0400 Received: from [2002:52e8:2fb:1:21e:8cff:feb0:693b] (helo=volta.aurel32.net) by hall.aurel32.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1MyXZ3-0007NP-BC for qemu-devel@nongnu.org; Thu, 15 Oct 2009 23:08:49 +0200 Received: from aurel32 by volta.aurel32.net with local (Exim 4.69) (envelope-from ) id 1MyXZ0-0003HA-JG for qemu-devel@nongnu.org; Thu, 15 Oct 2009 23:08:46 +0200 Date: Thu, 15 Oct 2009 23:08:46 +0200 From: Aurelien Jarno To: qemu-devel@nongnu.org Message-ID: <20091015210846.GB7071@volta.aurel32.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [PATCH] target-arm: fix sdiv helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org (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 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; }