aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2005-10-11 06:19:13 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2005-10-11 06:19:13 +0000
commit18c75543a89fc2b6a62b3e2967cb89b83fb96ada (patch)
treea25c3b10a5e437f7a6875e11b8b8bd9c85f26839 /libstdc++-v3/src
parente0c48a517ebd8213c2300b7d63907b2e85c0ef9c (diff)
downloadgcc-18c75543a89fc2b6a62b3e2967cb89b83fb96ada.zip
gcc-18c75543a89fc2b6a62b3e2967cb89b83fb96ada.tar.gz
gcc-18c75543a89fc2b6a62b3e2967cb89b83fb96ada.tar.bz2
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
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/locale.cc24
1 files changed, 24 insertions, 0 deletions
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 <cwctype> // For towupper, etc.
#include <locale>
#include <bits/atomicity.h>
+#include <bits/concurrence.h>
+
+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