Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/arch/sparc64/softfloat Fix unsigned 64 bit int to l...
details: https://anonhg.NetBSD.org/src/rev/6c679abc5785
branches: trunk
changeset: 326546:6c679abc5785
user: martin <martin%NetBSD.org@localhost>
date: Sun Feb 02 08:14:39 2014 +0000
description:
Fix unsigned 64 bit int to long double conversion for numbers that would not
fit into a signed 64 bit int. Found by latest t_floatunditf test case
failuer, hint from Matt Thomas.
diffstat:
lib/libc/arch/sparc64/softfloat/qp.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diffs (50 lines):
diff -r 9a9fefb1fa23 -r 6c679abc5785 lib/libc/arch/sparc64/softfloat/qp.c
--- a/lib/libc/arch/sparc64/softfloat/qp.c Sun Feb 02 04:28:42 2014 +0000
+++ b/lib/libc/arch/sparc64/softfloat/qp.c Sun Feb 02 08:14:39 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: qp.c,v 1.10 2013/02/15 09:24:05 martin Exp $ */
+/* $NetBSD: qp.c,v 1.11 2014/02/02 08:14:39 martin Exp $ */
/*-
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -32,6 +32,7 @@
#include "milieu.h"
#include "softfloat.h"
+int printf(const char *, ...);
void _Qp_add(float128 *c, float128 *a, float128 *b);
int _Qp_cmp(float128 *a, float128 *b);
@@ -166,9 +167,10 @@
/*
- * XXX need corresponding softfloat function
+ * XXX need corresponding softfloat functions
*/
static float128 __sf128_zero = {0x4034000000000000, 0x00000000};
+static float128 __sf128_one = {0x3fff000000000000, 0};
void
_Qp_neg(float128 *c, float128 *a)
@@ -268,13 +270,15 @@
void
_Qp_uxtoq(float128 *c, unsigned long a)
{
-
if (a & 0x8000000000000000ULL) {
- a = (a >> 1) | (a & 1);
+ /* a would not fit in a signed conversion */
+ *c = int64_to_float128((long long)(a>>1));
+ *c = float128_add(*c, *c);
+ if (a & 1)
+ *c = float128_add(*c, __sf128_one);
+ } else {
*c = int64_to_float128((long long)a);
- *c = float128_add(*c, *c);
- } else
- *c = int64_to_float128((long long)a);
+ }
}
Home |
Main Index |
Thread Index |
Old Index