From 3b6c93380e20c56b8151f9c6fc3916670b987df5 Mon Sep 17 00:00:00 2001 From: kan Date: Fri, 3 Jun 2005 03:29:38 +0000 Subject: Gcc 3.4.4 C++ support bits. --- contrib/libstdc++/src/allocator.cc | 33 +++++++++++++++++---------------- contrib/libstdc++/src/debug.cc | 23 ++++++++++++++++++----- contrib/libstdc++/src/ios.cc | 5 +++-- contrib/libstdc++/src/ios_init.cc | 3 +++ contrib/libstdc++/src/locale_init.cc | 24 ++++++++++++------------ contrib/libstdc++/src/localename.cc | 6 +++--- 6 files changed, 56 insertions(+), 38 deletions(-) (limited to 'contrib/libstdc++/src') diff --git a/contrib/libstdc++/src/allocator.cc b/contrib/libstdc++/src/allocator.cc index e35aa3e..4953d01 100644 --- a/contrib/libstdc++/src/allocator.cc +++ b/contrib/libstdc++/src/allocator.cc @@ -44,22 +44,22 @@ namespace __gnu_internal namespace __gnu_cxx { // Definitions for __pool_alloc_base. - __pool_base::_Obj* volatile* - __pool_base::_M_get_free_list(size_t __bytes) + __pool_alloc_base::_Obj* volatile* + __pool_alloc_base::_M_get_free_list(size_t __bytes) { size_t __i = ((__bytes + (size_t)_S_align - 1) / (size_t)_S_align - 1); return _S_free_list + __i; } mutex_type& - __pool_base::_M_get_mutex() + __pool_alloc_base::_M_get_mutex() { return __gnu_internal::palloc_init_mutex; } // Allocate memory in large chunks in order to avoid fragmenting the // heap too much. Assume that __n is properly aligned. We hold the // allocation lock. char* - __pool_base::_M_allocate_chunk(size_t __n, int& __nobjs) + __pool_alloc_base::_M_allocate_chunk(size_t __n, int& __nobjs) { char* __result; size_t __total_bytes = __n * __nobjs; @@ -91,8 +91,11 @@ namespace __gnu_cxx size_t __bytes_to_get = (2 * __total_bytes + _M_round_up(_S_heap_size >> 4)); - _S_start_free = static_cast(::operator new(__bytes_to_get)); - if (_S_start_free == 0) + try + { + _S_start_free = static_cast(::operator new(__bytes_to_get)); + } + catch (...) { // Try to make do with what we have. That can't hurt. We // do not try smaller requests, since that tends to result @@ -112,11 +115,9 @@ namespace __gnu_cxx // right free list. } } - _S_end_free = 0; // In case of exception. - - // This should either throw an exception or remedy the situation. - // Thus we assume it succeeded. - _S_start_free = static_cast(::operator new(__bytes_to_get)); + // What we have wasn't enough. Rethrow. + _S_start_free = _S_end_free = 0; // We have no chunk. + __throw_exception_again; } _S_heap_size += __bytes_to_get; _S_end_free = _S_start_free + __bytes_to_get; @@ -128,7 +129,7 @@ namespace __gnu_cxx // __n"'s free list. We assume that __n is properly aligned. We // hold the allocation lock. void* - __pool_base::_M_refill(size_t __n) + __pool_alloc_base::_M_refill(size_t __n) { int __nobjs = 20; char* __chunk = _M_allocate_chunk(__n, __nobjs); @@ -159,11 +160,11 @@ namespace __gnu_cxx return __result; } - __pool_base::_Obj* volatile __pool_base::_S_free_list[_S_free_list_size]; + __pool_alloc_base::_Obj* volatile __pool_alloc_base::_S_free_list[_S_free_list_size]; - char* __pool_base::_S_start_free = 0; + char* __pool_alloc_base::_S_start_free = 0; - char* __pool_base::_S_end_free = 0; + char* __pool_alloc_base::_S_end_free = 0; - size_t __pool_base::_S_heap_size = 0; + size_t __pool_alloc_base::_S_heap_size = 0; } // namespace __gnu_cxx diff --git a/contrib/libstdc++/src/debug.cc b/contrib/libstdc++/src/debug.cc index 05ebc2f..415fcbf 100644 --- a/contrib/libstdc++/src/debug.cc +++ b/contrib/libstdc++/src/debug.cc @@ -37,9 +37,15 @@ #include #include #include +#include using namespace std; +namespace __gnu_internal +{ + __glibcxx_mutex_define_initialized(iterator_base_mutex); +} // namespace __gnu_internal + namespace __gnu_debug { const char* _S_debug_messages[] = @@ -188,6 +194,7 @@ namespace __gnu_debug // Attach to the new sequence (if there is one) if (__seq) { + __gnu_cxx::lock sentry(__gnu_internal::iterator_base_mutex); _M_sequence = __seq; _M_version = _M_sequence->_M_version; _M_prior = 0; @@ -212,6 +219,7 @@ namespace __gnu_debug _Safe_iterator_base:: _M_detach() { + __gnu_cxx::lock sentry(__gnu_internal::iterator_base_mutex); if (_M_sequence) { // Remove us from this sequence's list @@ -569,12 +577,17 @@ namespace __gnu_debug { // [__start, __end) denotes the next word __end = __start; - while (isalnum(*__end)) ++__end; - if (__start == __end) ++__end; - if (isspace(*__end)) ++__end; + while (isalnum(*__end)) + ++__end; + if (__start == __end) + ++__end; + if (isspace(*__end)) + ++__end; - assert(__end - __start + 1< __bufsize); - _M_format_word(__buf, __end - __start + 1, "%s", __start); + const ptrdiff_t __len = __end - __start; + assert(__len < __bufsize); + memcpy(__buf, __start, __len); + __buf[__len] = '\0'; _M_print_word(__buf); __start = __end; diff --git a/contrib/libstdc++/src/ios.cc b/contrib/libstdc++/src/ios.cc index 12ffe2f..e68ee54 100644 --- a/contrib/libstdc++/src/ios.cc +++ b/contrib/libstdc++/src/ios.cc @@ -37,8 +37,9 @@ #include namespace std -{ - // Definitions for static const data members of __ios_flags. +{ + // XXX GLIBCXX_ABI Deprecated + // Definitions for static const data members of __ios_flags. const __ios_flags::__int_type __ios_flags::_S_boolalpha; const __ios_flags::__int_type __ios_flags::_S_dec; const __ios_flags::__int_type __ios_flags::_S_fixed; diff --git a/contrib/libstdc++/src/ios_init.cc b/contrib/libstdc++/src/ios_init.cc index ae7b8e1..346ed4e 100644 --- a/contrib/libstdc++/src/ios_init.cc +++ b/contrib/libstdc++/src/ios_init.cc @@ -155,6 +155,9 @@ namespace std // currently synchronized. if (!__sync && __ret) { + // Make sure the standard streams are constructed. + ios_base::Init __init; + ios_base::Init::_S_synced_with_stdio = __sync; // Explicitly call dtors to free any memory that is diff --git a/contrib/libstdc++/src/locale_init.cc b/contrib/libstdc++/src/locale_init.cc index 7252bc5..b2c8ea2 100644 --- a/contrib/libstdc++/src/locale_init.cc +++ b/contrib/libstdc++/src/locale_init.cc @@ -89,9 +89,8 @@ namespace __gnu_internal extern std::__timepunct_cache timepunct_cache_w; #endif - // Mutex objects for locale initialization. - __glibcxx_mutex_define_initialized(locale_cons_mutex); - __glibcxx_mutex_define_initialized(locale_global_mutex); + // Mutex object for locale initialization. + __glibcxx_mutex_define_initialized(locale_mutex); } // namespace __gnu_internal namespace std @@ -101,23 +100,24 @@ namespace std locale::locale() throw() : _M_impl(0) { _S_initialize(); - __glibcxx_mutex_lock(__gnu_internal::locale_cons_mutex); + __gnu_cxx::lock sentry(__gnu_internal::locale_mutex); _S_global->_M_add_reference(); _M_impl = _S_global; - __glibcxx_mutex_unlock(__gnu_internal::locale_cons_mutex); } locale locale::global(const locale& __other) { _S_initialize(); - __glibcxx_mutex_lock(__gnu_internal::locale_global_mutex); - _Impl* __old = _S_global; - __other._M_impl->_M_add_reference(); - _S_global = __other._M_impl; - if (__other.name() != "*") - setlocale(LC_ALL, __other.name().c_str()); - __glibcxx_mutex_unlock(__gnu_internal::locale_global_mutex); + _Impl* __old; + { + __gnu_cxx::lock sentry(__gnu_internal::locale_mutex); + __old = _S_global; + __other._M_impl->_M_add_reference(); + _S_global = __other._M_impl; + if (__other.name() != "*") + setlocale(LC_ALL, __other.name().c_str()); + } // Reference count sanity check: one reference removed for the // subsition of __other locale, one added by return-by-value. Net diff --git a/contrib/libstdc++/src/localename.cc b/contrib/libstdc++/src/localename.cc index 503d055..9c40c68 100644 --- a/contrib/libstdc++/src/localename.cc +++ b/contrib/libstdc++/src/localename.cc @@ -212,11 +212,11 @@ namespace std } else { - const char* __beg = __s; + const char* __end = __s; for (size_t __i = 0; __i < _S_categories_size; ++__i) { - __beg = std::strchr(__beg, '=') + 1; - const char* __end = std::strchr(__beg, ';'); + const char* __beg = std::strchr(__end + 1, '=') + 1; + __end = std::strchr(__beg, ';'); if (!__end) __end = __s + __len; char* __new = new char[__end - __beg + 1]; -- cgit v1.1