From patchwork Thu Apr 5 18:12:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 7683 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 42CCC23ED0 for ; Thu, 5 Apr 2012 18:12:42 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 077C2A182E6 for ; Thu, 5 Apr 2012 18:12:41 +0000 (UTC) Received: by yenl4 with SMTP id l4so1110591yen.11 for ; Thu, 05 Apr 2012 11:12:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=6x0CHFjbCCAnAZFytIoTTkbf9x82PoABc5kADdUi3JI=; b=XfG4nw/OoPiSeQIKLBWnfZ4OO6YU9fvQv55hfe4ouuF4oWCMsCY/WLTBcn+J+IHwoM dKFvBh/7NPTjvJegdsnVxRAB2bWCWW3WwQ8mlZwl/SfWzVp5vziLFnHH8vhDLESSUF5j p8AowCVzHE/P+zOVXaeNK6wg8vwzQlZpsuBqHekaNNyl1KD0g4L0cExvEGmwdXNyx9Sw luZAFA63+FLj+5yF4SuDJhv1bfU6ZzhPRNXR0pLJbB1EC3Ju6B8DSj3krB6hhJYKMkKP kowQwrYwDm94J8FP7ul6uTWn7GkyIsT6XjqtHdsfH1LmbCFY7NWVt9zOC/RnWW/4IhCT YzEg== Received: by 10.50.173.35 with SMTP id bh3mr6014384igc.38.1333649561124; Thu, 05 Apr 2012 11:12:41 -0700 (PDT) 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.231.164.217 with SMTP id f25csp73265iby; Thu, 5 Apr 2012 11:12:40 -0700 (PDT) Received: by 10.213.8.3 with SMTP id f3mr478429ebf.179.1333649558919; Thu, 05 Apr 2012 11:12:38 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id n59si1539297eea.42.2012.04.05.11.12.37 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Apr 2012 11:12:38 -0700 (PDT) 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 1SFrAh-0003l9-FB; Thu, 05 Apr 2012 19:12:35 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH v2 1/2] softfloat: float*_to_int32_round_to_zero: don't assume int32 is 32 bits Date: Thu, 5 Apr 2012 19:12:34 +0100 Message-Id: <1333649555-14424-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1333649555-14424-1-git-send-email-peter.maydell@linaro.org> References: <1333649555-14424-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQkR8e5K8gR7spUh2FOeW3n9c4zcc9mbC6+uQQXI6/9L5aYglDkEFd8gGBdubkFByfIenHOe 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 81a7d1a..074fbc3 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 );