using std::size_t;
using std::ptrdiff_t;
- namespace balloc
+ namespace __balloc
{
/** @class __mini_vector bitmap_allocator.h bitmap_allocator.h
*
: public std::unary_function<typename std::pair<_Tp, _Tp>, 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;
// 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<size_t*>
(__bp.first) - (__diff + 1))
- == __gnu_cxx::balloc::__num_blocks(__bp))
+ == __gnu_cxx::__balloc::__num_blocks(__bp))
return false;
size_t* __rover = reinterpret_cast<size_t*>(__bp.first) - 1;
template<typename _Tp>
class _Bitmap_counter
{
- typedef typename balloc::__mini_vector<typename std::pair<_Tp, _Tp> >
+ typedef typename __balloc::__mini_vector<typename std::pair<_Tp, _Tp> >
_BPVector;
typedef typename _BPVector::size_type _Index_type;
typedef _Tp pointer;
size_t __mask = 1 << __pos;
*__pbmap |= __mask;
}
- } // namespace balloc
+ } // namespace __balloc
/** @brief Generic Version of the bsf instruction.
*/
class free_list
{
typedef size_t* value_type;
- typedef balloc::__mini_vector<value_type> vector_type;
+ typedef __balloc::__mini_vector<value_type> vector_type;
typedef vector_type::iterator iterator;
- typedef __mutex mutex_type;
+ typedef __mutex __mutex_type;
struct _LT_pointer_compare
{
};
#if defined __GTHREADS
- mutex_type&
+ __mutex_type&
_M_get_mutex()
{
- static mutex_type _S_mutex;
+ static __mutex_type _S_mutex;
return _S_mutex;
}
#endif
}
// 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());
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<typename _Tp1>
struct rebind
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
_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());
}
#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);
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:
{
// 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())
{
// 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());
size_t* __puse_count =
reinterpret_cast<size_t*>
(__bpi->first)
- - (__gnu_cxx::balloc::__num_bitmaps(*__bpi) + 1);
+ - (__gnu_cxx::__balloc::__num_bitmaps(*__bpi) + 1);
++(*__puse_count);
return __ret;
// _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<pointer>
(_S_last_request._M_base() + _S_last_request._M_offset() + __nz_bit);
size_t* __puse_count = reinterpret_cast<size_t*>
(_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);
_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;
}
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());
// 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<size_t*>
(_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<size_t*>
(_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);
template<typename _Tp>
size_t bitmap_allocator<_Tp>::_S_block_size =
- 2 * size_t(balloc::bits_per_block);
+ 2 * size_t(__balloc::bits_per_block);
template<typename _Tp>
typename __gnu_cxx::bitmap_allocator<_Tp>::_BPVector::size_type
bitmap_allocator<_Tp>::_S_last_dealloc_index = 0;
template<typename _Tp>
- __gnu_cxx::balloc::_Bitmap_counter
+ __gnu_cxx::__balloc::_Bitmap_counter
<typename bitmap_allocator<_Tp>::_Alloc_block*>
bitmap_allocator<_Tp>::_S_last_request(_S_mem_blocks);
#if defined __GTHREADS
template<typename _Tp>
- typename bitmap_allocator<_Tp>::mutex_type
+ typename bitmap_allocator<_Tp>::__mutex_type
bitmap_allocator<_Tp>::_S_mut;
#endif
// 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
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
- namespace balloc
+ namespace __balloc
{
- template class __mini_vector<std::pair<bitmap_allocator<char>::_Alloc_block*, bitmap_allocator<char>::_Alloc_block*> >;
- template class __mini_vector<std::pair<bitmap_allocator<wchar_t>::_Alloc_block*, bitmap_allocator<wchar_t>::_Alloc_block*> >;
+ template class __mini_vector<
+ std::pair<bitmap_allocator<char>::_Alloc_block*,
+ bitmap_allocator<char>::_Alloc_block*> >;
+
+ template class __mini_vector<
+ std::pair<bitmap_allocator<wchar_t>::_Alloc_block*,
+ bitmap_allocator<wchar_t>::_Alloc_block*> >;
+
template class __mini_vector<size_t*>;
template size_t** __lower_bound(size_t**, size_t**, size_t const&,
_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());
--__ctr;
try
{
- __ret = reinterpret_cast<size_t*>(::operator new(__sz + sizeof(size_t)));
+ __ret = reinterpret_cast<size_t*>
+ (::operator new(__sz + sizeof(size_t)));
}
catch(...)
{
}
}
- void
+ void
free_list::
_M_clear()
{