This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] libstdc++/37455
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 10 Sep 2008 18:51:14 +0200
- Subject: [v3] libstdc++/37455
Hi,
just move out of line two big, not frequently called, functions. Tested
generic/gnu/darwin locale models, committed to mainline.
Paolo.
///////////////////
2008-09-10 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/37455
* include/bits/locale_facets.h (ctype<char>::_M_narrow_init,
ctype<char>::_M_widen_init): Don't define inline.
* config/locale/darwin/ctype_members.cc: ... define here.
* config/locale/gnu/ctype_members.cc: ... likewise.
* config/locale/generic/ctype_members.cc: ... likewise.
* config/abi/pre/gnu.ver: Export.
Index: include/bits/locale_facets.h
===================================================================
*** include/bits/locale_facets.h (revision 140179)
--- include/bits/locale_facets.h (working copy)
***************
*** 1,7 ****
// Locale support -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
! // 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
--- 1,7 ----
// Locale support -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
! // 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 1161,1203 ****
}
private:
!
! void _M_widen_init() const
! {
! char __tmp[sizeof(_M_widen)];
! for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
! __tmp[__i] = __i;
! do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
!
! _M_widen_ok = 1;
! // Set _M_widen_ok to 2 if memcpy can't be used.
! if (__builtin_memcmp(__tmp, _M_widen, sizeof(_M_widen)))
! _M_widen_ok = 2;
! }
!
! // Fill in the narrowing cache and flag whether all values are
! // valid or not. _M_narrow_ok is set to 2 if memcpy can't
! // be used.
! void _M_narrow_init() const
! {
! char __tmp[sizeof(_M_narrow)];
! for (size_t __i = 0; __i < sizeof(_M_narrow); ++__i)
! __tmp[__i] = __i;
! do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
!
! _M_narrow_ok = 1;
! if (__builtin_memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
! _M_narrow_ok = 2;
! else
! {
! // Deal with the special case of zero: renarrow with a
! // different default and compare.
! char __c;
! do_narrow(__tmp, __tmp + 1, 1, &__c);
! if (__c == 1)
! _M_narrow_ok = 2;
! }
! }
};
template<>
--- 1161,1168 ----
}
private:
! void _M_narrow_init() const;
! void _M_widen_init() const;
};
template<>
Index: config/locale/darwin/ctype_members.cc
===================================================================
*** config/locale/darwin/ctype_members.cc (revision 140179)
--- config/locale/darwin/ctype_members.cc (working copy)
***************
*** 42,47 ****
--- 42,88 ----
namespace std
{
+ // Fill in the narrowing cache and flag whether all values are
+ // valid or not. _M_narrow_ok is set to 2 if memcpy can't
+ // be used.
+ void
+ ctype<char>::
+ _M_narrow_init() const
+ {
+ char __tmp[sizeof(_M_narrow)];
+ for (size_t __i = 0; __i < sizeof(_M_narrow); ++__i)
+ __tmp[__i] = __i;
+ do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
+
+ _M_narrow_ok = 1;
+ if (__builtin_memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
+ _M_narrow_ok = 2;
+ else
+ {
+ // Deal with the special case of zero: renarrow with a
+ // different default and compare.
+ char __c;
+ do_narrow(__tmp, __tmp + 1, 1, &__c);
+ if (__c == 1)
+ _M_narrow_ok = 2;
+ }
+ }
+
+ void
+ ctype<char>::
+ _M_widen_init() const
+ {
+ char __tmp[sizeof(_M_widen)];
+ for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
+ __tmp[__i] = __i;
+ do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
+
+ _M_widen_ok = 1;
+ // Set _M_widen_ok to 2 if memcpy can't be used.
+ if (__builtin_memcmp(__tmp, _M_widen, sizeof(_M_widen)))
+ _M_widen_ok = 2;
+ }
+
// NB: The other ctype<char> specializations are in src/locale.cc and
// various /config/os/* files.
Index: config/locale/gnu/ctype_members.cc
===================================================================
*** config/locale/gnu/ctype_members.cc (revision 140179)
--- config/locale/gnu/ctype_members.cc (working copy)
***************
*** 40,45 ****
--- 40,86 ----
_GLIBCXX_BEGIN_NAMESPACE(std)
+ // Fill in the narrowing cache and flag whether all values are
+ // valid or not. _M_narrow_ok is set to 2 if memcpy can't
+ // be used.
+ void
+ ctype<char>::
+ _M_narrow_init() const
+ {
+ char __tmp[sizeof(_M_narrow)];
+ for (size_t __i = 0; __i < sizeof(_M_narrow); ++__i)
+ __tmp[__i] = __i;
+ do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
+
+ _M_narrow_ok = 1;
+ if (__builtin_memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
+ _M_narrow_ok = 2;
+ else
+ {
+ // Deal with the special case of zero: renarrow with a
+ // different default and compare.
+ char __c;
+ do_narrow(__tmp, __tmp + 1, 1, &__c);
+ if (__c == 1)
+ _M_narrow_ok = 2;
+ }
+ }
+
+ void
+ ctype<char>::
+ _M_widen_init() const
+ {
+ char __tmp[sizeof(_M_widen)];
+ for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
+ __tmp[__i] = __i;
+ do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
+
+ _M_widen_ok = 1;
+ // Set _M_widen_ok to 2 if memcpy can't be used.
+ if (__builtin_memcmp(__tmp, _M_widen, sizeof(_M_widen)))
+ _M_widen_ok = 2;
+ }
+
// NB: The other ctype<char> specializations are in src/locale.cc and
// various /config/os/* files.
ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
Index: config/locale/generic/ctype_members.cc
===================================================================
*** config/locale/generic/ctype_members.cc (revision 140179)
--- config/locale/generic/ctype_members.cc (working copy)
***************
*** 41,46 ****
--- 41,87 ----
_GLIBCXX_BEGIN_NAMESPACE(std)
+ // Fill in the narrowing cache and flag whether all values are
+ // valid or not. _M_narrow_ok is set to 2 if memcpy can't
+ // be used.
+ void
+ ctype<char>::
+ _M_narrow_init() const
+ {
+ char __tmp[sizeof(_M_narrow)];
+ for (size_t __i = 0; __i < sizeof(_M_narrow); ++__i)
+ __tmp[__i] = __i;
+ do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
+
+ _M_narrow_ok = 1;
+ if (__builtin_memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
+ _M_narrow_ok = 2;
+ else
+ {
+ // Deal with the special case of zero: renarrow with a
+ // different default and compare.
+ char __c;
+ do_narrow(__tmp, __tmp + 1, 1, &__c);
+ if (__c == 1)
+ _M_narrow_ok = 2;
+ }
+ }
+
+ void
+ ctype<char>::
+ _M_widen_init() const
+ {
+ char __tmp[sizeof(_M_widen)];
+ for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
+ __tmp[__i] = __i;
+ do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
+
+ _M_widen_ok = 1;
+ // Set _M_widen_ok to 2 if memcpy can't be used.
+ if (__builtin_memcmp(__tmp, _M_widen, sizeof(_M_widen)))
+ _M_widen_ok = 2;
+ }
+
// NB: The other ctype<char> specializations are in src/locale.cc and
// various /config/os/* files.
ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
Index: config/abi/pre/gnu.ver
===================================================================
*** config/abi/pre/gnu.ver (revision 140179)
--- config/abi/pre/gnu.ver (working copy)
*************** GLIBCXX_3.4.11 {
*** 950,955 ****
--- 950,959 ----
_ZNSbIwSt11char_traitsIwESaIwEEaSESt16initializer_listIwE;
_ZNSbIwSt11char_traitsIwESaIwEEpLESt16initializer_listIwE;
+ # ctype<char>::_M_narrow_init and _M_widen_init
+ _ZNKSt5ctypeIcE14_M_narrow_initEv;
+ _ZNKSt5ctypeIcE13_M_widen_initEv;
+
} GLIBCXX_3.4.10;
# Symbols in the support library (libsupc++) have their own tag.