[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r10517 - in /libdfp/trunk: ./ include/ tests/



Author: ryanarn
Date: Thu May 20 14:47:47 2010
New Revision: 10517

Log:
2010-05-20  Ryan S. Arnold  <rsa@xxxxxxxxxx>

	* Makefile.in: Allow make check to work without --with-glibc-build.
	* tests/test-printf.c: Removed register_printf_dfp() invocation.
	* tests/test-amort.c: New file which is an amortiation benchmark.
	* tests/scaffold.c: Changed <decode.h> to "decode.h".
	* tests/decode.h (_DFP_DECODE_H): Added _DFP onto guard.
	* tests/debug-test.sh: Allow make check to work without
	--with-glibc-build by either debugging the app or the loader.
	* configure.ac: Incrememented the library version from 1.0.1 to 1.0.2
	due to the addition of the libdfp constructor which no longer requires
	register_printf_dfp().
	* README.user: More todos.
	* include/init_dfp.h (__libdfp_init): New file to add constructor
	prototype.
	* Makefile.gdb: Allow make check to work without --with-glibc-build.
	* init_dfp.c (__libdfp_init): New file.  Add a constructor to call
	register_printf_dfp().

Added:
    libdfp/trunk/include/init_dfp.h
    libdfp/trunk/init_dfp.c
    libdfp/trunk/tests/test-amort.c
Modified:
    libdfp/trunk/Makefile.gdb
    libdfp/trunk/Makefile.in
    libdfp/trunk/README.user
    libdfp/trunk/configure.ac
    libdfp/trunk/tests/debug-test.sh
    libdfp/trunk/tests/decode.h
    libdfp/trunk/tests/scaffold.c
    libdfp/trunk/tests/test-printf.c

Modified: libdfp/trunk/Makefile.gdb
==============================================================================
--- libdfp/trunk/Makefile.gdb (original)
+++ libdfp/trunk/Makefile.gdb Thu May 20 14:47:47 2010
@@ -19,22 +19,45 @@
 	@echo 'GDB_SCRIPT="$(patsubst %.conf,%,$@).gdb"' > $@
 	@echo 'APP="$(patsubst %.conf,%,$@)"' >> $@
 	@echo 'APP_SRC="$(patsubst %.conf,%,$@).c"' >> $@
+ifneq ($(glibc_builddir),)
+	@echo 'APP_OR_LOADER="$(glibc_builddir)/elf/ld.so"' >> $@
+else
+	@echo 'APP_OR_LOADER="$(top_builddir)/$(patsubst %.conf,%,$@)"' >> $@
+endif
 	@echo
 
+#$(addsuffix .gdb,$(libdfp_tests)): $(top_builddir)/$(patsubst %.gdb,%,$@)
 $(addsuffix .gdb,$(libdfp_tests)): $(libdfp_tests)
 	echo "Generating GDB script $@"
 	@echo 'set environment C -E -x c-header' > $@
+	@echo 'set environment LD_LIBRARY_PATH=$(top_builddir)/:$$LD_LIBRARY_PATH' >> $@
+ifneq ($(glibc_builddir),)
 	@echo 'break _dl_main_dispatch' >> $@
 	@echo 'run --library-path $(LIBRARY_PATH):$(glibc_builddir)/nptl_db:$(top_builddir)/ $(top_builddir)/$(patsubst %.gdb,%,$@)' >> $@
+else
+	@echo 'break main' >> $@
+	@echo 'run' >> $@
+endif
 	@echo '' >> $@
 	@echo -n 'add-symbol-file $(top_builddir)/$(patsubst %.gdb,%,$@) 0x' >> $@
 	@echo `$(dir $(firstword $(CC)))objdump -s --section=".text" $(top_builddir)/$(patsubst %.gdb,%,$@) | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}'` >> $@
 	@echo '' >> $@
 	@echo 'set $$libc = 0x' >> $@
 	@echo -n 'set $$start = 0x' >> $@
+ifneq ($(glibc_builddir),)
 	@echo `$(dir $(firstword $(CC)))objdump -s --section=".text" $(glibc_builddir)/libc.so | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}'` >> $@
+else
+	@$(dir $(firstword $(CC)))objdump -s --section=".text" `ldd $(patsubst %.gdb,%,$@) | grep libc.so | awk -F' ' '{print $$3}'` | grep Contents -A 1 | tail -n 1 | awk -F' ' '{printf $$1}' >> $@
+	@echo >> $@
+endif
 	@echo 'set $$addr = $$libc + $$start' >> $@
-	@echo 'add-symbol-file $(glibc_builddir)/libc.so $$addr' >> $@
+	@echo -n 'add-symbol-file ' >> $@
+ifneq ($(glibc_builddir),)
+	@echo -n '$(glibc_builddir)/libc.so' >> $@
+else
+	@echo -n `ldd $(patsubst %.gdb,%,$@) | grep libc.so | awk -F' ' '{print $$3}'` >> $@
+endif
+	@echo ' $$addr' >> $@
 	@echo '' >> $@
 	@echo 'set $$libdfp = 0x' >> $@
 	@echo -n 'set $$start = 0x' >> $@

Modified: libdfp/trunk/Makefile.in
==============================================================================
--- libdfp/trunk/Makefile.in (original)
+++ libdfp/trunk/Makefile.in Thu May 20 14:47:47 2010
@@ -164,14 +164,13 @@
 # directory Makefiles which are included (not recursively invoked).
 libdfp_files := dfptypeconv mapround decode fmt_d32 fmt_d64 fmt_d128 fe_decround \
 		strtod32 strtod64 strtod128 wcstod32 wcstod64 wcstod128 \
-	        printf_dfp
+		printf_dfp init_dfp
 
 # The sysdeps subdirs aren't recursively invoked, they're included so that
 # they can add files to the libdfp_files list.
 include $(foreach dir,$(makefile_dirs), $(dir)/Makefile )
 
 # Libdfp has a dependency on the backend so build that first.
-#all: first backend libdfp
 all: first $(dfp_backend)/$(dfp_backend_lib) libdfp
 
 # Fake rule to output the VPATH before we build anything.  Don't use .PHONY
@@ -198,7 +197,7 @@
 # $(SHARED_SONAME_LIB) symlink is created by ldconfig be reading the `soname'
 # from the SHARED_REALNAME_LIB.
 shared: $(top_builddir)/$(SHARED_REALNAME_LIB)  $(top_builddir)/$(SHARED_LINKERNAME_LIB) $(top_builddir)/$(SHARED_SONAME_LIB)
-	@echo Building shared lib and symlinks: $(notdir $?)
+	@echo +Building shared lib and symlinks: $(notdir $?)
 
 WARNS := -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wno-long-long
 C_DEFINES := -D__STDC_DEC_FP__=200704L -D__STDC_WANT_DEC_FP__=1 -DOPTION_EGLIBC_LOCALE_CODE=1 -D_POSIX_C_SOURCE=200809L -std=gnu99 -D_SVID_SOURCE
@@ -233,7 +232,7 @@
 
 # Create libdfp.so -> libdfp.so.1 symlink.
 $(top_builddir)/$(SHARED_LINKERNAME_LIB): $(top_builddir)/$(SHARED_REALNAME_LIB)
-	@echo "Creating linker .so symlink $(notdir $@) -> $(notdir $?)"
+	@echo "+Creating linker .so symlink $(notdir $@) -> $(notdir $?)"
 	ln -f -s $? $@
 	@echo
 
@@ -241,7 +240,7 @@
 # The $(SHARED_SONAME_LIB) -> $(SHARED_REALNAME_LIB) symlink is supposed to
 # be created by ldconfig be reading the `soname' from the SHARED_REALNAME_LIB.
 $(top_builddir)/$(SHARED_SONAME_LIB): $(top_builddir)/$(SHARED_REALNAME_LIB)
-	@echo "Running ldconfig to create the library compat symlink $(notdir $@) -> $(notdir $?)"
+	@echo "+Running ldconfig to create the library compat symlink $(notdir $@) -> $(notdir $?)"
 	$(LDCONFIG) -l $(notdir $?)
 	@echo
 
@@ -297,13 +296,18 @@
 # versions.awk which generates libdfp.map implicitly.
 $(top_builddir)/libdfp.map: $(top_builddir)/sysd-versions
 
+
+ifeq ($(glibc_builddir),)
+GLIBC_LIBS := -lc -lm -lpthread
+else
 GLIBC_LIBS := $(glibc_builddir)/libc.so $(glibc_builddir)/math/libm.so $(glibc_builddir)/nptl/libpthread.so
-
-libdfp_tests = test-printf test-param
+endif
+
+libdfp_tests = test-printf test-param test-amort
 
 # Explicitly link against the uninstalled GLIBC and the Libdfp.so.1 we just
 # built.
-$(libdfp_tests): %:%.o
+$(libdfp_tests): %:%.o $(top_builddir)/$(SHARED_SONAME_LIB)
 	$(CC) $(CFLAGS) $(GLIBC_LIBS) $(top_builddir)/$(SHARED_SONAME_LIB) $(top_builddir)/$(addsuffix .o,$@) -o $@
 	@echo
 
@@ -313,12 +317,20 @@
 # the .gdb files are generated before the tests are run so that they get
 # generated even if the tests fail.  Stderr is piped to the .out file while
 # stdout is dumped to /dev/null.
+#$(addsuffix .out,$(libdfp_tests)): $(libdfp_tests) $(addsuffix .gdb,$(patsubst %.out,%,$@))
 $(addsuffix .out,$(libdfp_tests)): $(libdfp_tests) $(addsuffix .gdb,$(libdfp_tests))
-	ulimit -c unlimited; GCONV_PATH=$(glibc_builddir)/iconvdata LC_ALL=C \
+ifneq ($(glibc_builddir),)
+	ulimit -c unlimited; \
+	GCONV_PATH=$(glibc_builddir)/iconvdata LC_ALL=C \
 	$(glibc_builddir)/elf/ld.so --library-path \
-	$(LIBRARY_PATH):$(top_builddir) $(top_builddir)/$(patsubst %.out,%,$@) \
+	$(LIBRARY_PATH):$(top_builddir) \
+	$(top_builddir)/$(patsubst %.out,%,$@) \
 	2> $(top_builddir)/$@ 1> /dev/null
 	@echo
+else
+	LD_LIBRARY_PATH=$(top_builddir)/:$$LD_LIBRARY_PATH $(top_builddir)/$(patsubst %.out,%,$@) 2> $(top_builddir)/$@ 1> /dev/null
+	@echo
+endif
 
 DISTCLEANFILES = $(top_builddir)/debug-test.conf
 
@@ -337,8 +349,6 @@
 	rm *.o *.os $(STATIC_LIB) $(SHARED_LINKERNAME_LIB) $(SHARED_SONAME_LIB) $(SHARED_REALNAME_LIB) Versions.all Versions.sysdeps libdfp.map Versions.tmp sysd-versions $(top_builddir)/$(dfp_backend)/*.o $(top_builddir)/$(dfp_backend)/*.a debug-test.conf $(addsuffix .out,$(libdfp_tests)) $(addsuffix .conf,$(libdfp_tests)) $(addsuffix .gdb,$(libdfp_tests)) $(libdfp_tests)
 
 .PHONY: clean
-
-#install_to := $(patsubst %/,%,$(install_root))
 
 install: all
 	$(INSTALL) -d $(inst_libdir)

Modified: libdfp/trunk/README.user
==============================================================================
--- libdfp/trunk/README.user (original)
+++ libdfp/trunk/README.user Thu May 20 14:47:47 2010
@@ -156,9 +156,8 @@
 Decimal Floating Point types by executing the following function prior to
 execution of printf with DFP types:
 
-	#include <dfp.h>
+	#include <dfp/dfp.h>
 	register_printf_dfp();
-	printf
 
 After registration of the DFP printf-hooks printf will recognize the following
 length modifiers:

Modified: libdfp/trunk/configure.ac
==============================================================================
--- libdfp/trunk/configure.ac (original)
+++ libdfp/trunk/configure.ac Thu May 20 14:47:47 2010
@@ -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.1, rsa@xxxxxxxxxx)
+AC_INIT(libdfp, 1.0.2, rsa@xxxxxxxxxx)
 AC_CONFIG_SRCDIR([printf_dfp.c])
 
 # We don't use Automake so this is necessary.

Added: libdfp/trunk/include/init_dfp.h
==============================================================================
--- libdfp/trunk/include/init_dfp.h (added)
+++ libdfp/trunk/include/init_dfp.h Thu May 20 14:47:47 2010
@@ -1,0 +1,31 @@
+/* Libdfp constructor prototype.
+
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   This file is part of the Decimal Floating Point C Library.
+
+   Author(s): Ryan S. Arnold <rsa@xxxxxxxxxx>
+
+   The Decimal Floating Point C Library is free software; you can
+   redistribute it and/or modify it under the terms of the GNU Lesser
+   General Public License version 2.1.
+
+   The Decimal Floating Point C Library is distributed in the hope that
+   it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+   the GNU Lesser General Public License version 2.1 for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License version 2.1 along with the Decimal Floating Point C Library;
+   if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+   Suite 330, Boston, MA 02111-1307 USA.
+
+   Please see dfp/COPYING.txt for more information.  */
+
+#ifndef	_INIT_DFP_H
+
+#define	_INIT_DFP_H	1
+
+extern void __libdfp_init (void);
+
+#endif

Added: libdfp/trunk/init_dfp.c
==============================================================================
--- libdfp/trunk/init_dfp.c (added)
+++ libdfp/trunk/init_dfp.c Thu May 20 14:47:47 2010
@@ -1,0 +1,33 @@
+/* Libdfp constructor and destructor functions.
+
+   Copyright (C) 2010, Free Software Foundation, Inc.
+
+   This file is part of the Decimal Floating Point C Library.
+
+   Author(s): Ryan S. Arnold <rsa@xxxxxxxxxx>
+
+   The Decimal Floating Point C Library is free software; you can
+   redistribute it and/or modify it under the terms of the GNU Lesser
+   General Public License version 2.1.
+
+   The Decimal Floating Point C Library is distributed in the hope that
+   it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+   the GNU Lesser General Public License version 2.1 for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License version 2.1 along with the Decimal Floating Point C Library;
+   if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+   Suite 330, Boston, MA 02111-1307 USA.
+
+   Please see libdfp/COPYING.txt for more information.  */
+
+#include <dfp/dfp.h>
+#include <init_dfp.h>
+
+void __attribute__ ((constructor)) __attribute__((visibility ("hidden")))
+__libdfp_init (void)
+{
+  /* At present this doesn't ever fail so we don't care about a return code.  */
+  register_printf_dfp();
+}

Modified: libdfp/trunk/tests/debug-test.sh
==============================================================================
--- libdfp/trunk/tests/debug-test.sh (original)
+++ libdfp/trunk/tests/debug-test.sh Thu May 20 14:47:47 2010
@@ -6,4 +6,6 @@
 	source debug-test.conf
 	source $1
 
-$DBG -x ${GDB_SCRIPT} -d ${LIBDFP_SRC} ${GLIBC_BUILD}/elf/ld.so
+# Depending on whether a [system|standalone] loader or a non-installed glibc
+# build's loader this will be invoked differently.
+$DBG -x ${GDB_SCRIPT} -d ${LIBDFP_SRC} ${APP_OR_LOADER}

Modified: libdfp/trunk/tests/decode.h
==============================================================================
--- libdfp/trunk/tests/decode.h (original)
+++ libdfp/trunk/tests/decode.h Thu May 20 14:47:47 2010
@@ -1,6 +1,6 @@
 /* Prototypes for decode functions, which output the DPD declets.
 
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 
    This file is part of the Decimal Floating Point C Library.
 
@@ -22,8 +22,8 @@
 
    Please see libdfp/COPYING.txt for more information.  */
 
-#ifndef _DECODE_H
-#define _DECODE_H
+#ifndef _DFP_DECODE_H
+#define _DFP_DECODE_H
 
 /* char * should ref a 14 byte char array, +0,000,000E+0\0  */
 extern char * decoded32 (_Decimal32, char*);
@@ -33,4 +33,4 @@
  * +0,000,000,000,000,000,000,000,000,000,000,000E+0\0  */
 extern char * decoded128 (_Decimal128, char*);
 
-#endif /* _DECODE_H  */
+#endif /* _DFP_DECODE_H  */

Modified: libdfp/trunk/tests/scaffold.c
==============================================================================
--- libdfp/trunk/tests/scaffold.c (original)
+++ libdfp/trunk/tests/scaffold.c Thu May 20 14:47:47 2010
@@ -24,6 +24,7 @@
 
 
 #include <stdio.h>
+#include "decode.h"
 
 #ifndef _C
 #include <string.h>

Added: libdfp/trunk/tests/test-amort.c
==============================================================================
--- libdfp/trunk/tests/test-amort.c (added)
+++ libdfp/trunk/tests/test-amort.c Thu May 20 14:47:47 2010
@@ -1,0 +1,366 @@
+/*
+set -ex
+
+gcc -m64 -O2 -g -D__STDC_WANT_DEC_FP__=1 -std=gnu99 test_amort.c -ldfp -ldecnumber -lm -o test_amort64
+
+gcc -m64 -O2 -g -D__STDC_WANT_DEC_FP__=1 -std=gnu99 test_amort.c -ldfp -ldecnumber -lm -o test_amort32
+
+gcc -m64 -O2 -mcpu=power6 -g -D__STDC_WANT_DEC_FP__=1 -std=gnu99 test_amort.c -ldfp -ldecnumber -lm -o test_amort64P6
+
+echo "generate input data"
+rm "amort.input"
+rm "test_amort.data"
+./test_amort64 10000.0 0.075 5.0
+./test_amort64 15000.0 0.050 5.0
+./test_amort64 20000.0 0.065 5.0
+./test_amort64 25000.0 0.080 5.0
+./test_amort64 30000.0 0.090 5.0
+
+./test_amort64 80000.0 0.055 20.0
+./test_amort64 120000.0 0.055 20.0
+./test_amort64 150000.0 0.055 20.0
+./test_amort64 185000.0 0.055 20.0
+./test_amort64 199500.0 0.055 20.0
+
+./test_amort64 180000.0 0.055 30.0
+./test_amort64 199500.0 0.055 30.0
+./test_amort64 210000.0 0.055 30.0
+./test_amort64 350000.0 0.055 30.0
+./test_amort64 550000.0 0.055 30.0
+
+echo "verify amortization tables"
+
+./test_amort64 -v > test_amort.data
+
+diff test_amort.verify.data test_amort.data
+
+echo "$?"
+
+echo "performance testing"
+
+./test_amort64 10000
+
+exit
+*/
+
+
+
+/* File test_amort.c created by sjmunroe on Mon Oct 30 2006. */
+/* -std=gnu99 */
+/* #define __STDC_WANT_DEC_FP__ 1 */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <float.h>
+#include <math.h>
+#include <sys/time.h>
+#include <dfp/dfp.h>
+
+//extern _Decimal64 powd64 (_Decimal64, _Decimal64);
+//extern _Decimal64 quantized64 (_Decimal64, _Decimal64);
+//extern _Decimal64 strtod64 (char *, char *);
+
+typedef struct
+{
+  _Decimal64
+    month,
+    payment,
+    interest_payed,
+    principal_payed, principal, accum_principal, accum_interest;
+} tabletype;
+
+tabletype *table;
+
+typedef struct
+{
+  _Decimal64 loan, rate, duration;
+} inputtype;
+
+static _Decimal64
+armort_monthly_payment (_Decimal64 loan, _Decimal64 yearly_rate,
+			_Decimal64 years)
+{
+  _Decimal64 payment = -1.0DD;
+  _Decimal64 months = years * 12.0DD;
+  _Decimal64 monthly_rate = yearly_rate / 12.0DD;
+  _Decimal64 temp0, temp1, temp2, temp3;
+
+  temp0 = 1.0DD / (1.0DD + monthly_rate);
+#ifdef __DEBUG_PRINT__
+  printf ("1/(1+r) = %Df\n", temp0);
+#endif
+  temp1 = 1.0DD - powd64 (temp0, months);
+#ifdef __DEBUG_PRINT__
+  printf ("1 - (1/(1+r))**n = %Df\n", temp1);
+#endif
+  temp2 = temp1 / monthly_rate;
+#ifdef __DEBUG_PRINT__
+  printf ("(1 - (1/(1+r))**n)/r = %Df\n", temp2);
+#endif
+  temp3 = loan / temp2;
+  payment = quantized64 (temp3, 1.00DD);
+#ifdef __DEBUG_PRINT__
+  printf ("quantized64(%Df, 1.00DD) = %Df\n", temp3, payment);
+#endif
+  return payment;
+}
+
+
+
+static void
+armort_monthly_table (_Decimal64 loan, _Decimal64 yearly_rate,
+		      _Decimal64 years, int format_enable,
+		      int print_enable)
+{
+  _Decimal64 months = years * 12.0DD;
+  _Decimal64 monthly_rate = yearly_rate / 12.0DD;
+  //_Decimal64 temp0, temp1, temp2, temp3;
+  _Decimal64 temp0;
+  _Decimal64 principal, principal_payed, interest_payed;
+  _Decimal64 accum_principal, accum_interest;
+  _Decimal64 payment;
+  char buf[80];
+
+  principal = loan;
+  accum_principal = 0.0DD;
+  accum_interest = 0.0DD;
+  
+  payment = armort_monthly_payment (loan,
+				    yearly_rate, years);
+  
+  if (format_enable)
+  {
+	  snprintf(buf, 80, "Loan %Df at %Df for %Df years payments %Df",
+		   loan, yearly_rate, years, payment);
+	  if (print_enable)
+	  {
+		  printf ("\n%s\n", buf);
+	  }
+  }
+
+  for (temp0 = 0.0DD; temp0 < (months); temp0 += 1.0DD)
+    {
+      interest_payed = quantized64 ((principal * monthly_rate), 1.00DD);
+      principal_payed = payment - interest_payed;
+      principal -= principal_payed;
+      accum_principal += principal_payed;
+      accum_interest += interest_payed;
+
+      if (temp0 >= (months - 1.0DD) && principal != 0.00DD)
+	{
+	  payment += principal;
+	  accum_principal += principal;
+	  principal = 0.00DD;
+	}
+
+	if (format_enable)
+      {
+        snprintf(buf, 80, "%Df: %Df-%Df=%Df, total(%Df,%Df) balance=%Df",
+         temp0, payment, interest_payed, principal_payed,
+         accum_interest, accum_principal, principal);
+	
+	if (print_enable)
+		printf ("%s\n", buf);
+      }
+      else 
+      {
+	tabletype *t;
+	t = table + (int) temp0;
+	t->month = temp0;
+	t->payment = payment;
+	t->interest_payed = interest_payed;
+	t->principal_payed = principal_payed;
+	t->accum_interest = accum_interest;
+	t->accum_principal = accum_principal;
+	t->principal = principal;
+      }
+    }
+
+  if ( principal > 0.0DD)
+  {
+	interest_payed = quantized64 ((principal * monthly_rate), 1.00DD);
+	principal_payed = payment - interest_payed;
+	principal -= principal_payed;
+	accum_principal += principal_payed;
+	accum_interest += interest_payed;
+	
+	if (principal != 0.00DD)
+	{
+	payment += principal;
+	accum_principal += principal;
+	principal = 0.00DD;
+	}
+	
+		if (format_enable)
+		{
+			snprintf(buf, 80, "%Df: %Df-%Df=%Df, total(%Df,%Df) balance=%Df\n",
+				temp0, payment, interest_payed, principal_payed,
+				accum_interest, accum_principal, principal);
+			if (print_enable)
+			{
+				printf ("%s\n", buf);
+			}
+		}
+  }
+}
+
+static void
+armort_verifier (inputtype *inputs, int numinputs)
+{
+//	_Decimal64 payment;
+	int i;
+	
+	for (i = 0; i < numinputs; i++)
+	{
+		inputtype *input = &inputs[i];
+
+		armort_monthly_table (input->loan,
+				      input->rate, 
+				      input->duration, 
+				      1,
+				      1);
+	}
+}
+
+typedef long long msec_t;
+
+static msec_t
+		getTimeOfDayMsec (void)
+{
+	msec_t result, msecs;
+	struct timeval time;
+	int rc;
+
+	rc = gettimeofday (&time, NULL);
+	if (rc == 0)
+	{
+		msecs = (msec_t) ((time.tv_usec + 500) / 1000);
+		result = (msec_t) (time.tv_sec);
+		result = (result * 1000) + msecs;
+	}
+	else
+	{
+		result = 0;
+	}
+
+	return result;
+}
+
+int
+main (int argc, char *argv[])
+{
+  int i, iterations;
+  msec_t startt, endt, deltat;
+  double mill_sec;
+  inputtype *inputs;
+  int numinputs;
+  FILE *inputfile;
+  char inputfilename[] = "amort.input";
+  char *argv_option;
+
+  table = (tabletype *) malloc (30 * 12 * sizeof (tabletype));
+  //printf ("table@%p for %d bytes\n", table, (30 * 12 * sizeof (tabletype)));
+  iterations = 50000;
+
+  if (argc < 2)
+	 {
+		 printf ("This application requires parameters.\n");
+		 return 0;
+	 }
+
+  argv_option = argv[1];
+  if (*argv_option == '-')
+	{
+		argv_option++;
+		if (*argv_option == 'v')
+			;
+		else {
+			printf ("only v is valid %s is not\n", argv[1]);
+			return 2;
+		}
+	} else {
+		argv_option = " ";
+		if (argc >= 4)
+		{
+			inputtype input;
+			input.loan = strtod64 (argv[1], NULL);
+			input.rate = strtod64 (argv[2], NULL);
+			input.duration = strtod64 (argv[3], NULL);
+			if ( input.duration > 30.0DD)
+				{
+				printf ("Maximum duration is 30 years, exiting\n");
+				return 1;
+				}
+			
+			inputfile = fopen (inputfilename, "a");
+			printf ("loan=%Df rate=%Df duration=%Df added to %s\n",
+				input.loan, input.rate, input.duration, inputfilename);
+			fwrite (&input, sizeof (inputtype), 1, inputfile);
+			fclose (inputfile);
+			return 0;
+		}
+		else
+		{
+		iterations = atoi (argv[1]);
+		}
+	}
+
+  inputfile = fopen (inputfilename, "r");
+  fseek (inputfile, 0, SEEK_END);
+  numinputs = ftell (inputfile) / sizeof (inputtype);
+  rewind (inputfile);
+  inputs = malloc (numinputs * sizeof (inputtype));
+  fread (inputs, sizeof (inputtype), numinputs, inputfile);
+  fclose (inputfile);
+
+  if (*argv_option == 'v')
+  {
+	  armort_verifier(inputs, numinputs);
+	  return 0;
+  }
+  
+  startt = getTimeOfDayMsec ();
+
+  for (i = 0; i < iterations; i++)
+    {
+      inputtype *input = &inputs[i % numinputs];
+
+      /*printf ("armort_monthly_payment(%Df,%Df,%Df) = %Df\n",
+         169900.0DD, 0.0725DD, 30.0DD, 0, 0); */
+      armort_monthly_table (input->loan,
+			    input->rate, 
+			    input->duration, 
+			    0, 0);
+    }
+
+  endt = getTimeOfDayMsec ();
+  deltat = endt - startt;
+  mill_sec = (double) deltat / 1000.0;
+
+  printf (" %d iterations of amort w/o formating requires %12.3f seconds\n", iterations,
+	  mill_sec);
+  
+  startt = getTimeOfDayMsec ();
+
+  for (i = 0; i < iterations; i++)
+  {
+	  inputtype *input = &inputs[i % numinputs];
+
+      /*printf ("armort_monthly_payment(%Df,%Df,%Df) = %Df\n",
+	  169900.0DD, 0.0725DD, 30.0DD, 0, 0); */
+	  armort_monthly_table (input->loan,
+				input->rate, 
+				input->duration, 
+				1, 0);
+  }
+
+  endt = getTimeOfDayMsec ();
+  deltat = endt - startt;
+  mill_sec = (double) deltat / 1000.0;
+
+  printf (" %d iterations of amort with formating requires %12.3f seconds\n", iterations,
+	  mill_sec);
+
+  return 0;
+}

Modified: libdfp/trunk/tests/test-printf.c
==============================================================================
--- libdfp/trunk/tests/test-printf.c (original)
+++ libdfp/trunk/tests/test-printf.c Thu May 20 14:47:47 2010
@@ -59,16 +59,6 @@
 {
   d128_type *dptr;
 
-  fprintf(stdout, "Testing marker prior to register_printf_dfp() invocation.\n");
-  _PC("1.234567e+00", "%e", (double) 1.234567);
-
-  register_printf_dfp();
-
-  /* We do this to make sure that the registration didn't mess up the printf
-   * internals.  */
-  fprintf(stdout, "Testing marker after register_printf_dfp() invocation.\n");
-  _PC("1.234567e+00", "%e", (double) 1.234567);
-
   for (dptr = printf_d128s; dptr->line; dptr++)
     {
       _PC_P(__FILE__,dptr->line, dptr->expect,dptr->format,dptr->d);