From patchwork Mon Jan 16 18:34:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 6235 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 102FD23E13 for ; Mon, 16 Jan 2012 18:34:24 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id F26B1A1830D for ; Mon, 16 Jan 2012 18:34:23 +0000 (UTC) Received: by mail-bk0-f52.google.com with SMTP id zt4so851653bkb.11 for ; Mon, 16 Jan 2012 10:34:23 -0800 (PST) Received: by 10.204.136.197 with SMTP id s5mr2343819bkt.9.1326738863785; Mon, 16 Jan 2012 10:34:23 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.82.144 with SMTP id ac16cs97537bkc; Mon, 16 Jan 2012 10:34:23 -0800 (PST) Received: by 10.204.156.133 with SMTP id x5mr1289249bkw.86.1326738861289; Mon, 16 Jan 2012 10:34:21 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id ug5si10795384bkb.129.2012.01.16.10.34.20 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jan 2012 10:34:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1RmrNq-0005Cx-Ly; Mon, 16 Jan 2012 18:34:18 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH 2/3] softfloat: float*_to_int32_round_to_zero: don't assume int32 is 32 bits Date: Mon, 16 Jan 2012 18:34:17 +0000 Message-Id: <1326738858-19992-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1326738858-19992-1-git-send-email-peter.maydell@linaro.org> References: <1326738858-19992-1-git-send-email-peter.maydell@linaro.org> Code in the float64_to_int32_round_to_zero() function was assuming that int32 would not be wider than 32 bits; this meant it might not correctly detect the overflow case. We take the simple approach of using int32_t. Also fix equivalent issues in the functions for other float sizes. Signed-off-by: Peter Maydell --- fpu/softfloat.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 6dbcb1b..08db899 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1378,7 +1378,7 @@ int32 float32_to_int32_round_to_zero( float32 a STATUS_PARAM ) flag aSign; int16 aExp, shiftCount; uint32_t aSig; - int32 z; + int32_t z; a = float32_squash_input_denormal(a STATUS_VAR); aSig = extractFloat32Frac( a ); @@ -2762,7 +2762,7 @@ int32 float64_to_int32_round_to_zero( float64 a STATUS_PARAM ) flag aSign; int16 aExp, shiftCount; uint64_t aSig, savedASig; - int32 z; + int32_t z; a = float64_squash_input_denormal(a STATUS_VAR); aSig = extractFloat64Frac( a ); @@ -4248,7 +4248,7 @@ int32 floatx80_to_int32_round_to_zero( floatx80 a STATUS_PARAM ) flag aSign; int32 aExp, shiftCount; uint64_t aSig, savedASig; - int32 z; + int32_t z; aSig = extractFloatx80Frac( a ); aExp = extractFloatx80Exp( a ); @@ -5277,7 +5277,7 @@ int32 float128_to_int32_round_to_zero( float128 a STATUS_PARAM ) flag aSign; int32 aExp, shiftCount; uint64_t aSig0, aSig1, savedASig; - int32 z; + int32_t z; aSig1 = extractFloat128Frac1( a ); aSig0 = extractFloat128Frac0( a );