// Locale support -*- C++ -*-
-// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// 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
// ISO C++ 14882: 22.1 Locales
//
+/** @file localefwd.h
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
+ */
+
#ifndef _CPP_BITS_LOCCORE_H
#define _CPP_BITS_LOCCORE_H 1
#include <bits/c++config.h>
#include <bits/c++locale.h> // Defines __c_locale, config-specific includes
-#include <bits/std_climits.h> // For CHAR_BIT
-#include <bits/std_string.h> // For string
-#include <bits/std_cctype.h> // For isspace, etc.
+#include <climits> // For CHAR_BIT
+#include <cctype> // For isspace, etc.
+#include <string> // For string
#include <bits/functexcept.h>
+#include <bits/atomicity.h>
+
namespace std
{
// NB: Don't instantiate required wchar_t facets if no wchar_t support.
template<typename _Facet>
locale
- combine(const locale& __other);
+ combine(const locale& __other) const;
// Locale operations:
string
static inline void
_S_initialize()
- { if (!_S_classic) classic(); }
+ {
+ if (!_S_classic)
+ classic();
+ }
static category
_S_normalize_category(category);
};
- // locale implementation object
+ // Implementation object for locale
class locale::_Impl
{
public:
private:
// Data Members.
- size_t _M_references;
+ _Atomic_word _M_references;
__vec_facet* _M_facets;
string _M_names[_S_num_categories];
static const locale::id* const _S_id_ctype[];
inline void
_M_add_reference() throw()
- { ++_M_references; } // XXX MT
+ { __atomic_add(&_M_references, 1); }
inline void
_M_remove_reference() throw()
{
- if (--_M_references == 0) // XXX MT
+ if (__exchange_and_add(&_M_references, -1) == 1)
{
try
{ delete this; }
_Impl(string __name, size_t);
~_Impl() throw();
- bool
+ inline bool
_M_check_same_name()
{
bool __ret = true;
__ret &= _M_names[i] == _M_names[i + 1];
return __ret;
}
+
void
_M_replace_categories(const _Impl*, category);
friend class locale::_Impl;
friend class __enc_traits;
+ private:
+ _Atomic_word _M_references;
+
protected:
+ // Contains data from the underlying "C" library for default "C"
+ // or "POSIX" locale.
+ static __c_locale _S_c_locale;
+
explicit
facet(size_t __refs = 0) throw();
virtual
- ~facet() { };
+ ~facet();
static void
_S_create_c_locale(__c_locale& __cloc, const char* __s);
_S_destroy_c_locale(__c_locale& __cloc);
private:
- size_t _M_references;
-
void
_M_add_reference() throw();
void
_M_remove_reference() throw();
- facet(const facet&); // not defined
+ facet(const facet&); // Not defined.
void
- operator=(const facet&); // not defined
+ operator=(const facet&); // Not defined.
};
mutable size_t _M_index;
// Last id number assigned
- static size_t _S_highwater;
+ static _Atomic_word _S_highwater;
void
operator=(const id&); // not defined
public:
// NB: This class is always a static data member, and thus can be
// counted on to be zero-initialized.
- // XXX id() : _M_index(0) { }
- id() { }
+ id();
};
template<typename _Facet>