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>
+
PR libstdc++/12855
* include/bits/ios_base.h (Init::_S_ios_base_init): Change to
_S_refcount, make atomic.
// _CharT() where the interface does not require it.
// 2. _M_capacity >= _M_length
// 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.
// 0: one reference, non-const.
// n>0: n + 1 references, operations require a lock, const.
{
size_type _M_length;
size_type _M_capacity;
- _Atomic_word _M_references;
+ _Atomic_word _M_refcount;
};
struct _Rep : _Rep_base
bool
_M_is_leaked() const
- { return this->_M_references < 0; }
+ { return this->_M_refcount < 0; }
bool
_M_is_shared() const
- { return this->_M_references > 0; }
+ { return this->_M_refcount > 0; }
void
_M_set_leaked()
- { this->_M_references = -1; }
+ { this->_M_refcount = -1; }
void
_M_set_sharable()
- { this->_M_references = 0; }
+ { this->_M_refcount = 0; }
_CharT*
_M_refdata() throw()
_M_dispose(const _Alloc& __a)
{
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);
} // XXX MT
_M_refcopy() throw()
{
if (__builtin_expect(this != &_S_empty_rep(), false))
- __atomic_add(&this->_M_references, 1);
+ __atomic_add(&this->_M_refcount, 1);
return _M_refdata();
} // XXX MT
friend class locale;
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.
static __c_locale _S_c_locale;
protected:
explicit
- facet(size_t __refs = 0) throw() : _M_references(__refs ? 1 : 0)
+ facet(size_t __refs = 0) throw() : _M_refcount(__refs ? 1 : 0)
{ }
virtual
private:
inline void
_M_add_reference() const throw()
- { __atomic_add(&_M_references, 1); }
+ { __atomic_add(&_M_refcount, 1); }
inline void
_M_remove_reference() const throw()
{
- if (__exchange_and_add(&_M_references, -1) == 1)
+ if (__exchange_and_add(&_M_refcount, -1) == 1)
{
try
{ delete this; }
mutable size_t _M_index;
// Last id number assigned.
- static _Atomic_word _S_highwater;
+ static _Atomic_word _S_refcount;
void
operator=(const id&); // Not defined.
private:
// Data Members.
- _Atomic_word _M_references;
+ _Atomic_word _M_refcount;
const facet** _M_facets;
size_t _M_facets_size;
const facet** _M_caches;
inline void
_M_add_reference() throw()
- { __atomic_add(&_M_references, 1); }
+ { __atomic_add(&_M_refcount, 1); }
inline void
_M_remove_reference() throw()
{
- if (__exchange_and_add(&_M_references, -1) == 1)
+ if (__exchange_and_add(&_M_refcount, -1) == 1)
{
try
{ delete this; }
// Clone existing _Impl object.
locale::_Impl::
_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_names = 0;
// 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
locale::id::_M_id() const
{
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;
}
} // namespace std
// Construct "C" _Impl.
locale::_Impl::
_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_caches = new (&cache_vec) const facet*[_M_facets_size];
// Construct named _Impl.
locale::_Impl::
_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
// see if the given name is valid.