From 80bd72a50950f57eb0fd1ada5247195be5c777fb Mon Sep 17 00:00:00 2001 From: paolo Date: Sun, 12 Nov 2006 10:37:00 +0000 Subject: [PATCH] 2006-11-12 Paolo Carlini * include/ext/bitmap_allocator.h: Uglify some names. * include/ext/concurrence.h: Likewise. * src/bitmap_allocator.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118722 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 6 +++ libstdc++-v3/include/ext/bitmap_allocator.h | 75 +++++++++++++++-------------- libstdc++-v3/include/ext/concurrence.h | 22 ++++----- libstdc++-v3/src/bitmap_allocator.cc | 23 ++++++--- 4 files changed, 70 insertions(+), 56 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c581a49..0cb3497 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2006-11-12 Paolo Carlini + + * include/ext/bitmap_allocator.h: Uglify some names. + * include/ext/concurrence.h: Likewise. + * src/bitmap_allocator.cc: Likewise. + 2006-11-11 Paolo Carlini PR libstdc++/29496 diff --git a/libstdc++-v3/include/ext/bitmap_allocator.h b/libstdc++-v3/include/ext/bitmap_allocator.h index 5dbe286..838aef8 100644 --- a/libstdc++-v3/include/ext/bitmap_allocator.h +++ b/libstdc++-v3/include/ext/bitmap_allocator.h @@ -53,7 +53,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) using std::size_t; using std::ptrdiff_t; - namespace balloc + namespace __balloc { /** @class __mini_vector bitmap_allocator.h bitmap_allocator.h * @@ -361,7 +361,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) : public std::unary_function, bool> { typedef typename std::pair<_Tp, _Tp> _Block_pair; - typedef typename balloc::__mini_vector<_Block_pair> _BPVector; + typedef typename __balloc::__mini_vector<_Block_pair> _BPVector; typedef typename _BPVector::difference_type _Counter_type; size_t* _M_pbitmap; @@ -385,11 +385,11 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) // store, then there is definitely no space for another single // object, so just return false. _Counter_type __diff = - __gnu_cxx::balloc::__num_bitmaps(__bp); + __gnu_cxx::__balloc::__num_bitmaps(__bp); if (*(reinterpret_cast (__bp.first) - (__diff + 1)) - == __gnu_cxx::balloc::__num_blocks(__bp)) + == __gnu_cxx::__balloc::__num_blocks(__bp)) return false; size_t* __rover = reinterpret_cast(__bp.first) - 1; @@ -428,7 +428,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) template class _Bitmap_counter { - typedef typename balloc::__mini_vector > + typedef typename __balloc::__mini_vector > _BPVector; typedef typename _BPVector::size_type _Index_type; typedef _Tp pointer; @@ -534,7 +534,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) size_t __mask = 1 << __pos; *__pbmap |= __mask; } - } // namespace balloc + } // namespace __balloc /** @brief Generic Version of the bsf instruction. */ @@ -550,9 +550,9 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) class free_list { typedef size_t* value_type; - typedef balloc::__mini_vector vector_type; + typedef __balloc::__mini_vector vector_type; typedef vector_type::iterator iterator; - typedef __mutex mutex_type; + typedef __mutex __mutex_type; struct _LT_pointer_compare { @@ -563,10 +563,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) }; #if defined __GTHREADS - mutex_type& + __mutex_type& _M_get_mutex() { - static mutex_type _S_mutex; + static __mutex_type _S_mutex; return _S_mutex; } #endif @@ -615,7 +615,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) } // Just add the block to the list of free lists unconditionally. - iterator __temp = __gnu_cxx::balloc::__lower_bound + iterator __temp = __gnu_cxx::__balloc::__lower_bound (__free_list.begin(), __free_list.end(), *__addr, _LT_pointer_compare()); @@ -717,7 +717,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) typedef _Tp& reference; typedef const _Tp& const_reference; typedef _Tp value_type; - typedef free_list::mutex_type mutex_type; + typedef free_list::__mutex_type __mutex_type; template struct rebind @@ -746,7 +746,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) typedef typename std::pair<_Alloc_block*, _Alloc_block*> _Block_pair; typedef typename - balloc::__mini_vector<_Block_pair> _BPVector; + __balloc::__mini_vector<_Block_pair> _BPVector; #if defined _GLIBCXX_DEBUG // Complexity: O(lg(N)). Where, N is the number of block of size @@ -755,13 +755,13 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _S_check_for_free_blocks() throw() { typedef typename - __gnu_cxx::balloc::_Ffit_finder<_Alloc_block*> _FFF; + __gnu_cxx::__balloc::_Ffit_finder<_Alloc_block*> _FFF; _FFF __fff; typedef typename _BPVector::iterator _BPiter; _BPiter __bpi = - __gnu_cxx::balloc::__find_if + __gnu_cxx::__balloc::__find_if (_S_mem_blocks.begin(), _S_mem_blocks.end(), - __gnu_cxx::balloc::_Functor_Ref<_FFF>(__fff)); + __gnu_cxx::__balloc::_Functor_Ref<_FFF>(__fff)); _GLIBCXX_DEBUG_ASSERT(__bpi == _S_mem_blocks.end()); } @@ -786,7 +786,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) #endif const size_t __num_bitmaps = (_S_block_size - / size_t(balloc::bits_per_block)); + / size_t(__balloc::bits_per_block)); const size_t __size_to_allocate = sizeof(size_t) + _S_block_size * sizeof(_Alloc_block) + __num_bitmaps * sizeof(size_t); @@ -820,11 +820,11 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) static _BPVector _S_mem_blocks; static size_t _S_block_size; - static __gnu_cxx::balloc:: + static __gnu_cxx::__balloc:: _Bitmap_counter<_Alloc_block*> _S_last_request; static typename _BPVector::size_type _S_last_dealloc_index; #if defined __GTHREADS - static mutex_type _S_mut; + static __mutex_type _S_mut; #endif public: @@ -872,13 +872,13 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) { // Fall Back to First Fit algorithm. typedef typename - __gnu_cxx::balloc::_Ffit_finder<_Alloc_block*> _FFF; + __gnu_cxx::__balloc::_Ffit_finder<_Alloc_block*> _FFF; _FFF __fff; typedef typename _BPVector::iterator _BPiter; _BPiter __bpi = - __gnu_cxx::balloc::__find_if + __gnu_cxx::__balloc::__find_if (_S_mem_blocks.begin(), _S_mem_blocks.end(), - __gnu_cxx::balloc::_Functor_Ref<_FFF>(__fff)); + __gnu_cxx::__balloc::_Functor_Ref<_FFF>(__fff)); if (__bpi != _S_mem_blocks.end()) { @@ -886,7 +886,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) // the right as 0, meaning Allocated. This bit is obtained // by calling _M_get() on __fff. size_t __nz_bit = _Bit_scan_forward(*__fff._M_get()); - balloc::__bit_allocate(__fff._M_get(), __nz_bit); + __balloc::__bit_allocate(__fff._M_get(), __nz_bit); _S_last_request._M_reset(__bpi - _S_mem_blocks.begin()); @@ -896,7 +896,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) size_t* __puse_count = reinterpret_cast (__bpi->first) - - (__gnu_cxx::balloc::__num_bitmaps(*__bpi) + 1); + - (__gnu_cxx::__balloc::__num_bitmaps(*__bpi) + 1); ++(*__puse_count); return __ret; @@ -918,14 +918,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) // _S_last_request holds a pointer to a valid bit map, that // points to a free block in memory. size_t __nz_bit = _Bit_scan_forward(*_S_last_request._M_get()); - balloc::__bit_allocate(_S_last_request._M_get(), __nz_bit); + __balloc::__bit_allocate(_S_last_request._M_get(), __nz_bit); pointer __ret = reinterpret_cast (_S_last_request._M_base() + _S_last_request._M_offset() + __nz_bit); size_t* __puse_count = reinterpret_cast (_S_mem_blocks[_S_last_request._M_where()].first) - - (__gnu_cxx::balloc:: + - (__gnu_cxx::__balloc:: __num_bitmaps(_S_mem_blocks[_S_last_request._M_where()]) + 1); ++(*__puse_count); @@ -957,10 +957,11 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index >= 0); - if (__gnu_cxx::balloc::_Inclusive_between<_Alloc_block*> + if (__gnu_cxx::__balloc::_Inclusive_between<_Alloc_block*> (__real_p) (_S_mem_blocks[_S_last_dealloc_index])) { - _GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index <= _S_mem_blocks.size() - 1); + _GLIBCXX_DEBUG_ASSERT(_S_last_dealloc_index + <= _S_mem_blocks.size() - 1); // Initial Assumption was correct! __diff = _S_last_dealloc_index; @@ -968,10 +969,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) } else { - _Iterator _iter = __gnu_cxx::balloc:: + _Iterator _iter = __gnu_cxx::__balloc:: __find_if(_S_mem_blocks.begin(), _S_mem_blocks.end(), - __gnu_cxx::balloc:: + __gnu_cxx::__balloc:: _Inclusive_between<_Alloc_block*>(__real_p)); _GLIBCXX_DEBUG_ASSERT(_iter != _S_mem_blocks.end()); @@ -983,16 +984,16 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) // Get the position of the iterator that has been found. const size_t __rotate = (__displacement - % size_t(balloc::bits_per_block)); + % size_t(__balloc::bits_per_block)); size_t* __bitmapC = reinterpret_cast (_S_mem_blocks[__diff].first) - 1; - __bitmapC -= (__displacement / size_t(balloc::bits_per_block)); + __bitmapC -= (__displacement / size_t(__balloc::bits_per_block)); - balloc::__bit_free(__bitmapC, __rotate); + __balloc::__bit_free(__bitmapC, __rotate); size_t* __puse_count = reinterpret_cast (_S_mem_blocks[__diff].first) - - (__gnu_cxx::balloc::__num_bitmaps(_S_mem_blocks[__diff]) + 1); + - (__gnu_cxx::__balloc::__num_bitmaps(_S_mem_blocks[__diff]) + 1); _GLIBCXX_DEBUG_ASSERT(*__puse_count != 0); @@ -1114,20 +1115,20 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) template size_t bitmap_allocator<_Tp>::_S_block_size = - 2 * size_t(balloc::bits_per_block); + 2 * size_t(__balloc::bits_per_block); template typename __gnu_cxx::bitmap_allocator<_Tp>::_BPVector::size_type bitmap_allocator<_Tp>::_S_last_dealloc_index = 0; template - __gnu_cxx::balloc::_Bitmap_counter + __gnu_cxx::__balloc::_Bitmap_counter ::_Alloc_block*> bitmap_allocator<_Tp>::_S_last_request(_S_mem_blocks); #if defined __GTHREADS template - typename bitmap_allocator<_Tp>::mutex_type + typename bitmap_allocator<_Tp>::__mutex_type bitmap_allocator<_Tp>::_S_mut; #endif diff --git a/libstdc++-v3/include/ext/concurrence.h b/libstdc++-v3/include/ext/concurrence.h index 868264d..56e07de 100644 --- a/libstdc++-v3/include/ext/concurrence.h +++ b/libstdc++-v3/include/ext/concurrence.h @@ -67,20 +67,20 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) // NB: As this is used in libsupc++, need to only depend on // exception. No stdexception classes, no use of std::string. - class concurrence_lock_error : public std::exception + class __concurrence_lock_error : public std::exception { public: virtual char const* what() const throw() - { return "__gnu_cxx::concurrence_lock_error"; } + { return "__gnu_cxx::__concurrence_lock_error"; } }; - class concurrence_unlock_error : public std::exception + class __concurrence_unlock_error : public std::exception { public: virtual char const* what() const throw() - { return "__gnu_cxx::concurrence_unlock_error"; } + { return "__gnu_cxx::__concurrence_unlock_error"; } }; // Substitute for concurrence_error object in the case of -fno-exceptions. @@ -88,7 +88,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) __throw_concurrence_lock_error() { #if __EXCEPTIONS - throw concurrence_lock_error(); + throw __concurrence_lock_error(); #else std::abort(); #endif @@ -98,7 +98,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) __throw_concurrence_unlock_error() { #if __EXCEPTIONS - throw concurrence_unlock_error(); + throw __concurrence_unlock_error(); #else std::abort(); #endif @@ -129,7 +129,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) } void lock() - { + { #if __GTHREADS if (__gthread_active_p()) { @@ -140,7 +140,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) } void unlock() - { + { #if __GTHREADS if (__gthread_active_p()) { @@ -204,16 +204,16 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) class __scoped_lock { public: - typedef __mutex mutex_type; + typedef __mutex __mutex_type; private: - mutex_type& _M_device; + __mutex_type& _M_device; __scoped_lock(const __scoped_lock&); __scoped_lock& operator=(const __scoped_lock&); public: - explicit __scoped_lock(mutex_type& __name) : _M_device(__name) + explicit __scoped_lock(__mutex_type& __name) : _M_device(__name) { _M_device.lock(); } ~__scoped_lock() throw() diff --git a/libstdc++-v3/src/bitmap_allocator.cc b/libstdc++-v3/src/bitmap_allocator.cc index 63208df..411c7a1 100644 --- a/libstdc++-v3/src/bitmap_allocator.cc +++ b/libstdc++-v3/src/bitmap_allocator.cc @@ -1,6 +1,6 @@ // Bitmap Allocator. Out of line function definitions. -*- C++ -*- -// Copyright (C) 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -31,10 +31,16 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) - namespace balloc + namespace __balloc { - template class __mini_vector::_Alloc_block*, bitmap_allocator::_Alloc_block*> >; - template class __mini_vector::_Alloc_block*, bitmap_allocator::_Alloc_block*> >; + template class __mini_vector< + std::pair::_Alloc_block*, + bitmap_allocator::_Alloc_block*> >; + + template class __mini_vector< + std::pair::_Alloc_block*, + bitmap_allocator::_Alloc_block*> >; + template class __mini_vector; template size_t** __lower_bound(size_t**, size_t**, size_t const&, @@ -46,10 +52,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _M_get(size_t __sz) throw(std::bad_alloc) { #if defined __GTHREADS - mutex_type& __bfl_mutex = _M_get_mutex(); + __mutex_type& __bfl_mutex = _M_get_mutex(); #endif const vector_type& __free_list = _M_get_free_list(); - using __gnu_cxx::balloc::__lower_bound; + using __gnu_cxx::__balloc::__lower_bound; iterator __tmp = __lower_bound(__free_list.begin(), __free_list.end(), __sz, _LT_pointer_compare()); @@ -71,7 +77,8 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) --__ctr; try { - __ret = reinterpret_cast(::operator new(__sz + sizeof(size_t))); + __ret = reinterpret_cast + (::operator new(__sz + sizeof(size_t))); } catch(...) { @@ -95,7 +102,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) } } - void + void free_list:: _M_clear() { -- 2.7.4