+2012-07-22 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ PR libstdc++/53270
+ * acinclude.m4 (GLIBCXX_GTHREADS_CXX11_COPY_ASSIGN): Define.
+ * configure.ac (GLIBCXX_GTHREADS_CXX11_COPY_ASSIGN): Use it.
+ * config.h.in: Regenerate.
+ * configure: Likewise.
+ * include/ext/concurrence.h (__copy_gthr_type): Define.
+ (__mutex::__mutex, __recursive_mutex::__recursive_mutex,
+ __cond::__cond): Use it.
+ * include/ext/rope (__copy_gthr_mutex): Define.
+ (_Refcount_Base::_Refcount_Base, _Rope_RopeRep::_Rope_RopeRep): Use
+ it.
+ * src/condition_variable.cc (condition_variable::condition_variable):
+ Use memcpy instead of assignment.
+
2012-07-07 Jonathan Wakely <jwakely.gcc@gmail.com>
PR libstdc++/53578
])
])
+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])
/* Define if a fully dynamic basic_string is wanted. */
#undef _GLIBCXX_FULLY_DYNAMIC_STRING
+/* Define if gthreads types cannot be copy-assigned in C++11. */
+#undef _GLIBCXX_GTHREADS_NO_COPY_ASSIGN_IN_CXX11
+
/* Define if gthreads library is available. */
#undef _GLIBCXX_HAS_GTHREADS
+# For copy-assignable gthreads types
+
+
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ 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
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gthreads types are copy-assignable in C++11 mode" >&5
+$as_echo_n "checking whether gthreads types are copy-assignable in C++11 mode... " >&6; }
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include "gthr.h"
+int
+main ()
+{
+
+ #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
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_gthread_cxx11_copy_assign=1
+else
+ ac_gthread_cxx11_copy_assign=0
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+ if test $ac_gthread_cxx11_copy_assign = 1 ; then res_gthr_copy_assign=yes ;
+ else res_gthr_copy_assign=no ; fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $res_gthr_copy_assign" >&5
+$as_echo "$res_gthr_copy_assign" >&6; }
+
+ if test x"$res_gthr_copy_assign" = x"no"; then
+
+$as_echo "#define _GLIBCXX_GTHREADS_NO_COPY_ASSIGN_IN_CXX11 1" >>confdefs.h
+
+ fi
+
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
ac_fn_c_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default"
if test "x$ac_cv_header_locale_h" = x""yes; then :
# For gthread support
GLIBCXX_CHECK_GTHREADS
+# For copy-assignable gthreads types
+GLIBCXX_GTHREADS_CXX11_COPY_ASSIGN
+
AC_LC_MESSAGES
# Check for available headers.
// 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
}
#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:
{
#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
{
#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
{
#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
// 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
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
{
#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
{
// 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); }
// 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
{
#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);