From patchwork Wed Apr 20 10:11:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 92150 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2E7F1B6FBE for ; Wed, 20 Apr 2011 20:18:48 +1000 (EST) Received: from localhost ([::1]:40756 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCUUf-0002cp-7U for incoming@patchwork.ozlabs.org; Wed, 20 Apr 2011 06:18:45 -0400 Received: from eggs.gnu.org ([140.186.70.92]:43338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCUOb-00005O-Gt for qemu-devel@nongnu.org; Wed, 20 Apr 2011 06:12:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QCUOX-0004Rx-6J for qemu-devel@nongnu.org; Wed, 20 Apr 2011 06:12:29 -0400 Received: from hall.aurel32.net ([88.191.126.93]:43741) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCUOW-0004Rb-T8 for qemu-devel@nongnu.org; Wed, 20 Apr 2011 06:12:25 -0400 Received: from [90.84.144.153] (helo=volta.aurel32.net) by hall.aurel32.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1QCUOW-0002qJ-8T; Wed, 20 Apr 2011 12:12:24 +0200 Received: from aurel32 by volta.aurel32.net with local (Exim 4.72) (envelope-from ) id 1QCUOO-0006HB-0D; Wed, 20 Apr 2011 12:12:16 +0200 From: Aurelien Jarno To: qemu-devel@nongnu.org Date: Wed, 20 Apr 2011 12:11:58 +0200 Message-Id: <1303294329-22634-10-git-send-email-aurelien@aurel32.net> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1303294329-22634-1-git-send-email-aurelien@aurel32.net> References: <1303294329-22634-1-git-send-email-aurelien@aurel32.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 88.191.126.93 Cc: Aurelien Jarno Subject: [Qemu-devel] [PATCH v2 09/20] softfloat-native: add float*_is_any_nan() functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add float*_is_any_nan() functions to match the softfloat API. Reviewed-by: Peter Maydell Signed-off-by: Aurelien Jarno --- fpu/softfloat-native.c | 26 ++++++++++++++++++++++++++ fpu/softfloat-native.h | 3 +++ 2 files changed, 29 insertions(+), 0 deletions(-) diff --git a/fpu/softfloat-native.c b/fpu/softfloat-native.c index 50355a4..8848651 100644 --- a/fpu/softfloat-native.c +++ b/fpu/softfloat-native.c @@ -263,6 +263,15 @@ int float32_is_quiet_nan( float32 a1 ) return ( 0xFF800000 < ( a<<1 ) ); } +int float32_is_any_nan( float32 a1 ) +{ + float32u u; + uint32_t a; + u.f = a1; + a = u.i; + return (a & ~(1 << 31)) > 0x7f800000U; +} + /*---------------------------------------------------------------------------- | Software IEC/IEEE double-precision conversion routines. *----------------------------------------------------------------------------*/ @@ -422,6 +431,16 @@ int float64_is_quiet_nan( float64 a1 ) } +int float64_is_any_nan( float64 a1 ) +{ + float64u u; + uint64_t a; + u.f = a1; + a = u.i; + + return (a & ~(1ULL << 63)) > LIT64 (0x7FF0000000000000 ); +} + #ifdef FLOATX80 /*---------------------------------------------------------------------------- @@ -511,4 +530,11 @@ int floatx80_is_quiet_nan( floatx80 a1 ) return ( ( u.i.high & 0x7FFF ) == 0x7FFF ) && (uint64_t) ( u.i.low<<1 ); } +int floatx80_is_any_nan( floatx80 a1 ) +{ + floatx80u u; + u.f = a1; + return ((u.i.high & 0x7FFF) == 0x7FFF) && ( u.i.low<<1 ); +} + #endif diff --git a/fpu/softfloat-native.h b/fpu/softfloat-native.h index f497e64..6afb74a 100644 --- a/fpu/softfloat-native.h +++ b/fpu/softfloat-native.h @@ -255,6 +255,7 @@ int float32_compare( float32, float32 STATUS_PARAM ); int float32_compare_quiet( float32, float32 STATUS_PARAM ); int float32_is_signaling_nan( float32 ); int float32_is_quiet_nan( float32 ); +int float32_is_any_nan( float32 ); INLINE float32 float32_abs(float32 a) { @@ -375,6 +376,7 @@ INLINE int float64_unordered_quiet( float64 a, float64 b STATUS_PARAM) int float64_compare( float64, float64 STATUS_PARAM ); int float64_compare_quiet( float64, float64 STATUS_PARAM ); int float64_is_signaling_nan( float64 ); +int float64_is_any_nan( float64 ); int float64_is_quiet_nan( float64 ); INLINE float64 float64_abs(float64 a) @@ -492,6 +494,7 @@ int floatx80_compare( floatx80, floatx80 STATUS_PARAM ); int floatx80_compare_quiet( floatx80, floatx80 STATUS_PARAM ); int floatx80_is_signaling_nan( floatx80 ); int floatx80_is_quiet_nan( floatx80 ); +int floatx80_is_any_nan( floatx80 ); INLINE floatx80 floatx80_abs(floatx80 a) {