[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commits] r16170 - in /libdfp/trunk: ChangeLog README.developer README.user dfp/decimal.tmp dfp/decimal/ dfp/decimal/decimal
- To: commits@xxxxxxxxxx
- Subject: [Commits] r16170 - in /libdfp/trunk: ChangeLog README.developer README.user dfp/decimal.tmp dfp/decimal/ dfp/decimal/decimal
- From: ryanarn@xxxxxxxxxx
- Date: Sat, 10 Dec 2011 15:51:34 -0000
Author: ryanarn
Date: Sat Dec 10 15:51:34 2011
New Revision: 16170
Log:
Finishing migrating dfp/decimal to dfp/decimal/decimal to complete previous
commit.
2011-12-10 Ryan S. Arnold <rsa@xxxxxxxxxxxxxxxxxx>
* README.user: Add instructions for using <decimal/decimal> to pick up
operator<< and operator>> overloads for decimal[32|64|128] types.
* README.developer: Removed necessity of including -isystem in
CPPFLAGS in order to pick up decimal headers.
* dfp/decimal: Created dfp/decimal/ header include directory.
* dfp/decimal.tmp: Moved decimal.tmp to decimal/decimal.
* dfp/decimal/decimal: Moved decimal.tmp to decimal/decimal.
Added:
libdfp/trunk/dfp/decimal/
libdfp/trunk/dfp/decimal/decimal
- copied unchanged from r16169, libdfp/trunk/dfp/decimal.tmp
Removed:
libdfp/trunk/dfp/decimal.tmp
Modified:
libdfp/trunk/ChangeLog
libdfp/trunk/README.developer
libdfp/trunk/README.user
Modified: libdfp/trunk/ChangeLog
==============================================================================
--- libdfp/trunk/ChangeLog (original)
+++ libdfp/trunk/ChangeLog Sat Dec 10 15:51:34 2011
@@ -1,3 +1,13 @@
+2011-12-10 Ryan S. Arnold <rsa@xxxxxxxxxxxxxxxxxx>
+
+ * README.user: Add instructions for using <decimal/decimal> to pick up
+ operator<< and operator>> overloads for decimal[32|64|128] types.
+ * README.developer: Removed necessity of including -isystem in
+ CPPFLAGS in order to pick up decimal headers.
+ * dfp/decimal: Created dfp/decimal/ header include directory.
+ * dfp/decimal.tmp: Moved decimal.tmp to decimal/decimal.
+ * dfp/decimal/decimal: Moved decimal.tmp to decimal/decimal.
+
2011-12-10 Ryan S. Arnold <rsa@xxxxxxxxxxxxxxxxxx>
* Makefile.in: Install dfp/decimal/ directory. Add
Modified: libdfp/trunk/README.developer
==============================================================================
--- libdfp/trunk/README.developer (original)
+++ libdfp/trunk/README.developer Sat Dec 10 15:51:34 2011
@@ -331,8 +331,7 @@
generally match the CFLAGS (for the most part).
CPPFLAGS
- Use this to pass specific flags to the C Preprocessor, e.g.,
- CPPFLAGS="-isystem /opt/at4.0/include/c++/4.5.4/decimal/"
+ Use this to pass specific flags to the C Preprocessor.
OBJDUMP
[OPTIONAL: Picked up from $PATH if not specified.]
@@ -432,14 +431,12 @@
Here are some easy-case configurations of libdfp using PATH:
PATH=/opt/at4.0/bin:$PATH \
- CPPFLAGS="-isystem /opt/at4.0/include/c++/4.5.4/decimal/" \
CXXFLAGS="-m32 -O2 -g" CFLAGS="-m32 -O2 -g" \
../libdfp-decimal/configure --with-backend=libdecnumber \
--enable-decimal-float=dpd --build=powerpc-linux-gnu \
--with-cpu=power6 2>&1 | tee _configure32_power6
PATH=/opt/at4.0/bin:$PATH \
- CPPFLAGS="-isystem /opt/at4.0/include/c++/4.5.4/decimal/" \
CXXFLAGS="-m64 -O2 -g" CFLAGS="-m64 -O2 -g" \
../libdfp-decimal/configure --with-backend=libdecnumber \
--enable-decimal-float=dpd --build=powerpc64-linux-gnu \
Modified: libdfp/trunk/README.user
==============================================================================
--- libdfp/trunk/README.user (original)
+++ libdfp/trunk/README.user Sat Dec 10 15:51:34 2011
@@ -34,6 +34,7 @@
4.3 GCC With --enable-decimal-float Support
5. _Decimal* Data Types
5.1 C++ decimal[32|64|128] Types Compatibility
+ 5.2 C++ decimal[32|64|128] operator<< and operator>> Overloads
6. DFP Headers
7. Compile and Link
8. Unsupported/Non-Standard Additions
@@ -260,7 +261,7 @@
5.1 C++ decimal[32|64|128] Types Compatibility
---------------------------------------------------------------------------
-C++ does not natively use the ISO C DFP _Decimal[32|64|128] types.
+Your C++ compiler may not provide 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",
@@ -275,21 +276,61 @@
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 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>
+Your compiler may or may not yet have this defined in float.h. As a matter
+of convenience, libdfp has provided these headers in the libdfp headers
+directory include/dfp/float.h
+
+5.2 C++ decimal[32|64|128] operator<< and operator>> Overloads
+---------------------------------------------------------------------------
+
+Your C++ compiler may not provide the operator<< and operator>> overloads
+for std::decimal::decimal[32|64|128] data 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
+<decimal> shall provide the following operator overloads.
+
+namespace std {
+namespace decimal {
+
+ template <class charT, class traits>
+ std::basic_istream<charT, traits> &
+ operator>>(std::basic_istream<charT, traits> & is,
+ decimal32 & d);
+
+ template <class charT, class traits>
+ std::basic_istream<charT, traits> &
+ operator>>(std::basic_istream<charT, traits> & is,
+ decimal64 & d);
+
+ template <class charT, class traits>
+ std::basic_istream<charT, traits> &
+ operator>>(std::basic_istream<charT, traits> & is,
+ decimal128 & d);
+
+ template <class charT, class traits>
+ std::basic_ostream<charT, traits> &
+ operator<<(std::basic_ostream<charT, traits> & os,
+ decimal32 d);
+
+ template <class charT, class traits>
+ std::basic_ostream<charT, traits> &
+ operator<<(std::basic_ostream<charT, traits> & os,
+ decimal64 d);
+
+ template <class charT, class traits>
+ std::basic_ostream<charT, traits> &
+ operator<<(std::basic_ostream<charT, traits> & os,
+ decimal128 d);
+}}
+
+Per http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51486, since C++ decimal
+support is defined in a technical report and not ratified into the actual
+C++ standard the <decimal> header shouldn't be located in the default
+headers include directory. As a result the <decimal> header is located in
+the include/decimal directory. Therefore, in order to include the decimal
+header implicitly use the following in applications:
+
+#include <decimal/decimal>
---------------------------------------------------------------------------
6. DFP Headers
@@ -302,11 +343,14 @@
dfp/math.h
dfp/stdlib.h
dfp/wchar.h
+ dfp/float.h
+ dfp/decimal/decimal
Each of these headers uses the GCC construct include_next in order to pick up
the system header as well, e.g.,
dfp/math.h will include_next <math.h>
+ dfp/decimal/decimal will include_next <decimal/decimal>
This mechanism allows Libdfp to add the Decimal interfaces required by the
specification to the aforementioned headers.
@@ -315,6 +359,10 @@
overrides compile with the following:
-I/pathto/include/dfp/ -D__STDC_WANT_DEC_FP__
+
+Using -I instead of -isystem is suggested because -I indicates that the
+specified headers are picked up BEFORE the system headers, which is what we
+want.
And then in the application source simply using the following include will
pick up both /pathto/include/dfp/<foo>.h and /usr/include/<foo>.h:
@@ -324,6 +372,10 @@
#include <stdlib.h>
#include <wchar.h>
+/* And for C++ programs */
+#include <float.h>
+#include <decimal/decimal>
+
Alternatively, if you don't want to use the -I/pathto/include/dfp/, for
instance, if you don't want to have to specify this directly, you may do the
following:
@@ -332,6 +384,10 @@
#include <dfp/fenv.h>
#include <dfp/stdlib.h>
#include <dfp/wchar.h>
+
+/* And for C++ programs */
+#include <dfp/float.h>
+#include <dfp/decimal/decimal>
---------------------------------------------------------------------------
7. Compile and Link
Removed: libdfp/trunk/dfp/decimal.tmp
==============================================================================
--- libdfp/trunk/dfp/decimal.tmp (original)
+++ libdfp/trunk/dfp/decimal.tmp (removed)
@@ -1,246 +1,0 @@
-/* <decimal> for libdfp and redirect to system <decimal>
-
- Copyright (C) 2011 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. */
-
-#ifndef _LIBDFP_DECIMAL_H
-#define _LIBDFP_DECIMAL_H 1
-
-#ifdef _GLIBCXX_DECIMAL_IMPL
-# error "<dfp/decimal> should be included before the system <decimal> header."
-#endif
-
-#ifdef __cplusplus
-
-/* Pick up the system <decimal> */
-#include_next <decimal/decimal>
-
-#pragma GCC system_header
-
-using namespace std::decimal;
-
-#include <ostream>
-using std::ostream;
-
-/* Per ISO/IEC JTC1 SC22 WG21 N2732 - TR 24733: "Extension for the programming
- * language C++ to support decimal floating point arithmetic" define the
- * ostream and istream operators. These are included in libdfp and NOT
- * libstdc++ because the ostream and istream operators rely upon libdfp
- * printf and strtod[32|64|128] support provided by libdfp. */
-
-/* Prototypes for functions providing ostream support in libdfp. */
-
-std::ostream &
-ostream_d32(std::ostream & os, std::decimal::decimal32 &d) __THROW;
-
-std::ostream &
-ostream_d64(std::ostream & os, std::decimal::decimal64 &d) __THROW;
-
-std::ostream &
-ostream_d128(std::ostream & os, std::decimal::decimal128 &d) __THROW;
-
-#include <stdio.h> /* pick up snprintf */
-
-#include <float.h> /* Pick up _Decimal[32|64|128] typedefs. */
-
-#include <string>
-using std::string;
-
-#include <iostream>
-using namespace std;
-
-template<unsigned int size>
-struct FIND_DEC_MANT_DIG
-{
- enum {RESULT = 0};
- static inline std::string get_fmt(char conv)
- {
- std::string spec = "";
- return spec;
- }
-};
-
-template <>
-struct FIND_DEC_MANT_DIG<4>
-{
- enum {RESULT = (__DEC32_MANT_DIG__) };
- static inline std::string get_fmt(char conv)
- {
- std::string spec = "%.*H";
- return spec.append(1,conv);
- }
-};
-template <>
-struct FIND_DEC_MANT_DIG<8>
-{
- enum {RESULT = (__DEC64_MANT_DIG__) };
- static inline std::string get_fmt(char conv)
- {
- std::string spec = "%.*D";
- return spec.append(1,conv);
- }
-
-};
-template <>
-struct FIND_DEC_MANT_DIG<16>
-{
- enum {RESULT = (__DEC128_MANT_DIG__) };
- static inline std::string get_fmt(char conv)
- {
- std::string spec = "%.*DD";
- return spec.append(1,conv);
- }
-};
-
-/* Template meta-programming so we only have to write this code once for use
- * with each of the _Decimal[32|64|128] types. */
-template<class decimal_type>
-class LIBDFP_META_PRINTF {
-private:
-public:
- static inline ostream & decimal_to_string(std::ostream &os, decimal_type &d)
- {
- char strbuf[64];
-
- ios_base::fmtflags flags = os.flags();
- unsigned int precision = os.precision();
-
- if (precision > DEC_MANT_DIG)
- precision = DEC_MANT_DIG;
-
- char conv = 'a';
-
- if (flags & ios::fixed)
- {
- /* Only used for "NAN" and "INF" rather than "nan" and "inf" for
- * "%.*Df". */
- if (flags & ios::uppercase)
- conv = 'F';
- else
- conv = 'f';
- }
- else if (flags & ios::scientific)
- {
- if (flags & ios::uppercase)
- conv = 'E';
- else
- conv = 'e';
- }
- else if (flags & ios::uppercase)
- conv = 'A';
-
- std::string fmtstr = FIND_DEC_MANT_DIG<(sizeof(decimal_type))>::get_fmt(conv);
- sprintf (strbuf, fmtstr.c_str(), precision, d.__getval());
- os << strbuf;
- return os;
- }
-
- enum {DEC_MANT_DIG = FIND_DEC_MANT_DIG<(sizeof(decimal_type))>::RESULT};
-};
-
-namespace std
-{
-namespace decimal
-{
-// ISO/IEC TR 27433 - 3.2.11 Formatted input:
-// template <class charT, class traits>
-// std::basic_istream<charT, traits> &
-// operator>>(std::basic_istream<charT, traits> & is, decimal32 & d);
-
-// template <class charT, class traits>
-// std::basic_istream<charT, traits> &
-// operator>>(std::basic_istream<charT, traits> & is, decimal64 & d);
-
-// template <class charT, class traits>
-// std::basic_istream<charT, traits> &
-// operator>>(std::basic_istream<charT, traits> & is, decimal128 & d);
-
-
- //ISO/IEC TR 24733 - 3.2.11 Formatted output:
-
- /* ISO/IEC TR 24733 doesn't have an equivalent to the 'a/A' conversion
- * specifier in ISO/IEC TR 24732. This ostream implementation can take one
- * of two approaches. It can either use 'a/A' by default or it can allow
- * the user to select f/F or e/E. It'd be nice to override */
-
-
- template <class charT, class traits>
- inline std::basic_ostream<charT, traits> &
- operator<<(std::basic_ostream<charT, traits> & os, decimal32 d)
- {
-
- /* 1 (leading zero)
- * + 1 (.)
- * + 7 (__DEC32_MANT_DIG__)
- * + 1 (e)
- * + 1 (+/-)
- * + 2 (digits in __DEC32_MAX_EXP__)
- * + 1 "\n"
- * = 14 -> round up to a power of 2 = 16. */
- LIBDFP_META_PRINTF<std::decimal::decimal32>::decimal_to_string(os, d);
- return os;
- }
-
- template <class charT, class traits>
- inline std::basic_ostream<charT, traits> &
- operator<<(std::basic_ostream<charT, traits> & os, decimal64 d)
- {
- /* 1 (leading zero)
- * + 1 (.)
- * + 16 (__DEC64_MANT_DIG__)
- * + 1 (e)
- * + 1 (+/-)
- * + 3 (digits in __DEC64_MAX_EXP__)
- * + 1 "\n"
- * = 24 -> round up to a power of 2 = 32. */
-
- LIBDFP_META_PRINTF<std::decimal::decimal64>::decimal_to_string(os, d);
- return os;
- }
-
- /* */
- template <class charT, class traits>
- inline std::basic_ostream<charT, traits> &
- operator<<(std::basic_ostream<charT, traits> & os, decimal128 d)
- {
-
- return ostream_d128(os, d);
- /* 1 (leading zero)
- * + 1 (.)
- * + 34 (__DEC128_MANT_DIG__)
- * + 1 (e)
- * + 1 (+/-)
- * + 4 (digits in __DEC128_MAX_EXP__)
- * + 1 "\n"
- * = 43 -> round up to a power of 2 = 64. */
- LIBDFP_META_PRINTF<std::decimal::decimal128>::decimal_to_string(os, d);
- return os;
- }
-
-} /* namespace decimal */
-} /* namespace std */
-
-#else
-# warning "<dfp/decimal> should only be included by C++ programs."
-#endif /* __cplusplus */
-
-#endif /* _LIBDFP_DECIMAL_H */
_______________________________________________
Commits mailing list
Commits@xxxxxxxxxx
http://eglibc.org/cgi-bin/mailman/listinfo/commits