OSDN Git Service

PR libstdc++/53270
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 Jul 2012 22:34:13 +0000 (22:34 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 Jul 2012 22:34:13 +0000 (22:34 +0000)
* include/ext/concurrence.h: Use NSDMI for gthreads types.
* include/ext/rope: Likewise. Destroy mutexes in destructors. Add
system_header pragma.

Revert:
2012-06-19  Jonathan Wakely  <jwakely.gcc@gmail.com>

PR libstdc++/53270
* config/os/gnu-linux/os_defines.h: Disable static initializer macros
for gthreads types in C++11 mode.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@189555 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/config/os/gnu-linux/os_defines.h
libstdc++-v3/include/ext/concurrence.h
libstdc++-v3/include/ext/rope

index e732667..e233cdb 100644 (file)
@@ -1,5 +1,19 @@
 2012-07-16  Jonathan Wakely  <jwakely.gcc@gmail.com>
 
 2012-07-16  Jonathan Wakely  <jwakely.gcc@gmail.com>
 
+       PR libstdc++/53270
+       * include/ext/concurrence.h: Use NSDMI for gthreads types.
+       * include/ext/rope: Likewise. Destroy mutexes in destructors. Add
+       system_header pragma.
+
+       Revert:
+       2012-06-19  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       PR libstdc++/53270
+       * config/os/gnu-linux/os_defines.h: Disable static initializer macros
+       for gthreads types in C++11 mode.
+
+2012-07-16  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
        PR libstdc++/53978
        * include/bits/alloc_traits.h (allocator_traits): Define static
        constants.
        PR libstdc++/53978
        * include/bits/alloc_traits.h (allocator_traits): Define static
        constants.
index f41160f..c4aa305 100644 (file)
 # undef _GLIBCXX_HAVE_GETS
 #endif
 
 # undef _GLIBCXX_HAVE_GETS
 #endif
 
-#if defined(__hppa__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
-# define _GTHREAD_USE_MUTEX_INIT_FUNC
-# define _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
-# define _GTHREAD_USE_COND_INIT_FUNC
-#endif
-
 #endif
 #endif
index 4719c84..18a3836 100644 (file)
@@ -1,6 +1,6 @@
 // Support for concurrent programing -*- C++ -*-
 
 // Support for concurrent programing -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -143,7 +143,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   class __mutex 
   {
   private:
   class __mutex 
   {
   private:
+#if __GTHREADS && defined __GTHREAD_MUTEX_INIT
+    __gthread_mutex_t _M_mutex = __GTHREAD_MUTEX_INIT;
+#else
     __gthread_mutex_t _M_mutex;
     __gthread_mutex_t _M_mutex;
+#endif
 
     __mutex(const __mutex&);
     __mutex& operator=(const __mutex&);
 
     __mutex(const __mutex&);
     __mutex& operator=(const __mutex&);
@@ -151,17 +155,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   public:
     __mutex() 
     { 
   public:
     __mutex() 
     { 
-#if __GTHREADS
+#if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT
       if (__gthread_active_p())
       if (__gthread_active_p())
-       {
-#if defined __GTHREAD_MUTEX_INIT
-         __gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
-         _M_mutex = __tmp;
-#else
-         __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex); 
+       __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
 #endif
 #endif
-       }
-#endif 
     }
 
 #if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT
     }
 
 #if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT
@@ -201,7 +198,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   class __recursive_mutex 
   {
   private:
   class __recursive_mutex 
   {
   private:
+#if __GTHREADS && defined __GTHREAD_RECURSIVE_MUTEX_INIT
+    __gthread_recursive_mutex_t _M_mutex = __GTHREAD_RECURSIVE_MUTEX_INIT;
+#else
     __gthread_recursive_mutex_t _M_mutex;
     __gthread_recursive_mutex_t _M_mutex;
+#endif
 
     __recursive_mutex(const __recursive_mutex&);
     __recursive_mutex& operator=(const __recursive_mutex&);
 
     __recursive_mutex(const __recursive_mutex&);
     __recursive_mutex& operator=(const __recursive_mutex&);
@@ -209,17 +210,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   public:
     __recursive_mutex() 
     { 
   public:
     __recursive_mutex() 
     { 
-#if __GTHREADS
+#if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT
       if (__gthread_active_p())
       if (__gthread_active_p())
-       {
-#if defined __GTHREAD_RECURSIVE_MUTEX_INIT
-         __gthread_recursive_mutex_t __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT;
-         _M_mutex = __tmp;
-#else
-         __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex); 
+       __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex);
 #endif
 #endif
-       }
-#endif 
     }
 
 #if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT
     }
 
 #if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT
@@ -319,7 +313,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   class __cond
   {
   private:
   class __cond
   {
   private:
+#if __GTHREADS && defined __GTHREAD_COND_INIT
+    __gthread_cond_t _M_cond = __GTHREAD_COND_INIT;
+#else
     __gthread_cond_t _M_cond;
     __gthread_cond_t _M_cond;
+#endif
 
     __cond(const __cond&);
     __cond& operator=(const __cond&);
 
     __cond(const __cond&);
     __cond& operator=(const __cond&);
@@ -327,17 +325,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   public:
     __cond() 
     { 
   public:
     __cond() 
     { 
-#if __GTHREADS
+#if __GTHREADS && ! defined __GTHREAD_COND_INIT
       if (__gthread_active_p())
       if (__gthread_active_p())
-       {
-#if defined __GTHREAD_COND_INIT
-         __gthread_cond_t __tmp = __GTHREAD_COND_INIT;
-         _M_cond = __tmp;
-#else
-         __GTHREAD_COND_INIT_FUNCTION(&_M_cond);
+       __GTHREAD_COND_INIT_FUNCTION(&_M_cond);
 #endif
 #endif
-       }
-#endif 
     }
 
 #if __GTHREADS && ! defined __GTHREAD_COND_INIT
     }
 
 #if __GTHREADS && ! defined __GTHREAD_COND_INIT
index 5e82811..d5b76ef 100644 (file)
@@ -1,7 +1,7 @@
 // SGI's rope class -*- C++ -*-
 
 // SGI's rope class -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-// Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+// 2012 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
 //
 // 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
@@ -44,6 +44,8 @@
 #ifndef _ROPE
 #define _ROPE 1
 
 #ifndef _ROPE
 #define _ROPE 1
 
+#pragma GCC system_header
+
 #include <algorithm>
 #include <iosfwd>
 #include <bits/stl_construct.h>
 #include <algorithm>
 #include <iosfwd>
 #include <bits/stl_construct.h>
@@ -458,20 +460,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     volatile _RC_t _M_ref_count;
 
     // Constructor
     volatile _RC_t _M_ref_count;
 
     // Constructor
+#ifdef __GTHREAD_MUTEX_INIT
+    __gthread_mutex_t _M_ref_count_lock = __GTHREAD_MUTEX_INIT;
+#else
     __gthread_mutex_t _M_ref_count_lock;
     __gthread_mutex_t _M_ref_count_lock;
+#endif
 
 
-    _Refcount_Base(_RC_t __n) : _M_ref_count(__n), _M_ref_count_lock()
+    _Refcount_Base(_RC_t __n) : _M_ref_count(__n)
     {
     {
-#ifdef __GTHREAD_MUTEX_INIT
-      __gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
-      _M_ref_count_lock = __tmp;
-#elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
+#ifndef __GTHREAD_MUTEX_INIT
+#ifdef __GTHREAD_MUTEX_INIT_FUNCTION
       __GTHREAD_MUTEX_INIT_FUNCTION (&_M_ref_count_lock);
 #else
 #error __GTHREAD_MUTEX_INIT or __GTHREAD_MUTEX_INIT_FUNCTION should be defined by gthr.h abstraction layer, report problem to libstdc++@gcc.gnu.org.
 #endif
       __GTHREAD_MUTEX_INIT_FUNCTION (&_M_ref_count_lock);
 #else
 #error __GTHREAD_MUTEX_INIT or __GTHREAD_MUTEX_INIT_FUNCTION should be defined by gthr.h abstraction layer, report problem to libstdc++@gcc.gnu.org.
 #endif
+#endif
     }
 
     }
 
+#ifndef __GTHREAD_MUTEX_INIT
+    ~_Refcount_Base()
+    { __gthread_mutex_destroy(&_M_ref_count_lock); }
+#endif
+
     void
     _M_incr()
     {
     void
     _M_incr()
     {
@@ -581,7 +591,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       bool _M_is_balanced:8;
       unsigned char _M_depth;
       __GC_CONST _CharT* _M_c_string;
       bool _M_is_balanced:8;
       unsigned char _M_depth;
       __GC_CONST _CharT* _M_c_string;
+#ifdef __GTHREAD_MUTEX_INIT
+      __gthread_mutex_t _M_c_string_lock = __GTHREAD_MUTEX_INIT;
+#else
       __gthread_mutex_t _M_c_string_lock;
       __gthread_mutex_t _M_c_string_lock;
+#endif
                         /* Flattened version of string, if needed.  */
                         /* typically 0.                             */
                         /* If it's not 0, then the memory is owned  */
                         /* Flattened version of string, if needed.  */
                         /* typically 0.                             */
                         /* If it's not 0, then the memory is owned  */
@@ -602,13 +616,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
        _M_tag(__t), _M_is_balanced(__b), _M_depth(__d), _M_c_string(0)
 #ifdef __GTHREAD_MUTEX_INIT
 #endif
        _M_tag(__t), _M_is_balanced(__b), _M_depth(__d), _M_c_string(0)
 #ifdef __GTHREAD_MUTEX_INIT
-    {
-      // Do not copy a POSIX/gthr mutex once in use.  However, bits are bits.
-      __gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
-      _M_c_string_lock = __tmp;
-    }
+      { }
 #else
 #else
-    { __GTHREAD_MUTEX_INIT_FUNCTION (&_M_c_string_lock); }
+      { __GTHREAD_MUTEX_INIT_FUNCTION (&_M_c_string_lock); }
+      ~_Rope_RopeRep()
+      { __gthread_mutex_destroy (&_M_c_string_lock); }
 #endif
 #ifdef __GC
       void
 #endif
 #ifdef __GC
       void