mirror of git://gcc.gnu.org/git/gcc.git
bitmap_allocator.h: Clean-up add/remove functions.
2004-10-14 Dhruv Matani <dhruvbird@gmx.net> * ext/bitmap_allocator.h: Clean-up add/remove functions. * src/bitmap_allocator.cc: New file. Contains the out-of-line function definitions, static initialization of variables, and explicit instantiations needed for the allocator. * src/Makefile.am: Add. * src/Makefile.in: Regenerate. * config/linker.map.gnu: Add the necessary symbols. From-SVN: r89042
This commit is contained in:
parent
a023975e42
commit
1399eca190
|
@ -1,3 +1,13 @@
|
|||
2004-10-14 Dhruv Matani <dhruvbird@gmx.net>
|
||||
|
||||
* ext/bitmap_allocator.h: Clean-up add/remove functions.
|
||||
* src/bitmap_allocator.cc: New file. Contains the out-of-line
|
||||
function definitions, static initialization of variables, and
|
||||
explicit instantiations needed for the allocator.
|
||||
* src/Makefile.am: Add.
|
||||
* src/Makefile.in: Regenerate.
|
||||
* config/linker.map.gnu: Add the necessary symbols.
|
||||
|
||||
2004-10-13 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/basic_string.tcc (_S_create): Use consistently
|
||||
|
|
|
@ -270,7 +270,12 @@ GLIBCXX_3.4.3 {
|
|||
_ZN9__gnu_cxx6__poolILb[01]EE16_M_reserve_blockE[jm][jm];
|
||||
_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_getEj;
|
||||
_ZN9__gnu_cxx9free_list8_M_clearEv;
|
||||
|
||||
# stub functions from libmath
|
||||
acosf;
|
||||
acosl;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -96,6 +96,7 @@ basic_file.cc: ${glibcxx_srcdir}/$(BASIC_FILE_CC)
|
|||
|
||||
# Sources present in the src directory.
|
||||
sources = \
|
||||
bitmap_allocator.cc \
|
||||
pool_allocator.cc \
|
||||
mt_allocator.cc \
|
||||
codecvt.cc \
|
||||
|
|
|
@ -64,14 +64,14 @@ am__objects_1 = atomicity.lo codecvt_members.lo collate_members.lo \
|
|||
ctype_members.lo messages_members.lo monetary_members.lo \
|
||||
numeric_members.lo time_members.lo
|
||||
am__objects_2 = basic_file.lo c++locale.lo
|
||||
am__objects_3 = pool_allocator.lo mt_allocator.lo codecvt.lo \
|
||||
complex_io.lo ctype.lo debug.lo debug_list.lo functexcept.lo \
|
||||
globals_locale.lo globals_io.lo ios.lo ios_failure.lo \
|
||||
ios_init.lo ios_locale.lo limits.lo list.lo locale.lo \
|
||||
locale_init.lo locale_facets.lo localename.lo stdexcept.lo \
|
||||
strstream.lo tree.lo allocator-inst.lo concept-inst.lo \
|
||||
fstream-inst.lo ext-inst.lo io-inst.lo istream-inst.lo \
|
||||
locale-inst.lo locale-misc-inst.lo misc-inst.lo \
|
||||
am__objects_3 = bitmap_allocator.lo pool_allocator.lo mt_allocator.lo \
|
||||
codecvt.lo complex_io.lo ctype.lo debug.lo debug_list.lo \
|
||||
functexcept.lo globals_locale.lo globals_io.lo ios.lo \
|
||||
ios_failure.lo ios_init.lo ios_locale.lo limits.lo list.lo \
|
||||
locale.lo locale_init.lo locale_facets.lo localename.lo \
|
||||
stdexcept.lo strstream.lo tree.lo allocator-inst.lo \
|
||||
concept-inst.lo fstream-inst.lo ext-inst.lo io-inst.lo \
|
||||
istream-inst.lo locale-inst.lo locale-misc-inst.lo misc-inst.lo \
|
||||
ostream-inst.lo sstream-inst.lo streambuf-inst.lo \
|
||||
string-inst.lo valarray-inst.lo wlocale-inst.lo \
|
||||
wstring-inst.lo $(am__objects_1) $(am__objects_2)
|
||||
|
@ -306,6 +306,7 @@ host_sources_extra = \
|
|||
|
||||
# Sources present in the src directory.
|
||||
sources = \
|
||||
bitmap_allocator.cc \
|
||||
pool_allocator.cc \
|
||||
mt_allocator.cc \
|
||||
codecvt.cc \
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
// Bitmap Allocator. Out of line function definitions. -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2004 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
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
// USA.
|
||||
|
||||
// As a special exception, you may use this file as part of a free software
|
||||
// library without restriction. Specifically, if other files instantiate
|
||||
// templates or use macros or inline functions from this file, or you compile
|
||||
// this file and link it with other files to produce an executable, this
|
||||
// file does not by itself cause the resulting executable to be covered by
|
||||
// the GNU General Public License. This exception does not however
|
||||
// invalidate any other reasons why the executable file might be covered by
|
||||
// the GNU General Public License.
|
||||
|
||||
#include <ext/bitmap_allocator.h>
|
||||
|
||||
namespace __gnu_cxx
|
||||
{
|
||||
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<unsigned int*>;
|
||||
|
||||
template unsigned int** __lower_bound
|
||||
(unsigned int**, unsigned int**,
|
||||
unsigned int 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;
|
||||
|
||||
unsigned int*
|
||||
free_list::
|
||||
_M_get(unsigned int __sz) throw(std::bad_alloc)
|
||||
{
|
||||
#if defined __GTHREADS
|
||||
_Lock __bfl_lock(&_S_bfl_mutex);
|
||||
__bfl_lock._M_lock();
|
||||
#endif
|
||||
iterator __temp =
|
||||
__gnu_cxx::balloc::__lower_bound
|
||||
(_S_free_list.begin(), _S_free_list.end(),
|
||||
__sz, _LT_pointer_compare());
|
||||
|
||||
if (__temp == _S_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
|
||||
// implementation.
|
||||
#if defined __GTHREADS
|
||||
__bfl_lock._M_unlock();
|
||||
#endif
|
||||
// Try twice to get the memory: once directly, and the 2nd
|
||||
// time after clearing the free list. If both fail, then
|
||||
// throw std::bad_alloc().
|
||||
unsigned int __ctr = 2;
|
||||
while (__ctr)
|
||||
{
|
||||
unsigned int* __ret = 0;
|
||||
--__ctr;
|
||||
try
|
||||
{
|
||||
__ret = reinterpret_cast<unsigned int*>
|
||||
(::operator new(__sz + sizeof(unsigned int)));
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
this->_M_clear();
|
||||
}
|
||||
if (!__ret)
|
||||
continue;
|
||||
*__ret = __sz;
|
||||
return reinterpret_cast<unsigned int*>
|
||||
(reinterpret_cast<char*>(__ret) + sizeof(unsigned int));
|
||||
}
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int* __ret = *__temp;
|
||||
_S_free_list.erase(__temp);
|
||||
#if defined __GTHREADS
|
||||
__bfl_lock._M_unlock();
|
||||
#endif
|
||||
return reinterpret_cast<unsigned int*>
|
||||
(reinterpret_cast<char*>(__ret) + sizeof(unsigned int));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
free_list::
|
||||
_M_clear()
|
||||
{
|
||||
#if defined __GTHREADS
|
||||
_Auto_Lock __bfl_lock(&_S_bfl_mutex);
|
||||
#endif
|
||||
iterator __iter = _S_free_list.begin();
|
||||
while (__iter != _S_free_list.end())
|
||||
{
|
||||
operator delete((void*)*__iter);
|
||||
++__iter;
|
||||
}
|
||||
_S_free_list.clear();
|
||||
}
|
||||
|
||||
// Instantiations.
|
||||
template class bitmap_allocator<char>;
|
||||
template class bitmap_allocator<wchar_t>;
|
||||
} // namespace __gnu_cxx
|
Loading…
Reference in New Issue