From 347f41f1c6caef14cd1a30315a6ce8dd2692da76 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 20 Aug 2008 23:12:27 +0000 Subject: Enable gcc 4.3.1 to build for uclibc. Revive the uclibc locale support. Fix gcc native breakage for 4.3.1. --- .../gcc/gcc-4.3.1/205-uclibc-locale-update.patch | 315 ++++++++++++++++----- 1 file changed, 239 insertions(+), 76 deletions(-) (limited to 'packages/gcc/gcc-4.3.1/205-uclibc-locale-update.patch') diff --git a/packages/gcc/gcc-4.3.1/205-uclibc-locale-update.patch b/packages/gcc/gcc-4.3.1/205-uclibc-locale-update.patch index 86b2844554..8da7461145 100644 --- a/packages/gcc/gcc-4.3.1/205-uclibc-locale-update.patch +++ b/packages/gcc/gcc-4.3.1/205-uclibc-locale-update.patch @@ -1,7 +1,18 @@ ---- gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100 -+++ gcc/libstdc++-v3/config/locale/uclibc/c_locale.cc 2006-03-10 15:39:14 +0100 -@@ -46,16 +47,13 @@ - __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err, +Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.cc +=================================================================== +--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-08-19 01:41:34.000000000 -0700 ++++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-08-19 02:52:48.000000000 -0700 +@@ -39,23 +39,20 @@ + #include + #include + +-namespace std +-{ ++_GLIBCXX_BEGIN_NAMESPACE(std) ++ + template<> + void + __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err, const __c_locale& __cloc) { - if (!(__err & ios_base::failbit)) @@ -24,8 +35,8 @@ } template<> -@@ -63,16 +61,13 @@ - __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err, +@@ -63,16 +60,13 @@ + __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err, const __c_locale& __cloc) { - if (!(__err & ios_base::failbit)) @@ -48,7 +59,7 @@ } template<> -@@ -80,16 +75,13 @@ +@@ -80,16 +74,13 @@ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err, const __c_locale& __cloc) { @@ -72,18 +83,50 @@ } void -@@ -110,7 +102,7 @@ +@@ -110,17 +101,18 @@ void locale::facet::_S_destroy_c_locale(__c_locale& __cloc) { - if (_S_get_c_locale() != __cloc) + if (__cloc && _S_get_c_locale() != __cloc) - __freelocale(__cloc); + __freelocale(__cloc); } ---- gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc.uclibc200_update~ 2006-03-10 15:32:37 +0100 -+++ gcc/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2006-03-10 15:39:14 +0100 -@@ -33,9 +33,14 @@ + __c_locale + locale::facet::_S_clone_c_locale(__c_locale& __cloc) + { return __duplocale(__cloc); } +-} // namespace std + +-namespace __gnu_cxx +-{ ++_GLIBCXX_END_NAMESPACE ++ ++_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ++ + const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] = + { + "LC_CTYPE", +@@ -138,9 +130,11 @@ + "LC_IDENTIFICATION" + #endif + }; +-} + +-namespace std +-{ ++_GLIBCXX_END_NAMESPACE ++ ++_GLIBCXX_BEGIN_NAMESPACE(std) ++ + const char* const* const locale::_S_categories = __gnu_cxx::category_names; +-} // namespace std ++ ++_GLIBCXX_END_NAMESPACE +Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/ctype_members.cc +=================================================================== +--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-08-19 01:41:34.000000000 -0700 ++++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-08-19 02:12:04.000000000 -0700 +@@ -33,16 +33,20 @@ // Written by Benjamin Kosnik @@ -97,11 +140,20 @@ +#endif #include - namespace std -@@ -138,20 +143,34 @@ +-namespace std +-{ ++_GLIBCXX_BEGIN_NAMESPACE(std) ++ + // NB: The other ctype specializations are in src/locale.cc and + // various /config/os/* files. +- template<> + ctype_byname::ctype_byname(const char* __s, size_t __refs) + : ctype(0, false, __refs) + { +@@ -138,17 +142,33 @@ ctype:: do_is(mask __m, wchar_t __c) const - { + { - // Highest bitmask in ctype_base == 10, but extra in "C" - // library for blank. + // The case of __m == ctype_base::space is particularly important, @@ -109,8 +161,9 @@ + // it first, exploiting the knowledge that on GNU systems _M_bit[5] + // is the mask corresponding to ctype_base::space. NB: an encoding + // change would not affect correctness! ++ bool __ret = false; -- const size_t __bitmasksize = 11; +- const size_t __bitmasksize = 11; - for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur) - if (__m & _M_bit[__bitcur] - && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype)) @@ -137,29 +190,29 @@ + break; + } + } - return __ret; - } -- + - const wchar_t* - ctype:: - do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const ---- gcc/libstdc++-v3/config/locale/uclibc/messages_members.h.uclibc200_update~ 2006-03-10 15:32:37 +0100 -+++ gcc/libstdc++-v3/config/locale/uclibc/messages_members.h 2006-03-10 15:39:14 +0100 -@@ -47,18 +47,21 @@ - template - messages<_CharT>::messages(size_t __refs) - : facet(__refs), _M_c_locale_messages(_S_get_c_locale()), -- _M_name_messages(_S_get_c_name()) -+ _M_name_messages(_S_get_c_name()) - { } + return __ret; + } +@@ -290,4 +310,5 @@ + #endif + } + #endif // _GLIBCXX_USE_WCHAR_T +-} ++ ++_GLIBCXX_END_NAMESPACE +Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/messages_members.h +=================================================================== +--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-08-19 01:41:34.000000000 -0700 ++++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-08-19 03:00:38.000000000 -0700 +@@ -53,12 +53,16 @@ template - messages<_CharT>::messages(__c_locale __cloc, const char* __s, - size_t __refs) + messages<_CharT>::messages(__c_locale __cloc, const char* __s, + size_t __refs) - : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)), - _M_name_messages(__s) -+ : facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL) ++ : facet(__refs), _M_c_locale_messages(NULL), ++ _M_name_messages(NULL) { - char* __tmp = new char[std::strlen(__s) + 1]; - std::strcpy(__tmp, __s); @@ -173,8 +226,10 @@ } template ---- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100 -+++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:39:14 +0100 +Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/monetary_members.cc +=================================================================== +--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-08-19 01:41:34.000000000 -0700 ++++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-08-19 02:29:18.000000000 -0700 @@ -33,9 +33,14 @@ // Written by Benjamin Kosnik @@ -199,8 +254,79 @@ } return __ret; } ---- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_update~ 2006-03-10 15:37:27 +0100 -+++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:39:14 +0100 +@@ -390,7 +395,9 @@ + __c_locale __old = __uselocale(__cloc); + #else + // Switch to named locale so that mbsrtowcs will work. +- char* __old = strdup(setlocale(LC_ALL, NULL)); ++ char* __old = setlocale(LC_ALL, NULL); ++ const size_t __llen = strlen(__old) + 1; ++ char* __sav = new char[__llen]; + setlocale(LC_ALL, __name); + #endif + +@@ -477,8 +484,8 @@ + #ifdef __UCLIBC_HAS_XLOCALE__ + __uselocale(__old); + #else +- setlocale(LC_ALL, __old); +- free(__old); ++ setlocale(LC_ALL, __sav); ++ delete [] __sav; + #endif + __throw_exception_again; + } +@@ -498,8 +505,8 @@ + #ifdef __UCLIBC_HAS_XLOCALE__ + __uselocale(__old); + #else +- setlocale(LC_ALL, __old); +- free(__old); ++ setlocale(LC_ALL, __sav); ++ delete [] __sav; + #endif + } + } +@@ -545,8 +552,11 @@ + __c_locale __old = __uselocale(__cloc); + #else + // Switch to named locale so that mbsrtowcs will work. +- char* __old = strdup(setlocale(LC_ALL, NULL)); +- setlocale(LC_ALL, __name); ++ char* __old = setlocale(LC_ALL, NULL); ++ const size_t __llen = strlen(__old) + 1; ++ char* __sav = new char[__llen]; ++ memcpy(__sav, __old, __llen); ++ setlocale(LC_ALL, __name); + #endif + + #ifdef __UCLIBC_MJN3_ONLY__ +@@ -633,8 +643,8 @@ + #ifdef __UCLIBC_HAS_XLOCALE__ + __uselocale(__old); + #else +- setlocale(LC_ALL, __old); +- free(__old); ++ setlocale(LC_ALL, __sav); ++ delete [] __sav; + #endif + __throw_exception_again; + } +@@ -653,8 +663,8 @@ + #ifdef __UCLIBC_HAS_XLOCALE__ + __uselocale(__old); + #else +- setlocale(LC_ALL, __old); +- free(__old); ++ setlocale(LC_ALL, __sav); ++ delete [] __sav; + #endif + } + } +Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/numeric_members.cc +=================================================================== +--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-08-19 01:41:34.000000000 -0700 ++++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-08-19 01:41:34.000000000 -0700 @@ -33,9 +33,14 @@ // Written by Benjamin Kosnik @@ -216,37 +342,24 @@ #include #ifdef __UCLIBC_MJN3_ONLY__ ---- gcc/libstdc++-v3/config/locale/uclibc/time_members.h.uclibc200_update~ 2006-03-10 15:06:17 +0100 -+++ gcc/libstdc++-v3/config/locale/uclibc/time_members.h 2006-03-10 15:39:14 +0100 -@@ -37,25 +37,33 @@ - template - __timepunct<_CharT>::__timepunct(size_t __refs) - : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL), -- _M_name_timepunct(_S_get_c_name()) -+ _M_name_timepunct(_S_get_c_name()) - { _M_initialize_timepunct(); } - - template - __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) - : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL), -- _M_name_timepunct(_S_get_c_name()) -+ _M_name_timepunct(_S_get_c_name()) - { _M_initialize_timepunct(); } - - template +Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/time_members.h +=================================================================== +--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/time_members.h 2008-08-19 01:41:34.000000000 -0700 ++++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/time_members.h 2008-08-19 03:00:38.000000000 -0700 +@@ -50,12 +50,21 @@ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, - size_t __refs) - : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL), + size_t __refs) + : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL), - _M_name_timepunct(__s) -+ _M_name_timepunct(NULL) - { ++ _M_name_timepunct(NULL) + { - char* __tmp = new char[std::strlen(__s) + 1]; - std::strcpy(__tmp, __s); + const size_t __len = std::strlen(__s) + 1; + char* __tmp = new char[__len]; + std::memcpy(__tmp, __s, __len); _M_name_timepunct = __tmp; -- _M_initialize_timepunct(__cloc); +- _M_initialize_timepunct(__cloc); + + try + { _M_initialize_timepunct(__cloc); } @@ -255,11 +368,14 @@ + delete [] _M_name_timepunct; + __throw_exception_again; + } ++ } template ---- gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h.old 2006-09-28 11:39:00.000000000 +0200 -+++ gcc-4.2/libstdc++-v3/config/locale/uclibc/c_locale.h 2006-09-28 12:10:41.000000000 +0200 +Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.h +=================================================================== +--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-08-19 01:41:34.000000000 -0700 ++++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-08-19 01:41:34.000000000 -0700 @@ -39,21 +39,23 @@ #pragma GCC system_header @@ -288,19 +404,11 @@ #endif #define _GLIBCXX_C_LOCALE_GNU 1 -@@ -62,7 +64,7 @@ - #endif - // #define _GLIBCXX_NUM_CATEGORIES 6 - #define _GLIBCXX_NUM_CATEGORIES 0 -- -+ - #ifdef __UCLIBC_HAS_XLOCALE__ - namespace __gnu_cxx - { -@@ -79,22 +81,24 @@ +@@ -78,23 +80,25 @@ + #else typedef int* __c_locale; #endif - +- - // Convert numeric value of type _Tv to string and return length of - // string. If snprintf is available use it, otherwise fall back to - // the unsafe sprintf which, in general, can be dangerous and should @@ -310,7 +418,7 @@ // be avoided. - template - int -- __convert_from_v(char* __out, +- __convert_from_v(char* __out, - const int __size __attribute__ ((__unused__)), - const char* __fmt, -#ifdef __UCLIBC_HAS_XCLOCALE__ @@ -318,7 +426,7 @@ + inline int + __convert_from_v(const __c_locale& +#ifndef __UCLIBC_HAS_XCLOCALE__ -+ __cloc __attribute__ ((__unused__)) ++ __cloc __attribute__ ((__unused__)) +#endif + , + char* __out, @@ -327,6 +435,7 @@ { + va_list __args; +#ifdef __UCLIBC_HAS_XCLOCALE__ ++ __c_locale __old = __gnu_cxx::__uselocale(__cloc); #else - _Tv __v, const __c_locale&, int __prec) @@ -345,3 +454,57 @@ #ifdef __UCLIBC_HAS_XCLOCALE__ __gnu_cxx::__uselocale(__old); +Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/time_members.cc +=================================================================== +--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/time_members.cc 2008-08-19 02:36:00.000000000 -0700 ++++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/time_members.cc 2008-08-19 02:38:23.000000000 -0700 +@@ -53,11 +53,14 @@ + const size_t __len = __strftime_l(__s, __maxlen, __format, __tm, + _M_c_locale_timepunct); + #else +- char* __old = strdup(setlocale(LC_ALL, NULL)); ++ char* __old = setlocale(LC_ALL, NULL); ++ const size_t __llen = strlen(__old) + 1; ++ char* __sav = new char[__llen]; ++ memcpy(__sav, __old, __llen); + setlocale(LC_ALL, _M_name_timepunct); + const size_t __len = strftime(__s, __maxlen, __format, __tm); +- setlocale(LC_ALL, __old); +- free(__old); ++ setlocale(LC_ALL, __sav); ++ delete [] __sav; + #endif + // Make sure __s is null terminated. + if (__len == 0) +@@ -207,11 +210,14 @@ + const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm, + _M_c_locale_timepunct); + #else +- char* __old = strdup(setlocale(LC_ALL, NULL)); ++ char* __old = setlocale(LC_ALL, NULL); ++ const size_t __llen = strlen(__old) + 1; ++ char* __sav = new char[__llen]; ++ memcpy(__sav, __old, __llen); + setlocale(LC_ALL, _M_name_timepunct); + const size_t __len = wcsftime(__s, __maxlen, __format, __tm); +- setlocale(LC_ALL, __old); +- free(__old); ++ setlocale(LC_ALL, __sav); ++ delete [] __sav; + #endif + // Make sure __s is null terminated. + if (__len == 0) +Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c++locale_internal.h +=================================================================== +--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2008-08-19 03:00:52.000000000 -0700 ++++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2008-08-19 03:01:11.000000000 -0700 +@@ -31,6 +31,9 @@ + + #include + #include ++#include ++#include ++#include + + #ifdef __UCLIBC_MJN3_ONLY__ + #warning clean this up -- cgit v1.2.3