2004-09-02 00:17:00 +02:00
|
|
|
// Allocator details.
|
|
|
|
|
2006-07-21 01:37:27 +02:00
|
|
|
// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
2004-09-02 00:17:00 +02:00
|
|
|
//
|
2005-09-12 06:49:11 +02:00
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
2004-09-02 00:17:00 +02:00
|
|
|
// 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
|
2005-08-17 04:28:44 +02:00
|
|
|
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
2004-09-02 00:17:00 +02:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
//
|
|
|
|
// ISO C++ 14882:
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <bits/c++config.h>
|
|
|
|
#include <bits/concurrence.h>
|
2004-10-06 06:22:42 +02:00
|
|
|
#include <ext/mt_allocator.h>
|
2006-09-02 10:31:45 +02:00
|
|
|
#include <cstring>
|
2004-09-02 00:17:00 +02:00
|
|
|
|
2006-07-28 06:57:34 +02:00
|
|
|
namespace
|
2004-09-02 00:17:00 +02:00
|
|
|
{
|
2005-09-12 06:49:11 +02:00
|
|
|
#ifdef __GTHREADS
|
|
|
|
struct __freelist
|
|
|
|
{
|
|
|
|
typedef __gnu_cxx::__pool<true>::_Thread_record _Thread_record;
|
|
|
|
_Thread_record* _M_thread_freelist;
|
|
|
|
_Thread_record* _M_thread_freelist_array;
|
|
|
|
size_t _M_max_threads;
|
|
|
|
__gthread_key_t _M_key;
|
|
|
|
|
|
|
|
~__freelist()
|
|
|
|
{
|
|
|
|
if (_M_thread_freelist_array)
|
|
|
|
{
|
|
|
|
__gthread_key_delete(_M_key);
|
|
|
|
::operator delete(static_cast<void*>(_M_thread_freelist_array));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Ensure freelist is constructed first.
|
|
|
|
static __freelist freelist;
|
2005-09-09 12:14:55 +02:00
|
|
|
static __glibcxx_mutex_define_initialized(freelist_mutex);
|
2004-09-02 00:17:00 +02:00
|
|
|
|
2005-09-12 06:49:11 +02:00
|
|
|
static void
|
|
|
|
_M_destroy_thread_key(void* __id)
|
|
|
|
{
|
2005-11-09 00:07:02 +01:00
|
|
|
// Return this thread id record to the front of thread_freelist.
|
2006-07-28 06:57:34 +02:00
|
|
|
__gnu_cxx::lock sentry(freelist_mutex);
|
2005-09-12 06:49:11 +02:00
|
|
|
size_t _M_id = reinterpret_cast<size_t>(__id);
|
|
|
|
|
|
|
|
typedef __gnu_cxx::__pool<true>::_Thread_record _Thread_record;
|
|
|
|
_Thread_record* __tr = &freelist._M_thread_freelist_array[_M_id - 1];
|
|
|
|
__tr->_M_next = freelist._M_thread_freelist;
|
|
|
|
freelist._M_thread_freelist = __tr;
|
|
|
|
}
|
2004-09-02 00:17:00 +02:00
|
|
|
#endif
|
2006-07-28 06:57:34 +02:00
|
|
|
} // anonymous namespace
|
2004-09-02 00:17:00 +02:00
|
|
|
|
2005-12-19 01:56:05 +01:00
|
|
|
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
|
|
|
|
2004-10-12 03:10:39 +02:00
|
|
|
void
|
|
|
|
__pool<false>::_M_destroy() throw()
|
2004-10-06 06:22:42 +02:00
|
|
|
{
|
|
|
|
if (_M_init && !_M_options._M_force_new)
|
|
|
|
{
|
|
|
|
for (size_t __n = 0; __n < _M_bin_size; ++__n)
|
|
|
|
{
|
|
|
|
_Bin_record& __bin = _M_bin[__n];
|
|
|
|
while (__bin._M_address)
|
|
|
|
{
|
|
|
|
_Block_address* __tmp = __bin._M_address->_M_next;
|
|
|
|
::operator delete(__bin._M_address->_M_initial);
|
|
|
|
__bin._M_address = __tmp;
|
|
|
|
}
|
2004-10-15 12:54:57 +02:00
|
|
|
::operator delete(__bin._M_first);
|
2004-10-06 06:22:42 +02:00
|
|
|
}
|
2004-10-15 12:54:57 +02:00
|
|
|
::operator delete(_M_bin);
|
|
|
|
::operator delete(_M_binmap);
|
2004-10-06 06:22:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
__pool<false>::_M_reclaim_block(char* __p, size_t __bytes)
|
|
|
|
{
|
|
|
|
// Round up to power of 2 and figure out which bin to use.
|
|
|
|
const size_t __which = _M_binmap[__bytes];
|
|
|
|
_Bin_record& __bin = _M_bin[__which];
|
|
|
|
|
2004-10-17 17:22:03 +02:00
|
|
|
char* __c = __p - _M_get_align();
|
2004-10-06 06:22:42 +02:00
|
|
|
_Block_record* __block = reinterpret_cast<_Block_record*>(__c);
|
|
|
|
|
|
|
|
// Single threaded application - return to global pool.
|
|
|
|
__block->_M_next = __bin._M_first[0];
|
|
|
|
__bin._M_first[0] = __block;
|
|
|
|
}
|
|
|
|
|
|
|
|
char*
|
|
|
|
__pool<false>::_M_reserve_block(size_t __bytes, const size_t __thread_id)
|
|
|
|
{
|
|
|
|
// Round up to power of 2 and figure out which bin to use.
|
|
|
|
const size_t __which = _M_binmap[__bytes];
|
2004-10-14 23:05:24 +02:00
|
|
|
_Bin_record& __bin = _M_bin[__which];
|
2004-10-06 06:22:42 +02:00
|
|
|
const _Tune& __options = _M_get_options();
|
2004-10-17 17:22:03 +02:00
|
|
|
const size_t __bin_size = (__options._M_min_bin << __which)
|
|
|
|
+ __options._M_align;
|
|
|
|
size_t __block_count = __options._M_chunk_size - sizeof(_Block_address);
|
|
|
|
__block_count /= __bin_size;
|
2004-10-06 06:22:42 +02:00
|
|
|
|
|
|
|
// Get a new block dynamically, set it up for use.
|
|
|
|
void* __v = ::operator new(__options._M_chunk_size);
|
2004-10-17 17:22:03 +02:00
|
|
|
_Block_address* __address = static_cast<_Block_address*>(__v);
|
|
|
|
__address->_M_initial = __v;
|
|
|
|
__address->_M_next = __bin._M_address;
|
|
|
|
__bin._M_address = __address;
|
|
|
|
|
|
|
|
char* __c = static_cast<char*>(__v) + sizeof(_Block_address);
|
|
|
|
_Block_record* __block = reinterpret_cast<_Block_record*>(__c);
|
2004-10-14 23:05:24 +02:00
|
|
|
__bin._M_first[__thread_id] = __block;
|
|
|
|
while (--__block_count > 0)
|
2004-10-06 06:22:42 +02:00
|
|
|
{
|
2004-10-17 17:22:03 +02:00
|
|
|
__c += __bin_size;
|
2004-10-14 23:05:24 +02:00
|
|
|
__block->_M_next = reinterpret_cast<_Block_record*>(__c);
|
|
|
|
__block = __block->_M_next;
|
2004-10-06 06:22:42 +02:00
|
|
|
}
|
2004-10-14 23:05:24 +02:00
|
|
|
__block->_M_next = NULL;
|
2004-10-06 06:22:42 +02:00
|
|
|
|
2004-10-14 23:05:24 +02:00
|
|
|
__block = __bin._M_first[__thread_id];
|
|
|
|
__bin._M_first[__thread_id] = __block->_M_next;
|
|
|
|
|
2004-10-06 06:22:42 +02:00
|
|
|
// NB: For alignment reasons, we can't use the first _M_align
|
|
|
|
// bytes, even when sizeof(_Block_record) < _M_align.
|
|
|
|
return reinterpret_cast<char*>(__block) + __options._M_align;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
__pool<false>::_M_initialize()
|
|
|
|
{
|
|
|
|
// _M_force_new must not change after the first allocate(), which
|
|
|
|
// in turn calls this method, so if it's false, it's false forever
|
|
|
|
// and we don't need to return here ever again.
|
|
|
|
if (_M_options._M_force_new)
|
|
|
|
{
|
|
|
|
_M_init = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the bins.
|
|
|
|
// Calculate the number of bins required based on _M_max_bytes.
|
|
|
|
// _M_bin_size is statically-initialized to one.
|
|
|
|
size_t __bin_size = _M_options._M_min_bin;
|
|
|
|
while (_M_options._M_max_bytes > __bin_size)
|
|
|
|
{
|
|
|
|
__bin_size <<= 1;
|
|
|
|
++_M_bin_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup the bin map for quick lookup of the relevant bin.
|
|
|
|
const size_t __j = (_M_options._M_max_bytes + 1) * sizeof(_Binmap_type);
|
|
|
|
_M_binmap = static_cast<_Binmap_type*>(::operator new(__j));
|
|
|
|
_Binmap_type* __bp = _M_binmap;
|
|
|
|
_Binmap_type __bin_max = _M_options._M_min_bin;
|
|
|
|
_Binmap_type __bint = 0;
|
|
|
|
for (_Binmap_type __ct = 0; __ct <= _M_options._M_max_bytes; ++__ct)
|
|
|
|
{
|
|
|
|
if (__ct > __bin_max)
|
|
|
|
{
|
|
|
|
__bin_max <<= 1;
|
|
|
|
++__bint;
|
|
|
|
}
|
|
|
|
*__bp++ = __bint;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize _M_bin and its members.
|
|
|
|
void* __v = ::operator new(sizeof(_Bin_record) * _M_bin_size);
|
|
|
|
_M_bin = static_cast<_Bin_record*>(__v);
|
|
|
|
for (size_t __n = 0; __n < _M_bin_size; ++__n)
|
|
|
|
{
|
|
|
|
_Bin_record& __bin = _M_bin[__n];
|
|
|
|
__v = ::operator new(sizeof(_Block_record*));
|
|
|
|
__bin._M_first = static_cast<_Block_record**>(__v);
|
|
|
|
__bin._M_first[0] = NULL;
|
|
|
|
__bin._M_address = NULL;
|
|
|
|
}
|
|
|
|
_M_init = true;
|
|
|
|
}
|
2005-09-12 06:49:11 +02:00
|
|
|
|
2004-10-06 06:22:42 +02:00
|
|
|
|
2004-09-02 00:17:00 +02:00
|
|
|
#ifdef __GTHREADS
|
2004-10-12 03:10:39 +02:00
|
|
|
void
|
|
|
|
__pool<true>::_M_destroy() throw()
|
2004-10-06 06:22:42 +02:00
|
|
|
{
|
|
|
|
if (_M_init && !_M_options._M_force_new)
|
|
|
|
{
|
|
|
|
if (__gthread_active_p())
|
|
|
|
{
|
|
|
|
for (size_t __n = 0; __n < _M_bin_size; ++__n)
|
|
|
|
{
|
|
|
|
_Bin_record& __bin = _M_bin[__n];
|
|
|
|
while (__bin._M_address)
|
|
|
|
{
|
|
|
|
_Block_address* __tmp = __bin._M_address->_M_next;
|
|
|
|
::operator delete(__bin._M_address->_M_initial);
|
|
|
|
__bin._M_address = __tmp;
|
|
|
|
}
|
2004-10-15 12:54:57 +02:00
|
|
|
::operator delete(__bin._M_first);
|
|
|
|
::operator delete(__bin._M_free);
|
|
|
|
::operator delete(__bin._M_used);
|
|
|
|
::operator delete(__bin._M_mutex);
|
2004-10-06 06:22:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (size_t __n = 0; __n < _M_bin_size; ++__n)
|
|
|
|
{
|
|
|
|
_Bin_record& __bin = _M_bin[__n];
|
|
|
|
while (__bin._M_address)
|
|
|
|
{
|
|
|
|
_Block_address* __tmp = __bin._M_address->_M_next;
|
|
|
|
::operator delete(__bin._M_address->_M_initial);
|
|
|
|
__bin._M_address = __tmp;
|
|
|
|
}
|
2004-10-15 12:54:57 +02:00
|
|
|
::operator delete(__bin._M_first);
|
2004-10-06 06:22:42 +02:00
|
|
|
}
|
|
|
|
}
|
2004-10-15 12:54:57 +02:00
|
|
|
::operator delete(_M_bin);
|
|
|
|
::operator delete(_M_binmap);
|
2004-10-06 06:22:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-02 00:17:00 +02:00
|
|
|
void
|
2004-10-06 06:22:42 +02:00
|
|
|
__pool<true>::_M_reclaim_block(char* __p, size_t __bytes)
|
2004-09-02 00:17:00 +02:00
|
|
|
{
|
|
|
|
// Round up to power of 2 and figure out which bin to use.
|
|
|
|
const size_t __which = _M_binmap[__bytes];
|
|
|
|
const _Bin_record& __bin = _M_bin[__which];
|
2004-10-06 06:22:42 +02:00
|
|
|
|
2004-10-17 17:22:03 +02:00
|
|
|
// Know __p not null, assume valid block.
|
|
|
|
char* __c = __p - _M_get_align();
|
2004-09-02 00:17:00 +02:00
|
|
|
_Block_record* __block = reinterpret_cast<_Block_record*>(__c);
|
|
|
|
if (__gthread_active_p())
|
|
|
|
{
|
|
|
|
// Calculate the number of records to remove from our freelist:
|
|
|
|
// in order to avoid too much contention we wait until the
|
|
|
|
// number of records is "high enough".
|
|
|
|
const size_t __thread_id = _M_get_thread_id();
|
2004-10-17 17:22:03 +02:00
|
|
|
const _Tune& __options = _M_get_options();
|
2006-09-02 10:31:45 +02:00
|
|
|
const size_t __limit = (100 * (_M_bin_size - __which)
|
|
|
|
* __options._M_freelist_headroom);
|
2004-10-17 17:22:03 +02:00
|
|
|
|
2006-09-02 10:31:45 +02:00
|
|
|
size_t __remove = __bin._M_free[__thread_id];
|
2004-10-17 17:22:03 +02:00
|
|
|
__remove *= __options._M_freelist_headroom;
|
2006-09-02 10:31:45 +02:00
|
|
|
|
|
|
|
// NB: We assume that reads of _Atomic_words are atomic.
|
|
|
|
const size_t __max_threads = __options._M_max_threads + 1;
|
|
|
|
_Atomic_word* const __reclaimed_base =
|
|
|
|
reinterpret_cast<_Atomic_word*>(__bin._M_used + __max_threads);
|
|
|
|
const _Atomic_word __reclaimed = __reclaimed_base[__thread_id];
|
|
|
|
const size_t __used = __bin._M_used[__thread_id] - __reclaimed;
|
|
|
|
|
|
|
|
// NB: For performance sake we don't resync every time, in order
|
|
|
|
// to spare atomic ops. Note that if __reclaimed increased by,
|
|
|
|
// say, 1024, since the last sync, it means that the other
|
|
|
|
// threads executed the atomic in the else below at least the
|
|
|
|
// same number of times (at least, because _M_reserve_block may
|
|
|
|
// have decreased the counter), therefore one more cannot hurt.
|
|
|
|
if (__reclaimed > 1024)
|
|
|
|
{
|
|
|
|
__bin._M_used[__thread_id] -= __reclaimed;
|
|
|
|
__atomic_add(&__reclaimed_base[__thread_id], -__reclaimed);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (__remove >= __used)
|
|
|
|
__remove -= __used;
|
2004-10-17 17:22:03 +02:00
|
|
|
else
|
|
|
|
__remove = 0;
|
|
|
|
if (__remove > __limit && __remove > __bin._M_free[__thread_id])
|
2004-09-02 00:17:00 +02:00
|
|
|
{
|
2004-10-17 17:22:03 +02:00
|
|
|
_Block_record* __first = __bin._M_first[__thread_id];
|
|
|
|
_Block_record* __tmp = __first;
|
2004-09-02 00:17:00 +02:00
|
|
|
__remove /= __options._M_freelist_headroom;
|
2006-09-02 10:31:45 +02:00
|
|
|
const size_t __removed = __remove;
|
2004-10-14 23:05:24 +02:00
|
|
|
while (--__remove > 0)
|
2004-09-02 00:17:00 +02:00
|
|
|
__tmp = __tmp->_M_next;
|
|
|
|
__bin._M_first[__thread_id] = __tmp->_M_next;
|
|
|
|
__bin._M_free[__thread_id] -= __removed;
|
|
|
|
|
|
|
|
__gthread_mutex_lock(__bin._M_mutex);
|
|
|
|
__tmp->_M_next = __bin._M_first[0];
|
|
|
|
__bin._M_first[0] = __first;
|
|
|
|
__bin._M_free[0] += __removed;
|
|
|
|
__gthread_mutex_unlock(__bin._M_mutex);
|
|
|
|
}
|
2004-10-17 17:22:03 +02:00
|
|
|
|
2004-09-02 00:17:00 +02:00
|
|
|
// Return this block to our list and update counters and
|
|
|
|
// owner id as needed.
|
2006-09-02 10:31:45 +02:00
|
|
|
if (__block->_M_thread_id == __thread_id)
|
|
|
|
--__bin._M_used[__thread_id];
|
|
|
|
else
|
|
|
|
__atomic_add(&__reclaimed_base[__block->_M_thread_id], 1);
|
|
|
|
|
2004-09-02 00:17:00 +02:00
|
|
|
__block->_M_next = __bin._M_first[__thread_id];
|
|
|
|
__bin._M_first[__thread_id] = __block;
|
|
|
|
|
|
|
|
++__bin._M_free[__thread_id];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Not using threads, so single threaded application - return
|
|
|
|
// to global pool.
|
|
|
|
__block->_M_next = __bin._M_first[0];
|
|
|
|
__bin._M_first[0] = __block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char*
|
2004-10-06 06:22:42 +02:00
|
|
|
__pool<true>::_M_reserve_block(size_t __bytes, const size_t __thread_id)
|
2004-09-02 00:17:00 +02:00
|
|
|
{
|
|
|
|
// Round up to power of 2 and figure out which bin to use.
|
|
|
|
const size_t __which = _M_binmap[__bytes];
|
|
|
|
const _Tune& __options = _M_get_options();
|
|
|
|
const size_t __bin_size = ((__options._M_min_bin << __which)
|
|
|
|
+ __options._M_align);
|
2004-10-17 17:22:03 +02:00
|
|
|
size_t __block_count = __options._M_chunk_size - sizeof(_Block_address);
|
|
|
|
__block_count /= __bin_size;
|
2004-09-02 00:17:00 +02:00
|
|
|
|
|
|
|
// Are we using threads?
|
|
|
|
// - Yes, check if there are free blocks on the global
|
|
|
|
// list. If so, grab up to __block_count blocks in one
|
|
|
|
// lock and change ownership. If the global list is
|
|
|
|
// empty, we allocate a new chunk and add those blocks
|
|
|
|
// directly to our own freelist (with us as owner).
|
|
|
|
// - No, all operations are made directly to global pool 0
|
|
|
|
// no need to lock or change ownership but check for free
|
|
|
|
// blocks on global list (and if not add new ones) and
|
|
|
|
// get the first one.
|
2004-10-06 06:22:42 +02:00
|
|
|
_Bin_record& __bin = _M_bin[__which];
|
|
|
|
_Block_record* __block = NULL;
|
2004-09-02 00:17:00 +02:00
|
|
|
if (__gthread_active_p())
|
|
|
|
{
|
2006-09-02 10:31:45 +02:00
|
|
|
// Resync the _M_used counters.
|
|
|
|
const size_t __max_threads = __options._M_max_threads + 1;
|
|
|
|
_Atomic_word* const __reclaimed_base =
|
|
|
|
reinterpret_cast<_Atomic_word*>(__bin._M_used + __max_threads);
|
|
|
|
const _Atomic_word __reclaimed = __reclaimed_base[__thread_id];
|
|
|
|
__bin._M_used[__thread_id] -= __reclaimed;
|
|
|
|
__atomic_add(&__reclaimed_base[__thread_id], -__reclaimed);
|
|
|
|
|
2004-10-06 18:31:19 +02:00
|
|
|
__gthread_mutex_lock(__bin._M_mutex);
|
2004-09-02 00:17:00 +02:00
|
|
|
if (__bin._M_first[0] == NULL)
|
|
|
|
{
|
2004-10-17 17:22:03 +02:00
|
|
|
void* __v = ::operator new(__options._M_chunk_size);
|
|
|
|
_Block_address* __address = static_cast<_Block_address*>(__v);
|
|
|
|
__address->_M_initial = __v;
|
|
|
|
__address->_M_next = __bin._M_address;
|
|
|
|
__bin._M_address = __address;
|
2004-10-06 18:31:19 +02:00
|
|
|
__gthread_mutex_unlock(__bin._M_mutex);
|
|
|
|
|
2004-10-17 17:22:03 +02:00
|
|
|
// No need to hold the lock when we are adding a whole
|
|
|
|
// chunk to our own list.
|
|
|
|
char* __c = static_cast<char*>(__v) + sizeof(_Block_address);
|
|
|
|
__block = reinterpret_cast<_Block_record*>(__c);
|
2004-09-02 00:17:00 +02:00
|
|
|
__bin._M_free[__thread_id] = __block_count;
|
2004-10-14 23:05:24 +02:00
|
|
|
__bin._M_first[__thread_id] = __block;
|
|
|
|
while (--__block_count > 0)
|
2004-09-02 00:17:00 +02:00
|
|
|
{
|
2004-10-17 17:22:03 +02:00
|
|
|
__c += __bin_size;
|
2004-09-02 00:17:00 +02:00
|
|
|
__block->_M_next = reinterpret_cast<_Block_record*>(__c);
|
|
|
|
__block = __block->_M_next;
|
|
|
|
}
|
|
|
|
__block->_M_next = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-10-06 06:22:42 +02:00
|
|
|
// Is the number of required blocks greater than or equal
|
|
|
|
// to the number that can be provided by the global free
|
|
|
|
// list?
|
2004-09-02 00:17:00 +02:00
|
|
|
__bin._M_first[__thread_id] = __bin._M_first[0];
|
|
|
|
if (__block_count >= __bin._M_free[0])
|
|
|
|
{
|
|
|
|
__bin._M_free[__thread_id] = __bin._M_free[0];
|
|
|
|
__bin._M_free[0] = 0;
|
|
|
|
__bin._M_first[0] = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__bin._M_free[__thread_id] = __block_count;
|
|
|
|
__bin._M_free[0] -= __block_count;
|
|
|
|
__block = __bin._M_first[0];
|
2004-10-14 23:05:24 +02:00
|
|
|
while (--__block_count > 0)
|
2004-09-02 00:17:00 +02:00
|
|
|
__block = __block->_M_next;
|
|
|
|
__bin._M_first[0] = __block->_M_next;
|
|
|
|
__block->_M_next = NULL;
|
|
|
|
}
|
|
|
|
__gthread_mutex_unlock(__bin._M_mutex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
void* __v = ::operator new(__options._M_chunk_size);
|
2004-10-17 17:22:03 +02:00
|
|
|
_Block_address* __address = static_cast<_Block_address*>(__v);
|
|
|
|
__address->_M_initial = __v;
|
|
|
|
__address->_M_next = __bin._M_address;
|
|
|
|
__bin._M_address = __address;
|
|
|
|
|
|
|
|
char* __c = static_cast<char*>(__v) + sizeof(_Block_address);
|
|
|
|
_Block_record* __block = reinterpret_cast<_Block_record*>(__c);
|
|
|
|
__bin._M_first[0] = __block;
|
2004-10-14 23:05:24 +02:00
|
|
|
while (--__block_count > 0)
|
2004-09-02 00:17:00 +02:00
|
|
|
{
|
2004-10-17 17:22:03 +02:00
|
|
|
__c += __bin_size;
|
2004-09-02 00:17:00 +02:00
|
|
|
__block->_M_next = reinterpret_cast<_Block_record*>(__c);
|
|
|
|
__block = __block->_M_next;
|
|
|
|
}
|
|
|
|
__block->_M_next = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
__block = __bin._M_first[__thread_id];
|
2004-10-14 23:05:24 +02:00
|
|
|
__bin._M_first[__thread_id] = __block->_M_next;
|
2004-09-02 00:17:00 +02:00
|
|
|
|
|
|
|
if (__gthread_active_p())
|
|
|
|
{
|
|
|
|
__block->_M_thread_id = __thread_id;
|
|
|
|
--__bin._M_free[__thread_id];
|
|
|
|
++__bin._M_used[__thread_id];
|
|
|
|
}
|
|
|
|
|
|
|
|
// NB: For alignment reasons, we can't use the first _M_align
|
|
|
|
// bytes, even when sizeof(_Block_record) < _M_align.
|
|
|
|
return reinterpret_cast<char*>(__block) + __options._M_align;
|
|
|
|
}
|
|
|
|
|
2005-09-12 06:49:11 +02:00
|
|
|
void
|
|
|
|
__pool<true>::_M_initialize()
|
2004-09-02 00:17:00 +02:00
|
|
|
{
|
|
|
|
// _M_force_new must not change after the first allocate(),
|
|
|
|
// which in turn calls this method, so if it's false, it's false
|
|
|
|
// forever and we don't need to return here ever again.
|
|
|
|
if (_M_options._M_force_new)
|
|
|
|
{
|
|
|
|
_M_init = true;
|
|
|
|
return;
|
|
|
|
}
|
2005-09-12 06:49:11 +02:00
|
|
|
|
2004-10-06 06:22:42 +02:00
|
|
|
// Create the bins.
|
2004-09-02 00:17:00 +02:00
|
|
|
// Calculate the number of bins required based on _M_max_bytes.
|
|
|
|
// _M_bin_size is statically-initialized to one.
|
|
|
|
size_t __bin_size = _M_options._M_min_bin;
|
|
|
|
while (_M_options._M_max_bytes > __bin_size)
|
|
|
|
{
|
|
|
|
__bin_size <<= 1;
|
|
|
|
++_M_bin_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup the bin map for quick lookup of the relevant bin.
|
|
|
|
const size_t __j = (_M_options._M_max_bytes + 1) * sizeof(_Binmap_type);
|
|
|
|
_M_binmap = static_cast<_Binmap_type*>(::operator new(__j));
|
|
|
|
_Binmap_type* __bp = _M_binmap;
|
|
|
|
_Binmap_type __bin_max = _M_options._M_min_bin;
|
|
|
|
_Binmap_type __bint = 0;
|
|
|
|
for (_Binmap_type __ct = 0; __ct <= _M_options._M_max_bytes; ++__ct)
|
|
|
|
{
|
|
|
|
if (__ct > __bin_max)
|
|
|
|
{
|
|
|
|
__bin_max <<= 1;
|
|
|
|
++__bint;
|
|
|
|
}
|
|
|
|
*__bp++ = __bint;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize _M_bin and its members.
|
|
|
|
void* __v = ::operator new(sizeof(_Bin_record) * _M_bin_size);
|
|
|
|
_M_bin = static_cast<_Bin_record*>(__v);
|
|
|
|
|
|
|
|
// If __gthread_active_p() create and initialize the list of
|
|
|
|
// free thread ids. Single threaded applications use thread id 0
|
|
|
|
// directly and have no need for this.
|
|
|
|
if (__gthread_active_p())
|
|
|
|
{
|
2005-09-12 06:49:11 +02:00
|
|
|
{
|
2006-07-28 06:57:34 +02:00
|
|
|
__gnu_cxx::lock sentry(freelist_mutex);
|
2005-09-12 06:49:11 +02:00
|
|
|
|
2006-07-28 06:57:34 +02:00
|
|
|
if (!freelist._M_thread_freelist_array
|
|
|
|
|| freelist._M_max_threads
|
2005-09-12 06:49:11 +02:00
|
|
|
< _M_options._M_max_threads)
|
|
|
|
{
|
|
|
|
const size_t __k = sizeof(_Thread_record)
|
|
|
|
* _M_options._M_max_threads;
|
|
|
|
__v = ::operator new(__k);
|
|
|
|
_Thread_record* _M_thread_freelist
|
|
|
|
= static_cast<_Thread_record*>(__v);
|
|
|
|
|
|
|
|
// NOTE! The first assignable thread id is 1 since the
|
|
|
|
// global pool uses id 0
|
|
|
|
size_t __i;
|
|
|
|
for (__i = 1; __i < _M_options._M_max_threads; ++__i)
|
|
|
|
{
|
|
|
|
_Thread_record& __tr = _M_thread_freelist[__i - 1];
|
|
|
|
__tr._M_next = &_M_thread_freelist[__i];
|
|
|
|
__tr._M_id = __i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set last record.
|
|
|
|
_M_thread_freelist[__i - 1]._M_next = NULL;
|
|
|
|
_M_thread_freelist[__i - 1]._M_id = __i;
|
|
|
|
|
2006-07-28 06:57:34 +02:00
|
|
|
if (!freelist._M_thread_freelist_array)
|
2005-09-12 06:49:11 +02:00
|
|
|
{
|
|
|
|
// Initialize per thread key to hold pointer to
|
|
|
|
// _M_thread_freelist.
|
2006-07-28 06:57:34 +02:00
|
|
|
__gthread_key_create(&freelist._M_key,
|
|
|
|
::_M_destroy_thread_key);
|
|
|
|
freelist._M_thread_freelist
|
2005-09-12 06:49:11 +02:00
|
|
|
= _M_thread_freelist;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_Thread_record* _M_old_freelist
|
2006-07-28 06:57:34 +02:00
|
|
|
= freelist._M_thread_freelist;
|
2005-09-12 06:49:11 +02:00
|
|
|
_Thread_record* _M_old_array
|
2006-07-28 06:57:34 +02:00
|
|
|
= freelist._M_thread_freelist_array;
|
|
|
|
freelist._M_thread_freelist
|
2005-09-12 06:49:11 +02:00
|
|
|
= &_M_thread_freelist[_M_old_freelist - _M_old_array];
|
|
|
|
while (_M_old_freelist)
|
|
|
|
{
|
|
|
|
size_t next_id;
|
|
|
|
if (_M_old_freelist->_M_next)
|
|
|
|
next_id = _M_old_freelist->_M_next - _M_old_array;
|
|
|
|
else
|
2006-07-28 06:57:34 +02:00
|
|
|
next_id = freelist._M_max_threads;
|
2005-09-12 06:49:11 +02:00
|
|
|
_M_thread_freelist[_M_old_freelist->_M_id - 1]._M_next
|
|
|
|
= &_M_thread_freelist[next_id];
|
|
|
|
_M_old_freelist = _M_old_freelist->_M_next;
|
|
|
|
}
|
|
|
|
::operator delete(static_cast<void*>(_M_old_array));
|
|
|
|
}
|
2006-07-28 06:57:34 +02:00
|
|
|
freelist._M_thread_freelist_array
|
2005-09-12 06:49:11 +02:00
|
|
|
= _M_thread_freelist;
|
2006-07-28 06:57:34 +02:00
|
|
|
freelist._M_max_threads
|
2005-09-12 06:49:11 +02:00
|
|
|
= _M_options._M_max_threads;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-02 00:17:00 +02:00
|
|
|
const size_t __max_threads = _M_options._M_max_threads + 1;
|
|
|
|
for (size_t __n = 0; __n < _M_bin_size; ++__n)
|
|
|
|
{
|
|
|
|
_Bin_record& __bin = _M_bin[__n];
|
|
|
|
__v = ::operator new(sizeof(_Block_record*) * __max_threads);
|
2006-09-02 10:31:45 +02:00
|
|
|
std::memset(__v, 0, sizeof(_Block_record*) * __max_threads);
|
2004-09-02 00:17:00 +02:00
|
|
|
__bin._M_first = static_cast<_Block_record**>(__v);
|
2004-10-06 06:22:42 +02:00
|
|
|
|
|
|
|
__bin._M_address = NULL;
|
|
|
|
|
2004-09-02 00:17:00 +02:00
|
|
|
__v = ::operator new(sizeof(size_t) * __max_threads);
|
2006-09-02 10:31:45 +02:00
|
|
|
std::memset(__v, 0, sizeof(size_t) * __max_threads);
|
2004-09-02 00:17:00 +02:00
|
|
|
__bin._M_free = static_cast<size_t*>(__v);
|
2006-09-02 10:31:45 +02:00
|
|
|
|
|
|
|
__v = ::operator new(sizeof(size_t) * __max_threads
|
|
|
|
+ sizeof(_Atomic_word) * __max_threads);
|
|
|
|
std::memset(__v, 0, (sizeof(size_t) * __max_threads
|
|
|
|
+ sizeof(_Atomic_word) * __max_threads));
|
2004-09-02 00:17:00 +02:00
|
|
|
__bin._M_used = static_cast<size_t*>(__v);
|
|
|
|
|
|
|
|
__v = ::operator new(sizeof(__gthread_mutex_t));
|
|
|
|
__bin._M_mutex = static_cast<__gthread_mutex_t*>(__v);
|
|
|
|
|
|
|
|
#ifdef __GTHREAD_MUTEX_INIT
|
|
|
|
{
|
|
|
|
// Do not copy a POSIX/gthr mutex once in use.
|
|
|
|
__gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
|
|
|
|
*__bin._M_mutex = __tmp;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
{ __GTHREAD_MUTEX_INIT_FUNCTION(__bin._M_mutex); }
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-10-06 06:22:42 +02:00
|
|
|
for (size_t __n = 0; __n < _M_bin_size; ++__n)
|
2004-09-02 00:17:00 +02:00
|
|
|
{
|
2004-10-06 06:22:42 +02:00
|
|
|
_Bin_record& __bin = _M_bin[__n];
|
|
|
|
__v = ::operator new(sizeof(_Block_record*));
|
|
|
|
__bin._M_first = static_cast<_Block_record**>(__v);
|
|
|
|
__bin._M_first[0] = NULL;
|
|
|
|
__bin._M_address = NULL;
|
2004-09-02 00:17:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_M_init = true;
|
|
|
|
}
|
2004-10-06 06:22:42 +02:00
|
|
|
|
2004-09-02 00:17:00 +02:00
|
|
|
size_t
|
|
|
|
__pool<true>::_M_get_thread_id()
|
|
|
|
{
|
|
|
|
// If we have thread support and it's active we check the thread
|
|
|
|
// key value and return its id or if it's not set we take the
|
|
|
|
// first record from _M_thread_freelist and sets the key and
|
|
|
|
// returns it's id.
|
|
|
|
if (__gthread_active_p())
|
|
|
|
{
|
2006-07-28 06:57:34 +02:00
|
|
|
void* v = __gthread_getspecific(freelist._M_key);
|
2005-09-12 06:49:11 +02:00
|
|
|
size_t _M_id = (size_t)v;
|
|
|
|
if (_M_id == 0)
|
2004-09-02 00:17:00 +02:00
|
|
|
{
|
|
|
|
{
|
2006-07-28 06:57:34 +02:00
|
|
|
__gnu_cxx::lock sentry(freelist_mutex);
|
|
|
|
if (freelist._M_thread_freelist)
|
2005-09-12 06:49:11 +02:00
|
|
|
{
|
2006-07-28 06:57:34 +02:00
|
|
|
_M_id = freelist._M_thread_freelist->_M_id;
|
|
|
|
freelist._M_thread_freelist
|
|
|
|
= freelist._M_thread_freelist->_M_next;
|
2005-09-12 06:49:11 +02:00
|
|
|
}
|
2004-09-02 00:17:00 +02:00
|
|
|
}
|
2005-09-12 06:49:11 +02:00
|
|
|
|
2006-07-28 06:57:34 +02:00
|
|
|
__gthread_setspecific(freelist._M_key,
|
2005-09-12 06:49:11 +02:00
|
|
|
(void*)_M_id);
|
2004-09-02 00:17:00 +02:00
|
|
|
}
|
2005-09-12 06:49:11 +02:00
|
|
|
return _M_id >= _M_options._M_max_threads ? 0 : _M_id;
|
2004-09-02 00:17:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise (no thread support or inactive) all requests are
|
|
|
|
// served from the global pool 0.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-09-12 06:49:11 +02:00
|
|
|
// XXX GLIBCXX_ABI Deprecated
|
|
|
|
void
|
|
|
|
__pool<true>::_M_destroy_thread_key(void*) { }
|
|
|
|
|
|
|
|
// XXX GLIBCXX_ABI Deprecated
|
2004-09-02 00:17:00 +02:00
|
|
|
void
|
2005-09-12 06:49:11 +02:00
|
|
|
__pool<true>::_M_initialize(__destroy_handler)
|
2004-09-02 00:17:00 +02:00
|
|
|
{
|
2005-09-12 06:49:11 +02:00
|
|
|
// _M_force_new must not change after the first allocate(),
|
|
|
|
// which in turn calls this method, so if it's false, it's false
|
|
|
|
// forever and we don't need to return here ever again.
|
|
|
|
if (_M_options._M_force_new)
|
|
|
|
{
|
|
|
|
_M_init = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the bins.
|
|
|
|
// Calculate the number of bins required based on _M_max_bytes.
|
|
|
|
// _M_bin_size is statically-initialized to one.
|
|
|
|
size_t __bin_size = _M_options._M_min_bin;
|
|
|
|
while (_M_options._M_max_bytes > __bin_size)
|
|
|
|
{
|
|
|
|
__bin_size <<= 1;
|
|
|
|
++_M_bin_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup the bin map for quick lookup of the relevant bin.
|
|
|
|
const size_t __j = (_M_options._M_max_bytes + 1) * sizeof(_Binmap_type);
|
|
|
|
_M_binmap = static_cast<_Binmap_type*>(::operator new(__j));
|
|
|
|
_Binmap_type* __bp = _M_binmap;
|
|
|
|
_Binmap_type __bin_max = _M_options._M_min_bin;
|
|
|
|
_Binmap_type __bint = 0;
|
|
|
|
for (_Binmap_type __ct = 0; __ct <= _M_options._M_max_bytes; ++__ct)
|
|
|
|
{
|
|
|
|
if (__ct > __bin_max)
|
|
|
|
{
|
|
|
|
__bin_max <<= 1;
|
|
|
|
++__bint;
|
|
|
|
}
|
|
|
|
*__bp++ = __bint;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize _M_bin and its members.
|
|
|
|
void* __v = ::operator new(sizeof(_Bin_record) * _M_bin_size);
|
|
|
|
_M_bin = static_cast<_Bin_record*>(__v);
|
|
|
|
|
|
|
|
// If __gthread_active_p() create and initialize the list of
|
|
|
|
// free thread ids. Single threaded applications use thread id 0
|
|
|
|
// directly and have no need for this.
|
|
|
|
if (__gthread_active_p())
|
|
|
|
{
|
|
|
|
{
|
2006-07-28 06:57:34 +02:00
|
|
|
__gnu_cxx::lock sentry(freelist_mutex);
|
2005-09-12 06:49:11 +02:00
|
|
|
|
2006-07-28 06:57:34 +02:00
|
|
|
if (!freelist._M_thread_freelist_array
|
|
|
|
|| freelist._M_max_threads
|
2005-09-12 06:49:11 +02:00
|
|
|
< _M_options._M_max_threads)
|
|
|
|
{
|
|
|
|
const size_t __k = sizeof(_Thread_record)
|
|
|
|
* _M_options._M_max_threads;
|
|
|
|
__v = ::operator new(__k);
|
|
|
|
_Thread_record* _M_thread_freelist
|
|
|
|
= static_cast<_Thread_record*>(__v);
|
|
|
|
|
|
|
|
// NOTE! The first assignable thread id is 1 since the
|
|
|
|
// global pool uses id 0
|
|
|
|
size_t __i;
|
|
|
|
for (__i = 1; __i < _M_options._M_max_threads; ++__i)
|
|
|
|
{
|
|
|
|
_Thread_record& __tr = _M_thread_freelist[__i - 1];
|
|
|
|
__tr._M_next = &_M_thread_freelist[__i];
|
|
|
|
__tr._M_id = __i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set last record.
|
|
|
|
_M_thread_freelist[__i - 1]._M_next = NULL;
|
|
|
|
_M_thread_freelist[__i - 1]._M_id = __i;
|
|
|
|
|
2006-07-28 06:57:34 +02:00
|
|
|
if (!freelist._M_thread_freelist_array)
|
2005-09-12 06:49:11 +02:00
|
|
|
{
|
|
|
|
// Initialize per thread key to hold pointer to
|
|
|
|
// _M_thread_freelist.
|
2006-07-28 06:57:34 +02:00
|
|
|
__gthread_key_create(&freelist._M_key,
|
|
|
|
::_M_destroy_thread_key);
|
|
|
|
freelist._M_thread_freelist = _M_thread_freelist;
|
2005-09-12 06:49:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_Thread_record* _M_old_freelist
|
2006-07-28 06:57:34 +02:00
|
|
|
= freelist._M_thread_freelist;
|
2005-09-12 06:49:11 +02:00
|
|
|
_Thread_record* _M_old_array
|
2006-07-28 06:57:34 +02:00
|
|
|
= freelist._M_thread_freelist_array;
|
|
|
|
freelist._M_thread_freelist
|
2005-09-12 06:49:11 +02:00
|
|
|
= &_M_thread_freelist[_M_old_freelist - _M_old_array];
|
|
|
|
while (_M_old_freelist)
|
|
|
|
{
|
|
|
|
size_t next_id;
|
|
|
|
if (_M_old_freelist->_M_next)
|
|
|
|
next_id = _M_old_freelist->_M_next - _M_old_array;
|
|
|
|
else
|
2006-07-28 06:57:34 +02:00
|
|
|
next_id = freelist._M_max_threads;
|
2005-09-12 06:49:11 +02:00
|
|
|
_M_thread_freelist[_M_old_freelist->_M_id - 1]._M_next
|
|
|
|
= &_M_thread_freelist[next_id];
|
|
|
|
_M_old_freelist = _M_old_freelist->_M_next;
|
|
|
|
}
|
|
|
|
::operator delete(static_cast<void*>(_M_old_array));
|
|
|
|
}
|
2006-07-28 06:57:34 +02:00
|
|
|
freelist._M_thread_freelist_array = _M_thread_freelist;
|
|
|
|
freelist._M_max_threads = _M_options._M_max_threads;
|
2005-09-12 06:49:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const size_t __max_threads = _M_options._M_max_threads + 1;
|
|
|
|
for (size_t __n = 0; __n < _M_bin_size; ++__n)
|
|
|
|
{
|
|
|
|
_Bin_record& __bin = _M_bin[__n];
|
|
|
|
__v = ::operator new(sizeof(_Block_record*) * __max_threads);
|
2006-09-02 10:31:45 +02:00
|
|
|
std::memset(__v, 0, sizeof(_Block_record*) * __max_threads);
|
2005-09-12 06:49:11 +02:00
|
|
|
__bin._M_first = static_cast<_Block_record**>(__v);
|
|
|
|
|
|
|
|
__bin._M_address = NULL;
|
|
|
|
|
|
|
|
__v = ::operator new(sizeof(size_t) * __max_threads);
|
2006-09-02 10:31:45 +02:00
|
|
|
std::memset(__v, 0, sizeof(size_t) * __max_threads);
|
2005-09-12 06:49:11 +02:00
|
|
|
__bin._M_free = static_cast<size_t*>(__v);
|
|
|
|
|
2006-09-02 10:31:45 +02:00
|
|
|
__v = ::operator new(sizeof(size_t) * __max_threads +
|
|
|
|
sizeof(_Atomic_word) * __max_threads);
|
|
|
|
std::memset(__v, 0, (sizeof(size_t) * __max_threads
|
|
|
|
+ sizeof(_Atomic_word) * __max_threads));
|
2005-09-12 06:49:11 +02:00
|
|
|
__bin._M_used = static_cast<size_t*>(__v);
|
2006-09-02 10:31:45 +02:00
|
|
|
|
2005-09-12 06:49:11 +02:00
|
|
|
__v = ::operator new(sizeof(__gthread_mutex_t));
|
|
|
|
__bin._M_mutex = static_cast<__gthread_mutex_t*>(__v);
|
|
|
|
|
|
|
|
#ifdef __GTHREAD_MUTEX_INIT
|
|
|
|
{
|
|
|
|
// Do not copy a POSIX/gthr mutex once in use.
|
|
|
|
__gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
|
|
|
|
*__bin._M_mutex = __tmp;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
{ __GTHREAD_MUTEX_INIT_FUNCTION(__bin._M_mutex); }
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (size_t __n = 0; __n < _M_bin_size; ++__n)
|
|
|
|
{
|
|
|
|
_Bin_record& __bin = _M_bin[__n];
|
|
|
|
__v = ::operator new(sizeof(_Block_record*));
|
|
|
|
__bin._M_first = static_cast<_Block_record**>(__v);
|
|
|
|
__bin._M_first[0] = NULL;
|
|
|
|
__bin._M_address = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_M_init = true;
|
2004-09-02 00:17:00 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Instantiations.
|
|
|
|
template class __mt_alloc<char>;
|
|
|
|
template class __mt_alloc<wchar_t>;
|
2005-12-19 01:56:05 +01:00
|
|
|
|
|
|
|
_GLIBCXX_END_NAMESPACE
|