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.
# 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
// 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
class __mutex
{
private:
+#if __GTHREADS && defined __GTHREAD_MUTEX_INIT
+ __gthread_mutex_t _M_mutex = __GTHREAD_MUTEX_INIT;
+#else
__gthread_mutex_t _M_mutex;
+#endif
__mutex(const __mutex&);
__mutex& operator=(const __mutex&);
public:
__mutex()
{
-#if __GTHREADS
+#if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT
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
}
#if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT
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;
+#endif
__recursive_mutex(const __recursive_mutex&);
__recursive_mutex& operator=(const __recursive_mutex&);
public:
__recursive_mutex()
{
-#if __GTHREADS
+#if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT
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
}
#if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT
class __cond
{
private:
+#if __GTHREADS && defined __GTHREAD_COND_INIT
+ __gthread_cond_t _M_cond = __GTHREAD_COND_INIT;
+#else
__gthread_cond_t _M_cond;
+#endif
__cond(const __cond&);
__cond& operator=(const __cond&);
public:
__cond()
{
-#if __GTHREADS
+#if __GTHREADS && ! defined __GTHREAD_COND_INIT
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
}
#if __GTHREADS && ! defined __GTHREAD_COND_INIT
// 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
#ifndef _ROPE
#define _ROPE 1
+#pragma GCC system_header
+
#include <algorithm>
#include <iosfwd>
#include <bits/stl_construct.h>
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;
+#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
+#endif
}
+#ifndef __GTHREAD_MUTEX_INIT
+ ~_Refcount_Base()
+ { __gthread_mutex_destroy(&_M_ref_count_lock); }
+#endif
+
void
_M_incr()
{
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;
+#endif
/* Flattened version of string, if needed. */
/* typically 0. */
/* If it's not 0, then the memory is owned */
#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
- { __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