From 18c75543a89fc2b6a62b3e2967cb89b83fb96ada Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 11 Oct 2005 06:19:13 +0000 Subject: re PR libstdc++/13583 (__use_cache not threadsafe) PR libstdc++/13583 * include/bits/locale_classes.h (locale::_Impl::_M_install_cache): Move out of line. * src/locale.cc: Define here, add mutex. * configure.ac (libtool_VERSION): To 6:7:0. * configure: Regenerate. * testsuite/testsuite_abi.cc (check_version): Add GLIBCXX_3.4.7. * config/linker-map.gnu: Export locale::_Impl::_M_install_cache. From-SVN: r105221 --- libstdc++-v3/src/locale.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'libstdc++-v3/src') diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc index 0117d15..5498eae 100644 --- a/libstdc++-v3/src/locale.cc +++ b/libstdc++-v3/src/locale.cc @@ -33,6 +33,13 @@ #include // For towupper, etc. #include #include +#include + +namespace __gnu_internal +{ + // Mutex object for cache access + static __glibcxx_mutex_define_initialized(locale_cache_mutex); +} namespace std { @@ -366,6 +373,23 @@ namespace std } } + void + locale::_Impl:: + _M_install_cache(const facet* __cache, size_t __index) + { + __gnu_cxx::lock sentry(__gnu_internal::locale_cache_mutex); + if (_M_caches[__index] != 0) + { + // Some other thread got in first. + delete __cache; + } + else + { + __cache->_M_add_reference(); + _M_caches[__index] = __cache; + } + } + // locale::id // Definitions for static const data members of locale::id _Atomic_word locale::id::_S_refcount; // init'd to 0 by linker -- cgit v1.1