basic_string.h: Change _*_references to _*_refcount.
2003-12-15 Benjamin Kosnik <bkoz@redhat.com> * include/bits/basic_string.h: Change _*_references to _*_refcount. * include/bits/locale_classes.h: Same. * src/locale.cc: Same. * src/locale_name.cc: Same. * src/locale_init.cc: Same. From-SVN: r74645
This commit is contained in:
parent
61a8f1edff
commit
1313d87fd3
|
@ -1,3 +1,11 @@
|
||||||
|
2003-12-15 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
* include/bits/basic_string.h: Change _*_references to _*_refcount.
|
||||||
|
* include/bits/locale_classes.h: Same.
|
||||||
|
* src/locale.cc: Same.
|
||||||
|
* src/locale_name.cc: Same.
|
||||||
|
* src/locale_init.cc: Same.
|
||||||
|
|
||||||
2003-12-15 Benjamin Kosnik <bkoz@redhat.com>
|
2003-12-15 Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
PR libstdc++/12855
|
PR libstdc++/12855
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace std
|
||||||
// _CharT() where the interface does not require it.
|
// _CharT() where the interface does not require it.
|
||||||
// 2. _M_capacity >= _M_length
|
// 2. _M_capacity >= _M_length
|
||||||
// Allocated memory is always _M_capacity + (1 * sizeof(_CharT)).
|
// Allocated memory is always _M_capacity + (1 * sizeof(_CharT)).
|
||||||
// 3. _M_references has three states:
|
// 3. _M_refcount has three states:
|
||||||
// -1: leaked, one reference, no ref-copies allowed, non-const.
|
// -1: leaked, one reference, no ref-copies allowed, non-const.
|
||||||
// 0: one reference, non-const.
|
// 0: one reference, non-const.
|
||||||
// n>0: n + 1 references, operations require a lock, const.
|
// n>0: n + 1 references, operations require a lock, const.
|
||||||
|
@ -146,7 +146,7 @@ namespace std
|
||||||
{
|
{
|
||||||
size_type _M_length;
|
size_type _M_length;
|
||||||
size_type _M_capacity;
|
size_type _M_capacity;
|
||||||
_Atomic_word _M_references;
|
_Atomic_word _M_refcount;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Rep : _Rep_base
|
struct _Rep : _Rep_base
|
||||||
|
@ -180,19 +180,19 @@ namespace std
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_M_is_leaked() const
|
_M_is_leaked() const
|
||||||
{ return this->_M_references < 0; }
|
{ return this->_M_refcount < 0; }
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_M_is_shared() const
|
_M_is_shared() const
|
||||||
{ return this->_M_references > 0; }
|
{ return this->_M_refcount > 0; }
|
||||||
|
|
||||||
void
|
void
|
||||||
_M_set_leaked()
|
_M_set_leaked()
|
||||||
{ this->_M_references = -1; }
|
{ this->_M_refcount = -1; }
|
||||||
|
|
||||||
void
|
void
|
||||||
_M_set_sharable()
|
_M_set_sharable()
|
||||||
{ this->_M_references = 0; }
|
{ this->_M_refcount = 0; }
|
||||||
|
|
||||||
_CharT*
|
_CharT*
|
||||||
_M_refdata() throw()
|
_M_refdata() throw()
|
||||||
|
@ -217,7 +217,7 @@ namespace std
|
||||||
_M_dispose(const _Alloc& __a)
|
_M_dispose(const _Alloc& __a)
|
||||||
{
|
{
|
||||||
if (__builtin_expect(this != &_S_empty_rep(), false))
|
if (__builtin_expect(this != &_S_empty_rep(), false))
|
||||||
if (__exchange_and_add(&this->_M_references, -1) <= 0)
|
if (__exchange_and_add(&this->_M_refcount, -1) <= 0)
|
||||||
_M_destroy(__a);
|
_M_destroy(__a);
|
||||||
} // XXX MT
|
} // XXX MT
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ namespace std
|
||||||
_M_refcopy() throw()
|
_M_refcopy() throw()
|
||||||
{
|
{
|
||||||
if (__builtin_expect(this != &_S_empty_rep(), false))
|
if (__builtin_expect(this != &_S_empty_rep(), false))
|
||||||
__atomic_add(&this->_M_references, 1);
|
__atomic_add(&this->_M_refcount, 1);
|
||||||
return _M_refdata();
|
return _M_refdata();
|
||||||
} // XXX MT
|
} // XXX MT
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ namespace std
|
||||||
friend class locale;
|
friend class locale;
|
||||||
friend class locale::_Impl;
|
friend class locale::_Impl;
|
||||||
|
|
||||||
mutable _Atomic_word _M_references;
|
mutable _Atomic_word _M_refcount;
|
||||||
|
|
||||||
// Contains data from the underlying "C" library for the classic locale.
|
// Contains data from the underlying "C" library for the classic locale.
|
||||||
static __c_locale _S_c_locale;
|
static __c_locale _S_c_locale;
|
||||||
|
@ -208,7 +208,7 @@ namespace std
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit
|
explicit
|
||||||
facet(size_t __refs = 0) throw() : _M_references(__refs ? 1 : 0)
|
facet(size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
|
@ -235,12 +235,12 @@ namespace std
|
||||||
private:
|
private:
|
||||||
inline void
|
inline void
|
||||||
_M_add_reference() const throw()
|
_M_add_reference() const throw()
|
||||||
{ __atomic_add(&_M_references, 1); }
|
{ __atomic_add(&_M_refcount, 1); }
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
_M_remove_reference() const throw()
|
_M_remove_reference() const throw()
|
||||||
{
|
{
|
||||||
if (__exchange_and_add(&_M_references, -1) == 1)
|
if (__exchange_and_add(&_M_refcount, -1) == 1)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{ delete this; }
|
{ delete this; }
|
||||||
|
@ -277,7 +277,7 @@ namespace std
|
||||||
mutable size_t _M_index;
|
mutable size_t _M_index;
|
||||||
|
|
||||||
// Last id number assigned.
|
// Last id number assigned.
|
||||||
static _Atomic_word _S_highwater;
|
static _Atomic_word _S_refcount;
|
||||||
|
|
||||||
void
|
void
|
||||||
operator=(const id&); // Not defined.
|
operator=(const id&); // Not defined.
|
||||||
|
@ -315,7 +315,7 @@ namespace std
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Data Members.
|
// Data Members.
|
||||||
_Atomic_word _M_references;
|
_Atomic_word _M_refcount;
|
||||||
const facet** _M_facets;
|
const facet** _M_facets;
|
||||||
size_t _M_facets_size;
|
size_t _M_facets_size;
|
||||||
const facet** _M_caches;
|
const facet** _M_caches;
|
||||||
|
@ -330,12 +330,12 @@ namespace std
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
_M_add_reference() throw()
|
_M_add_reference() throw()
|
||||||
{ __atomic_add(&_M_references, 1); }
|
{ __atomic_add(&_M_refcount, 1); }
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
_M_remove_reference() throw()
|
_M_remove_reference() throw()
|
||||||
{
|
{
|
||||||
if (__exchange_and_add(&_M_references, -1) == 1)
|
if (__exchange_and_add(&_M_refcount, -1) == 1)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{ delete this; }
|
{ delete this; }
|
||||||
|
|
|
@ -211,7 +211,7 @@ namespace std
|
||||||
// Clone existing _Impl object.
|
// Clone existing _Impl object.
|
||||||
locale::_Impl::
|
locale::_Impl::
|
||||||
_Impl(const _Impl& __imp, size_t __refs)
|
_Impl(const _Impl& __imp, size_t __refs)
|
||||||
: _M_references(__refs), _M_facets_size(__imp._M_facets_size)
|
: _M_refcount(__refs), _M_facets_size(__imp._M_facets_size)
|
||||||
{
|
{
|
||||||
_M_facets = _M_caches = 0;
|
_M_facets = _M_caches = 0;
|
||||||
_M_names = 0;
|
_M_names = 0;
|
||||||
|
@ -350,13 +350,13 @@ namespace std
|
||||||
|
|
||||||
// locale::id
|
// locale::id
|
||||||
// Definitions for static const data members of locale::id
|
// Definitions for static const data members of locale::id
|
||||||
_Atomic_word locale::id::_S_highwater; // init'd to 0 by linker
|
_Atomic_word locale::id::_S_refcount; // init'd to 0 by linker
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
locale::id::_M_id() const
|
locale::id::_M_id() const
|
||||||
{
|
{
|
||||||
if (!_M_index)
|
if (!_M_index)
|
||||||
_M_index = 1 + __exchange_and_add(&_S_highwater, 1);
|
_M_index = 1 + __exchange_and_add(&_S_refcount, 1);
|
||||||
return _M_index - 1;
|
return _M_index - 1;
|
||||||
}
|
}
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
|
@ -241,7 +241,7 @@ namespace std
|
||||||
// Construct "C" _Impl.
|
// Construct "C" _Impl.
|
||||||
locale::_Impl::
|
locale::_Impl::
|
||||||
_Impl(size_t __refs) throw()
|
_Impl(size_t __refs) throw()
|
||||||
: _M_references(__refs), _M_facets_size(_GLIBCXX_NUM_FACETS)
|
: _M_refcount(__refs), _M_facets_size(_GLIBCXX_NUM_FACETS)
|
||||||
{
|
{
|
||||||
_M_facets = new (&facet_vec) const facet*[_M_facets_size];
|
_M_facets = new (&facet_vec) const facet*[_M_facets_size];
|
||||||
_M_caches = new (&cache_vec) const facet*[_M_facets_size];
|
_M_caches = new (&cache_vec) const facet*[_M_facets_size];
|
||||||
|
|
|
@ -178,7 +178,7 @@ namespace std
|
||||||
// Construct named _Impl.
|
// Construct named _Impl.
|
||||||
locale::_Impl::
|
locale::_Impl::
|
||||||
_Impl(const char* __s, size_t __refs)
|
_Impl(const char* __s, size_t __refs)
|
||||||
: _M_references(__refs), _M_facets_size(_GLIBCXX_NUM_FACETS)
|
: _M_refcount(__refs), _M_facets_size(_GLIBCXX_NUM_FACETS)
|
||||||
{
|
{
|
||||||
// Initialize the underlying locale model, which also checks to
|
// Initialize the underlying locale model, which also checks to
|
||||||
// see if the given name is valid.
|
// see if the given name is valid.
|
||||||
|
|
Loading…
Reference in New Issue