diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-02-06 08:48:41 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-02-06 08:48:41 +0000 |
commit | 13c89565e8b716fac8521f5195b23c7cb9f818c1 (patch) | |
tree | 5eb865f1df000c3e6a1e5940dd746e10912f11bd /libstdc++-v3/include/bits | |
parent | 194589c5f6dc71acb90ab653830bbc32898ad7a2 (diff) | |
download | gcc-13c89565e8b716fac8521f5195b23c7cb9f818c1.tar.gz |
2012-02-03 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 183926 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@183929 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits')
-rw-r--r-- | libstdc++-v3/include/bits/atomic_base.h | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index aa43bccd1bf..9d5f4eb6ff0 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -1,6 +1,6 @@ // -*- C++ -*- header. -// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 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 @@ -621,6 +621,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __pointer_type _M_p; + // Factored out to facilitate explicit specialization. + constexpr ptrdiff_t + _M_type_size(ptrdiff_t __d) { return __d * sizeof(_PTp); } + + constexpr ptrdiff_t + _M_type_size(ptrdiff_t __d) volatile { return __d * sizeof(_PTp); } + public: __atomic_base() noexcept = default; ~__atomic_base() noexcept = default; @@ -669,43 +676,51 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __pointer_type operator++() noexcept - { return __atomic_add_fetch(&_M_p, 1, memory_order_seq_cst); } + { return __atomic_add_fetch(&_M_p, _M_type_size(1), + memory_order_seq_cst); } __pointer_type operator++() volatile noexcept - { return __atomic_add_fetch(&_M_p, 1, memory_order_seq_cst); } + { return __atomic_add_fetch(&_M_p, _M_type_size(1), + memory_order_seq_cst); } __pointer_type operator--() noexcept - { return __atomic_sub_fetch(&_M_p, 1, memory_order_seq_cst); } + { return __atomic_sub_fetch(&_M_p, _M_type_size(1), + memory_order_seq_cst); } __pointer_type operator--() volatile noexcept - { return __atomic_sub_fetch(&_M_p, 1, memory_order_seq_cst); } + { return __atomic_sub_fetch(&_M_p, _M_type_size(1), + memory_order_seq_cst); } __pointer_type operator+=(ptrdiff_t __d) noexcept - { return __atomic_add_fetch(&_M_p, __d, memory_order_seq_cst); } + { return __atomic_add_fetch(&_M_p, _M_type_size(__d), + memory_order_seq_cst); } __pointer_type operator+=(ptrdiff_t __d) volatile noexcept - { return __atomic_add_fetch(&_M_p, __d, memory_order_seq_cst); } + { return __atomic_add_fetch(&_M_p, _M_type_size(__d), + memory_order_seq_cst); } __pointer_type operator-=(ptrdiff_t __d) noexcept - { return __atomic_sub_fetch(&_M_p, __d, memory_order_seq_cst); } + { return __atomic_sub_fetch(&_M_p, _M_type_size(__d), + memory_order_seq_cst); } __pointer_type operator-=(ptrdiff_t __d) volatile noexcept - { return __atomic_sub_fetch(&_M_p, __d, memory_order_seq_cst); } + { return __atomic_sub_fetch(&_M_p, _M_type_size(__d), + memory_order_seq_cst); } bool is_lock_free() const noexcept - { return __atomic_is_lock_free (sizeof (_M_p), &_M_p); } + { return __atomic_is_lock_free(_M_type_size(1), &_M_p); } bool is_lock_free() const volatile noexcept - { return __atomic_is_lock_free (sizeof (_M_p), &_M_p); } + { return __atomic_is_lock_free(_M_type_size(1), &_M_p); } void store(__pointer_type __p, @@ -789,22 +804,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __pointer_type fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) noexcept - { return __atomic_fetch_add(&_M_p, __d, __m); } + { return __atomic_fetch_add(&_M_p, _M_type_size(__d), __m); } __pointer_type fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile noexcept - { return __atomic_fetch_add(&_M_p, __d, __m); } + { return __atomic_fetch_add(&_M_p, _M_type_size(__d), __m); } __pointer_type fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) noexcept - { return __atomic_fetch_sub(&_M_p, __d, __m); } + { return __atomic_fetch_sub(&_M_p, _M_type_size(__d), __m); } __pointer_type fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile noexcept - { return __atomic_fetch_sub(&_M_p, __d, __m); } + { return __atomic_fetch_sub(&_M_p, _M_type_size(__d), __m); } }; // @} group atomics |