From patchwork Thu Dec 1 02:32:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Kosnik X-Patchwork-Id: 128628 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 0B6C2B6F71 for ; Thu, 1 Dec 2011 13:33:32 +1100 (EST) Received: (qmail 1376 invoked by alias); 1 Dec 2011 02:33:13 -0000 Received: (qmail 830 invoked by uid 22791); 1 Dec 2011 02:32:56 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_BG, TW_CX, TW_XX X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Dec 2011 02:32:24 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pB12WNDq006053 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 Nov 2011 21:32:23 -0500 Received: from shotwell (ovpn-113-63.phx2.redhat.com [10.3.113.63]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pB12WM9U009115 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 30 Nov 2011 21:32:22 -0500 Date: Wed, 30 Nov 2011 18:32:22 -0800 From: Benjamin Kosnik To: Andrew MacLeod Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: [PATCH] Re: [v3] updated atomic configury Message-ID: <20111130183222.49f3f911@shotwell> In-Reply-To: <4ED3F280.5070600@redhat.com> References: <4ED3F280.5070600@redhat.com> Mime-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Thanks Andrew. Here's the updated patch, as checked in. This removes one level of cruft WRT atomic configure-ness (leaving us with the most primordial...). tested x86/linux tested x86/linux x arm-eabi tested x86/linux x cris-elf -benjamin 2011-11-30 Benjamin Kosnik * acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): Remove size-specific macros. _GLIBCXX_ATOMIC_BUILTINS_1, _GLIBCXX_ATOMIC_BUILTINS_2, _GLIBCXX_ATOMIC_BUILTINS_4, _GLIBCXX_ATOMIC_BUILTINS_8. Use _GLIBCXX_ATOMIC_BUILTINS to indicate use of C++11 atomic builtins. * config.h.in: Regenerate. * configure: Regenerate. * include/Makefile.am (bits_sup_headers): Add atomic_lockfree_defines.h. * include/Makefile.in: Regenerate. * libsupc++/Makefile.am: Compile C++11 support with -std=gnu++0x. * libsupc++/Makefile.in: Regenerate. * include/bits/atomic_base.h: Move lock-free property macros... * libsupc++/atomic_lockfree_defines.h: ...here. * include/std/future: Use C++11 macros. * libsupc++/eh_ptr.cc: Same. * libsupc++/eh_throw.cc: Same. * libsupc++/exception: Same. * libsupc++/exception_ptr.h: Same. * libsupc++/guard.cc: Same. * libsupc++/nested_exception.cc: Same. * libsupc++/nested_exception.h: Same. * src/future.cc: Same. * include/ext/atomicity.h: Use _GLIBCXX_ATOMIC_BUILTINS. * doc/doxygen/user.cfg.in * doc/xml/manual/concurrency_extensions.xml * testsuite/18_support/exception_ptr/lifespan.cc * testsuite/lib/libstdc++.exp diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index fee5c6f..9d08178 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -2683,12 +2683,6 @@ dnl dnl Note: dnl libgomp and libgfortran use a link test, see CHECK_SYNC_FETCH_AND_ADD. dnl -dnl Defines: -dnl _GLIBCXX_ATOMIC_BUILTINS_1 -dnl _GLIBCXX_ATOMIC_BUILTINS_2 -dnl _GLIBCXX_ATOMIC_BUILTINS_4 -dnl _GLIBCXX_ATOMIC_BUILTINS_8 -dnl AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [ AC_LANG_SAVE AC_LANG_CPLUSPLUS @@ -2729,10 +2723,6 @@ AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [ [glibcxx_cv_atomic_bool=yes], [glibcxx_cv_atomic_bool=no]) ]) - if test $glibcxx_cv_atomic_bool = yes; then - AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1, - [Define if builtin atomic operations for bool are supported on this host.]) - fi AC_MSG_RESULT($glibcxx_cv_atomic_bool) AC_MSG_CHECKING([for atomic builtins for short]) @@ -2751,10 +2741,6 @@ AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [ [glibcxx_cv_atomic_short=yes], [glibcxx_cv_atomic_short=no]) ]) - if test $glibcxx_cv_atomic_short = yes; then - AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1, - [Define if builtin atomic operations for short are supported on this host.]) - fi AC_MSG_RESULT($glibcxx_cv_atomic_short) AC_MSG_CHECKING([for atomic builtins for int]) @@ -2773,10 +2759,6 @@ AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [ [glibcxx_cv_atomic_int=yes], [glibcxx_cv_atomic_int=no]) ]) - if test $glibcxx_cv_atomic_int = yes; then - AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1, - [Define if builtin atomic operations for int are supported on this host.]) - fi AC_MSG_RESULT($glibcxx_cv_atomic_int) AC_MSG_CHECKING([for atomic builtins for long long]) @@ -2795,10 +2777,6 @@ AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [ [glibcxx_cv_atomic_long_long=yes], [glibcxx_cv_atomic_long_long=no]) ]) - if test $glibcxx_cv_atomic_long_long = yes; then - AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1, - [Define if builtin atomic operations for long long are supported on this host.]) - fi AC_MSG_RESULT($glibcxx_cv_atomic_long_long) else @@ -2832,8 +2810,6 @@ EOF if grep __sync_ conftest.s >/dev/null 2>&1 ; then glibcxx_cv_atomic_bool=no else - AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1, - [Define if builtin atomic operations for bool are supported on this host.]) glibcxx_cv_atomic_bool=yes fi fi @@ -2862,8 +2838,6 @@ EOF if grep __sync_ conftest.s >/dev/null 2>&1 ; then glibcxx_cv_atomic_short=no else - AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1, - [Define if builtin atomic operations for short are supported on this host.]) glibcxx_cv_atomic_short=yes fi fi @@ -2893,8 +2867,6 @@ EOF if grep __sync_ conftest.s >/dev/null 2>&1 ; then glibcxx_cv_atomic_int=no else - AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1, - [Define if builtin atomic operations for int are supported on this host.]) glibcxx_cv_atomic_int=yes fi fi @@ -2923,8 +2895,6 @@ EOF if grep __sync_ conftest.s >/dev/null 2>&1 ; then glibcxx_cv_atomic_long_long=no else - AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1, - [Define if builtin atomic operations for long long are supported on this host.]) glibcxx_cv_atomic_long_long=yes fi fi @@ -2938,6 +2908,8 @@ EOF # Set atomicity_dir to builtins if either of above tests pass. if test $glibcxx_cv_atomic_int = yes || test $glibcxx_cv_atomic_bool = yes ; then + AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS, 1, + [Define if the compiler supports C++11 atomics.]) atomicity_dir=cpu/generic/atomicity_builtins fi diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index 7215a7f..378ddab 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -689,19 +689,8 @@ /* Version number of package */ #undef VERSION -/* Define if builtin atomic operations for bool are supported on this host. */ -#undef _GLIBCXX_ATOMIC_BUILTINS_1 - -/* Define if builtin atomic operations for short are supported on this host. - */ -#undef _GLIBCXX_ATOMIC_BUILTINS_2 - -/* Define if builtin atomic operations for int are supported on this host. */ -#undef _GLIBCXX_ATOMIC_BUILTINS_4 - -/* Define if builtin atomic operations for long long are supported on this - host. */ -#undef _GLIBCXX_ATOMIC_BUILTINS_8 +/* Define if the compiler supports C++11 atomics. */ +#undef _GLIBCXX_ATOMIC_BUILTINS /* Define to use concept checking code from the boost libraries. */ #undef _GLIBCXX_CONCEPT_CHECKS diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 5221836..3c64a28 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -15147,11 +15147,6 @@ rm -f core conftest.err conftest.$ac_objext \ fi - if test $glibcxx_cv_atomic_bool = yes; then - -$as_echo "#define _GLIBCXX_ATOMIC_BUILTINS_1 1" >>confdefs.h - - fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_bool" >&5 $as_echo "$glibcxx_cv_atomic_bool" >&6; } @@ -15193,11 +15188,6 @@ rm -f core conftest.err conftest.$ac_objext \ fi - if test $glibcxx_cv_atomic_short = yes; then - -$as_echo "#define _GLIBCXX_ATOMIC_BUILTINS_2 1" >>confdefs.h - - fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_short" >&5 $as_echo "$glibcxx_cv_atomic_short" >&6; } @@ -15239,11 +15229,6 @@ rm -f core conftest.err conftest.$ac_objext \ fi - if test $glibcxx_cv_atomic_int = yes; then - -$as_echo "#define _GLIBCXX_ATOMIC_BUILTINS_4 1" >>confdefs.h - - fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_int" >&5 $as_echo "$glibcxx_cv_atomic_int" >&6; } @@ -15285,11 +15270,6 @@ rm -f core conftest.err conftest.$ac_objext \ fi - if test $glibcxx_cv_atomic_long_long = yes; then - -$as_echo "#define _GLIBCXX_ATOMIC_BUILTINS_8 1" >>confdefs.h - - fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_atomic_long_long" >&5 $as_echo "$glibcxx_cv_atomic_long_long" >&6; } @@ -15303,7 +15283,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; } # Fake what AC_TRY_COMPILE does. cat > conftest.$ac_ext << EOF -#line 15306 "configure" +#line 15286 "configure" int main() { typedef bool atomic_type; @@ -15329,9 +15309,6 @@ $as_echo_n "checking for atomic builtins for bool... " >&6; } if grep __sync_ conftest.s >/dev/null 2>&1 ; then glibcxx_cv_atomic_bool=no else - -$as_echo "#define _GLIBCXX_ATOMIC_BUILTINS_1 1" >>confdefs.h - glibcxx_cv_atomic_bool=yes fi fi @@ -15340,7 +15317,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 15343 "configure" +#line 15320 "configure" int main() { typedef short atomic_type; @@ -15366,9 +15343,6 @@ $as_echo_n "checking for atomic builtins for short... " >&6; } if grep __sync_ conftest.s >/dev/null 2>&1 ; then glibcxx_cv_atomic_short=no else - -$as_echo "#define _GLIBCXX_ATOMIC_BUILTINS_2 1" >>confdefs.h - glibcxx_cv_atomic_short=yes fi fi @@ -15377,7 +15351,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 15380 "configure" +#line 15354 "configure" int main() { // NB: _Atomic_word not necessarily int. @@ -15404,9 +15378,6 @@ $as_echo_n "checking for atomic builtins for int... " >&6; } if grep __sync_ conftest.s >/dev/null 2>&1 ; then glibcxx_cv_atomic_int=no else - -$as_echo "#define _GLIBCXX_ATOMIC_BUILTINS_4 1" >>confdefs.h - glibcxx_cv_atomic_int=yes fi fi @@ -15415,7 +15386,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 15418 "configure" +#line 15389 "configure" int main() { typedef long long atomic_type; @@ -15441,9 +15412,6 @@ $as_echo_n "checking for atomic builtins for long long... " >&6; } if grep __sync_ conftest.s >/dev/null 2>&1 ; then glibcxx_cv_atomic_long_long=no else - -$as_echo "#define _GLIBCXX_ATOMIC_BUILTINS_8 1" >>confdefs.h - glibcxx_cv_atomic_long_long=yes fi fi @@ -15463,6 +15431,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # Set atomicity_dir to builtins if either of above tests pass. if test $glibcxx_cv_atomic_int = yes || test $glibcxx_cv_atomic_bool = yes ; then + +$as_echo "#define _GLIBCXX_ATOMIC_BUILTINS 1" >>confdefs.h + atomicity_dir=cpu/generic/atomicity_builtins fi @@ -15491,7 +15462,7 @@ $as_echo "$as_me: WARNING: Performance of certain classes will degrade as a resu # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 15494 "configure" +#line 15465 "configure" int main() { _Decimal32 d1; @@ -15533,7 +15504,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 15536 "configure" +#line 15507 "configure" template struct same { typedef T2 type; }; @@ -15567,7 +15538,7 @@ $as_echo "$enable_int128" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 15570 "configure" +#line 15541 "configure" template struct same { typedef T2 type; }; diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in index 0b01ceb..9178b0c 100644 --- a/libstdc++-v3/doc/doxygen/user.cfg.in +++ b/libstdc++-v3/doc/doxygen/user.cfg.in @@ -1645,10 +1645,6 @@ PREDEFINED = __cplusplus \ _GLIBCXX_USE_WCHAR_T \ _GLIBCXX_USE_LONG_LONG \ _GLIBCXX_USE_C99_STDINT_TR1 \ - _GLIBCXX_ATOMIC_BUILTINS_1 \ - _GLIBCXX_ATOMIC_BUILTINS_2 \ - _GLIBCXX_ATOMIC_BUILTINS_4 \ - _GLIBCXX_ATOMIC_BUILTINS_8 \ _GLIBCXX_USE_SCHED_YIELD \ _GLIBCXX_USE_NANOSLEEP \ PB_DS_DATA_TRUE_INDICATOR \ diff --git a/libstdc++-v3/doc/xml/manual/concurrency_extensions.xml b/libstdc++-v3/doc/xml/manual/concurrency_extensions.xml index 9092c8d..c87f41b 100644 --- a/libstdc++-v3/doc/xml/manual/concurrency_extensions.xml +++ b/libstdc++-v3/doc/xml/manual/concurrency_extensions.xml @@ -210,11 +210,19 @@ usage vary depending on the target hardware and the flags used during compile. + + + + +Incomplete/inconsistent. This is only C++11. + + + If builtins are possible for bool-sized integral types, -_GLIBCXX_ATOMIC_BUILTINS_1 will be defined. +ATOMIC_BOOL_LOCK_FREE will be defined. If builtins are possible for int-sized integral types, -_GLIBCXX_ATOMIC_BUILTINS_4 will be defined. +ATOMIC_INT_LOCK_FREE will be defined. diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 121a642..1e9b144 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -177,6 +177,7 @@ bits_headers = \ bits_sup_srcdir = ${glibcxx_srcdir}/libsupc++ bits_sup_headers = \ + ${bits_sup_srcdir}/atomic_lockfree_defines.h \ ${bits_sup_srcdir}/cxxabi_forced.h \ ${bits_sup_srcdir}/exception_defines.h \ ${bits_sup_srcdir}/exception_ptr.h \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 70c0781..fec2d94 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -429,6 +429,7 @@ bits_headers = \ bits_sup_srcdir = ${glibcxx_srcdir}/libsupc++ bits_sup_headers = \ + ${bits_sup_srcdir}/atomic_lockfree_defines.h \ ${bits_sup_srcdir}/cxxabi_forced.h \ ${bits_sup_srcdir}/exception_defines.h \ ${bits_sup_srcdir}/exception_ptr.h \ diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index 2711323..3f00cda 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -35,6 +35,7 @@ #include #include #include +#include namespace std _GLIBCXX_VISIBILITY(default) { @@ -70,15 +71,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline void atomic_thread_fence(memory_order __m) noexcept - { - __atomic_thread_fence (__m); - } + { __atomic_thread_fence(__m); } inline void atomic_signal_fence(memory_order __m) noexcept - { - __atomic_thread_fence (__m); - } + { __atomic_thread_fence(__m); } /// kill_dependency template @@ -89,19 +86,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __ret; } - /// Lock-free Property - - -#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE -#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE -#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE -#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE -#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE -#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE -#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE -#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE -#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE -#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE // Base types for atomics. template diff --git a/libstdc++-v3/include/ext/atomicity.h b/libstdc++-v3/include/ext/atomicity.h index f0c7752..c63b1d4 100644 --- a/libstdc++-v3/include/ext/atomicity.h +++ b/libstdc++-v3/include/ext/atomicity.h @@ -1,6 +1,6 @@ // Support for atomic operations -*- C++ -*- -// Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 +// Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -42,7 +42,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // To abstract locking primitives across all thread policies, use: // __exchange_and_add_dispatch // __atomic_add_dispatch -#ifdef _GLIBCXX_ATOMIC_BUILTINS_4 +#ifdef _GLIBCXX_ATOMIC_BUILTINS static inline _Atomic_word __exchange_and_add(volatile _Atomic_word* __mem, int __val) { return __sync_fetch_and_add(__mem, __val); } diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index bfd1ff9..040f573 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -187,7 +187,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION async(_Fn&& __fn, _Args&&... __args); #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \ - && defined(_GLIBCXX_ATOMIC_BUILTINS_4) + && (ATOMIC_INT_LOCK_FREE > 1) /// Base class and enclosing scope. struct __future_base @@ -1493,7 +1493,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 - // && _GLIBCXX_ATOMIC_BUILTINS_4 + // && ATOMIC_INT_LOCK_FREE // @} group futures _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am index c8e661d..fb5c26f 100644 --- a/libstdc++-v3/libsupc++/Makefile.am +++ b/libstdc++-v3/libsupc++/Makefile.am @@ -35,8 +35,8 @@ std_HEADERS = \ cxxabi.h exception initializer_list new typeinfo bits_HEADERS = \ - cxxabi_forced.h hash_bytes.h \ - exception_defines.h exception_ptr.h nested_exception.h + atomic_lockfree_defines.h cxxabi_forced.h \ + exception_defines.h exception_ptr.h hash_bytes.h nested_exception.h headers = $(std_HEADERS) $(bits_HEADERS) @@ -136,6 +136,22 @@ cp-demangle.o: cp-demangle.c $(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $< +# Use special rules for the C++0x sources so that the proper flags are passed. +eh_ptr.lo: eh_ptr.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +eh_ptr.o: eh_ptr.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + +eh_throw.lo: eh_throw.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +eh_throw.o: eh_throw.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + +guard.lo: guard.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +guard.o: guard.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + nested_exception.lo: nested_exception.cc $(LTCXXCOMPILE) -std=gnu++0x -c $< nested_exception.o: nested_exception.cc diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in index 191bd28..2cc92ec 100644 --- a/libstdc++-v3/libsupc++/Makefile.in +++ b/libstdc++-v3/libsupc++/Makefile.in @@ -346,8 +346,8 @@ std_HEADERS = \ cxxabi.h exception initializer_list new typeinfo bits_HEADERS = \ - cxxabi_forced.h hash_bytes.h \ - exception_defines.h exception_ptr.h nested_exception.h + atomic_lockfree_defines.h cxxabi_forced.h \ + exception_defines.h exception_ptr.h hash_bytes.h nested_exception.h headers = $(std_HEADERS) $(bits_HEADERS) @GLIBCXX_HOSTED_TRUE@c_sources = \ @@ -770,6 +770,22 @@ cp-demangle.lo: cp-demangle.c cp-demangle.o: cp-demangle.c $(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $< +# Use special rules for the C++0x sources so that the proper flags are passed. +eh_ptr.lo: eh_ptr.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +eh_ptr.o: eh_ptr.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + +eh_throw.lo: eh_throw.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +eh_throw.o: eh_throw.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + +guard.lo: guard.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +guard.o: guard.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + nested_exception.lo: nested_exception.cc $(LTCXXCOMPILE) -std=gnu++0x -c $< nested_exception.o: nested_exception.cc diff --git a/libstdc++-v3/libsupc++/atomic_lockfree_defines.h b/libstdc++-v3/libsupc++/atomic_lockfree_defines.h new file mode 100644 index 0000000..22331b6 --- /dev/null +++ b/libstdc++-v3/libsupc++/atomic_lockfree_defines.h @@ -0,0 +1,63 @@ +// -*- C++ -*- header. + +// Copyright (C) 2008, 2009, 2010, 2011 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 +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file bits/atomic_lockfree_defines.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{atomic} + */ + +#ifndef _GLIBCXX_ATOMIC_LOCK_FREE_H +#define _GLIBCXX_ATOMIC_LOCK_FREE_H 1 + +#pragma GCC system_header + +/** + * @addtogroup atomics + * @{ + */ + +/** + * Lock-free property. + * + * 0 indicates that the types are never lock-free. + * 1 indicates that the types are sometimes lock-free. + * 2 indicates that the types are always lock-free. + */ + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE +#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE +#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE +#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE +#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE +#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE +#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE +#endif + +// @} group atomics + +#endif diff --git a/libstdc++-v3/libsupc++/eh_ptr.cc b/libstdc++-v3/libsupc++/eh_ptr.cc index 94c2842..0e710f2 100644 --- a/libstdc++-v3/libsupc++/eh_ptr.cc +++ b/libstdc++-v3/libsupc++/eh_ptr.cc @@ -1,5 +1,5 @@ // -*- C++ -*- Implement the members of exception_ptr. -// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. // // This file is part of GCC. // @@ -23,8 +23,9 @@ // . #include +#include -#ifdef _GLIBCXX_ATOMIC_BUILTINS_4 +#if ATOMIC_INT_LOCK_FREE > 1 #define _GLIBCXX_EH_PTR_COMPAT diff --git a/libstdc++-v3/libsupc++/eh_throw.cc b/libstdc++-v3/libsupc++/eh_throw.cc index 78cfc13..728c5cc 100644 --- a/libstdc++-v3/libsupc++/eh_throw.cc +++ b/libstdc++-v3/libsupc++/eh_throw.cc @@ -43,7 +43,7 @@ __gxx_exception_cleanup (_Unwind_Reason_Code code, _Unwind_Exception *exc) if (code != _URC_FOREIGN_EXCEPTION_CAUGHT && code != _URC_NO_REASON) __terminate (header->exc.terminateHandler); -#ifdef _GLIBCXX_ATOMIC_BUILTINS_4 +#if ATOMIC_INT_LOCK_FREE > 1 if (__sync_sub_and_fetch (&header->referenceCount, 1) == 0) { #endif @@ -51,7 +51,7 @@ __gxx_exception_cleanup (_Unwind_Reason_Code code, _Unwind_Exception *exc) header->exc.exceptionDestructor (header + 1); __cxa_free_exception (header + 1); -#ifdef _GLIBCXX_ATOMIC_BUILTINS_4 +#if ATOMIC_INT_LOCK_FREE > 1 } #endif } diff --git a/libstdc++-v3/libsupc++/exception b/libstdc++-v3/libsupc++/exception index db75ad1..3deb45e 100644 --- a/libstdc++-v3/libsupc++/exception +++ b/libstdc++-v3/libsupc++/exception @@ -37,6 +37,7 @@ #pragma GCC visibility push(default) #include +#include extern "C++" { @@ -149,8 +150,7 @@ _GLIBCXX_END_NAMESPACE_VERSION #pragma GCC visibility pop -#if (defined(__GXX_EXPERIMENTAL_CXX0X__) \ - && defined(_GLIBCXX_ATOMIC_BUILTINS_4)) +#if defined(__GXX_EXPERIMENTAL_CXX0X__) && (ATOMIC_INT_LOCK_FREE > 1) #include #include #endif diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h index 00b30fd..bd18dc1 100644 --- a/libstdc++-v3/libsupc++/exception_ptr.h +++ b/libstdc++-v3/libsupc++/exception_ptr.h @@ -36,7 +36,7 @@ #include #include -#if !defined(_GLIBCXX_ATOMIC_BUILTINS_4) +#if ATOMIC_INT_LOCK_FREE < 2 # error This platform does not support exception propagation. #endif diff --git a/libstdc++-v3/libsupc++/guard.cc b/libstdc++-v3/libsupc++/guard.cc index 21bca58..643ecd7 100644 --- a/libstdc++-v3/libsupc++/guard.cc +++ b/libstdc++-v3/libsupc++/guard.cc @@ -32,7 +32,7 @@ #include #include #if defined(__GTHREADS) && defined(__GTHREAD_HAS_COND) \ - && defined(_GLIBCXX_ATOMIC_BUILTINS_4) && defined(_GLIBCXX_HAVE_LINUX_FUTEX) + && (ATOMIC_INT_LOCK_FREE > 1) && defined(_GLIBCXX_HAVE_LINUX_FUTEX) # include # include # include diff --git a/libstdc++-v3/libsupc++/nested_exception.cc b/libstdc++-v3/libsupc++/nested_exception.cc index ecbc4c8..ad83ecd 100644 --- a/libstdc++-v3/libsupc++/nested_exception.cc +++ b/libstdc++-v3/libsupc++/nested_exception.cc @@ -25,7 +25,7 @@ namespace std { -#ifdef _GLIBCXX_ATOMIC_BUILTINS_4 +#if ATOMIC_INT_LOCK_FREE > 1 nested_exception::~nested_exception() = default; #endif } // namespace std diff --git a/libstdc++-v3/libsupc++/nested_exception.h b/libstdc++-v3/libsupc++/nested_exception.h index d4804bb..9b99c32 100644 --- a/libstdc++-v3/libsupc++/nested_exception.h +++ b/libstdc++-v3/libsupc++/nested_exception.h @@ -38,7 +38,7 @@ #include -#if !defined(_GLIBCXX_ATOMIC_BUILTINS_4) +#if ATOMIC_INT_LOCK_FREE < 2 # error This platform does not support exception propagation. #endif diff --git a/libstdc++-v3/src/future.cc b/libstdc++-v3/src/future.cc index 8569bf0..e68642c3 100644 --- a/libstdc++-v3/src/future.cc +++ b/libstdc++-v3/src/future.cc @@ -78,7 +78,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION future_error::what() const noexcept { return _M_code.message().c_str(); } #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \ - && defined(_GLIBCXX_ATOMIC_BUILTINS_4) + && (ATOMIC_INT_LOCK_FREE > 1) __future_base::_Result_base::_Result_base() = default; __future_base::_Result_base::~_Result_base() = default; diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/lifespan.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/lifespan.cc index 704f77e..b417ea6 100644 --- a/libstdc++-v3/testsuite/18_support/exception_ptr/lifespan.cc +++ b/libstdc++-v3/testsuite/18_support/exception_ptr/lifespan.cc @@ -150,11 +150,14 @@ void test06() may_destruct = false; - try { - test06_helper(); - } catch(...) { - may_destruct = true; - } + try + { + test06_helper(); + } + catch(...) + { + may_destruct = true; + } may_destruct = false; } @@ -167,11 +170,14 @@ void test99() may_destruct = false; - try { - throw destructing(); - } catch(...) { - gep = current_exception(); - } + try + { + throw destructing(); + } + catch(...) + { + gep = current_exception(); + } } int main() diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index e419192..abb92bf 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -1219,14 +1219,16 @@ proc check_v3_target_atomic_builtins { } { set src atomic_builtins[pid].cc set f [open $src "w"] - puts $f "#include " - puts $f "#ifndef _GLIBCXX_ATOMIC_BUILTINS_4" - puts $f "# error No atomic builtins" + puts $f "#if __GCC_ATOMIC_BOOL_LOCK_FREE < 2" + puts $f "# error No atomic bool" + puts $f "#endif" + puts $f "#if __GCC_ATOMIC_INT_LOCK_FREE < 2" + puts $f "# error No atomic int" puts $f "#endif" close $f set cxxflags_saved $cxxflags - set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror" + set cxxflags "$cxxflags $DEFAULT_CXXFLAGS -Werror -std=gnu++0x" set lines [v3_target_compile $src /dev/null preprocess ""] set cxxflags $cxxflags_saved