This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/16248] [3.5 Regression] recent concurrence.h chanes breaks mingw bootstrap
- From: "membar at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Jun 2004 20:34:33 -0000
- Subject: [Bug libstdc++/16248] [3.5 Regression] recent concurrence.h chanes breaks mingw bootstrap
- References: <20040628163801.16248.bothner@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From membar at gcc dot gnu dot org 2004-06-29 20:34 -------
AAARGH! You're right in your analyses for all the reasons you mentioned.
The "proper" solution would be to modify gthread_once, like you mentioned. But
that seems too far-reaching. As a compromise, why not answer a hack with a
hack?:
2004-06-29 Mohan Embar <gnustuff@thisiscool.com>
* include/bits/concurrence.h (__glibcxx_mutex): New macro.
(__glibcxx_mutex_parms): New macro.
(__gnu_cxx::lock): Change device field from a pointer to a
reference; use new __glibcxx_mutex and __glibcxx_mutex_parms
macros in constructor.
* src/locale_init.cc (locale::locale): Use __glibcxx_mutex
macro.
(locale::global): Likewise.
Index: include/bits/concurrence.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/concurrence.h,v
retrieving revision 1.5
diff -u -2 -r1.5 concurrence.h
--- include/bits/concurrence.h 25 Jun 2004 16:36:13 -0000 1.5
+++ include/bits/concurrence.h 29 Jun 2004 20:26:58 -0000
@@ -55,4 +55,8 @@
# define __glibcxx_mutex_unlock(NAME) __gthread_mutex_unlock(&NAME)
+// Needed for __gnu_cxx::lock class
+# define __glibcxx_mutex(NAME) NAME, NAME ## _once, NAME ## _init
+# define __glibcxx_mutex_parms(NAME) __gthread_mutex_t& NAME,
__gthread_once_t& NAME ## _once, void (* NAME ## _init) ()
+
#else
@@ -63,4 +67,10 @@
#endif
+// Needed for __gnu_cxx::lock class
+#ifndef __glibcxx_mutex
+# define __glibcxx_mutex(NAME) NAME
+# define __glibcxx_mutex_parms(NAME) __gthread_mutex_t& NAME
+#endif
+
namespace __gnu_cxx
{
@@ -68,14 +78,14 @@
{
// Externally defined and initialized.
- __gthread_mutex_t* device;
+ __gthread_mutex_t& device;
public:
// Acquire the mutex here with a constructor call. This ensures
// that it is released in exit or during stack unwinding.
- explicit lock(__gthread_mutex_t& name) : device(&name)
- { __glibcxx_mutex_lock(*device); }
+ explicit lock( __glibcxx_mutex_parms(name) ) : device(name)
+ { __glibcxx_mutex_lock(name); }
~lock() throw()
- { __glibcxx_mutex_unlock(*device); }
+ { __glibcxx_mutex_unlock(device); }
private:
Index: src/locale_init.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale_init.cc,v
retrieving revision 1.14
diff -u -2 -r1.14 locale_init.cc
--- src/locale_init.cc 25 Jun 2004 06:10:44 -0000 1.14
+++ src/locale_init.cc 29 Jun 2004 20:26:59 -0000
@@ -102,5 +102,5 @@
{
_S_initialize();
- __gnu_cxx::lock sentry(__gnu_internal::locale_cons_mutex);
+ __gnu_cxx::lock sentry(__glibcxx_mutex(locale_cons_mutex));
_S_global->_M_add_reference();
_M_impl = _S_global;
@@ -113,5 +113,5 @@
_Impl* __old;
{
- __gnu_cxx::lock sentry(__gnu_internal::locale_global_mutex);
+ __gnu_cxx::lock sentry(__glibcxx_mutex(locale_global_mutex));
__old = _S_global;
__other._M_impl->_M_add_reference();
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16248