aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/ext
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely.gcc@gmail.com>2012-06-14 22:20:52 +0000
committerJonathan Wakely <jwakely.gcc@gmail.com>2012-06-14 22:20:52 +0000
commitb027a77c763203192e7b2add65d3b3a80ca54d1e (patch)
treec2b8faaf7a39b649a2119c86c3f2ea46f55e9f80 /libstdc++-v3/include/ext
parent1cc4b748afc80a294dc4316815c5bb0fe79c8cc7 (diff)
PR libstdc++/53270
* include/ext/concurrence.h (__mutex, __recursive_mutex, __cond): Use NSDMI in C++11 mode. * include/ext/rope (_Refcount_Base): Likewise. Destroy mutex in destructor when initialized by function. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@188637 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/ext')
-rw-r--r--libstdc++-v3/include/ext/concurrence.h21
-rw-r--r--libstdc++-v3/include/ext/rope11
2 files changed, 32 insertions, 0 deletions
diff --git a/libstdc++-v3/include/ext/concurrence.h b/libstdc++-v3/include/ext/concurrence.h
index fc8f63f827e..22c433bff33 100644
--- a/libstdc++-v3/include/ext/concurrence.h
+++ b/libstdc++-v3/include/ext/concurrence.h
@@ -143,7 +143,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class __mutex
{
private:
+#if __GTHREADS && defined __GTHREAD_MUTEX_INIT \
+ && defined __GXX_EXPERIMENTAL_CXX0X__
+ __gthread_mutex_t _M_mutex = __GTHREAD_MUTEX_INIT;
+#else
__gthread_mutex_t _M_mutex;
+#endif
__mutex(const __mutex&);
__mutex& operator=(const __mutex&);
@@ -155,8 +160,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
if (__gthread_active_p())
{
#if defined __GTHREAD_MUTEX_INIT
+# ifndef __GXX_EXPERIMENTAL_CXX0X__
__gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
_M_mutex = __tmp;
+# endif
#else
__GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
#endif
@@ -201,7 +208,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class __recursive_mutex
{
private:
+#if __GTHREADS && defined __GTHREAD_RECURSIVE_MUTEX_INIT \
+ && defined __GXX_EXPERIMENTAL_CXX0X__
+ __gthread_recursive_mutex_t _M_mutex = __GTHREAD_RECURSIVE_MUTEX_INIT;
+#else
__gthread_recursive_mutex_t _M_mutex;
+#endif
__recursive_mutex(const __recursive_mutex&);
__recursive_mutex& operator=(const __recursive_mutex&);
@@ -213,8 +225,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
if (__gthread_active_p())
{
#if defined __GTHREAD_RECURSIVE_MUTEX_INIT
+# ifndef __GXX_EXPERIMENTAL_CXX0X__
__gthread_recursive_mutex_t __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT;
_M_mutex = __tmp;
+# endif
#else
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex);
#endif
@@ -319,7 +333,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class __cond
{
private:
+#if __GTHREADS && defined __GTHREAD_COND_INIT \
+ && defined __GXX_EXPERIMENTAL_CXX0X__
+ __gthread_cond_t _M_cond = __GTHREAD_COND_INIT;
+#else
__gthread_cond_t _M_cond;
+#endif
__cond(const __cond&);
__cond& operator=(const __cond&);
@@ -331,8 +350,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
if (__gthread_active_p())
{
#if defined __GTHREAD_COND_INIT
+# ifndef __GXX_EXPERIMENTAL_CXX0X__
__gthread_cond_t __tmp = __GTHREAD_COND_INIT;
_M_cond = __tmp;
+# endif
#else
__GTHREAD_COND_INIT_FUNCTION(&_M_cond);
#endif
diff --git a/libstdc++-v3/include/ext/rope b/libstdc++-v3/include/ext/rope
index 5e82811757c..15cb423df68 100644
--- a/libstdc++-v3/include/ext/rope
+++ b/libstdc++-v3/include/ext/rope
@@ -458,13 +458,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
volatile _RC_t _M_ref_count;
// Constructor
+#if defined __GTHREAD_MUTEX_INIT && defined __GXX_EXPERIMENTAL_CXX0X__
+ __gthread_mutex_t _M_ref_count_lock = __GTHREAD_MUTEX_INIT;
+#else
__gthread_mutex_t _M_ref_count_lock;
+#endif
_Refcount_Base(_RC_t __n) : _M_ref_count(__n), _M_ref_count_lock()
{
#ifdef __GTHREAD_MUTEX_INIT
+# ifndef __GXX_EXPERIMENTAL_CXX0X__
__gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
_M_ref_count_lock = __tmp;
+# endif
#elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
__GTHREAD_MUTEX_INIT_FUNCTION (&_M_ref_count_lock);
#else
@@ -472,6 +478,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
}
+#ifndef __GTHREAD_MUTEX_INIT
+ ~_Refcount_Base()
+ { __gthread_mutex_destroy(&_M_ref_count_lock); }
+#endif
+
void
_M_incr()
{