mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-03 08:44:23 +08:00
2005-04-14 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/bitmap_allocator.h (__gnu_cxx::free_list::_M_get_mutex): New. (__gnu_cxx::free_list::_M_get_free_list): New. (__gnu_cxx::free_list::_S_bfl_mutex): Remove. (__gnu_cxx::free_list::_S_free_list): Remove. * src/bitmap_allocator.cc: Same. * config/linker-map.gnu: Remove free_list and mutex export. From-SVN: r98173
This commit is contained in:
parent
25cd19de2f
commit
57b11c9654
@ -1,3 +1,13 @@
|
||||
2005-04-14 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* include/ext/bitmap_allocator.h
|
||||
(__gnu_cxx::free_list::_M_get_mutex): New.
|
||||
(__gnu_cxx::free_list::_M_get_free_list): New.
|
||||
(__gnu_cxx::free_list::_S_bfl_mutex): Remove.
|
||||
(__gnu_cxx::free_list::_S_free_list): Remove.
|
||||
* src/bitmap_allocator.cc: Same.
|
||||
* config/linker-map.gnu: Remove free_list and mutex export.
|
||||
|
||||
2005-04-14 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* include/ext/pod_char_traits.h (__gnu_cxx::character): Add char_type.
|
||||
|
@ -299,8 +299,6 @@ GLIBCXX_3.4.4 {
|
||||
_ZN9__gnu_cxx6__poolILb[01]EE16_M_reclaim_blockEPc[jm];
|
||||
_ZN9__gnu_cxx6__poolILb[01]EE10_M_destroyEv;
|
||||
|
||||
_ZN9__gnu_cxx9free_list12_S_free_listE;
|
||||
_ZN9__gnu_cxx9free_list12_S_bfl_mutexE;
|
||||
_ZN9__gnu_cxx9free_list6_M_getE*;
|
||||
_ZN9__gnu_cxx9free_list8_M_clearEv;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Bitmap Allocator. -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2004, 2005 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
|
||||
@ -717,10 +717,21 @@ namespace __gnu_cxx
|
||||
{ return *__pui < __cui; }
|
||||
};
|
||||
|
||||
#if defined __GTHREADS
|
||||
static _Mutex _S_bfl_mutex;
|
||||
#if defined __GTHREADS
|
||||
_Mutex*
|
||||
_M_get_mutex()
|
||||
{
|
||||
static _Mutex _S_mutex;
|
||||
return &_S_mutex;
|
||||
}
|
||||
#endif
|
||||
static vector_type _S_free_list;
|
||||
|
||||
vector_type&
|
||||
_M_get_free_list()
|
||||
{
|
||||
static vector_type _S_free_list;
|
||||
return _S_free_list;
|
||||
}
|
||||
|
||||
/** @brief Performs validation of memory based on their size.
|
||||
*
|
||||
@ -735,12 +746,13 @@ namespace __gnu_cxx
|
||||
void
|
||||
_M_validate(size_t* __addr) throw()
|
||||
{
|
||||
vector_type& __free_list = _M_get_free_list();
|
||||
const vector_type::size_type __max_size = 64;
|
||||
if (_S_free_list.size() >= __max_size)
|
||||
if (__free_list.size() >= __max_size)
|
||||
{
|
||||
// Ok, the threshold value has been reached. We determine
|
||||
// which block to remove from the list of free blocks.
|
||||
if (*__addr >= *_S_free_list.back())
|
||||
if (*__addr >= *__free_list.back())
|
||||
{
|
||||
// Ok, the new block is greater than or equal to the
|
||||
// last block in the list of free blocks. We just free
|
||||
@ -752,18 +764,18 @@ namespace __gnu_cxx
|
||||
{
|
||||
// Deallocate the last block in the list of free lists,
|
||||
// and insert the new one in it's correct position.
|
||||
::operator delete(static_cast<void*>(_S_free_list.back()));
|
||||
_S_free_list.pop_back();
|
||||
::operator delete(static_cast<void*>(__free_list.back()));
|
||||
__free_list.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
// Just add the block to the list of free lists unconditionally.
|
||||
iterator __temp = __gnu_cxx::balloc::__lower_bound
|
||||
(_S_free_list.begin(), _S_free_list.end(),
|
||||
(__free_list.begin(), __free_list.end(),
|
||||
*__addr, _LT_pointer_compare());
|
||||
|
||||
// We may insert the new free list before _temp;
|
||||
_S_free_list.insert(__temp, __addr);
|
||||
__free_list.insert(__temp, __addr);
|
||||
}
|
||||
|
||||
/** @brief Decides whether the wastage of memory is acceptable for
|
||||
@ -801,7 +813,7 @@ namespace __gnu_cxx
|
||||
_M_insert(size_t* __addr) throw()
|
||||
{
|
||||
#if defined __GTHREADS
|
||||
_Auto_Lock __bfl_lock(&_S_bfl_mutex);
|
||||
_Auto_Lock __bfl_lock(_M_get_mutex());
|
||||
#endif
|
||||
// Call _M_validate to decide what should be done with
|
||||
// this particular free list.
|
||||
|
@ -48,25 +48,20 @@ namespace __gnu_cxx
|
||||
size_t const&, free_list::_LT_pointer_compare);
|
||||
}
|
||||
|
||||
#if defined __GTHREADS
|
||||
_Mutex free_list::_S_bfl_mutex;
|
||||
#endif
|
||||
free_list::vector_type free_list::_S_free_list;
|
||||
|
||||
size_t*
|
||||
free_list::
|
||||
_M_get(size_t __sz) throw(std::bad_alloc)
|
||||
{
|
||||
#if defined __GTHREADS
|
||||
_Lock __bfl_lock(&_S_bfl_mutex);
|
||||
_Lock __bfl_lock(_M_get_mutex());
|
||||
__bfl_lock._M_lock();
|
||||
#endif
|
||||
iterator __temp =
|
||||
__gnu_cxx::balloc::__lower_bound
|
||||
(_S_free_list.begin(), _S_free_list.end(),
|
||||
(_M_get_free_list().begin(), _M_get_free_list().end(),
|
||||
__sz, _LT_pointer_compare());
|
||||
|
||||
if (__temp == _S_free_list.end() || !_M_should_i_give(**__temp, __sz))
|
||||
if (__temp == _M_get_free_list().end() || !_M_should_i_give(**__temp, __sz))
|
||||
{
|
||||
// We release the lock here, because operator new is
|
||||
// guaranteed to be thread-safe by the underlying
|
||||
@ -101,7 +96,7 @@ namespace __gnu_cxx
|
||||
else
|
||||
{
|
||||
size_t* __ret = *__temp;
|
||||
_S_free_list.erase(__temp);
|
||||
_M_get_free_list().erase(__temp);
|
||||
#if defined __GTHREADS
|
||||
__bfl_lock._M_unlock();
|
||||
#endif
|
||||
@ -114,15 +109,16 @@ namespace __gnu_cxx
|
||||
_M_clear()
|
||||
{
|
||||
#if defined __GTHREADS
|
||||
_Auto_Lock __bfl_lock(&_S_bfl_mutex);
|
||||
_Auto_Lock __bfl_lock(_M_get_mutex());
|
||||
#endif
|
||||
iterator __iter = _S_free_list.begin();
|
||||
while (__iter != _S_free_list.end())
|
||||
vector_type& __free_list = _M_get_free_list();
|
||||
iterator __iter = __free_list.begin();
|
||||
while (__iter != __free_list.end())
|
||||
{
|
||||
::operator delete((void*)*__iter);
|
||||
++__iter;
|
||||
}
|
||||
_S_free_list.clear();
|
||||
__free_list.clear();
|
||||
}
|
||||
|
||||
// Instantiations.
|
||||
|
Loading…
Reference in New Issue
Block a user