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

[commits] r4902 - in /branches/libdfp/libc: ./ dfp/ dfp/sysdeps/dfp/ dfp/sysdeps/dfp/math/ dfp/sysdeps/dfp/math/bits/ dfp/sysdeps/dfp/...



Author: eberlein
Date: Tue Jan 15 13:45:22 2008
New Revision: 4902

Log:
2008-01-15  Pete Eberlein  <eberlein@xxxxxxxxxx>


	* stdlib/stdlib.h: Merged DFP code.
	* wcsmbs/wchar.h: Merged DFP code.
	* configure.in: Added --enable-decimal-float option.
	* math/math.h: Merged DFP code.
	* math/fenv.h: Merged DFP code.
	* math/bits/mathcalls.h: Merged DFP code.
	* config.h.in: Added __STDC_DEC_FP__ define.
	* stdio-common/printf.h: Merged DFP code.
	* stdio-common/vfprintf.c: Merged DFP code.
	* stdio-common/vfscanf.c: Merged DFP code.
	* stdio-common/printf-parse.h: Merged DFP code.
	* configure: Regenerated.
	* dfp/sysdeps/powerpc/powerpc32/power6/fpu/Versions: Changed to GLIBC_2.6.
	* dfp/sysdeps/powerpc/powerpc64/power6/fpu/Versions: Changed to GLIBC_2.6.
	* dfp/sysdeps/soft-dfp/Versions: Changed to GLIBC_2.6.
	* dfp/sysdeps/dfp/stdlib/stdlib.h: Deleted file.
	* dfp/sysdeps/dfp/stdio-common/vfprintf.c: Deleted file.
	* dfp/sysdeps/dfp/stdio-common/printf-parse.h: Deleted file.
	* dfp/sysdeps/dfp/stdio-common/vfscanf.c: Deleted file.
	* dfp/sysdeps/dfp/stdio-common/printf.h: Deleted file.
	* dfp/sysdeps/dfp/Versions: Changed to GLIBC_2.6
	* dfp/sysdeps/dfp/math/math.h: Deleted file.
	* dfp/sysdeps/dfp/math/bits: Deleted file.
	* dfp/sysdeps/dfp/math/bits/mathcalls.h: Deleted file.
	* dfp/sysdeps/dfp/math/fenv.h: Deleted file.
	* dfp/sysdeps/dfp/wcsmbs/wchar.h: Deleted file.
	* dfp/Versions.def: Changed to GLIBC_2.6.
	* dfp/Versions: Changed to GLIBC_2.6.
	* dfp/Makefile: No longer build libdecnumber.so, instead only libdfp.so.


Removed:
    branches/libdfp/libc/dfp/sysdeps/dfp/math/bits/
    branches/libdfp/libc/dfp/sysdeps/dfp/math/fenv.h
    branches/libdfp/libc/dfp/sysdeps/dfp/math/math.h
    branches/libdfp/libc/dfp/sysdeps/dfp/stdio-common/printf-parse.h
    branches/libdfp/libc/dfp/sysdeps/dfp/stdio-common/printf.h
    branches/libdfp/libc/dfp/sysdeps/dfp/stdio-common/vfprintf.c
    branches/libdfp/libc/dfp/sysdeps/dfp/stdio-common/vfscanf.c
    branches/libdfp/libc/dfp/sysdeps/dfp/stdlib/stdlib.h
    branches/libdfp/libc/dfp/sysdeps/dfp/wcsmbs/wchar.h
Modified:
    branches/libdfp/libc/config.h.in
    branches/libdfp/libc/configure
    branches/libdfp/libc/configure.in
    branches/libdfp/libc/dfp/Makefile
    branches/libdfp/libc/dfp/Versions
    branches/libdfp/libc/dfp/Versions.def
    branches/libdfp/libc/dfp/sysdeps/dfp/Versions
    branches/libdfp/libc/dfp/sysdeps/powerpc/powerpc32/power6/fpu/Versions
    branches/libdfp/libc/dfp/sysdeps/powerpc/powerpc64/power6/fpu/Versions
    branches/libdfp/libc/dfp/sysdeps/soft-dfp/Versions
    branches/libdfp/libc/math/bits/mathcalls.h
    branches/libdfp/libc/math/fenv.h
    branches/libdfp/libc/math/math.h
    branches/libdfp/libc/stdio-common/printf-parse.h
    branches/libdfp/libc/stdio-common/printf.h
    branches/libdfp/libc/stdio-common/vfprintf.c
    branches/libdfp/libc/stdio-common/vfscanf.c
    branches/libdfp/libc/stdlib/stdlib.h
    branches/libdfp/libc/wcsmbs/wchar.h

Modified: branches/libdfp/libc/config.h.in
==============================================================================
--- branches/libdfp/libc/config.h.in (original)
+++ branches/libdfp/libc/config.h.in Tue Jan 15 13:45:22 2008
@@ -188,6 +188,9 @@
 
 /* Define if __stack_chk_guard canary should be randomized at program startup.  */
 #undef ENABLE_STACKGUARD_RANDOMIZE
+
+/* Define if decimal floating point support is desired.  */
+#undef __STDC_DEC_FP__
 
 /*
  */

Modified: branches/libdfp/libc/configure
==============================================================================
--- branches/libdfp/libc/configure (original)
+++ branches/libdfp/libc/configure Tue Jan 15 13:45:22 2008
@@ -313,7 +313,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS with_fp with_cvs enable_check_abi oldest_abi bindnow force_install all_warnings build build_cpu build_vendor build_os host host_cpu host_vendor host_os subdirs add_ons add_on_subdirs base_machine submachine sysnames sysdeps_add_ons INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC OBJEXT BUILD_CC cross_compiling CPP CXX CXXFLAGS ac_ct_CXX AR NM OBJDUMP RANLIB ac_ct_RANLIB MIG AS LD PWD_P MAKE MSGFMT MAKEINFO SED AUTOCONF SYSINCLUDES CXX_SYSINCLUDES libc_cv_gcc_static_libgcc BASH_SHELL libc_cv_have_bash2 KSH libc_cv_have_ksh AWK PERL INSTALL_INFO BISON VERSIONING libc_cv_cc_with_libunwind libc_cv_Bgroup libc_cv_libgcc_s_suffix libc_cv_as_needed ASFLAGS_config libc_cv_z_combreloc libc_cv_z_execstack libc_cv_fpie libc_cv_hashstyle fno_unit_at_a_time libc_cv_ssp libc_cv_gnu89_inline libc_cv_have_initfini no_whole_archive exceptions LIBGD have_libaudit have_libcap have_selinux EGREP sizeof_long_double libc_cv_gcc_unwind_find_fde uname_sysname uname_release uname_version old_glibc_headers libc_cv_slibdir libc_cv_localedir libc_cv_sysconfdir libc_cv_rootsbindir libc_cv_forced_unwind use_ldconfig ldd_rewrite_script elf xcoff static shared pic_default profile omitfp bounded static_nss nopic_initfini DEFINES mach_interface_list VERSION RELEASE LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS with_fp with_cvs enable_check_abi oldest_abi bindnow force_install all_warnings libc_cv_cc_with_decimal_float build build_cpu build_vendor build_os host host_cpu host_vendor host_os subdirs add_ons add_on_subdirs base_machine submachine sysnames sysdeps_add_ons INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC OBJEXT BUILD_CC cross_compiling CPP CXX CXXFLAGS ac_ct_CXX AR NM OBJDUMP RANLIB ac_ct_RANLIB MIG AS LD PWD_P MAKE MSGFMT MAKEINFO SED AUTOCONF SYSINCLUDES CXX_SYSINCLUDES libc_cv_gcc_static_libgcc BASH_SHELL libc_cv_have_bash2 KSH libc_cv_have_ksh AWK PERL INSTALL_INFO BISON VERSIONING libc_cv_cc_with_libunwind libc_cv_Bgroup libc_cv_libgcc_s_suffix libc_cv_as_needed ASFLAGS_config libc_cv_z_combreloc libc_cv_z_execstack libc_cv_fpie libc_cv_hashstyle fno_unit_at_a_time libc_cv_ssp libc_cv_gnu89_inline libc_cv_have_initfini no_whole_archive exceptions LIBGD have_libaudit have_libcap have_selinux EGREP sizeof_long_double libc_cv_gcc_unwind_find_fde uname_sysname uname_release uname_version old_glibc_headers libc_cv_slibdir libc_cv_localedir libc_cv_sysconfdir libc_cv_rootsbindir libc_cv_forced_unwind use_ldconfig ldd_rewrite_script elf xcoff static shared pic_default profile omitfp bounded static_nss nopic_initfini DEFINES mach_interface_list VERSION RELEASE LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -905,6 +905,7 @@
                           default]
   --with-tls              enable support for TLS
   --without-__thread      do not use TLS features even when supporting them
