This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Further fix for 12658


Paolo Carlini wrote:

Agreed! I will post soon what would go in 3_4-branch...

... like the below. I will wait 'til tomorrow before actually applying it.


Tested x86/x86_64(4-way)

Paolo.

///////////////
2004-07-29  Paolo Carlini  <pcarlini@suse.de>
            Petur Runolfsson  <peturr02@ru.is>

	PR libstdc++/12658 (continued)
	* src/locale_init.cc (locale::locale, locale::global): Use
	a single locale_mutex instead of two separate mutexes.

2004-07-29  Paolo Carlini  <pcarlini@suse.de>

	* testsuite/22_locale/locale/cons/12658_thread.cc: Xfail: due to
	a bug in glibcs older than 2004-07-16, it can unpredictably fail
	irrespective of the correctness of libstdc++.

2004-07-29  Benjamin Kosnik  <bkoz@redhat.com>

	* src/locale_init.cc: Use __gnu_cxx::lock.
diff -urN libstdc++-v3-orig/src/locale_init.cc libstdc++-v3/src/locale_init.cc
--- libstdc++-v3-orig/src/locale_init.cc	2004-05-24 22:49:54.000000000 +0200
+++ libstdc++-v3/src/locale_init.cc	2004-07-29 18:37:36.000000000 +0200
@@ -89,9 +89,8 @@
   extern std::__timepunct_cache<wchar_t>	 timepunct_cache_w;
 #endif
 
-  // Mutex objects for locale initialization.
-  __glibcxx_mutex_define_initialized(locale_cons_mutex);
-  __glibcxx_mutex_define_initialized(locale_global_mutex);
+  // Mutex object for locale initialization.
+  __glibcxx_mutex_define_initialized(locale_mutex);
 } // namespace __gnu_internal
 
 namespace std 
@@ -101,23 +100,24 @@
   locale::locale() throw() : _M_impl(0)
   { 
     _S_initialize(); 
-    __glibcxx_mutex_lock(__gnu_internal::locale_cons_mutex);
+    __gnu_cxx::lock sentry(__gnu_internal::locale_mutex);
     _S_global->_M_add_reference();
     _M_impl = _S_global;
-    __glibcxx_mutex_unlock(__gnu_internal::locale_cons_mutex);
   }
 
   locale
   locale::global(const locale& __other)
   {
     _S_initialize();
-    __glibcxx_mutex_lock(__gnu_internal::locale_global_mutex);
-    _Impl* __old = _S_global;
-    __other._M_impl->_M_add_reference();
-    _S_global = __other._M_impl; 
-    if (__other.name() != "*")
-      setlocale(LC_ALL, __other.name().c_str());
-   __glibcxx_mutex_unlock(__gnu_internal::locale_global_mutex);
+    _Impl* __old;
+    {
+      __gnu_cxx::lock sentry(__gnu_internal::locale_mutex);
+      __old = _S_global;
+      __other._M_impl->_M_add_reference();
+      _S_global = __other._M_impl; 
+      if (__other.name() != "*")
+	setlocale(LC_ALL, __other.name().c_str());
+    }
 
     // Reference count sanity check: one reference removed for the
     // subsition of __other locale, one added by return-by-value. Net
diff -urN libstdc++-v3-orig/testsuite/22_locale/locale/cons/12658_thread.cc libstdc++-v3/testsuite/22_locale/locale/cons/12658_thread.cc
--- libstdc++-v3-orig/testsuite/22_locale/locale/cons/12658_thread.cc	2004-03-18 18:37:26.000000000 +0100
+++ libstdc++-v3/testsuite/22_locale/locale/cons/12658_thread.cc	2004-07-29 18:52:24.000000000 +0200
@@ -22,6 +22,8 @@
 
 // 22.1.1.2 locale constructors and destructors [lib.locale.cons]
 
+// { dg-do run { xfail *-*-* } }
+
 #include <locale>
 #include <pthread.h>
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]