[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r12594 - in /libdfp/trunk: ./ tests/
- To: commits@xxxxxxxxxx
- Subject: [commits] r12594 - in /libdfp/trunk: ./ tests/
- From: ryanarn@xxxxxxxxxx
- Date: Tue, 18 Jan 2011 22:16:59 -0000
Author: ryanarn
Date: Tue Jan 18 14:16:57 2011
New Revision: 12594
Log:
The following fixes correct a bug in __printf_dfp where values with a
sufficiently negative exponent would cause a segv on s390 (we got lucky on
PowerPC) when the 'index' (position of the digit to use for rounding) became
negative. Also cleaned up test cases.
Bumped version to 1.0.6.
2011-1-18 Ryan S. Arnold <rsa@xxxxxxxxxx>
* configure: Regenerated.
* tests/test-isfinite.c: Changed expectation on isfinite() for
negative numbers on Power5 to '1'. Power6 (hardware isfinite) returns
'-1' on isfinite. The spec simply says that non-zero means finite.
* tests/test-logd.c: Removed half completed 'quantize compare'
functionality which was throwing a false error.
* tests/test-decode.c: Removed dangling printf that wasn't useful.
* tests/test-printf.c: Added a _Decimal128 test for printing (1.0DL /
1.000000e-123DL) which has a sufficiently negative exponent that it
forced the 'index' (rounding digit) position to be negative and caused
a segv when __printf_dfp() tried to erroneously round the result on
s390. We got lucky up until now on PowerPC due to the kernel
reserving space on the top of the stack.
* configure.ac: Incremented the version number to 1.0.6.
* Versions.def: Incremented the version number to 1.0.6.
2011-1-18 Andreas Krebbel <Andreas.Krebbel@xxxxxxxxxx>
* printf_dfp.c (__printf_dfp): Fixed segv where, if the exponent is
sufficiently negative it pushes 'index' (the digit used to round
values to the left) into a negative number. In that case we simply
don't need to round at all.
Modified:
libdfp/trunk/ChangeLog
libdfp/trunk/Versions.def
libdfp/trunk/configure
libdfp/trunk/configure.ac
libdfp/trunk/printf_dfp.c
libdfp/trunk/tests/test-decode.c
libdfp/trunk/tests/test-isfinite.c
libdfp/trunk/tests/test-logd.c
libdfp/trunk/tests/test-printf.c
Modified: libdfp/trunk/ChangeLog
==============================================================================
--- libdfp/trunk/ChangeLog (original)
+++ libdfp/trunk/ChangeLog Tue Jan 18 14:16:57 2011
@@ -1,3 +1,28 @@
+2011-1-18 Ryan S. Arnold <rsa@xxxxxxxxxx>
+
+ * configure: Regenerated.
+ * tests/test-isfinite.c: Changed expectation on isfinite() for
+ negative numbers on Power5 to '1'. Power6 (hardware isfinite) returns
+ '-1' on isfinite. The spec simply says that non-zero means finite.
+ * tests/test-logd.c: Removed half completed 'quantize compare'
+ functionality which was throwing a false error.
+ * tests/test-decode.c: Removed dangling printf that wasn't useful.
+ * tests/test-printf.c: Added a _Decimal128 test for printing (1.0DL /
+ 1.000000e-123DL) which has a sufficiently negative exponent that it
+ forced the 'index' (rounding digit) position to be negative and caused
+ a segv when __printf_dfp() tried to erroneously round the result on
+ s390. We got lucky up until now on PowerPC due to the kernel
+ reserving space on the top of the stack.
+ * configure.ac: Incremented the version number to 1.0.6.
+ * Versions.def: Incremented the version number to 1.0.6.
+
+2011-1-18 Andreas Krebbel <Andreas.Krebbel@xxxxxxxxxx>
+
+ * printf_dfp.c (__printf_dfp): Fixed segv where, if the exponent is
+ sufficiently negative it pushes 'index' (the digit used to round
+ values to the left) into a negative number. In that case we simply
+ don't need to round at all.
+
2011-1-18 Ryan S. Arnold <rsa@xxxxxxxxxx>
* tests/test-strtod.c: Adjusted assumptions of tests from truncation
Modified: libdfp/trunk/Versions.def
==============================================================================
--- libdfp/trunk/Versions.def (original)
+++ libdfp/trunk/Versions.def Tue Jan 18 14:16:57 2011
@@ -4,5 +4,6 @@
LIBDFP_1.0.3
LIBDFP_1.0.4
LIBDFP_1.0.5
+ LIBDFP_1.0.6
LIBDFP_PRIVATE
}
Modified: libdfp/trunk/configure
==============================================================================
--- libdfp/trunk/configure (original)
+++ libdfp/trunk/configure Tue Jan 18 14:16:57 2011
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for libdfp 1.0.5.
+# Generated by GNU Autoconf 2.59 for libdfp 1.0.6.
#
# Report bugs to <rsa@xxxxxxxxxx>.
#
@@ -269,8 +269,8 @@
# Identity of this package.
PACKAGE_NAME='libdfp'
PACKAGE_TARNAME='libdfp'
-PACKAGE_VERSION='1.0.5'
-PACKAGE_STRING='libdfp 1.0.5'
+PACKAGE_VERSION='1.0.6'
+PACKAGE_STRING='libdfp 1.0.6'
PACKAGE_BUGREPORT='rsa@xxxxxxxxxx'
ac_unique_file="printf_dfp.c"
@@ -741,7 +741,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libdfp 1.0.5 to adapt to many kinds of systems.
+\`configure' configures libdfp 1.0.6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -802,7 +802,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libdfp 1.0.5:";;
+ short | recursive ) echo "Configuration of libdfp 1.0.6:";;
esac
cat <<\_ACEOF
@@ -947,7 +947,7 @@
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
-libdfp configure 1.0.5
+libdfp configure 1.0.6
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@@ -961,7 +961,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libdfp $as_me 1.0.5, which was
+It was created by libdfp $as_me 1.0.6, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -3434,7 +3434,7 @@
} >&5
cat >&5 <<_CSEOF
-This file was extended by libdfp $as_me 1.0.5, which was
+This file was extended by libdfp $as_me 1.0.6, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -3494,7 +3494,7 @@
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-libdfp config.status 1.0.5
+libdfp config.status 1.0.6
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
Modified: libdfp/trunk/configure.ac
==============================================================================
--- libdfp/trunk/configure.ac (original)
+++ libdfp/trunk/configure.ac Tue Jan 18 14:16:57 2011
@@ -5,7 +5,7 @@
# has a hard-coded 2.59 requirement and Libdfp doesn't really care, but can't
# control libdecnumber.
AC_PREREQ(2.59)
-AC_INIT(libdfp, 1.0.5, rsa@xxxxxxxxxx)
+AC_INIT(libdfp, 1.0.6, rsa@xxxxxxxxxx)
AC_CONFIG_SRCDIR([printf_dfp.c])
# We don't use Automake so this is necessary.
Modified: libdfp/trunk/printf_dfp.c
==============================================================================
--- libdfp/trunk/printf_dfp.c (original)
+++ libdfp/trunk/printf_dfp.c Tue Jan 18 14:16:57 2011
@@ -645,6 +645,8 @@
char rounddigit = '4';
if (spec == 'f')
+ /* This may force index to negative, in which case we ignore it at a
+ * later time. */
index = n + nd + exp + prec;
/* Goofy special case where we round significant digits which aren't
* right of the decimal place. */
@@ -673,8 +675,9 @@
}
/* If this is true then the requested precision is smaller than the
- * default and rounding is required. */
- if (index < mw && digits[index] > rounddigit)
+ * default and rounding is required. If 'exp' was sufficiently negative
+ * 'index' may be negative, in which case we don't need to round. */
+ if (index > 0 && index < mw && digits[index] > rounddigit)
do {
int trailzero = index+1;
if (digits[index] == rounddigit+1)
@@ -696,9 +699,14 @@
if (roundmode == 6 && trailzero) break;
}
- while (digits[--index] == '9') digits[index] = '0';
+ while (digits[--index] == '9')
+ digits[index] = '0';
digits[index]++;
- if (index < n) { n--; nd++; }
+ if (index < n)
+ {
+ n--;
+ nd++;
+ }
} while (0);
} /* Done rounding. */
Modified: libdfp/trunk/tests/test-decode.c
==============================================================================
--- libdfp/trunk/tests/test-decode.c (original)
+++ libdfp/trunk/tests/test-decode.c Tue Jan 18 14:16:57 2011
@@ -99,10 +99,6 @@
_DC_P(__FILE__,d64ptr->line, d64ptr->expect,d64ptr->d);
}
- printf("foo: %.8lx%.8lx\n", d64u.i[0],d64u.i[1]);
- printf("foo: %.8lx%.8lx%.8lx%.8lx\n", d128u.i[0],d128u.i[1],d128u.i[2],d128u.i[3]);
-/* printf("foo: %lld\n", d128u.lli); */
-
_REPORT();
/* fail comes from scaffold.c */
Modified: libdfp/trunk/tests/test-isfinite.c
==============================================================================
--- libdfp/trunk/tests/test-isfinite.c (original)
+++ libdfp/trunk/tests/test-isfinite.c Tue Jan 18 14:16:57 2011
@@ -47,7 +47,7 @@
{__LINE__, DEC_NAN, 0, "%d"},
{__LINE__, HUGE_VAL_D128, 0, "%d"},
{__LINE__, DEC_INFINITY, 0, "%d"},
-#if defined __s390__ || defined __s390x__
+#if defined __s390__ || defined __s390x__ || !defined _ARCH_PWR6
{__LINE__, -1.95DL, 1, "%d"},
#else
/* isfinite returns 'nonzero' if the argument is finite. This could be
@@ -70,7 +70,7 @@
{__LINE__, DEC_NAN, 0, "%d"},
{__LINE__, HUGE_VAL_D64, 0, "%d"},
{__LINE__, DEC_INFINITY, 0, "%d"},
-#if defined __s390__ || defined __s390x__
+#if defined __s390__ || defined __s390x__ || !defined _ARCH_PWR6
{__LINE__, -1.95DD, 1, "%d"},
#else
/* isfinite returns 'nonzero' if the argument is finite. This could be
@@ -94,7 +94,7 @@
{__LINE__, DEC_NAN, 0, "%d"},
{__LINE__, HUGE_VAL_D32, 0, "%d"},
{__LINE__, DEC_INFINITY, 0, "%d"},
-#if defined __s390__ || defined __s390x__
+#if defined __s390__ || defined __s390x__ || !defined _ARCH_PWR6
{__LINE__, -1.95DF, 1, "%d"},
#else
/* isfinite returns 'nonzero' if the argument is finite. This could be
Modified: libdfp/trunk/tests/test-logd.c
==============================================================================
--- libdfp/trunk/tests/test-logd.c (original)
+++ libdfp/trunk/tests/test-logd.c Tue Jan 18 14:16:57 2011
@@ -50,7 +50,6 @@
{__LINE__, 0.9956440572495333DD, -0.004365457509639973DD, "%DfDD",'v'},
{__LINE__, 0.9828009828009828DD, -0.01734863833461300DD, "%DfDD",'v'},
{__LINE__, 1.0DD, 0.0DD, "%DfDD",'v'},
- {__LINE__, 1.02DD, 0.019803DD, "%.6DfDD",'q'},
{__LINE__, 1.02DD, 0.01980262729617971DD, "%DfDD",'v'},
{__LINE__, 3.14DD, 1.144222799920162DD, "%DfDD",'v'},
#ifndef _ARCH_PWR6 /* This returns NaN in the hard-DFP case. */
@@ -89,14 +88,7 @@
{
_Decimal64 retval = logd64(d64ptr->x);
fprintf(stdout,"%DfDD = logd64(%DfDD) in: %s:%d\n", retval, d64ptr->x,__FILE__,__LINE__-1);
- if(d64ptr->vorq == 'v')
- _VC_P(__FILE__,d64ptr->line, d64ptr->e,retval,d64ptr->format);
- if(d64ptr->e != retval)
- {
- static char rbuf[CHAR_MAX];
- static char pbuf[CHAR_MAX];
- fprintf(stderr,"decoded64(retval) [%s] != decoded64(expected) [%s]\n", decoded64(retval, &rbuf[0]), decoded64(d64ptr->e, &pbuf[0]));
- }
+ _VC_P(__FILE__,d64ptr->line, d64ptr->e,retval,d64ptr->format);
}
for (d64dptr = decode_d64s; d64dptr->line; d64dptr++)
Modified: libdfp/trunk/tests/test-printf.c
==============================================================================
--- libdfp/trunk/tests/test-printf.c (original)
+++ libdfp/trunk/tests/test-printf.c Tue Jan 18 14:16:57 2011
@@ -704,6 +704,10 @@
/* Fixed by Andreas Schwab on 2010-20-04 */
{__LINE__, 0.9999999999DL, "1.000000", "%DDf"},
+ /* Caused a segv due to a the negative exponent generating a negative 'index'.
+ * It was fixed by Andreas Krebbel on 2011-01-18 */
+ {__LINE__, (1.0DL / 1.000000e-123DL), "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000", "%DDf"},
+
{0,0,0,0 }
};