+  --decimal-float         enable support for decimal floating point.
   --with-cpu=CPU          select code for CPU variant
 
 Some influential environment variables:
@@ -1690,6 +1691,45 @@
   enableval="$enable_all_warnings"
   all_warnings=$enableval
 fi;
+
+
+
+# Check whether --with-decimal-float or --without-decimal-float was given.
+if test "${with_decimal_float+set}" = set; then
+  withval="$with_decimal_float"
+  usedfp=$withval
+else
+  usedfp=yes
+fi;
+if test "$usedfp" != no; then
+# Check to make sure the compiler supports decimal floating point.
+echo "$as_me:$LINENO: checking for decimal-float-support in compiler" >&5
+echo $ECHO_N "checking for decimal-float-support in compiler... $ECHO_C" >&6
+if test "${libc_cv_cc_with_decimal_float+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+  cat > conftest.c <<EOF
+int main (void) { _Decimal32 d32; d32 = 1.0D; return 0; }
+EOF
+  if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
+     conftest.c -v 2>&1 >/dev/null | grep -q " --enable-decimal-float ";
+then
+    libc_cv_cc_with_decimal_float=yes
+  else
+    libc_cv_cc_with_decimal_float=no
+  fi
+  rm -f conftest*
+fi
+echo "$as_me:$LINENO: result: $libc_cv_cc_with_decimal_float" >&5
+echo "${ECHO_T}$libc_cv_cc_with_decimal_float" >&6
+
+if test $libc_cv_cc_with_decimal_float = yes; then
+  cat >> confdefs.h <<\EOF
+#define __STDC_DEC_FP__ 200704L
+EOF
+fi
+fi
 
 
 # Make sure we can run config.sub.
@@ -8464,6 +8504,7 @@
 s,@bindnow@,$bindnow,;t t
 s,@force_install@,$force_install,;t t
 s,@all_warnings@,$all_warnings,;t t
+s,@libc_cv_cc_with_decimal_float@,$libc_cv_cc_with_decimal_float,;t t
 s,@build@,$build,;t t
 s,@build_cpu@,$build_cpu,;t t
 s,@build_vendor@,$build_vendor,;t t

Modified: branches/libdfp/libc/configure.in
==============================================================================
--- branches/libdfp/libc/configure.in (original)
+++ branches/libdfp/libc/configure.in Tue Jan 15 13:45:22 2008
@@ -253,6 +253,35 @@
 	      [all_warnings=$enableval],
 	      [])
 AC_SUBST(all_warnings)
+
+AC_ARG_WITH([decimal-float],
+	    AC_HELP_STRING([--decimal-float],
+			   [enable support for decimal floating point.]),
+	    [usedfp=$withval],
+	    [usedfp=yes])
+if test "$usedfp" != no; then
+# Check to make sure the compiler supports decimal floating point.
+AC_CACHE_CHECK(for decimal-float-support in compiler,
+               libc_cv_cc_with_decimal_float, [
+  cat > conftest.c <<EOF
+int main (void) { _Decimal32 d32; d32 = 1.0D; return 0; }
+EOF
+  if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
+     conftest.c -v 2>&1 >/dev/null | grep -q " --enable-decimal-float ";
+then
+    libc_cv_cc_with_decimal_float=yes
+  else
+    libc_cv_cc_with_decimal_float=no
+  fi
+  rm -f conftest*])
+AC_SUBST(libc_cv_cc_with_decimal_float)
+if test $libc_cv_cc_with_decimal_float = yes; then
+  cat >> confdefs.h <<\EOF
+#define __STDC_DEC_FP__ 200704L
+EOF
+fi
+fi
+
 
 AC_CANONICAL_HOST
 

Modified: branches/libdfp/libc/dfp/Makefile
==============================================================================
--- branches/libdfp/libc/dfp/Makefile (original)
+++ branches/libdfp/libc/dfp/Makefile Tue Jan 15 13:45:22 2008
@@ -4,8 +4,8 @@
 
 # Build the -ldfp and -libdecnumber libraries.
 
-#extra-libs := libdfp
-extra-libs := libdfp libdecnumber
+extra-libs := libdfp
+#extra-libs := libdfp libdecnumber
 extra-libs-others := $(extra-libs)
 # install-lib-ldscripts := libdfp.so
 
@@ -15,16 +15,17 @@
 
 
 # Some symbols need to be in libdfp.so as well as libc.
-libdfp-shared = fmt_d32 fmt_d64 fmt_d128 dfptypeconv decode-decimal
+libdfp-shared = fmt_d32 fmt_d64 fmt_d128 dfptypeconv decode-decimal \
+	decNumber decimal32 decimal64 decimal128 decContext
 
 # The libdecnumber printing functions need to be in libc.so as well as
 # libdecnumber.
-libdecnumber-shared = decNumber decimal32 decimal64 decimal128 decContext
+#libdecnumber-shared = decNumber decimal32 decimal64 decimal128 decContext
 
 include ../Makeconfig
 
 # libDecNumber contains some functionality which isn't needed in libc.
-libdecnumber-routines := $(libdecnumber-shared) decNumberMath
+#libdecnumber-routines := $(libdecnumber-shared) decNumberMath
 
 # These get added to libdfp.  Anything in $(libdfp-shared) gets
 # added to libc.so as well because they're the printf helpers.
@@ -98,11 +99,12 @@
 	fmodd32 fmodd64 fmodd128 \
 	hypotd32 hypotd64 hypotd128 \
 	fmad32 fmad64 fmad128 \
-	mapround fe_decround
+	mapround fe_decround \
+	decNumberMath
 
 # Some of these functions are picked up out of the dfp/sysdeps/dfp directory
 # due to the sysdeps/unix/sysv/linux/Implies sydeps/dfp/Subdirs chain.
