aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely.gcc@gmail.com>2013-11-18 13:52:39 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2013-11-18 13:52:39 +0000
commitad098ad1335f0e2684d721793232de8eab45936c (patch)
treefd998863a3c6a189e7248fe2024450ae6b8ca589 /libstdc++-v3
parent6d3f673cf6a37752959803a28eee39190d800d8a (diff)
downloadgcc-ad098ad1335f0e2684d721793232de8eab45936c.zip
gcc-ad098ad1335f0e2684d721793232de8eab45936c.tar.gz
gcc-ad098ad1335f0e2684d721793232de8eab45936c.tar.bz2
shared_ptr_base.h (_Sp_counted_base<_S_single>): Use non-atomic operations.
* include/bits/shared_ptr_base.h (_Sp_counted_base<_S_single>): Use non-atomic operations. * testsuite/20_util/shared_ptr/cons/43820_neg.cc: Adjust line number. * testsuite/20_util/shared_ptr/cons/void_neg.cc: Likewise. From-SVN: r204949
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/shared_ptr_base.h43
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc2
4 files changed, 47 insertions, 7 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 696aca4..5af235f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2013-11-18 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * include/bits/shared_ptr_base.h (_Sp_counted_base<_S_single>): Use
+ non-atomic operations.
+ * testsuite/20_util/shared_ptr/cons/43820_neg.cc: Adjust line number.
+ * testsuite/20_util/shared_ptr/cons/void_neg.cc: Likewise.
+
2013-11-16 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement N3762 string_view: a non-owning reference to a string.
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index cf90d7a..68ccc9e 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -209,11 +209,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Sp_counted_base<_S_single>::
_M_add_ref_lock()
{
- if (__gnu_cxx::__exchange_and_add_dispatch(&_M_use_count, 1) == 0)
- {
- _M_use_count = 0;
- __throw_bad_weak_ptr();
- }
+ if (_M_use_count == 0)
+ __throw_bad_weak_ptr();
+ ++_M_use_count;
}
template<>
@@ -248,6 +246,41 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__ATOMIC_RELAXED));
}
+ template<>
+ inline void
+ _Sp_counted_base<_S_single>::_M_add_ref_copy()
+ { ++_M_use_count; }
+
+ template<>
+ inline void
+ _Sp_counted_base<_S_single>::_M_release() noexcept
+ {
+ if (--_M_use_count == 0)
+ {
+ _M_dispose();
+ if (--_M_weak_count == 0)
+ _M_destroy();
+ }
+ }
+
+ template<>
+ inline void
+ _Sp_counted_base<_S_single>::_M_weak_add_ref() noexcept
+ { ++_M_weak_count; }
+
+ template<>
+ inline void
+ _Sp_counted_base<_S_single>::_M_weak_release() noexcept
+ {
+ if (--_M_weak_count == 0)
+ _M_destroy();
+ }
+
+ template<>
+ inline long
+ _Sp_counted_base<_S_single>::_M_get_use_count() const noexcept
+ { return _M_use_count; }
+
// Forward declarations.
template<typename _Tp, _Lock_policy _Lp = __default_lock_policy>
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc
index db3fcac..01acca5 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc
@@ -32,7 +32,7 @@ void test01()
{
X* px = 0;
std::shared_ptr<X> p1(px); // { dg-error "here" }
- // { dg-error "incomplete" "" { target *-*-* } 779 }
+ // { dg-error "incomplete" "" { target *-*-* } 812 }
std::shared_ptr<X> p9(ap()); // { dg-error "here" }
// { dg-error "incomplete" "" { target *-*-* } 307 }
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc
index 3fd38cf..5389159 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc
@@ -25,5 +25,5 @@
void test01()
{
std::shared_ptr<void> p((void*)nullptr); // { dg-error "here" }
- // { dg-error "incomplete" "" { target *-*-* } 778 }
+ // { dg-error "incomplete" "" { target *-*-* } 811 }
}