This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] gcc-3_3-branch remove __locale_cache
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, mark at codesourcery dot com
- Date: Thu, 1 May 2003 21:06:56 -0400 (EDT)
- Subject: [v3] gcc-3_3-branch remove __locale_cache
tested x86/linux
gcc-3_3-branch
This removes memory and ABI issues.
2003-05-01 Benjamin Kosnik <bkoz@redhat.com>
Revert __locale_cache.
* include/bits/locale_facets.tcc (num_put::_M_convert_int): Remove
__locale_cache.
(num_put::_M_convert_int): Same.
(num_put::do_put(bool)): Same.
(__locale_cache::_M_init): Same.
(__locale_cache::_S_callback): Same.
* include/bits/locale_facets.h (__locale_cache_base): Remove.
(__locale_cache): Remove.
* include/bits/basic_ios.h (basic_ios::init): Remove __locale_cache.
(basic_ios::_M_cache_locale): Same.
* include/bits/basic_ios.tcc: Same.
* include/bits/ios_base.h: Same.
(ios_base::_M_cache): Remove.
* src/locale-inst.cc: Same.
* src/ios.cc: Same.
* src/globals.cc: Same.
* config/linker-map.gnu: Same.
Index: config/linker-map.gnu
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/linker-map.gnu,v
retrieving revision 1.25.2.8
diff -c -p -r1.25.2.8 linker-map.gnu
*** config/linker-map.gnu 1 May 2003 22:20:09 -0000 1.25.2.8
--- config/linker-map.gnu 2 May 2003 00:38:52 -0000
*************** GLIBCPP_3.2.3 {
*** 393,406 ****
# __basic_file::showmanyc_helper
_ZNSt12__basic_fileIcE16showmanyc_helperEv;
- # vtable
- _ZTVSt19__locale_cache_base;
- _ZTVSt14__locale_cacheI[cw]E;
-
- # typeinfo
- _ZTSSt19__locale_cache_base;
- _ZTISt14__locale_cacheI[cw]E;
-
} GLIBCPP_3.2.2;
--- 393,398 ----
Index: include/bits/basic_ios.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/basic_ios.h,v
retrieving revision 1.14.2.4
diff -c -p -r1.14.2.4 basic_ios.h
*** include/bits/basic_ios.h 22 Apr 2003 15:40:34 -0000 1.14.2.4
--- include/bits/basic_ios.h 2 May 2003 00:38:53 -0000
*************** namespace std
*** 425,432 ****
* memory.
*/
void
! init(basic_streambuf<_CharT, _Traits>* __sb,
! __locale_cache<_CharT>* __cache=0);
bool
_M_check_facet(const locale::facet* __f) const
--- 425,431 ----
* memory.
*/
void
! init(basic_streambuf<_CharT, _Traits>* __sb);
bool
_M_check_facet(const locale::facet* __f) const
*************** namespace std
*** 437,443 ****
}
void
! _M_cache_locale(const locale& __loc,__locale_cache<_CharT>* __cache = 0);
#if 1
// XXX GLIBCXX_ABI Deprecated, compatibility only.
--- 436,442 ----
}
void
! _M_cache_locale(const locale& __loc);
#if 1
// XXX GLIBCXX_ABI Deprecated, compatibility only.
Index: include/bits/basic_ios.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/basic_ios.tcc,v
retrieving revision 1.17.4.3
diff -c -p -r1.17.4.3 basic_ios.tcc
*** include/bits/basic_ios.tcc 22 Apr 2003 15:40:34 -0000 1.17.4.3
--- include/bits/basic_ios.tcc 2 May 2003 00:38:53 -0000
*************** namespace std
*** 144,155 ****
template<typename _CharT, typename _Traits>
void
! basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb,
! __locale_cache<_CharT>* __cache)
{
// NB: This may be called more than once on the same object.
ios_base::_M_init();
! _M_cache_locale(_M_ios_locale, __cache);
_M_tie = 0;
// NB: The 27.4.4.1 Postconditions Table specifies requirements
--- 144,154 ----
template<typename _CharT, typename _Traits>
void
! basic_ios<_CharT, _Traits>::init(basic_streambuf<_CharT, _Traits>* __sb)
{
// NB: This may be called more than once on the same object.
ios_base::_M_init();
! _M_cache_locale(_M_ios_locale);
_M_tie = 0;
// NB: The 27.4.4.1 Postconditions Table specifies requirements
*************** namespace std
*** 174,181 ****
template<typename _CharT, typename _Traits>
void
! basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc,
! __locale_cache<_CharT>* __cache)
{
if (__builtin_expect(has_facet<__ctype_type>(__loc), true))
_M_fctype = &use_facet<__ctype_type>(__loc);
--- 173,179 ----
template<typename _CharT, typename _Traits>
void
! basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc)
{
if (__builtin_expect(has_facet<__ctype_type>(__loc), true))
_M_fctype = &use_facet<__ctype_type>(__loc);
*************** namespace std
*** 189,209 ****
_M_fnumget = &use_facet<__numget_type>(__loc);
else
_M_fnumget = 0;
- typedef __locale_cache<_CharT> __cache_t;
- if (!pword(0)) {
- // We store the cache at pword(0). iword(0) is set to 1 to
- // indicate that this is a static storage cache that shouldn't
- // be deleted.
- if (__cache)
- {
- pword(0) = auto_ptr<__cache_t>(new (__cache) __cache_t()).release();
- iword(0) = 1; // so we don't try to clobber static cache
- }
- else
- pword(0) = auto_ptr<__cache_t>(new __cache_t()).release();
- register_callback(__cache_t::_S_callback, 0);
- }
- static_cast<__cache_t&>(_M_cache())._M_init(__loc);
}
#if 1
--- 187,192 ----
Index: include/bits/ios_base.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/ios_base.h,v
retrieving revision 1.21.2.5
diff -c -p -r1.21.2.5 ios_base.h
*** include/bits/ios_base.h 5 Mar 2003 19:09:45 -0000 1.21.2.5
--- include/bits/ios_base.h 2 May 2003 00:38:55 -0000
*************** namespace std
*** 146,153 ****
enum _Ios_Seekdir { _M_ios_seekdir_end = 1L << 16 };
- class __locale_cache_base;
-
// 27.4.2 Class ios_base
/**
* @brief The very top of the I/O class hierarchy.
--- 146,151 ----
*************** namespace std
*** 643,653 ****
? _M_word[__ix] : _M_grow_words(__ix);
return __word._M_pword;
}
-
- // Access to the cache. Not safe to call until basic_ios::_M_init() has
- // happened.
- __locale_cache_base&
- _M_cache() { return *static_cast<__locale_cache_base*>(pword(0)); }
// Destructor
/**
--- 641,646 ----
Index: include/bits/locale_facets.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_facets.h,v
retrieving revision 1.49.4.6
diff -c -p -r1.49.4.6 locale_facets.h
*** include/bits/locale_facets.h 5 Mar 2003 04:40:07 -0000 1.49.4.6
--- include/bits/locale_facets.h 2 May 2003 00:38:57 -0000
*************** namespace std
*** 1953,2032 ****
inline _CharT
tolower(_CharT __c, const locale& __loc)
{ return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
-
- // __locale_cache holds the information extracted from the
- // numpunct<> and moneypunct<> facets in a form optimized for
- // parsing and formatting. To avoid breaking the 3.2 library
- // API, it is stored in ios_base::_M_local_word[0]. as a member of basic_ios and accessed via a void* pointer in
- // the ios_base object passed to the _get and _put facets.
-
- // Its intent is to avoid the cost of creating a locale object and
- // calling the virtual functions in locale facets.
- class __locale_cache_base
- {
- public:
- virtual
- ~__locale_cache_base() {}
- };
-
- template<typename _CharT>
- class __locale_cache : public __locale_cache_base
- {
- // Types:
- typedef _CharT char_type;
- typedef char_traits<_CharT> traits_type;
- typedef basic_string<_CharT> string_type;
-
-
- public:
- // Data Members:
-
- // A list of valid numeric literals: for the standard "C" locale, this
- // is "-+xX0123456789abcdef0123456789ABCDEF". This array contains the
- // chars after having been passed through the current locale's
- // ctype<_CharT>.widen().
- _CharT _M_literals[__num_base::_S_end];
-
-
- // The sign used to separate decimal values: for standard US
- // locales, this would usually be: "."
- // Abstracted from numpunct::decimal_point().
- _CharT _M_decimal_point;
-
- // The sign used to separate groups of digits into smaller
- // strings that the eye can parse with less difficulty: for
- // standard US locales, this would usually be: ","
- // Abstracted from numpunct::thousands_sep().
- _CharT _M_thousands_sep;
-
- // However the US's "false" and "true" are translated.
- // From numpunct::truename() and numpunct::falsename(), respectively.
- string_type _M_truename;
- string_type _M_falsename;
-
- // If we are checking groupings. This should be equivalent to
- // numpunct::groupings().size() != 0
- bool _M_use_grouping;
-
- // If we are using numpunct's groupings, this is the current grouping
- // string in effect (from numpunct::grouping()).
- string _M_grouping;
-
- __locale_cache() : _M_use_grouping(false)
- { };
-
- __locale_cache&
- operator=(const __locale_cache& __lc);
-
-
- // Make sure the cache is built before the first use.
- void
- _M_init(const locale&);
-
- // ios_base::pword callbacks come here
- static void
- _S_callback(ios_base::event __ev, ios_base& __io, int);
- };
} // namespace std
#endif
--- 1953,1958 ----
Index: include/bits/locale_facets.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_facets.tcc,v
retrieving revision 1.82.4.9
diff -c -p -r1.82.4.9 locale_facets.tcc
*** include/bits/locale_facets.tcc 22 Apr 2003 15:40:34 -0000 1.82.4.9
--- include/bits/locale_facets.tcc 2 May 2003 00:38:59 -0000
*************** namespace std
*** 768,781 ****
_M_convert_int(_OutIter __s, ios_base& __io, _CharT __fill,
_ValueT __v) const
{
- typedef __locale_cache<_CharT> __cache_type;
- __cache_type& __lc = static_cast<__cache_type&>(__io._M_cache());
- _CharT* __lit = __lc._M_literals;
-
// Long enough to hold hex, dec, and octal representations.
int __ilen = 4 * sizeof(_ValueT);
_CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __ilen));
// [22.2.2.2.2] Stage 1, numeric conversion to character.
// Result is returned right-justified in the buffer.
--- 768,785 ----
_M_convert_int(_OutIter __s, ios_base& __io, _CharT __fill,
_ValueT __v) const
{
// Long enough to hold hex, dec, and octal representations.
int __ilen = 4 * sizeof(_ValueT);
_CharT* __cs = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __ilen));
+ // Buildup list of digits given the current ctype.
+ _CharT __lit[_S_end];
+ const locale __loc = __io.getloc();
+ if (__builtin_expect(has_facet<ctype<_CharT> >(__loc), true))
+ {
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
+ __ct.widen(_S_atoms_out, _S_atoms_out + _S_end, __lit);
+ }
// [22.2.2.2.2] Stage 1, numeric conversion to character.
// Result is returned right-justified in the buffer.
*************** namespace std
*** 784,797 ****
__cs = __cs + __ilen - __len;
// Add grouping, if necessary.
_CharT* __cs2;
! if (__lc._M_use_grouping)
{
// Grouping can add (almost) as many separators as the
// number of digits, but no more.
__cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len * 2));
! _M_group_int(__lc._M_grouping, __lc._M_thousands_sep, __io,
__cs2, __cs, __len);
__cs = __cs2;
}
--- 788,803 ----
__cs = __cs + __ilen - __len;
// Add grouping, if necessary.
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+ const string __grouping = __np.grouping();
_CharT* __cs2;
! if (__grouping.size())
{
// Grouping can add (almost) as many separators as the
// number of digits, but no more.
__cs2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len * 2));
! _M_group_int(__grouping, __np.thousands_sep(), __io,
__cs2, __cs, __len);
__cs = __cs2;
}
*************** namespace std
*** 873,881 ****
else if (__prec < static_cast<streamsize>(0))
__prec = static_cast<streamsize>(6);
- typedef __locale_cache<_CharT> __cache_type;
- __cache_type& __lc = static_cast<__cache_type&>(__io._M_cache());
-
// [22.2.2.2.2] Stage 1, numeric conversion to character.
int __len;
// Long enough for the max format spec.
--- 879,884 ----
*************** namespace std
*** 927,947 ****
__ctype.widen(__cs, __cs + __len, __ws);
// Replace decimal point.
const _CharT __cdec = __ctype.widen('.');
! const _CharT __dec = __lc._M_decimal_point;
const _CharT* __p;
if (__p = char_traits<_CharT>::find(__ws, __len, __cdec))
__ws[__p - __ws] = __dec;
// Add grouping, if necessary.
_CharT* __ws2;
! if (__lc._M_use_grouping)
{
// Grouping can add (almost) as many separators as the
// number of digits, but no more.
__ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len * 2));
! _M_group_float(__lc._M_grouping, __lc._M_thousands_sep, __p,
__ws2, __ws, __len);
__ws = __ws2;
}
--- 930,952 ----
__ctype.widen(__cs, __cs + __len, __ws);
// Replace decimal point.
+ const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
const _CharT __cdec = __ctype.widen('.');
! const _CharT __dec = __np.decimal_point();
const _CharT* __p;
if (__p = char_traits<_CharT>::find(__ws, __len, __cdec))
__ws[__p - __ws] = __dec;
// Add grouping, if necessary.
_CharT* __ws2;
! const string __grouping = __np.grouping();
! if (__grouping.size())
{
// Grouping can add (almost) as many separators as the
// number of digits, but no more.
__ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT)
* __len * 2));
! _M_group_float(__grouping, __np.thousands_sep(), __p,
__ws2, __ws, __len);
__ws = __ws2;
}
*************** namespace std
*** 975,988 ****
}
else
{
! typedef __locale_cache<_CharT> __cache_type;
! __cache_type& __lc = static_cast<__cache_type&>(__io._M_cache());
typedef basic_string<_CharT> __string_type;
__string_type __name;
if (__v)
! __name = __lc._M_truename;
else
! __name = __lc._M_falsename;
const _CharT* __cs = __name.c_str();
int __len = __name.size();
--- 980,993 ----
}
else
{
! locale __loc = __io.getloc();
! const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
typedef basic_string<_CharT> __string_type;
__string_type __name;
if (__v)
! __name = __np.truename();
else
! __name = __np.falsename();
const _CharT* __cs = __name.c_str();
int __len = __name.size();
*************** namespace std
*** 2260,2315 ****
*__s++ = *__first++;
while (__first != __last);
return __s;
- }
-
- template<typename _CharT>
- void
- __locale_cache<_CharT>::_M_init(const locale& __loc)
- {
- if (__builtin_expect(has_facet<numpunct<_CharT> >(__loc), true))
- {
- const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
- _M_falsename = __np.falsename();
- _M_truename = __np.truename();
- _M_thousands_sep = __np.thousands_sep();
- _M_decimal_point = __np.decimal_point();
- _M_grouping = __np.grouping();
- _M_use_grouping = _M_grouping.size() != 0
- && _M_grouping.data()[0] != 0;
- }
- if (__builtin_expect(has_facet<ctype<_CharT> >(__loc), true))
- {
- const ctype<_CharT>& __ct = use_facet< ctype<_CharT> >(__loc);
- __ct.widen(__num_base::_S_atoms_out,
- __num_base::_S_atoms_out + __num_base::_S_end,
- _M_literals);
- }
- }
-
- template<typename _CharT>
- void
- __locale_cache<_CharT>::_S_callback(ios_base::event __ev, ios_base& __io, int)
- {
- switch (__ev)
- {
- case ios_base::erase_event:
- if (__io.pword(0) && !__io.iword(0))
- delete &__io._M_cache();
- break;
-
- case ios_base::imbue_event:
- break;
-
- case ios_base::copyfmt_event:
- // This routine is called with the new ios_base, but pword(0) still
- // points to the cache from the old ios_base. This replaces it with
- // a new cache. Done here, so we don't get an extra callback from
- // basic_ios::_M_cache_locale.
- typedef __locale_cache<_CharT> __cache_t;
- __io.pword(0) = auto_ptr<__cache_t>(new __cache_t()).release();
- __io.iword(0) = 0;
- break;
- }
}
#if 1
--- 2265,2270 ----
Index: src/globals.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/globals.cc,v
retrieving revision 1.12.4.2
diff -c -p -r1.12.4.2 globals.cc
*** src/globals.cc 22 Apr 2003 15:40:34 -0000 1.12.4.2
--- src/globals.cc 2 May 2003 00:39:01 -0000
***************
*** 47,69 ****
namespace __gnu_cxx
{
using namespace std;
-
- // Also, need locale caches for standard stream objects...
- typedef char fake_locale_cache[sizeof(__locale_cache<char>)]
- __attribute__ ((aligned(__alignof__(__locale_cache<char>))));
- fake_locale_cache locale_cache_cout;
- fake_locale_cache locale_cache_cin;
- fake_locale_cache locale_cache_cerr;
- fake_locale_cache locale_cache_clog;
-
- #ifdef _GLIBCPP_USE_WCHAR_T
- typedef char fake_wlocale_cache[sizeof(__locale_cache<wchar_t>)]
- __attribute__ ((aligned(__alignof__(__locale_cache<wchar_t>))));
- fake_wlocale_cache locale_cache_wcout;
- fake_wlocale_cache locale_cache_wcin;
- fake_wlocale_cache locale_cache_wcerr;
- fake_wlocale_cache locale_cache_wclog;
- #endif
typedef char fake_facet_name[sizeof(char*)]
__attribute__ ((aligned(__alignof__(char*))));
--- 47,52 ----
Index: src/ios.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/ios.cc,v
retrieving revision 1.33.2.6
diff -c -p -r1.33.2.6 ios.cc
*** src/ios.cc 22 Apr 2003 15:40:34 -0000 1.33.2.6
--- src/ios.cc 2 May 2003 00:39:01 -0000
*************** namespace __gnu_cxx
*** 48,66 ****
extern stdio_filebuf<char> buf_cout;
extern stdio_filebuf<char> buf_cin;
extern stdio_filebuf<char> buf_cerr;
- extern std::__locale_cache<char> locale_cache_cout;
- extern std::__locale_cache<char> locale_cache_cin;
- extern std::__locale_cache<char> locale_cache_cerr;
- extern std::__locale_cache<char> locale_cache_clog;
#ifdef _GLIBCPP_USE_WCHAR_T
extern stdio_filebuf<wchar_t> buf_wcout;
extern stdio_filebuf<wchar_t> buf_wcin;
extern stdio_filebuf<wchar_t> buf_wcerr;
- extern std::__locale_cache<wchar_t> locale_cache_wcout;
- extern std::__locale_cache<wchar_t> locale_cache_wcin;
- extern std::__locale_cache<wchar_t> locale_cache_wcerr;
- extern std::__locale_cache<wchar_t> locale_cache_wclog;
#endif
} // namespace __gnu_cxx
--- 48,58 ----
*************** namespace std
*** 186,195 ****
new (&cin) istream(&buf_cin);
new (&cerr) ostream(&buf_cerr);
new (&clog) ostream(&buf_cerr);
! cout.init(&buf_cout, &locale_cache_cout);
! cin.init(&buf_cin, &locale_cache_cin);
! cerr.init(&buf_cerr, &locale_cache_cerr);
! clog.init(&buf_cerr, &locale_cache_clog);
cin.tie(&cout);
cerr.flags(ios_base::unitbuf);
--- 178,187 ----
new (&cin) istream(&buf_cin);
new (&cerr) ostream(&buf_cerr);
new (&clog) ostream(&buf_cerr);
! cout.init(&buf_cout);
! cin.init(&buf_cin);
! cerr.init(&buf_cerr);
! clog.init(&buf_cerr);
cin.tie(&cout);
cerr.flags(ios_base::unitbuf);
*************** namespace std
*** 201,210 ****
new (&wcin) wistream(&buf_wcin);
new (&wcerr) wostream(&buf_wcerr);
new (&wclog) wostream(&buf_wcerr);
! wcout.init(&buf_wcout, &locale_cache_wcout);
! wcin.init(&buf_wcin, &locale_cache_wcin);
! wcerr.init(&buf_wcerr, &locale_cache_wcerr);
! wclog.init(&buf_wcerr, &locale_cache_wclog);
wcin.tie(&wcout);
wcerr.flags(ios_base::unitbuf);
#endif
--- 193,202 ----
new (&wcin) wistream(&buf_wcin);
new (&wcerr) wostream(&buf_wcerr);
new (&wclog) wostream(&buf_wcerr);
! wcout.init(&buf_wcout);
! wcin.init(&buf_wcin);
! wcerr.init(&buf_wcerr);
! wclog.init(&buf_wcerr);
wcin.tie(&wcout);
wcerr.flags(ios_base::unitbuf);
#endif
Index: src/locale-inst.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale-inst.cc,v
retrieving revision 1.35.4.3
diff -c -p -r1.35.4.3 locale-inst.cc
*** src/locale-inst.cc 5 Mar 2003 04:40:08 -0000 1.35.4.3
--- src/locale-inst.cc 2 May 2003 00:39:01 -0000
*************** namespace std
*** 545,557 ****
ios_base::fmtflags, bool);
#endif
#endif
-
- template<typename _CharT>
- void
- __locale_cache<_CharT>::_S_callback(ios_base::event __ev, ios_base& __io, int);
-
- template class __locale_cache<char>;
- #ifdef _GLIBCPP_USE_WCHAR_T
- template class __locale_cache<wchar_t>;
- #endif
} // namespace std
--- 545,548 ----