-routines = $(libdecnumber-shared:%=libc_%) $(libdfp-shared:%=libc_%) \
+routines = $(libdfp-shared:%=libc_%) \
 	decroundtls strtod32 strtod64 strtod128 \
 	wcstod32 wcstod64 wcstod128 printf_dfp printf_dfphex
 
@@ -198,10 +200,10 @@
 
 # Required to get libdfp linked against the test cases.
 ifeq ($(build-shared),yes)
-$(addprefix $(objpfx),$(tests)): $(objpfx)libdfp.so$(libdfp.so-version) $(objpfx)libdecnumber.so$(libdecnumber.so-version)
+$(addprefix $(objpfx),$(tests)): $(objpfx)libdfp.so$(libdfp.so-version)
 endif
 
 # libc is required for libdfp in order to query the rounding mode when
 # invoking dfp functions because we need the TLS functions.
 # We current link libm.so because we need _LIB_VERSION.
-$(objpfx)libdfp.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a $(common-objpfx)dfp/libdecnumber.so $(common-objpfx)math/libm.so
+$(objpfx)libdfp.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a $(common-objpfx)math/libm.so

Modified: branches/libdfp/libc/dfp/Versions
==============================================================================
--- branches/libdfp/libc/dfp/Versions (original)
+++ branches/libdfp/libc/dfp/Versions Tue Jan 15 13:45:22 2008
@@ -1,5 +1,5 @@
 libdfp {
-  GLIBC_2.5 {
+  GLIBC_2.6 {
     # functions potentially used in other libraries
     fe_dec_getround;
     fe_dec_setround;
@@ -220,66 +220,11 @@
     __isnand32;
     __isnand64;
     __isnand128;
-  };
-}
-libc {
-  GLIBC_2.5 {
-    __decrm_location;
-    strtod32;
-    strtod64;
-    strtod128;
-    wcstod32;
-    wcstod64;
-    wcstod128;
-  };
-}
-libdecnumber {
-  GLIBC_2.5 {
-#    ___decNumberFromString;
-#    ___decNumberToString;
-#    ___decNumberToEngString;
-#    ___decNumberAbs;
-#    ___decNumberAdd;
-#    ___decNumberCompare;
-#    ___decNumberCompareTotal;
-#    ___decNumberDivide;
-#    ___decNumberDivideInteger;
-#    ___decNumberExp;
-#    ___decNumberFromInt32;
-#    ___decNumberFromUInt32;
-#    ___decNumberLn;
-#    ___decNumberLog10;
-#    ___decNumberMax;
-#    ___decNumberMin;
-#    ___decNumberMinus;
-#    ___decNumberMultiply;
-#    ___decNumberNormalize;
-#    ___decNumberPlus;
-#    ___decNumberPower;
-#    ___decNumberQuantize;
-#    ___decNumberRemainder;
-#    ___decNumberRemainderNear;
-#    ___decNumberRescale;
-#    ___decNumberSameQuantum;
-#    ___decNumberScaleB;
-#    ___decNumberSquareRoot;
-#    ___decNumberSubtract;
-#    ___decNumberToIntegralValue;
-#    ___decNumberCopy;
-#    ___decNumberTrim;
-#    ___decNumberVersion;
-#    ___decNumberZero;
-#    ___decContextDefault;
-#    ___decContextSetStatus;
-#    ___decContextStatusToString;
-#    ___decContextSetStatusFromString;
-#    ___decNumberLog10;
-#    ___decNumberLn;
-#    ___decNumberExp;
-
-#    ___decNumberSquareRoot;
-#    ___decNumberMin;
-#    ___decNumberMax;
+
+#  };
+#}
+#libdecnumber {
+#  GLIBC_2.6 {
 
 # From decContext.c
     ___decContextClearStatus;
@@ -390,3 +335,15 @@
     ___decimal32ToNumber;
   };
 }
+libc {
+  GLIBC_2.6 {
+    __decrm_location;
+    strtod32;
+    strtod64;
+    strtod128;
+    wcstod32;
+    wcstod64;
+    wcstod128;
+  };
+}
+

Modified: branches/libdfp/libc/dfp/Versions.def
==============================================================================
--- branches/libdfp/libc/dfp/Versions.def (original)
+++ branches/libdfp/libc/dfp/Versions.def Tue Jan 15 13:45:22 2008
@@ -1,6 +1,6 @@
 libdfp {
-  GLIBC_2.5
+  GLIBC_2.6
 }
-libdecnumber {
-  GLIBC_2.5
-}
+#libdecnumber {
+#  GLIBC_2.6
+#}

Modified: branches/libdfp/libc/dfp/sysdeps/dfp/Versions
==============================================================================
--- branches/libdfp/libc/dfp/sysdeps/dfp/Versions (original)
+++ branches/libdfp/libc/dfp/sysdeps/dfp/Versions Tue Jan 15 13:45:22 2008
@@ -1,5 +1,5 @@
 libc {
-  GLIBC_2.5 {
+  GLIBC_2.6 {
     # functions used in other libraries
     __printf_dfp;
   };

Modified: branches/libdfp/libc/dfp/sysdeps/powerpc/powerpc32/power6/fpu/Versions
==============================================================================
--- branches/libdfp/libc/dfp/sysdeps/powerpc/powerpc32/power6/fpu/Versions (original)
+++ branches/libdfp/libc/dfp/sysdeps/powerpc/powerpc32/power6/fpu/Versions Tue Jan 15 13:45:22 2008
@@ -1,5 +1,5 @@
 libdfp {
-  GLIBC_2.5 {
+  GLIBC_2.6 {
     __addsd3; __adddd3; __addtd3;
     __subsd3; __subdd3; __subtd3;
     __mulsd3; __muldd3; __multd3;

Modified: branches/libdfp/libc/dfp/sysdeps/powerpc/powerpc64/power6/fpu/Versions
==============================================================================
--- branches/libdfp/libc/dfp/sysdeps/powerpc/powerpc64/power6/fpu/Versions (original)
+++ branches/libdfp/libc/dfp/sysdeps/powerpc/powerpc64/power6/fpu/Versions Tue Jan 15 13:45:22 2008
@@ -1,5 +1,5 @@
 libdfp {
-  GLIBC_2.5 {
+  GLIBC_2.6 {
     __addsd3; __adddd3; __addtd3;
     __subsd3; __subdd3; __subtd3;
     __mulsd3; __muldd3; __multd3;

Modified: branches/libdfp/libc/dfp/sysdeps/soft-dfp/Versions
==============================================================================
--- branches/libdfp/libc/dfp/sysdeps/soft-dfp/Versions (original)
+++ branches/libdfp/libc/dfp/sysdeps/soft-dfp/Versions Tue Jan 15 13:45:22 2008
@@ -1,5 +1,5 @@
 libdfp {
-  GLIBC_2.5 {
+  GLIBC_2.6 {
     __addsd3; __adddd3; __addtd3;
     __subsd3; __subdd3; __subtd3;
     __mulsd3; __muldd3; __multd3;

Modified: branches/libdfp/libc/math/bits/mathcalls.h
==============================================================================
--- branches/libdfp/libc/math/bits/mathcalls.h (original)
+++ branches/libdfp/libc/math/bits/mathcalls.h Tue Jan 15 13:45:22 2008
@@ -281,7 +281,9 @@
 
 /* Return X + epsilon if X < Y, X - epsilon if X > Y.  */
 __MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
-# if defined __USE_ISOC99 && !defined __LDBL_COMPAT
+# if defined __STDC_WANT_DEC_FP__ && __USE_DEC_FP_NEXTTOWARD__
+__MATHCALLX (nexttoward,, (_Mdouble_ __x, _Decimal128 __y), (__const__));
+# elif defined __USE_ISOC99 && !defined __LDBL_COMPAT
 __MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__));
 # endif
 

Modified: branches/libdfp/libc/math/fenv.h
==============================================================================
--- branches/libdfp/libc/math/fenv.h (original)
+++ branches/libdfp/libc/math/fenv.h Tue Jan 15 13:45:22 2008
@@ -56,6 +56,10 @@
    FE_TOWARDZERO	round toward 0
 */
 #include <bits/fenv.h>
+
+#ifdef __STDC_WANT_DEC_FP__
+#  include <bits/dfpfenv.h>
+#endif
 
 __BEGIN_DECLS
 

Modified: branches/libdfp/libc/math/math.h
==============================================================================
--- branches/libdfp/libc/math/math.h (original)
+++ branches/libdfp/libc/math/math.h Tue Jan 15 13:45:22 2008
@@ -64,6 +64,10 @@
 #define __MATHDECL_1(type, function,suffix, args) \
   extern type __MATH_PRECNAME(function,suffix) args __THROW
 
+#ifdef __USE_DEC_FP_NEXTTOWARD__
+#undef __USE_DEC_FP_NEXTTOWARD__
+#endif
+
 #define _Mdouble_ 		double
 #define __MATH_PRECNAME(name,r)	__CONCAT(name,r)
 # define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
@@ -73,6 +77,87 @@
 #undef _Mdouble_BEGIN_NAMESPACE
 #undef _Mdouble_END_NAMESPACE
 #undef	__MATH_PRECNAME
+
+/* Decimal-Floating point support is outlined in ISO proposed C-specification
+   WG14 N1176 and IEEE 754r.  */
+#ifdef __STDC_WANT_DEC_FP__
+#define DEC_INFINITY	__builtin_infd32()
+#define DEC_NAN		(0.0DF * DEC_INFINITY)
+# define HUGE_VAL_D64	__builtin_infd64()
+/*# define DEC_INFINITY   (9999999.E96DF + 1.E96df)
+#define DEC_NAN (0.0DF * DEC_INFINITY)
+# define HUGE_VAL_D64   (9.999999999999999E384DD + 1.E384dd) */
+# define HUGE_VAL_D32	HUGE_VAL_D64
+# define HUGE_VAL_D128	HUGE_VAL_D64
+
+/* this causes the nexttoward mathcall to get a _Decimal128 second parameter
+ * rather than a long double one.  */
+#define __USE_DEC_FP_NEXTTOWARD__ 1
+
+#define __dfp_compatible(X) ((_Decimal128)(__typeof__(X))1.E-50DL == 1.E-50DL)
+
+/* For _Decimal32  */
+# ifndef _M_Decimal32_
+#  define _M_Decimal32_		_Decimal32
+# endif
+# define _Mdouble_		_M_Decimal32_
+# ifdef __STDC__
+#  define __MATH_PRECNAME(name,r) name##d32##r
+# else
+#  define __MATH_PRECNAME(name,r) name/**/d32/**/r
+# endif
+# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
+# define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99
+# include <bits/mathcalls.h>
+# include <bits/dfpcalls.h>
+# undef	_Mdouble_
+# undef _Mdouble_BEGIN_NAMESPACE
+# undef _Mdouble_END_NAMESPACE
+# undef	__MATH_PRECNAME
+
+/* For _Decimal64 */
+# ifndef _M_Decimal64_
+#  define _M_Decimal64_		_Decimal64
+# endif
+# define _Mdouble_		_M_Decimal64_
+# ifdef __STDC__
+#  define __MATH_PRECNAME(name,r) name##d64##r
+# else
+#  define __MATH_PRECNAME(name,r) name/**/d64/**/r
+# endif
+# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
+# define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99
+# include <bits/mathcalls.h>
+# include <bits/dfpcalls.h>
+# undef	_Mdouble_
+# undef _Mdouble_BEGIN_NAMESPACE
+# undef _Mdouble_END_NAMESPACE
+# undef	__MATH_PRECNAME
+
+/* For _Decimal128 */
+# ifndef _M_Decimal128_
+#  define _M_Decimal128_	_Decimal128
+# endif
+# define _Mdouble_		_M_Decimal128_
+# ifdef __STDC__
+#  define __MATH_PRECNAME(name,r) name##d128##r
+# else
+#  define __MATH_PRECNAME(name,r) name/**/d128/**/r
+# endif
+# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
+# define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99
+# include <bits/mathcalls.h>
+# include <bits/dfpcalls.h>
+# undef	_Mdouble_
+# undef _Mdouble_BEGIN_NAMESPACE
+# undef _Mdouble_END_NAMESPACE
+# undef	__MATH_PRECNAME
+
+#endif /* __STDC_WANT_DEC_FP__  */
+
+#ifdef __USE_DEC_FP_NEXTTOWARD__
+#undef __USE_DEC_FP_NEXTTOWARD__
+#endif
 
 #if defined __USE_MISC || defined __USE_ISOC99
 
@@ -194,7 +279,8 @@
 
 */
 
-/* All floating-point numbers can be put in one of these categories.  */
+/* All decimal and binary floating-point numbers can be put in one of these
+   categories.  */
 enum
   {
     FP_NAN,
@@ -211,66 +297,140 @@
 
 /* Return number of classification appropriate for X.  */
 # ifdef __NO_LONG_DOUBLE_MATH
-#  define fpclassify(x) \
+#  define ____fpclassify(x) \
      (sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x))
 # else
-#  define fpclassify(x) \
+#  define ____fpclassify(x) \
      (sizeof (x) == sizeof (float)					      \
       ? __fpclassifyf (x)						      \
       : sizeof (x) == sizeof (double)					      \
       ? __fpclassify (x) : __fpclassifyl (x))
 # endif
 
+# ifdef __STDC_WANT_DEC_FP__
+#  define fpclassify(x) \
+     (									      \
+       (!__dfp_compatible(x)? (____fpclassify(x)) :			      \
+	 (sizeof (x) == sizeof (_Decimal128)? __fpclassifyd128(x):	      \
+	    (sizeof (x) == sizeof (_Decimal64)? __fpclassifyd64(x):	      \
+	      __fpclassifyd32(x)					      \
+	    )								      \
+	 )								      \
+       )								      \
+     )
+# else
+#  define fpclassify(x) ____fpclassify(x)
+# endif
+
 /* Return nonzero value if sign of X is negative.  */
 # ifdef __NO_LONG_DOUBLE_MATH
-#  define signbit(x) \
+#  define ____signbit(x) \
      (sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x))
 # else
-#  define signbit(x) \
+#  define ____signbit(x) \
      (sizeof (x) == sizeof (float)					      \
       ? __signbitf (x)							      \
       : sizeof (x) == sizeof (double)					      \
       ? __signbit (x) : __signbitl (x))
 # endif
 
+# ifdef __STDC_WANT_DEC_FP__
+#  define signbit(x) \
+     (									      \
+       (!__dfp_compatible(x)? (____signbit(x)) :			      \
+	 (sizeof (x) == sizeof (_Decimal128)? __signbitd128(x):		      \
+	    (sizeof (x) == sizeof (_Decimal64)? __signbitd64(x):	      \
+	      __signbitd32(x)						      \
+	    )								      \
+	 )								      \
+       )								      \
+     )
+# else
+#  define signbit(x) ____signbit(x)
+# endif
+
 /* Return nonzero value if X is not +-Inf or NaN.  */
 # ifdef __NO_LONG_DOUBLE_MATH
-#  define isfinite(x) \
+#  define ____isfinite(x) \
      (sizeof (x) == sizeof (float) ? __finitef (x) : __finite (x))
 # else
-#  define isfinite(x) \
+#  define ____isfinite(x) \
      (sizeof (x) == sizeof (float)					      \
       ? __finitef (x)							      \
       : sizeof (x) == sizeof (double)					      \
       ? __finite (x) : __finitel (x))
 # endif
 
+# ifdef __STDC_WANT_DEC_FP__
+#  define isfinite(x) \
+     (									      \
+       (!__dfp_compatible(x)? (____isfinite(x)) :			      \
+	 (sizeof (x) == sizeof (_Decimal128)? __finited128(x):	      \
+	    (sizeof (x) == sizeof (_Decimal64)? __finited64(x):	      \
+	      __finited32(x)						      \
+	    )								      \
+	 )								      \
+       )								      \
+     )
+# else
+#  define isfinite(x) ____isfinite(x)
+# endif
+
 /* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN.  */
 # define isnormal(x) (fpclassify (x) == FP_NORMAL)
 
 /* Return nonzero value if X is a NaN.  We could use `fpclassify' but
    we already have this functions `__isnan' and it is faster.  */
 # ifdef __NO_LONG_DOUBLE_MATH
+#  define ____isnan(x) \
+     (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
+# else
+#  define ____isnan(x) \
+     (sizeof (x) == sizeof (float)		      \
+      ? __isnanf (x)				      \
+      : sizeof (x) == sizeof (double)		      \
+      ? __isnan (x) : __isnanl (x))
+# endif
+
+# ifdef __STDC_WANT_DEC_FP__
 #  define isnan(x) \
-     (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
-# else
-#  define isnan(x) \
-     (sizeof (x) == sizeof (float)					      \
-      ? __isnanf (x)							      \
-      : sizeof (x) == sizeof (double)					      \
-      ? __isnan (x) : __isnanl (x))
+     (!__dfp_compatible(x)			      \
+      ? (____isnan(x))				      \
+      : (sizeof (x) == sizeof (_Decimal128)	      \
+	? __isnand128(x)			      \
+	: (sizeof (x) == sizeof (_Decimal64)	      \
+	  ? __isnand64(x)			      \
+	  : __isnand32(x)))			      \
+     )
+# else
+#  define isnan(x) ____isnan(x)
 # endif
 
 /* Return nonzero value is X is positive or negative infinity.  */
 # ifdef __NO_LONG_DOUBLE_MATH
-#  define isinf(x) \
+#  define _____isinf(x) \
      (sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x))
 # else
-#  define isinf(x) \
+#  define ____isinf(x) \
      (sizeof (x) == sizeof (float)					      \
       ? __isinff (x)							      \
       : sizeof (x) == sizeof (double)					      \
       ? __isinf (x) : __isinfl (x))
+# endif
+
+# ifdef __STDC_WANT_DEC_FP__
+#  define isinf(x) \
+     (									      \
+       (!__dfp_compatible(x)? (____isinf(x)) :				      \
+	 (sizeof (x) == sizeof (_Decimal128)? __isinfd128(x):		      \
+	    (sizeof (x) == sizeof (_Decimal64)? __isinfd64(x):		      \
+	      __isinfd32(x)						      \
+	    )								      \
+	 )								      \
+       )								      \
+     )
+# else
+#  define isinf(x) ____isinf(x)
 # endif
 
 /* Bitmasks for the math_errhandling macro.  */
@@ -381,6 +541,23 @@
 # define M_SQRT1_2l	0.7071067811865475244008443621048490L  /* 1/sqrt(2) */
 #endif
 
+/* Some useful constants for DFP support (with the DL specifier).  Proper
+ * truncation to DD and DF will be handled by libdfp. */
+#ifdef __STDC_WANT_DEC_FP__
+#  define M_Edl		2.7182818284590452353602874713526625DL  /* e */
+#  define M_LOG2Edl	1.4426950408889634073599246810018921DL  /* log_2 e */
+#  define M_LOG10Edl	0.4342944819032518276511289189166051DL  /* log_10 e */
+#  define M_LN2dl	0.6931471805599453094172321214581766DL  /* log_e 2 */
+#  define M_LN10dl	2.3025850929940456840179914546843642DL  /* log_e 10 */
+#  define M_PIdl	3.1415926535897932384626433832795029DL  /* pi */
+#  define M_PI_2dl	1.5707963267948966192313216916397514DL  /* pi/2 */
+#  define M_PI_4dl	0.7853981633974483096156608458198757DL  /* pi/4 */
+#  define M_1_PIdl	0.3183098861837906715377675267450287DL  /* 1/pi */
+#  define M_2_PIdl	0.6366197723675813430755350534900574DL  /* 2/pi */
+#  define M_2_SQRTPIdl	1.1283791670955125738961589031215452DL  /* 2/sqrt(pi) */
+#  define M_SQRT2dl	1.4142135623730950488016887242096981DL  /* sqrt(2) */
+#  define M_SQRT1_2dl	0.7071067811865475244008443621048490DL  /* 1/sqrt(2) */
+#endif /* __STDC_WANT_DEC_FP__  */
 
 /* When compiling in strict ISO C compatible mode we must not use the
    inline functions since they, among other things, do not set the

Modified: branches/libdfp/libc/stdio-common/printf-parse.h
==============================================================================
--- branches/libdfp/libc/stdio-common/printf-parse.h (original)
+++ branches/libdfp/libc/stdio-common/printf-parse.h Tue Jan 15 13:45:22 2008
@@ -60,6 +60,11 @@
     const char *pa_string;
     const wchar_t *pa_wstring;
     void *pa_pointer;
+#ifdef __STDC_DEC_FP__
+    _Decimal128 pa_decimal128;
+    _Decimal64 pa_decimal64;
+    _Decimal32 pa_decimal32;
+#endif
   };
 
 

Modified: branches/libdfp/libc/stdio-common/printf.h
==============================================================================
--- branches/libdfp/libc/stdio-common/printf.h (original)
+++ branches/libdfp/libc/stdio-common/printf.h Tue Jan 15 13:45:22 2008
@@ -48,6 +48,9 @@
   unsigned int is_char:1;	/* hh flag.  */
   unsigned int wide:1;		/* Nonzero for wide character streams.  */
   unsigned int i18n:1;		/* I flag.  */
+#ifdef __STDC_DEC_FP__
+  unsigned int is_decimal:1;    /* H/D/DD flags.  */
+#endif
   wchar_t pad;			/* Padding character.  */
 };
 
@@ -112,6 +115,9 @@
   PA_POINTER,			/* void * */
   PA_FLOAT,			/* float */
   PA_DOUBLE,			/* double */
+#ifdef __STDC_DEC_FP__
+  PA_DECIMAL,                   /* _Decimal* types */
+#endif
   PA_LAST
 };
 

Modified: branches/libdfp/libc/stdio-common/vfprintf.c
==============================================================================
--- branches/libdfp/libc/stdio-common/vfprintf.c (original)
+++ branches/libdfp/libc/stdio-common/vfprintf.c Tue Jan 15 13:45:22 2008
@@ -31,6 +31,12 @@
 #include "_itoa.h"
 #include <locale/localeinfo.h>
 #include <stdio.h>
+#ifdef __STDC_DEC_FP__
+#include <printf_dfp.h>
+#define IFDEF__STDC_DEC_FP__(...) __VA_ARGS__
+#else
+#define IFDEF__STDC_DEC_FP__(...)
+#endif
 
 /* This code is shared between the standard stdio implementation found
    in GNU C library and the libio implementation originally found in
@@ -236,8 +242,13 @@
     /* '8' */  8, /* '9' */  8,            0,            0,
 	       0,            0,            0,            0,
 	       0, /* 'A' */ 26,            0, /* 'C' */ 25,
+#ifdef __STDC_DEC_FP__
+    /* 'D' */ 31, /* 'E' */ 19, /* F */   19, /* 'G' */ 19,
+    /* 'H' */ 30, /* 'I' */ 29,            0,            0,
+#else
 	       0, /* 'E' */ 19, /* F */   19, /* 'G' */ 19,
 	       0, /* 'I' */ 29,            0,            0,
+#endif
     /* 'L' */ 12,            0,            0,            0,
 	       0,            0,            0, /* 'S' */ 21,
 	       0,            0,            0,            0,
@@ -285,7 +296,7 @@
 
 #define STEP0_3_TABLE							      \
     /* Step 0: at the beginning.  */					      \
-    static JUMP_TABLE_TYPE step0_jumps[30] =				      \
+    static JUMP_TABLE_TYPE step0_jumps[] =				      \
     {									      \
       REF (form_unknown),						      \
       REF (flag_space),		/* for ' ' */				      \
@@ -316,10 +327,14 @@
       REF (form_floathex),	/* for 'A', 'a' */			      \
       REF (mod_ptrdiff_t),      /* for 't' */				      \
       REF (mod_intmax_t),       /* for 'j' */				      \
-      REF (flag_i18n),	        /* for 'I' */				      \
+      REF (flag_i18n)	        /* for 'I' */				      \
+IFDEF__STDC_DEC_FP__(,						      \
+      REF (mod_decimal_half),   /* for 'H' */				      \
+      REF (mod_decimal)         /* for 'D' */				      \
+)									      \
     };									      \
     /* Step 1: after processing width.  */				      \
-    static JUMP_TABLE_TYPE step1_jumps[30] =				      \
+    static JUMP_TABLE_TYPE step1_jumps[] =				      \
     {									      \
       REF (form_unknown),						      \
       REF (form_unknown),	/* for ' ' */				      \
@@ -351,9 +366,13 @@
       REF (mod_ptrdiff_t),      /* for 't' */				      \
       REF (mod_intmax_t),       /* for 'j' */				      \
       REF (form_unknown)        /* for 'I' */				      \
+IFDEF__STDC_DEC_FP__(,						      \
+      REF (mod_decimal_half),   /* for 'H' */				      \
+      REF (mod_decimal),        /* for 'D' */				      \
+)									      \
     };									      \
     /* Step 2: after processing precision.  */				      \
-    static JUMP_TABLE_TYPE step2_jumps[30] =				      \
+    static JUMP_TABLE_TYPE step2_jumps[] =				      \
     {									      \
       REF (form_unknown),						      \
       REF (form_unknown),	/* for ' ' */				      \
@@ -385,9 +404,13 @@
       REF (mod_ptrdiff_t),      /* for 't' */				      \
       REF (mod_intmax_t),       /* for 'j' */				      \
       REF (form_unknown)        /* for 'I' */				      \
+IFDEF__STDC_DEC_FP__(,						      \
+      REF (mod_decimal_half),   /* for 'H' */				      \
+      REF (mod_decimal)         /* for 'D' */				      \
+)									      \
     };									      \
     /* Step 3a: after processing first 'h' modifier.  */		      \
-    static JUMP_TABLE_TYPE step3a_jumps[30] =				      \
+    static JUMP_TABLE_TYPE step3a_jumps[] =				      \
     {									      \
       REF (form_unknown),						      \
       REF (form_unknown),	/* for ' ' */				      \
@@ -419,9 +442,13 @@
       REF (form_unknown),       /* for 't' */				      \
       REF (form_unknown),       /* for 'j' */				      \
       REF (form_unknown)        /* for 'I' */				      \
+IFDEF__STDC_DEC_FP__(,						      \
+      REF (form_unknown),       /* for 'H' */				      \
+      REF (form_unknown)	/* for 'D' */				      \
+)									      \
     };									      \
     /* Step 3b: after processing first 'l' modifier.  */		      \
-    static JUMP_TABLE_TYPE step3b_jumps[30] =				      \
+    static JUMP_TABLE_TYPE step3b_jumps[] =				      \
     {									      \
       REF (form_unknown),						      \
       REF (form_unknown),	/* for ' ' */				      \
@@ -453,11 +480,52 @@
       REF (form_unknown),       /* for 't' */				      \
       REF (form_unknown),       /* for 'j' */				      \
       REF (form_unknown)        /* for 'I' */				      \
+IFDEF__STDC_DEC_FP__(,						      \
+      REF (form_unknown),       /* for 'H' */				      \
+      REF (form_unknown)        /* for 'D' */				      \
+    };									      \
+    /* Some format codes should not be allowed for decimal-float.  */	      \
+    /* Step 3c: after processing first 'D' modifier.  */		      \
+    static JUMP_TABLE_TYPE step3c_jumps[] =				      \
+    {									      \
+      REF (form_unknown),						      \
+      REF (form_unknown),	/* for ' ' */				      \
+      REF (form_unknown),	/* for '+' */				      \
+      REF (form_unknown),	/* for '-' */				      \
+      REF (form_unknown),	/* for '<hash>' */			      \
+      REF (form_unknown),	/* for '0' */				      \
+      REF (form_unknown),	/* for '\'' */				      \
+      REF (form_unknown),	/* for '*' */				      \
+      REF (form_unknown),	/* for '1'...'9' */			      \
+      REF (form_unknown),	/* for '.' */				      \
+      REF (form_unknown),	/* for 'h' */				      \
+      REF (form_unknown),	/* for 'l' */				      \
+      REF (form_unknown),	/* for 'L', 'q' */			      \
+      REF (form_unknown),	/* for 'z', 'Z' */			      \
+      REF (form_percent),	/* for '%' */				      \
+      REF (form_integer),	/* for 'd', 'i' */			      \
+      REF (form_unsigned),	/* for 'u' */				      \
+      REF (form_octal),		/* for 'o' */				      \
+      REF (form_hexa),		/* for 'X', 'x' */			      \
+      REF (form_float),		/* for 'E', 'e', 'F', 'f', 'G', 'g' */	      \
+      REF (form_character),	/* for 'c' */				      \
+      REF (form_string),	/* for 's', 'S' */			      \
+      REF (form_pointer),	/* for 'p' */				      \
+      REF (form_number),	/* for 'n' */				      \
+      REF (form_strerror),	/* for 'm' */				      \
+      REF (form_wcharacter),	/* for 'C' */				      \
+      REF (form_floathex),	/* for 'A', 'a' */			      \
+      REF (form_unknown),	/* for 't' */				      \
+      REF (form_unknown),	/* for 'j' */				      \
+      REF (form_unknown),	/* for 'I' */				      \
+      REF (form_unknown),	/* for 'H' */				      \
+      REF (mod_decimal_long)    /* for 'D' */				      \
+)									      \
     }
 
 #define STEP4_TABLE							      \
     /* Step 4: processing format specifier.  */				      \
-    static JUMP_TABLE_TYPE step4_jumps[30] =				      \
+    static JUMP_TABLE_TYPE step4_jumps[] =				      \
     {									      \
       REF (form_unknown),						      \
       REF (form_unknown),	/* for ' ' */				      \
@@ -489,6 +557,10 @@
       REF (form_unknown),       /* for 't' */				      \
       REF (form_unknown),       /* for 'j' */				      \
       REF (form_unknown)        /* for 'I' */				      \
+IFDEF__STDC_DEC_FP__(,						      \
+      REF (form_unknown),	/* for 'H' */				      \
+      REF (form_unknown)	/* for 'D' */				      \
+)									      \
     }
 
 
@@ -782,14 +854,30 @@
 					.pad = pad,			      \
 					.extra = 0,			      \
 					.i18n = use_outdigits,		      \
+IFDEF__STDC_DEC_FP__(		.is_decimal = is_decimal, )	      \
 					.wide = sizeof (CHAR_T) != 1 };	      \
 									      \
-	    if (is_long_double)						      \
+	    if (is_long_double IFDEF__STDC_DEC_FP__(&& !is_decimal))     \
 	      the_arg.pa_long_double = va_arg (ap, long double);	      \
+IFDEF__STDC_DEC_FP__(						      \
+	    else if (is_long_double && is_decimal)			      \
+	      the_arg.pa_decimal128 = va_arg (ap, _Decimal128);		      \
+	    else if (is_short && is_decimal)				      \
+	      /* The specification indicates that _Decimal32 should  */	      \
+	      /* NOT be promoted to _Decimal64 for DFP types.  */	      \
+	      the_arg.pa_decimal32 = va_arg (ap, _Decimal32);		      \
+	    else if (is_decimal && !is_long_double && !is_short)	      \
+	      the_arg.pa_decimal64 = va_arg (ap, _Decimal64);		      \
+)									      \
 	    else							      \
 	      the_arg.pa_double = va_arg (ap, double);			      \
 	    ptr = (const void *) &the_arg;				      \
 									      \
+IFDEF__STDC_DEC_FP__(						      \
+	    if (is_decimal)						      \
+	      function_done = __printf_dfp (s, &info, &ptr);		      \
+	    else							      \
+)									      \
 	    function_done = __printf_fp (s, &info, &ptr);		      \
 	  }								      \
 	else								      \
@@ -839,14 +927,28 @@
 					.group = group,			      \
 					.pad = pad,			      \
 					.extra = 0,			      \
+IFDEF__STDC_DEC_FP__(		.is_decimal = is_decimal, )	      \
 					.wide = sizeof (CHAR_T) != 1 };	      \
 									      \
-	    if (is_long_double)						      \
+	    if (is_long_double IFDEF__STDC_DEC_FP__(&& !is_decimal))     \
 	      the_arg.pa_long_double = va_arg (ap, long double);	      \
+IFDEF__STDC_DEC_FP__(						      \
+	    else if (is_long_double && is_decimal)			      \
+	      the_arg.pa_decimal128 = va_arg (ap, _Decimal128);		      \
+	    else if (is_short && is_decimal)				      \
+	      the_arg.pa_decimal32 = va_arg (ap, _Decimal32);		      \
+	    else if (is_decimal && !is_long_double && !is_short)	      \
+	      the_arg.pa_decimal64 = va_arg (ap, _Decimal64);		      \
+)									      \
 	    else							      \
 	      the_arg.pa_double = va_arg (ap, double);			      \
 	    ptr = (const void *) &the_arg;				      \
 									      \
+IFDEF__STDC_DEC_FP__(						      \
+	    if (is_decimal)						      \
+	      function_done = __printf_dfphex (s, &info, &ptr);		      \
+	    else							      \
+)									      \
 	    function_done = __printf_fphex (s, &info, &ptr);		      \
 	  }								      \
 	else								      \
@@ -855,6 +957,12 @@
 	    if (__ldbl_is_dbl)						      \
 	      fspec->info.is_long_double = 0;				      \
 									      \
+IFDEF__STDC_DEC_FP__(						      \
+	    /* FIX ME */						      \
+	    if (is_decimal)						      \
+	      function_done = __printf_dfphex (s, &fspec->info, &ptr);	      \
+	    else							      \
+)									      \
 	    function_done = __printf_fphex (s, &fspec->info, &ptr);	      \
 	  }								      \
 									      \
@@ -1336,6 +1444,9 @@
       int is_short = 0;	/* Argument is short int.  */
       int is_long = 0;	/* Argument is long int.  */
       int is_char = 0;	/* Argument is promoted (unsigned) char.  */
+#ifdef __STDC_DEC_FP__
+      int is_decimal = 0; /* Argument is decimal floating point.  */
+#endif
       int width = 0;	/* Width of output; 0 means none specified.  */
       int prec = -1;	/* Precision of output; -1 means none specified.  */
       /* This flag is set by the 'I' modifier and selects the use of the
@@ -1553,6 +1664,31 @@
       is_long = sizeof (intmax_t) > sizeof (unsigned int);
       JUMP (*++f, step4_jumps);
 
+#ifdef __STDC_DEC_FP__
+      /* Process 'H' modifier.  No other modifier is allowed to follow.  */
+    LABEL (mod_decimal_half):
+      is_decimal = 1;
+      is_short = 1;
+      JUMP (*++f, step4_jumps);
+
+      /* Process 'D' modifier.  There might be another 'D' following.  */
+    LABEL (mod_decimal):
+      is_decimal = 1;
+      is_short = 0;
+      is_long = 0;
+      JUMP (*++f, step3c_jumps);
+
+      /* Process 'DD' modifier.  */
+    LABEL (mod_decimal_long):
+      /* is_decimal = 0;  */
+      is_decimal = 1;
+      is_long_double = 1;
+      JUMP (*++f, step4_jumps);
+
+      /* The previous step3c_jumps or step4_jumps will jump directly
+       * to the LABELs defined in the process_arg macro.  */
+#endif
+
       /* Process current format.  */
       while (1)
 	{
@@ -1730,6 +1866,11 @@
 	T (PA_INT|PA_FLAG_LONG_LONG, pa_long_long_int, long long int);
 	T (PA_FLOAT, pa_double, double);	/* Promoted.  */
 	T (PA_DOUBLE, pa_double, double);
+#ifdef __STDC_DEC_FP__
+	T (PA_DECIMAL, pa_decimal32, _Decimal32);
+	T (PA_DECIMAL|PA_FLAG_SHORT, pa_decimal64, _Decimal64);
+	T (PA_DECIMAL|PA_FLAG_LONG_DOUBLE, pa_decimal128, _Decimal128);
+#endif
 	case PA_DOUBLE|PA_FLAG_LONG_DOUBLE:
 	  if (__ldbl_is_dbl)
 	    {
@@ -1792,6 +1933,9 @@
 	int width = specs[nspecs_done].info.width;
 	int prec = specs[nspecs_done].info.prec;
 	int use_outdigits = specs[nspecs_done].info.i18n;
+#ifdef __STDC_DEC_FP__
+	int is_decimal = specs[nspecs_done].info.is_decimal;
+#endif
 	char pad = specs[nspecs_done].info.pad;
 	CHAR_T spec = specs[nspecs_done].info.spec;
 

Modified: branches/libdfp/libc/stdio-common/vfscanf.c
==============================================================================
--- branches/libdfp/libc/stdio-common/vfscanf.c (original)
+++ branches/libdfp/libc/stdio-common/vfscanf.c Tue Jan 15 13:45:22 2008
@@ -24,6 +24,9 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
+#ifdef __STDC_DEC_FP__
+#include <dfpstdlib.h>
+#endif
 #include <string.h>
 #include <wchar.h>
 #include <wctype.h>
@@ -67,6 +70,9 @@
 #define READ_POINTER	0x1000	/* this is a pointer value */
 #define POSIX_MALLOC	0x2000	/* m: malloc strings */
 #define MALLOC		(GNU_MALLOC | POSIX_MALLOC)
+#ifdef __STDC_DEC_FP__
+#define DECIMAL		0x4000  /* H/D/DD: decimal float */
+#endif
 
 #include <locale/localeinfo.h>
 #include <libioP.h>
@@ -583,6 +589,9 @@
 	  skip_space = 0;
 	}
 
+#ifdef __STDC_DEC_FP__
+found_decimal:
+#endif
       switch (fc)
 	{
 	case L_('%'):	/* Must match a literal '%'.  */
@@ -1777,6 +1786,31 @@
 	    }
 	  break;
 
+#ifdef __STDC_DEC_FP__
+	case L_('H'):   /* _Decimal32  */
+	  base = 10;
+	  /*number_signed = 1;*/
+	  negative = 1;
+	  flags |= DECIMAL | SHORT;
+	  fc = *f++;
+	  /* Pick up trailing float modifier.  */
+	  goto found_decimal;
+
+	case L_('D'):   /* _Decimal64  */
+	  flags |= DECIMAL;
+	  base = 10;
+	  /*number_signed = 1;*/
+	  negative = 1;
+	  char tfc;
+	  tfc = *f++;
+	  if (tfc == L_('D'))  /* _Decimal128  */
+	    flags |= LONGDBL;
+	  else
+	    --f;        /* Only one 'D'.  Back it up.  It is not %DD.  */
+	  fc = *f++;
+	  /* Pick up trailing float modifier.  */
+	  goto found_decimal;
+#endif
 	case L_('e'):	/* Floating-point numbers.  */
 	case L_('E'):
 	case L_('f'):
@@ -2253,6 +2287,29 @@
 	scan_float:
 	  /* Convert the number.  */
 	  ADDW (L_('\0'));
+#ifdef __STDC_DEC_FP__
+	  if((flags & DECIMAL) && (flags & SHORT))
+	    {
+	      _Decimal32 d = __strtod32_internal(wp, &tw, flags & GROUP);
+	      if (!(flags & SUPPRESS) && tw != wp)
+	        /* va_arg is currently busted in libgcc for _Decimal32 so this
+	         * will segfault */
+	        *ARG (_Decimal32 *) = negative ? -d : d;
+	    }
+	  else if((flags & DECIMAL) && (flags & LONGDBL))
+	    {
+	      _Decimal128 d = __strtod128_internal(wp, &tw, flags & GROUP);
+	      if (!(flags & SUPPRESS) && tw != wp)
+	        *ARG (_Decimal128 *) = negative ? -d : d;
+	    }
+	  else if (flags & DECIMAL)
+	    {
+	      _Decimal64 d = __strtod64_internal(wp, &tw, flags & GROUP);
+	      if (!(flags & SUPPRESS) && tw != wp)
+	        *ARG (_Decimal64 *) = negative ? -d : d;
+	    }
+	  else
+#endif
 	  if ((flags & LONGDBL) && !__ldbl_is_dbl)
 	    {
 	      long double d = __strtold_internal (wp, &tw, flags & GROUP);

Modified: branches/libdfp/libc/stdlib/stdlib.h
==============================================================================
--- branches/libdfp/libc/stdlib/stdlib.h (original)
+++ branches/libdfp/libc/stdlib/stdlib.h Tue Jan 15 13:45:22 2008
@@ -217,6 +217,26 @@
      __THROW __nonnull ((1)) __wur;
 __END_NAMESPACE_C99
 #endif /* ISO C99 or GCC and use MISC.  */
+
+
+#ifdef __STDC_WANT_DEC_FP__
+__BEGIN_NAMESPACE_STD
+/* Convert a string to a _Decimal32 number.  */
+extern _Decimal32 strtod32 (__const char *__restrict __nptr,
+                     char **__restrict __endptr)
+     __THROW __nonnull ((1)) __wur;
+/* Convert a string to a _Decimal64 number.  */
+
+extern _Decimal64 strtod64 (__const char *__restrict __nptr,
+                     char **__restrict __endptr)
+     __THROW __nonnull ((1)) __wur;
+
+/* Convert a string to a _Decimal128 number.  */
+extern _Decimal128 strtod128 (__const char *__restrict __nptr,
+                     char **__restrict __endptr)
+     __THROW __nonnull ((1)) __wur;
+__END_NAMESPACE_STD
+#endif /* __STDC_WANT_DEC_FP__ */
 
 
 #ifdef __USE_GNU

Modified: branches/libdfp/libc/wcsmbs/wchar.h
==============================================================================
--- branches/libdfp/libc/wcsmbs/wchar.h (original)
+++ branches/libdfp/libc/wcsmbs/wchar.h Tue Jan 15 13:45:22 2008
@@ -455,6 +455,17 @@
 				       wchar_t **__restrict __endptr,
 				       int __base) __THROW;
 #endif /* GCC and use GNU.  */
+
+#ifdef __STDC_WANT_DEC_FP__
+extern _Decimal32 wcstod32 (__const wchar_t *__restrict __nptr,
+		     wchar_t **__restrict __endptr) __THROW;
+
+extern _Decimal64 wcstod64 (__const wchar_t *__restrict __nptr,
+		     wchar_t **__restrict __endptr) __THROW;
+
+extern _Decimal128 wcstod128 (__const wchar_t *__restrict __nptr,
+		     wchar_t **__restrict __endptr) __THROW;
+#endif /* __STDC_WANT_DEC_FP__ */
 
 #ifdef __USE_GNU
 /* The concept of one static locale per category is not very well