@@ -3213,6 +3213,58 @@ AC_DEFUN([AC_LC_MESSAGES], [
])
])
+dnl
+dnl Check whether gthreads types can be copy-assigned in C++11 mode.
+dnl
+AC_DEFUN([GLIBCXX_GTHREADS_CXX11_COPY_ASSIGN], [
+
+ AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -std=c++0x -I${toplevel_srcdir}/gcc"
+
+ target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
+ case $target_thread_file in
+ posix)
+ CXXFLAGS="$CXXFLAGS -DSUPPORTS_WEAK -DGTHREAD_USE_WEAK -D_PTHREADS"
+ esac
+
+ AC_MSG_CHECKING([whether gthreads types are copy-assignable in C++11 mode])
+
+ AC_TRY_COMPILE([#include "gthr.h"],
+ [
+ #ifdef __GTHREAD_MUTEX_INIT
+ __gthread_mutex_t m1;
+ __gthread_mutex_t m2 = __GTHREAD_MUTEX_INIT;
+ m1 = m2;
+ #endif
+ #ifdef __GTHREAD_RECURSIVE_MUTEX_INIT
+ __gthread_recursive_mutex_t r1;
+ __gthread_recursive_mutex_t r2 = __GTHREAD_RECURSIVE_MUTEX_INIT;
+ r1 = r2;
+ #endif
+ #ifdef __GTHREAD_HAS_COND
+ #ifdef __GTHREAD_COND_INIT
+ __gthread_cond_t c1;
+ __gthread_cond_t c2 = __GTHREAD_COND_INIT;
+ c1 = c2;
+ #endif
+ #endif
+ ], [ac_gthread_cxx11_copy_assign=1], [ac_gthread_cxx11_copy_assign=0])
+
+ if test $ac_gthread_cxx11_copy_assign = 1 ; then res_gthr_copy_assign=yes ;
+ else res_gthr_copy_assign=no ; fi
+ AC_MSG_RESULT([$res_gthr_copy_assign])
+
+ if test x"$res_gthr_copy_assign" = x"no"; then
+ AC_DEFINE(_GLIBCXX_GTHREADS_NO_COPY_ASSIGN_IN_CXX11, 1,
+ [Define if gthreads types cannot be copy-assigned in C++11.])
+ fi
+
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ AC_LANG_RESTORE
+])
+
# Macros from the top-level gcc directory.
m4_include([../config/gc++filt.m4])
m4_include([../config/tls.m4])
@@ -164,6 +164,9 @@ GLIBCXX_ENABLE_LIBSTDCXX_TIME([no])
# For gthread support
GLIBCXX_CHECK_GTHREADS
+# For copy-assignable gthreads types
+GLIBCXX_GTHREADS_CXX11_COPY_ASSIGN
+
AC_LC_MESSAGES
# Check for available headers.
@@ -1,6 +1,6 @@
// 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
@@ -140,6 +140,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
#endif
+ template<typename _Tp>
+ static inline void
+ __copy_gthr_type(_Tp& __to, const _Tp& __from)
+ {
+#if defined __GXX_EXPERIMENTAL_CXX0X__ \
+ && defined _GLIBCXX_GTHREADS_NO_COPY_ASSIGN_IN_CXX11
+ __builtin_memcpy(&__to, &__from, sizeof(__to));
+#else
+ __to = __from;
+#endif
+ }
+
class __mutex
{
private:
@@ -156,7 +168,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
#if defined __GTHREAD_MUTEX_INIT
__gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
- _M_mutex = __tmp;
+ __copy_gthr_type(_M_mutex, __tmp);
#else
__GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
#endif
@@ -214,7 +226,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
#if defined __GTHREAD_RECURSIVE_MUTEX_INIT
__gthread_recursive_mutex_t __tmp = __GTHREAD_RECURSIVE_MUTEX_INIT;
- _M_mutex = __tmp;
+ __copy_gthr_type(_M_mutex, __tmp);
#else
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex);
#endif
@@ -332,7 +344,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
#if defined __GTHREAD_COND_INIT
__gthread_cond_t __tmp = __GTHREAD_COND_INIT;
- _M_cond = __tmp;
+ __copy_gthr_type(_M_cond, __tmp);
#else
__GTHREAD_COND_INIT_FUNCTION(&_M_cond);
#endif
@@ -1,7 +1,7 @@
// 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
@@ -445,6 +445,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
identity_element(_Rope_Concat_fn<_CharT, _Alloc>)
{ return rope<_CharT, _Alloc>(); }
+ static inline void
+ __copy_gthr_mutex(__gthread_mutex_t& __to, const __gthread_mutex_t& __from)
+ {
+#if defined __GXX_EXPERIMENTAL_CXX0X__ \
+ && defined _GLIBCXX_GTHREADS_NO_COPY_ASSIGN_IN_CXX11
+ __builtin_memcpy(&__to, &__from, sizeof(__to));
+#else
+ __to = __from;
+#endif
+ }
+
// Class _Refcount_Base provides a type, _RC_t, a data member,
// _M_ref_count, and member functions _M_incr and _M_decr, which perform
// atomic preincrement/predecrement. The constructor initializes
@@ -464,7 +475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
#ifdef __GTHREAD_MUTEX_INIT
__gthread_mutex_t __tmp = __GTHREAD_MUTEX_INIT;
- _M_ref_count_lock = __tmp;
+ __copy_gthr_mutex(_M_ref_count_lock, __tmp);
#elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
__GTHREAD_MUTEX_INIT_FUNCTION (&_M_ref_count_lock);
#else
@@ -605,7 +616,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
// 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;
+ __copy_gthr_mutex(_M_c_string_lock, __tmp);
}
#else
{ __GTHREAD_MUTEX_INIT_FUNCTION (&_M_c_string_lock); }
@@ -1,6 +1,6 @@
// condition_variable -*- C++ -*-
-// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2008, 2009, 2010, 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
@@ -34,7 +34,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
#ifdef __GTHREAD_COND_INIT
__native_type __tmp = __GTHREAD_COND_INIT;
+#if defined __GXX_EXPERIMENTAL_CXX0X__ \
+ && defined _GLIBCXX_GTHREADS_NO_COPY_ASSIGN_IN_CXX11
+ __builtin_memcpy(&_M_cond, &__tmp, sizeof(_M_cond));
+#else
_M_cond = __tmp;
+#endif
#else
int __e = __gthread_cond_init(&_M_cond, 0);