diff options
author | Benjamin Kosnik <bkoz@redhat.com> | 2012-02-10 18:20:43 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2012-02-10 18:20:43 +0000 |
commit | 75cee7c62ab4a51c1e9c18f1c06febbd38b8021b (patch) | |
tree | 0dbe6745de2f1b55e6c7f809f4157e564668753a /libstdc++-v3/include | |
parent | 6c9b75b06175c0859a7c340600069c58e083d7c3 (diff) | |
download | gcc-75cee7c62ab4a51c1e9c18f1c06febbd38b8021b.tar.gz |
PR libstdc++/51798 continued.
2012-02-10 Benjamin Kosnik <bkoz@redhat.com>
Jonathan Wakely <jwakely.gcc@gmail.com>
PR libstdc++/51798 continued.
* acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): Use __atomic_*
builtins instead of __sync_* builtins for atomic functionality.
* include/bits/shared_ptr_base.h: Same.
* include/parallel/compatibility.h: Same.
* include/profile/impl/profiler_state.h: Same.
* include/tr1/shared_ptr.h: Same.
* libsupc++/eh_ptr.cc: Same.
* libsupc++/eh_throw.cc: Same.
* libsupc++/eh_tm.cc: Same.
* libsupc++/guard.cc: Same.
* configure: Regenerated.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Adjust line numbers.
Co-Authored-By: Jonathan Wakely <jwakely.gcc@gmail.com>
From-SVN: r184110
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/shared_ptr_base.h | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/parallel/compatibility.h | 17 | ||||
-rw-r--r-- | libstdc++-v3/include/profile/impl/profiler_state.h | 11 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1/shared_ptr.h | 10 |
4 files changed, 29 insertions, 19 deletions
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index c024b70fb50..ebdc7ed9452 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -1,6 +1,7 @@ // shared_ptr and weak_ptr implementation details -*- C++ -*- -// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010, 2011, 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 @@ -193,7 +194,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // No memory barrier is used here so there is no synchronization // with other threads. - return const_cast<const volatile _Atomic_word&>(_M_use_count); + return __atomic_load_n(&_M_use_count, __ATOMIC_RELAXED); } private: @@ -245,8 +246,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Replace the current counter value with the old value + 1, as // long as it's not changed meanwhile. } - while (!__sync_bool_compare_and_swap(&_M_use_count, __count, - __count + 1)); + while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1, + true, __ATOMIC_ACQ_REL, + __ATOMIC_RELAXED)); } diff --git a/libstdc++-v3/include/parallel/compatibility.h b/libstdc++-v3/include/parallel/compatibility.h index 9fffd8e012c..460345ef399 100644 --- a/libstdc++-v3/include/parallel/compatibility.h +++ b/libstdc++-v3/include/parallel/compatibility.h @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2007, 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 terms @@ -102,7 +102,7 @@ namespace __gnu_parallel return _InterlockedExchangeAdd(reinterpret_cast<volatile long*>(__ptr), __addend); #elif defined(__GNUC__) - return __sync_fetch_and_add(__ptr, __addend); + return __atomic_fetch_add(__ptr, __addend, __ATOMIC_ACQ_REL); #elif defined(__SUNPRO_CC) && defined(__sparc) volatile int32_t __before, __after; do @@ -145,11 +145,11 @@ namespace __gnu_parallel return _InterlockedExchangeAdd64(__ptr, __addend); #endif #elif defined(__GNUC__) && defined(__x86_64) - return __sync_fetch_and_add(__ptr, __addend); + return __atomic_fetch_add(__ptr, __addend, __ATOMIC_ACQ_REL); #elif defined(__GNUC__) && defined(__i386) && \ (defined(__i686) || defined(__pentium4) || defined(__athlon) \ || defined(__k8) || defined(__core2)) - return __sync_fetch_and_add(__ptr, __addend); + return __atomic_fetch_add(__ptr, __addend, __ATOMIC_ACQ_REL); #elif defined(__SUNPRO_CC) && defined(__sparc) volatile int64_t __before, __after; do @@ -252,7 +252,8 @@ namespace __gnu_parallel __replacement, __comparand) == __comparand; #elif defined(__GNUC__) - return __sync_bool_compare_and_swap(__ptr, __comparand, __replacement); + return __atomic_compare_exchange_n(__ptr, &__comparand, __replacement, true, + __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); #elif defined(__SUNPRO_CC) && defined(__sparc) return atomic_cas_32((volatile unsigned int*)__ptr, __comparand, __replacement) == __comparand; @@ -298,11 +299,13 @@ namespace __gnu_parallel #endif #elif defined(__GNUC__) && defined(__x86_64) - return __sync_bool_compare_and_swap(__ptr, __comparand, __replacement); + return __atomic_compare_exchange_n(__ptr, &__comparand, __replacement, true, + __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); #elif defined(__GNUC__) && defined(__i386) && \ (defined(__i686) || defined(__pentium4) || defined(__athlon) \ || defined(__k8) || defined(__core2)) - return __sync_bool_compare_and_swap(__ptr, __comparand, __replacement); + return __atomic_compare_exchange_n(__ptr, &__comparand, __replacement, true, + __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); #elif defined(__SUNPRO_CC) && defined(__sparc) return atomic_cas_64((volatile unsigned long long*)__ptr, __comparand, __replacement) == __comparand; diff --git a/libstdc++-v3/include/profile/impl/profiler_state.h b/libstdc++-v3/include/profile/impl/profiler_state.h index 111b97e0eca..573aa0eeb40 100644 --- a/libstdc++-v3/include/profile/impl/profiler_state.h +++ b/libstdc++-v3/include/profile/impl/profiler_state.h @@ -1,6 +1,6 @@ // -*- C++ -*- // -// Copyright (C) 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 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 terms @@ -45,9 +45,12 @@ namespace __gnu_profile inline bool __turn(__state_type __s) - { return (_GLIBCXX_PROFILE_DATA(__state) - == __sync_val_compare_and_swap(&_GLIBCXX_PROFILE_DATA(__state), - __INVALID, __s)); } + { + __state_type inv(__INVALID); + return __atomic_compare_exchange_n(&_GLIBCXX_PROFILE_DATA(__state), + &inv, __s, true, __ATOMIC_ACQ_REL, + __ATOMIC_RELAXED); + } inline bool __turn_on() diff --git a/libstdc++-v3/include/tr1/shared_ptr.h b/libstdc++-v3/include/tr1/shared_ptr.h index c42084c9539..723e317646d 100644 --- a/libstdc++-v3/include/tr1/shared_ptr.h +++ b/libstdc++-v3/include/tr1/shared_ptr.h @@ -1,6 +1,7 @@ // <tr1/shared_ptr.h> -*- C++ -*- -// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010, 2011, 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 @@ -246,9 +247,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Replace the current counter value with the old value + 1, as // long as it's not changed meanwhile. } - while (!__sync_bool_compare_and_swap(&_M_use_count, __count, - __count + 1)); - } + while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1, + true, __ATOMIC_ACQ_REL, + __ATOMIC_RELAXED)); + } template<typename _Ptr, typename _Deleter, _Lock_policy _Lp> class _Sp_counted_base_impl |