From: Jonathan Wakely Date: Sun, 22 Jul 2012 16:46:02 +0000 (+0000) Subject: re PR libstdc++/53270 (Error when bootstrapping gcc on hppa2.0-unknown-linux-gcc) X-Git-Tag: releases/gcc-4.6.4~437 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7fe951294e3d1e2cdde7745247c0db697cb66e8;p=thirdparty%2Fgcc.git re PR libstdc++/53270 (Error when bootstrapping gcc on hppa2.0-unknown-linux-gcc) 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. From-SVN: r189758 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index afd687ae4be9..aa94768620eb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,19 @@ +2012-07-22 Jonathan Wakely + + 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 PR libstdc++/53578 diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index d6735e9b5f59..788966c66497 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -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]) diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index 6ab257fa3440..2a8afaf43979 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -692,6 +692,9 @@ /* 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 diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index c6a033625511..84b6ea94a017 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -19477,6 +19477,84 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +# 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 : diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index cc4c9bf2da14..427cf0b88153 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -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. diff --git a/libstdc++-v3/include/ext/concurrence.h b/libstdc++-v3/include/ext/concurrence.h index 4719c84f474f..ce999e5e3831 100644 --- a/libstdc++-v3/include/ext/concurrence.h +++ b/libstdc++-v3/include/ext/concurrence.h @@ -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 + 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 diff --git a/libstdc++-v3/include/ext/rope b/libstdc++-v3/include/ext/rope index 42921516e40b..84837ac8e633 100644 --- a/libstdc++-v3/include/ext/rope +++ b/libstdc++-v3/include/ext/rope @@ -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); } diff --git a/libstdc++-v3/src/condition_variable.cc b/libstdc++-v3/src/condition_variable.cc index 7f1e1946a551..be22dc04bb60 100644 --- a/libstdc++-v3/src/condition_variable.cc +++ b/libstdc++-v3/src/condition_variable.cc @@ -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);