[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commits] r16042 - in /libdfp/trunk: ChangeLog Makefile.in README.user sysdeps/powerpc/dfpu/expd64.c tests/scaffold.c
- To: commits@xxxxxxxxxx
- Subject: [Commits] r16042 - in /libdfp/trunk: ChangeLog Makefile.in README.user sysdeps/powerpc/dfpu/expd64.c tests/scaffold.c
- From: ryanarn@xxxxxxxxxx
- Date: Thu, 01 Dec 2011 21:31:32 -0000
Author: ryanarn
Date: Thu Dec 1 21:31:31 2011
New Revision: 16042
Log:
Fix power[6|7] expd32() and expd64() handling of negative vals.
This fix correct the buggy optimized version expd64() for power[6|7] so that
it can handle negative input values. e^-n is simply 1/(e^n).
2011-12-01 Ryan S. Arnold <rsa@xxxxxxxxxxxxxxxxxx>
* Makefile.in (libdfp_tests): Add test-expd, testing
expd[64|128](-1.0) which was previously failing.
(libdfp_tests.so): New dummy rule to add
$(top_srcdir)/tests/scaffold.c as a dependency so that scaffold.c
changes result in rebuilding the libdfp_test .so files on make check.
* tests/test-expd.c: New file testing expd[32|64|128].
* tests/scaffold.c (_AVC _AVC_P): New macros which do a value compare
but allow a +/- variation.
* README.user: Added instructions for C++ types compatibility with
ISO-C DFP types.
* sysdeps/powerpc/dfpu/expd64.c: Existing code only accounts for
positive 'n' in e^n. This fix allows for e^-n, which is just 1/(e^n).
Modified:
libdfp/trunk/ChangeLog
libdfp/trunk/Makefile.in
libdfp/trunk/README.user
libdfp/trunk/sysdeps/powerpc/dfpu/expd64.c
libdfp/trunk/tests/scaffold.c
Modified: libdfp/trunk/ChangeLog
==============================================================================
--- libdfp/trunk/ChangeLog (original)
+++ libdfp/trunk/ChangeLog Thu Dec 1 21:31:31 2011
@@ -1,3 +1,18 @@
+2011-12-01 Ryan S. Arnold <rsa@xxxxxxxxxxxxxxxxxx>
+
+ * Makefile.in (libdfp_tests): Add test-expd, testing
+ expd[64|128](-1.0) which was previously failing.
+ (libdfp_tests.so): New dummy rule to add
+ $(top_srcdir)/tests/scaffold.c as a dependency so that scaffold.c
+ changes result in rebuilding the libdfp_test .so files on make check.
+ * tests/test-expd.c: New file testing expd[32|64|128].
+ * tests/scaffold.c (_AVC _AVC_P): New macros which do a value compare
+ but allow a +/- variation.
+ * README.user: Added instructions for C++ types compatibility with
+ ISO-C DFP types.
+ * sysdeps/powerpc/dfpu/expd64.c: Existing code only accounts for
+ positive 'n' in e^n. This fix allows for e^-n, which is just 1/(e^n).
+
2011-11-16 Ryan S. Arnold <rsa@xxxxxxxxxxxxxxxxxx>
* README.user: Updated with instructions for using #include <dfp/ >.
Modified: libdfp/trunk/Makefile.in
==============================================================================
--- libdfp/trunk/Makefile.in (original)
+++ libdfp/trunk/Makefile.in Thu Dec 1 21:31:31 2011
@@ -214,6 +214,7 @@
@echo
# Build the shared object files.
+#.c.os: $(if $(findstring %, $(libdfp_tests)), $(top_srcdir)/tests/scaffold.c)
.c.os:
$(CC) $(CFLAGS) $(mzarch) -c $< $(C_DEFINES) $(WARNS) -include $(top_srcdir)/include/libdfp-symbols.h -include $(top_builddir)/config.h $(foreach dir, $(header_search_dirs), -I$(dir)) $(glibc_headers_dir) -o $@
@echo
@@ -319,7 +320,13 @@
libdfp_tests = test-printf test-param test-amort test-decode test-quantize \
test-isnan test-isinf test-isfinite test-fpclassify test-logd \
test-log10d test-strtod test-numdigits test-get_digits \
- test-round test-bfp-conversions test-stdlib test-wchar
+ test-round test-bfp-conversions test-stdlib test-wchar \
+ test-expd
+
+# Empty rule which simply makes the libdfp_tests .so's dependent on
+# tests/scaffold.c so that when the scaffold file changes all of the test .so
+# files are rebuilt since almost all of them depend on the scaffold anyway.
+$(addsuffix .os, $(libdfp_tests)): $(top_srcdir)/tests/scaffold.c
# Explicitly link against the uninstalled GLIBC and the Libdfp.so.1 we just
# built.
Modified: libdfp/trunk/README.user
==============================================================================
--- libdfp/trunk/README.user (original)
+++ libdfp/trunk/README.user Thu Dec 1 21:31:31 2011
@@ -32,6 +32,7 @@
4.2 GLIBC Minimum Version
4.3 GCC With --enable-decimal-float Support
5. _Decimal* Data Types
+ 5.1 C++ Interoperability
6. DFP Headers
7. Compile and Link
8. Unsupported/Non-Standard Additions
@@ -226,6 +227,40 @@
The following will result in a binary-float to decimal-float conversion:
_Decimal64 d64 = 1.0;
+
+
+5.1 C++ Interoperability
+---------------------------------------------------------------------------
+C++ does not natively use the ISO C DFP _Decimal[32|64|128] types.
+
+Per the C++ DFP specification: ISO/IEC JTC1 SC22 WG21 N2732 "Extension for
+the programming language C++ to support decimal floating point arithmetic",
+the header float.h shall include the following C-compatibility convenience
+typedefs:
+
+ typedef std::decimal::decimal32 _Decimal32;
+ typedef std::decimal::decimal64 _Decimal64;
+ typedef std::decimal::decimal128 _Decimal128;
+
+This allows C++ programs, which use the native decimal32, decimal64, and
+decimal128 types to use the _Decimal32, _Decimal64, and_Decimal128
+types.
+
+Your compiler may or may not yet have this defined in float.h. If it is
+not defined you will need to define them yourself before including any dfp
+headers, e.g.,
+
+ #ifndef _Decimal32
+ typedef std::decimal::decimal32 _Decimal32;
+ #endif
+ #ifndef _Decimal64
+ typedef std::decimal::decimal64 _Decimal64;
+ #endif
+ #ifndef _Decimal128
+ typedef std::decimal::decimal128 _Decimal128;
+ #endif
+
+ #include <dfp/stdlib.h>
---------------------------------------------------------------------------
6. DFP Headers
Modified: libdfp/trunk/sysdeps/powerpc/dfpu/expd64.c
==============================================================================
--- libdfp/trunk/sysdeps/powerpc/dfpu/expd64.c (original)
+++ libdfp/trunk/sysdeps/powerpc/dfpu/expd64.c Thu Dec 1 21:31:31 2011
@@ -56,12 +56,20 @@
long exp;
long tmp;
+ int neg = 0;
+
if (__isinfd64(val))
{
if (val < DFP_CONSTANT(0.0))
return DFP_CONSTANT(0.0); /* exp(-inf) = 0 */
else
return val; /* exp(inf) = inf */
+ }
+
+ if (val < DFP_CONSTANT(0.0))
+ {
+ neg = 1;
+ val = FUNC_D(fabs) (val);
}
tmp = val;
@@ -164,6 +172,10 @@
else
result = 1.DD;
}
+
+ if (neg)
+ result = 1/result;
+
return result;
}
Modified: libdfp/trunk/tests/scaffold.c
==============================================================================
--- libdfp/trunk/tests/scaffold.c (original)
+++ libdfp/trunk/tests/scaffold.c Thu Dec 1 21:31:31 2011
@@ -82,6 +82,48 @@
#define _PC(x,y,...) _PC_P (__FILE__,__LINE__,x,y,__VA_ARGS__)
#endif /* _PC */
#endif /* _WANT_PC */
+
+/* Approximate Value Compare (takes a variation limit) */
+#ifdef _WANT_AVC
+static char bufx[CHAR_MAX];
+static char bufy[CHAR_MAX];
+static char bufz[CHAR_MAX];
+#ifndef _AVC
+/* _AVC_P == Approximate Value Compare with Position */
+#define _AVC_P(f,l,x,y,lim,fmt,lfmt) do { \
+ ++testnum; \
+ memset(bufx,'\0',CHAR_MAX); \
+ memset(bufy,'\0',CHAR_MAX); \
+ memset(bufz,'\0',CHAR_MAX); \
+ /* Invokes printf dfp. */ \
+ sprintf(bufx, fmt, x); \
+ sprintf(bufy, fmt, y); \
+ sprintf(bufz, lfmt, lim); \
+ if(y<(x+lim) && y>(x+lim)) { \
+ fprintf(stderr, "%-3d Error: Expected: \"%s\"\n", testnum, bufx); \
+ fprintf(stderr, " Result: \"%s\"\n", bufy); \
+ fprintf(stderr, " lim: \"%s\"\n", bufz); \
+ fprintf(stderr, " in: %s:%d.\n\n", f,l); \
+ ++fail; \
+ } else { \
+ fprintf(stdout, "%-3d Success: Expected: \"%s\"\n", testnum, bufx); \
+ fprintf(stdout, " Result: \"%s\"\n", bufy); \
+ fprintf(stderr, " lim: \"%s\"\n", bufz); \
+ fprintf(stdout, " in: %s:%d.\n\n", f,l); \
+ } \
+} while (0)
+
+/* _AVC == Approximate Value Compare
+ *
+ * Macro used to compare the result of an operation against an approximate expected result.
+ * X: Expected Value
+ * Y: Actual Value
+ * lim: The variation +/- from the expected that the actual can fall into for a
+ * "success"
+ */
+#define _AVC(x,y,lim, fmt,lfmt) _AVC_P (__FILE__,__LINE__,x,y,lim, fmt,lfmt)
+#endif /* _AVC */
+#endif /* _WANT_AVC */
#ifdef _WANT_VC
static char bufx[CHAR_MAX];
_______________________________________________
Commits mailing list
Commits@xxxxxxxxxx
http://eglibc.org/cgi-bin/mailman/listinfo/commits