Add "integer width" and "numeric limits" support to uclibc++ for ptlib.
authornix <nix@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Tue, 17 Jun 2008 11:17:43 +0000 (11:17 +0000)
committernix <nix@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Tue, 17 Jun 2008 11:17:43 +0000 (11:17 +0000)
See bug #3555.

git-svn-id: svn://svn.openwrt.org/openwrt/packages@11522 3c298f89-4303-0410-b956-a3cf2f4a3e73

libs/uclibc++/patches/007-numeric_limits.patch [new file with mode: 0644]
libs/uclibc++/patches/008-integer_width.patch [new file with mode: 0644]

diff --git a/libs/uclibc++/patches/007-numeric_limits.patch b/libs/uclibc++/patches/007-numeric_limits.patch
new file mode 100644 (file)
index 0000000..1ed7d6c
--- /dev/null
@@ -0,0 +1,66 @@
+Index: uClibc++-0.2.2/include/limits
+===================================================================
+--- uClibc++-0.2.2/include/limits      (revision 1877)
++++ uClibc++-0.2.2/include/limits      (revision 1878)
+@@ -143,6 +143,53 @@
+       static T signaling_NaN();
+ };
++template <> class numeric_limits<bool> {
++public:
++      typedef bool T;
++      // General -- meaningful for all specializations.
++      static const bool is_specialized = true;
++      static T min(){
++              return false;
++      }
++      static T max(){
++              return true;
++      }
++      static const int radix = 2;
++      static const int digits = 1;
++      static const int digits10 = 0;
++      static const bool is_signed = false;
++      static const bool is_integer = true;
++      static const bool is_exact = true;
++      static const bool traps = false;
++      static const bool is_modulo = false;
++      static const bool is_bounded = true;
++
++      // Floating point specific.
++
++      static T epsilon(){
++              return 0;
++      }
++      static T round_error(){
++              return 0;
++      }
++      static const int min_exponent10 = 0;
++      static const int max_exponent10 = 0;
++      static const int min_exponent = 0;
++
++      static const int max_exponent = 0;
++      static const bool has_infinity = false;
++      static const bool has_quiet_NaN = false;
++      static const bool has_signaling_NaN = false;
++      static const bool is_iec559 = false;
++      static const bool has_denorm = false;
++      static const bool tinyness_before = false;
++      static const float_round_style round_style = round_indeterminate;
++      static T denorm_min();
++      static T infinity();
++      static T quiet_NaN();
++      static T signaling_NaN();
++};
++
+ template <> class numeric_limits<unsigned char> {
+ public:
+       typedef unsigned char T;
+@@ -567,6 +614,7 @@
+ };
+ template <> class numeric_limits<double> {
++public:
+       typedef double numeric_type;
+       static const bool is_specialized = true;
diff --git a/libs/uclibc++/patches/008-integer_width.patch b/libs/uclibc++/patches/008-integer_width.patch
new file mode 100644 (file)
index 0000000..c467e60
--- /dev/null
@@ -0,0 +1,314 @@
+Index: uClibc++-0.2.2/include/ostream
+===================================================================
+--- uClibc++-0.2.2/include/ostream     (revision 708)
++++ uClibc++-0.2.2/include/ostream     (revision 709)
+@@ -129,6 +129,18 @@
+                       return *this;
+               }
++              _UCXXEXPORT void printout(const char_type* s, streamsize n)
++                {
++                  int extra = ios::width() - n;
++                  if ((ios::flags()&ios::adjustfield) == ios::right)
++                    while (extra-- > 0)
++                      put(ios::fill());
++                  write(s, n);
++                  if ((ios::flags()&ios::adjustfield) == ios::left)
++                    while (extra-- > 0)
++                      put(ios::fill());
++                }
++
+       protected:
+               basic_ostream(const basic_ostream<charT,traits> &){ }
+               basic_ostream<charT,traits> & operator=(const basic_ostream<charT,traits> &){ return *this; }
+@@ -142,15 +154,15 @@
+               sentry s(*this);
+               if( basic_ios<charT,traits>::flags() & ios_base::boolalpha){
+                       if(n){
+-                              write("true", 4);
++                              printout("true", 4);
+                       }else{
+-                              write("false", 5);
++                              printout("false", 5);
+                       }
+               }else{
+                       if(n){
+-                              write("1", 1);
++                              printout("1", 1);
+                       }else{
+-                              write("0", 1);
++                              printout("0", 1);
+                       }
+               }
+               if(basic_ios<charT,traits>::flags() & ios_base::unitbuf){
+@@ -219,7 +231,7 @@
+       template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(void* p){
+               sentry s(*this);
+               char buffer[20];
+-              write(buffer, snprintf(buffer, 20, "%p", p) );
++              printout(buffer, snprintf(buffer, 20, "%p", p) );
+               if(basic_ios<charT,traits>::flags() & ios_base::unitbuf){
+                       flush();
+               }
+@@ -356,7 +368,7 @@
+               operator<<(basic_ostream<charT,traits>& out, const charT* c)
+       {
+               typename basic_ostream<charT,traits>::sentry s(out);
+-              out.write(c, traits::length(c) );
++              out.printout(c, traits::length(c) );
+               return out;
+       }
+       
+@@ -364,7 +376,7 @@
+               operator<<(basic_ostream<charT,traits>& out, const char* c)
+       {
+               typename basic_ostream<charT,traits>::sentry s(out);
+-              out.write(c, char_traits<char>::length(c) );
++              out.printout(c, char_traits<char>::length(c) );
+               return out;
+       }
+@@ -373,7 +385,7 @@
+               operator<<(basic_ostream<char,traits>& out, const char* c)
+       {
+               typename basic_ostream<char,traits>::sentry s(out);
+-              out.write(c, traits::length(c));
++              out.printout(c, traits::length(c));
+               return out;
+       }
+@@ -389,7 +401,7 @@
+                       temp[i] = out.widen(c[i]);
+               }
+-              out.write(temp, numChars);
++              out.printout(temp, numChars);
+               return out;
+       }
+ #endif
+@@ -399,7 +411,7 @@
+               operator<<(basic_ostream<char,traits>& out, const signed char* c)
+       {
+               typename basic_ostream<char,traits>::sentry s(out);
+-              out.write(reinterpret_cast<const char *>(c), traits::length( reinterpret_cast<const char *>(c)));
++              out.printout(reinterpret_cast<const char *>(c), traits::length( reinterpret_cast<const char *>(c)));
+               return out;
+       }
+       
+@@ -407,7 +419,7 @@
+               operator<<(basic_ostream<char,traits>& out, const unsigned char* c)
+       {
+               typename basic_ostream<char,traits>::sentry s(out);
+-              out.write(reinterpret_cast<const char *>(c), traits::length( reinterpret_cast<const char *>(c)));
++              out.printout(reinterpret_cast<const char *>(c), traits::length( reinterpret_cast<const char *>(c)));
+               return out;
+       }
+Index: uClibc++-0.2.2/include/ostream_helpers
+===================================================================
+--- uClibc++-0.2.2/include/ostream_helpers     (revision 708)
++++ uClibc++-0.2.2/include/ostream_helpers     (revision 709)
+@@ -88,7 +88,7 @@
+                               }
+                       }
+-                      stream.write(buffer, snprintf(buffer, 20, formatString, n) );
++                      stream.printout(buffer, snprintf(buffer, 20, formatString, n) );
+                       if(stream.flags() & ios_base::unitbuf){
+                               stream.flush();
+@@ -135,7 +135,7 @@
+                               }
+                       }
+-                      stream.write(buffer, snprintf(buffer, 20, formatString, n));
++                      stream.printout(buffer, snprintf(buffer, 20, formatString, n));
+                       if(stream.flags() & ios_base::unitbuf){
+                               stream.flush();
+                       }
+@@ -182,7 +182,7 @@
+                               }
+                       }
+-                      stream.write(buffer, snprintf(buffer, 27, formatString, n) );
++                      stream.printout(buffer, snprintf(buffer, 27, formatString, n) );
+                       if(stream.flags() & ios_base::unitbuf){
+                               stream.flush();
+@@ -228,7 +228,7 @@
+                               }
+                       }
+-                      stream.write(buffer, snprintf(buffer, 27, formatString, n) );
++                      stream.printout(buffer, snprintf(buffer, 27, formatString, n) );
+                       if(stream.flags() & ios_base::unitbuf){
+                               stream.flush();
+@@ -256,7 +256,7 @@
+                       } else {
+                               length = snprintf(buffer, 32, "%*.*g",static_cast<int>(stream.width()),static_cast<int>(stream.precision()), f);
+                       }
+-                      stream.write(buffer, length);
++                      stream.printout(buffer, length);
+                       if(stream.flags() & ios_base::unitbuf){
+                               stream.flush();
+                       }
+@@ -280,7 +280,7 @@
+                       } else {
+                               length = snprintf(buffer, 32, "%*.*Lg", static_cast<int>(stream.width()), static_cast<int>(stream.precision()), f);
+                       }
+-                      stream.write(buffer, length);
++                      stream.printout(buffer, length);
+                       if(stream.flags() & ios_base::unitbuf){
+                               stream.flush();
+                       }
+@@ -295,25 +295,25 @@
+               {
+                       wchar_t buffer[20];
+                       if( stream.flags() & ios_base::dec){
+-                              stream.write(buffer, swprintf(buffer, 20, L"%ld", n));
++                              stream.printout(buffer, swprintf(buffer, 20, L"%ld", n));
+                       }else if( stream.flags() & ios_base::oct){
+                               if( stream.flags() & ios_base::showbase){
+-                                      stream.write(buffer, swprintf(buffer, 20, L"%#lo", n));
++                                      stream.printout(buffer, swprintf(buffer, 20, L"%#lo", n));
+                               }else{
+-                                      stream.write(buffer, swprintf(buffer, 20, L"%lo", n) );
++                                      stream.printout(buffer, swprintf(buffer, 20, L"%lo", n) );
+                               }
+                       }else if (stream.flags() & ios_base::hex){
+                               if(stream.flags() & ios_base::showbase){
+                                       if(stream.flags() & ios_base::uppercase){
+-                                              stream.write(buffer, swprintf(buffer, 20, L"%#lX", n) );
++                                              stream.printout(buffer, swprintf(buffer, 20, L"%#lX", n) );
+                                       }else{
+-                                              stream.write(buffer, swprintf(buffer, 20, L"%#lx", n) );
++                                              stream.printout(buffer, swprintf(buffer, 20, L"%#lx", n) );
+                                       }
+                               }else{
+                                       if(stream.flags() & ios_base::uppercase){
+-                                              stream.write(buffer, swprintf(buffer, 20, L"%lX", n) );
++                                              stream.printout(buffer, swprintf(buffer, 20, L"%lX", n) );
+                                       }else{
+-                                              stream.write(buffer, swprintf(buffer, 20, L"%lx", n) );
++                                              stream.printout(buffer, swprintf(buffer, 20, L"%lx", n) );
+                                       }
+                               }
+                       }
+@@ -329,25 +329,25 @@
+               {
+                       wchar_t buffer[20];
+                       if( stream.flags() & ios_base::dec){
+-                              stream.write(buffer, swprintf(buffer, 20, L"%lu", n));
++                              stream.printout(buffer, swprintf(buffer, 20, L"%lu", n));
+                       }else if( stream.flags() & ios_base::oct){
+                               if( stream.flags() & ios_base::showbase){
+-                                      stream.write(buffer, swprintf(buffer, 20, L"%#lo", n));
++                                      stream.printout(buffer, swprintf(buffer, 20, L"%#lo", n));
+                               }else{
+-                                      stream.write(buffer, swprintf(buffer, 20, L"%lo", n) );
++                                      stream.printout(buffer, swprintf(buffer, 20, L"%lo", n) );
+                               }
+                       }else if (stream.flags() & ios_base::hex){
+                               if(stream.flags() & ios_base::showbase){
+                                       if(stream.flags() & ios_base::uppercase){
+-                                              stream.write(buffer, swprintf(buffer, 20, L"%#lX", n) );
++                                              stream.printout(buffer, swprintf(buffer, 20, L"%#lX", n) );
+                                       }else{
+-                                              stream.write(buffer, swprintf(buffer, 20, L"%#lx", n) );
++                                              stream.printout(buffer, swprintf(buffer, 20, L"%#lx", n) );
+                                       }
+                               }else{
+                                       if(stream.flags() & ios_base::uppercase){
+-                                              stream.write(buffer, swprintf(buffer, 20, L"%lX", n) );
++                                              stream.printout(buffer, swprintf(buffer, 20, L"%lX", n) );
+                                       }else{
+-                                              stream.write(buffer, swprintf(buffer, 20, L"%lx", n) );
++                                              stream.printout(buffer, swprintf(buffer, 20, L"%lx", n) );
+                                       }
+                               }
+                       }
+@@ -365,25 +365,25 @@
+               {
+                       wchar_t buffer[28];
+                       if( stream.flags() & ios_base::dec){
+-                              stream.write(buffer, swprintf(buffer, 27, L"%lld", n));
++                              stream.printout(buffer, swprintf(buffer, 27, L"%lld", n));
+                       }else if( stream.flags() & ios_base::oct){
+                               if( stream.flags() & ios_base::showbase){
+-                                      stream.write(buffer, swprintf(buffer, 27, L"%#llo", n));
++                                      stream.printout(buffer, swprintf(buffer, 27, L"%#llo", n));
+                               }else{
+-                                      stream.write(buffer, swprintf(buffer, 27, L"%llo", n) );
++                                      stream.printout(buffer, swprintf(buffer, 27, L"%llo", n) );
+                               }
+                       }else if (stream.flags() & ios_base::hex){
+                               if(stream.flags() & ios_base::showbase){
+                                       if(stream.flags() & ios_base::uppercase){
+-                                              stream.write(buffer, swprintf(buffer, 27, L"%#llX", n) );
++                                              stream.printout(buffer, swprintf(buffer, 27, L"%#llX", n) );
+                                       }else{
+-                                              stream.write(buffer, swprintf(buffer, 27, L"%#llx", n) );
++                                              stream.printout(buffer, swprintf(buffer, 27, L"%#llx", n) );
+                                       }
+                               }else{
+                                       if(stream.flags() & ios_base::uppercase){
+-                                              stream.write(buffer, swprintf(buffer, 27, L"%llX", n) );
++                                              stream.printout(buffer, swprintf(buffer, 27, L"%llX", n) );
+                                       }else{
+-                                              stream.write(buffer, swprintf(buffer, 27, L"%llx", n) );
++                                              stream.printout(buffer, swprintf(buffer, 27, L"%llx", n) );
+                                       }
+                               }
+                       }
+@@ -399,25 +399,25 @@
+               {
+                       wchar_t buffer[28];
+                       if( stream.flags() & ios_base::dec){
+-                              stream.write(buffer, swprintf(buffer, 27, L"%llu", n));
++                              stream.printout(buffer, swprintf(buffer, 27, L"%llu", n));
+                       }else if( stream.flags() & ios_base::oct){
+                               if( stream.flags() & ios_base::showbase){
+-                                      stream.write(buffer, swprintf(buffer, 27, L"%#llo", n));
++                                      stream.printout(buffer, swprintf(buffer, 27, L"%#llo", n));
+                               }else{
+-                                      stream.write(buffer, swprintf(buffer, 27, L"%llo", n) );
++                                      stream.printout(buffer, swprintf(buffer, 27, L"%llo", n) );
+                               }
+                       }else if (stream.flags() & ios_base::hex){
+                               if(stream.flags() & ios_base::showbase){
+                                       if(stream.flags() & ios_base::uppercase){
+-                                              stream.write(buffer, swprintf(buffer, 27, L"%#llX", n) );
++                                              stream.printout(buffer, swprintf(buffer, 27, L"%#llX", n) );
+                                       }else{
+-                                              stream.write(buffer, swprintf(buffer, 27, L"%#llx", n) );
++                                              stream.printout(buffer, swprintf(buffer, 27, L"%#llx", n) );
+                                       }
+                               }else{
+                                       if(stream.flags() & ios_base::uppercase){
+-                                              stream.write(buffer, swprintf(buffer, 27, L"%llX", n) );
++                                              stream.printout(buffer, swprintf(buffer, 27, L"%llX", n) );
+                                       }else{
+-                                              stream.write(buffer, swprintf(buffer, 27, L"%llx", n) );
++                                              stream.printout(buffer, swprintf(buffer, 27, L"%llx", n) );
+                                       }
+                               }
+                       }
+@@ -447,7 +447,7 @@
+                       } else {
+                               swprintf(format_string, 32, L"%%%u.%ug", static_cast<int>(stream.width()), static_cast<unsigned int>(stream.precision()));
+                       }
+-                      stream.write(buffer, swprintf(buffer, 32, format_string, f) );
++                      stream.printout(buffer, swprintf(buffer, 32, format_string, f) );
+                       if(stream.flags() & ios_base::unitbuf){
+                               stream.flush();
+                       }
+@@ -471,7 +471,7 @@
+                       } else {
+                               swprintf(format_string, 32, L"%%%u.%uLg", static_cast<unsigned int>(stream.width()), static_cast<unsigned int>(stream.precision()));
+                       }
+-                      stream.write(buffer, swprintf(buffer, 32, format_string, f) );
++                      stream.printout(buffer, swprintf(buffer, 32, format_string, f) );
+                       if(stream.flags() & ios_base::unitbuf){
+                               stream.flush();
+                       }