summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-17 01:23:28 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-17 01:23:28 +0000
commit99a3c3ba2b530cfd97cc3ae3a4eb54ae3451bc21 (patch)
treec642bf970c37532ec353e2a74b686069564d3d9f
parent34aaed439380226950d65f37c02a549dfdebb16c (diff)
downloadgcc-99a3c3ba2b530cfd97cc3ae3a4eb54ae3451bc21.tar.gz
PR libstdc++/60940
* include/bits/atomic_base.h: Remove atomic integral typedefs as synonyms for __atomic_base<int> etc. * include/std/atomic: Make atomic_int a synonym for atomic<int> and likewise for all atomic integral types. * testsuite/29_atomics/atomic_integral/cons/copy_list.cc: New. * testsuite/29_atomics/atomic/60695.cc: Adjust dg-error line number. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219790 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog10
-rw-r--r--libstdc++-v3/include/bits/atomic_base.h114
-rw-r--r--libstdc++-v3/include/std/atomic210
-rw-r--r--libstdc++-v3/testsuite/29_atomics/atomic/60695.cc2
-rw-r--r--libstdc++-v3/testsuite/29_atomics/atomic_integral/60940.cc38
5 files changed, 204 insertions, 170 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ae4f3cc8e1a..1dc68e7f5e0 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,15 @@
2015-01-17 Jonathan Wakely <jwakely@redhat.com>
+ PR libstdc++/60940
+ * include/bits/atomic_base.h: Remove atomic integral typedefs as
+ synonyms for __atomic_base<int> etc.
+ * include/std/atomic: Make atomic_int a synonym for atomic<int> and
+ likewise for all atomic integral types.
+ * testsuite/29_atomics/atomic_integral/cons/copy_list.cc: New.
+ * testsuite/29_atomics/atomic/60695.cc: Adjust dg-error line number.
+
+2015-01-17 Jonathan Wakely <jwakely@redhat.com>
+
PR libstdc++/56785
* include/std/tuple (_Tuple_impl): Remove zero-element specialization
and define one-element specialization.
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index 29ee9e7e014..5e610f1c3ee 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -119,120 +119,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _IntTp>
struct __atomic_base;
- /// atomic_char
- typedef __atomic_base<char> atomic_char;
-
- /// atomic_schar
- typedef __atomic_base<signed char> atomic_schar;
-
- /// atomic_uchar
- typedef __atomic_base<unsigned char> atomic_uchar;
-
- /// atomic_short
- typedef __atomic_base<short> atomic_short;
-
- /// atomic_ushort
- typedef __atomic_base<unsigned short> atomic_ushort;
-
- /// atomic_int
- typedef __atomic_base<int> atomic_int;
-
- /// atomic_uint
- typedef __atomic_base<unsigned int> atomic_uint;
-
- /// atomic_long
- typedef __atomic_base<long> atomic_long;
-
- /// atomic_ulong
- typedef __atomic_base<unsigned long> atomic_ulong;
-
- /// atomic_llong
- typedef __atomic_base<long long> atomic_llong;
-
- /// atomic_ullong
- typedef __atomic_base<unsigned long long> atomic_ullong;
-
- /// atomic_wchar_t
- typedef __atomic_base<wchar_t> atomic_wchar_t;
-
- /// atomic_char16_t
- typedef __atomic_base<char16_t> atomic_char16_t;
-
- /// atomic_char32_t
- typedef __atomic_base<char32_t> atomic_char32_t;
-
- /// atomic_char32_t
- typedef __atomic_base<char32_t> atomic_char32_t;
-
-
- /// atomic_int_least8_t
- typedef __atomic_base<int_least8_t> atomic_int_least8_t;
-
- /// atomic_uint_least8_t
- typedef __atomic_base<uint_least8_t> atomic_uint_least8_t;
-
- /// atomic_int_least16_t
- typedef __atomic_base<int_least16_t> atomic_int_least16_t;
-
- /// atomic_uint_least16_t
- typedef __atomic_base<uint_least16_t> atomic_uint_least16_t;
-
- /// atomic_int_least32_t
- typedef __atomic_base<int_least32_t> atomic_int_least32_t;
-
- /// atomic_uint_least32_t
- typedef __atomic_base<uint_least32_t> atomic_uint_least32_t;
-
- /// atomic_int_least64_t
- typedef __atomic_base<int_least64_t> atomic_int_least64_t;
-
- /// atomic_uint_least64_t
- typedef __atomic_base<uint_least64_t> atomic_uint_least64_t;
-
-
- /// atomic_int_fast8_t
- typedef __atomic_base<int_fast8_t> atomic_int_fast8_t;
-
- /// atomic_uint_fast8_t
- typedef __atomic_base<uint_fast8_t> atomic_uint_fast8_t;
-
- /// atomic_int_fast16_t
- typedef __atomic_base<int_fast16_t> atomic_int_fast16_t;
-
- /// atomic_uint_fast16_t
- typedef __atomic_base<uint_fast16_t> atomic_uint_fast16_t;
-
- /// atomic_int_fast32_t
- typedef __atomic_base<int_fast32_t> atomic_int_fast32_t;
-
- /// atomic_uint_fast32_t
- typedef __atomic_base<uint_fast32_t> atomic_uint_fast32_t;
-
- /// atomic_int_fast64_t
- typedef __atomic_base<int_fast64_t> atomic_int_fast64_t;
-
- /// atomic_uint_fast64_t
- typedef __atomic_base<uint_fast64_t> atomic_uint_fast64_t;
-
-
- /// atomic_intptr_t
- typedef __atomic_base<intptr_t> atomic_intptr_t;
-
- /// atomic_uintptr_t
- typedef __atomic_base<uintptr_t> atomic_uintptr_t;
-
- /// atomic_size_t
- typedef __atomic_base<size_t> atomic_size_t;
-
- /// atomic_intmax_t
- typedef __atomic_base<intmax_t> atomic_intmax_t;
-
- /// atomic_uintmax_t
- typedef __atomic_base<uintmax_t> atomic_uintmax_t;
-
- /// atomic_ptrdiff_t
- typedef __atomic_base<ptrdiff_t> atomic_ptrdiff_t;
-
#define ATOMIC_VAR_INIT(_VI) { _VI }
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index 61611afe09f..43cf4f339fd 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -49,21 +49,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @{
*/
- /// atomic_bool
+ template<typename _Tp>
+ struct atomic;
+
+ /// atomic<bool>
// NB: No operators or fetch-operations for this type.
- struct atomic_bool
+ template<>
+ struct atomic<bool>
{
private:
__atomic_base<bool> _M_base;
public:
- atomic_bool() noexcept = default;
- ~atomic_bool() noexcept = default;
- atomic_bool(const atomic_bool&) = delete;
- atomic_bool& operator=(const atomic_bool&) = delete;
- atomic_bool& operator=(const atomic_bool&) volatile = delete;
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
- constexpr atomic_bool(bool __i) noexcept : _M_base(__i) { }
+ constexpr atomic(bool __i) noexcept : _M_base(__i) { }
bool
operator=(bool __i) noexcept
@@ -485,31 +489,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
- /// Explicit specialization for bool.
- template<>
- struct atomic<bool> : public atomic_bool
- {
- typedef bool __integral_type;
- typedef atomic_bool __base_type;
-
- atomic() noexcept = default;
- ~atomic() noexcept = default;
- atomic(const atomic&) = delete;
- atomic& operator=(const atomic&) = delete;
- atomic& operator=(const atomic&) volatile = delete;
-
- constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
-
- using __base_type::operator __integral_type;
- using __base_type::operator=;
- };
-
/// Explicit specialization for char.
template<>
- struct atomic<char> : public atomic_char
+ struct atomic<char> : __atomic_base<char>
{
typedef char __integral_type;
- typedef atomic_char __base_type;
+ typedef __atomic_base<char> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -525,10 +510,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for signed char.
template<>
- struct atomic<signed char> : public atomic_schar
+ struct atomic<signed char> : __atomic_base<signed char>
{
typedef signed char __integral_type;
- typedef atomic_schar __base_type;
+ typedef __atomic_base<signed char> __base_type;
atomic() noexcept= default;
~atomic() noexcept = default;
@@ -544,10 +529,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for unsigned char.
template<>
- struct atomic<unsigned char> : public atomic_uchar
+ struct atomic<unsigned char> : __atomic_base<unsigned char>
{
typedef unsigned char __integral_type;
- typedef atomic_uchar __base_type;
+ typedef __atomic_base<unsigned char> __base_type;
atomic() noexcept= default;
~atomic() noexcept = default;
@@ -563,10 +548,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for short.
template<>
- struct atomic<short> : public atomic_short
+ struct atomic<short> : __atomic_base<short>
{
typedef short __integral_type;
- typedef atomic_short __base_type;
+ typedef __atomic_base<short> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -582,10 +567,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for unsigned short.
template<>
- struct atomic<unsigned short> : public atomic_ushort
+ struct atomic<unsigned short> : __atomic_base<unsigned short>
{
typedef unsigned short __integral_type;
- typedef atomic_ushort __base_type;
+ typedef __atomic_base<unsigned short> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -601,10 +586,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for int.
template<>
- struct atomic<int> : atomic_int
+ struct atomic<int> : __atomic_base<int>
{
typedef int __integral_type;
- typedef atomic_int __base_type;
+ typedef __atomic_base<int> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -620,10 +605,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for unsigned int.
template<>
- struct atomic<unsigned int> : public atomic_uint
+ struct atomic<unsigned int> : __atomic_base<unsigned int>
{
typedef unsigned int __integral_type;
- typedef atomic_uint __base_type;
+ typedef __atomic_base<unsigned int> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -639,10 +624,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for long.
template<>
- struct atomic<long> : public atomic_long
+ struct atomic<long> : __atomic_base<long>
{
typedef long __integral_type;
- typedef atomic_long __base_type;
+ typedef __atomic_base<long> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -658,10 +643,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for unsigned long.
template<>
- struct atomic<unsigned long> : public atomic_ulong
+ struct atomic<unsigned long> : __atomic_base<unsigned long>
{
typedef unsigned long __integral_type;
- typedef atomic_ulong __base_type;
+ typedef __atomic_base<unsigned long> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -677,10 +662,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for long long.
template<>
- struct atomic<long long> : public atomic_llong
+ struct atomic<long long> : __atomic_base<long long>
{
typedef long long __integral_type;
- typedef atomic_llong __base_type;
+ typedef __atomic_base<long long> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -696,10 +681,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for unsigned long long.
template<>
- struct atomic<unsigned long long> : public atomic_ullong
+ struct atomic<unsigned long long> : __atomic_base<unsigned long long>
{
typedef unsigned long long __integral_type;
- typedef atomic_ullong __base_type;
+ typedef __atomic_base<unsigned long long> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -715,10 +700,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for wchar_t.
template<>
- struct atomic<wchar_t> : public atomic_wchar_t
+ struct atomic<wchar_t> : __atomic_base<wchar_t>
{
typedef wchar_t __integral_type;
- typedef atomic_wchar_t __base_type;
+ typedef __atomic_base<wchar_t> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -734,10 +719,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for char16_t.
template<>
- struct atomic<char16_t> : public atomic_char16_t
+ struct atomic<char16_t> : __atomic_base<char16_t>
{
typedef char16_t __integral_type;
- typedef atomic_char16_t __base_type;
+ typedef __atomic_base<char16_t> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -753,10 +738,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Explicit specialization for char32_t.
template<>
- struct atomic<char32_t> : public atomic_char32_t
+ struct atomic<char32_t> : __atomic_base<char32_t>
{
typedef char32_t __integral_type;
- typedef atomic_char32_t __base_type;
+ typedef __atomic_base<char32_t> __base_type;
atomic() noexcept = default;
~atomic() noexcept = default;
@@ -771,6 +756,121 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
+ /// atomic_bool
+ typedef atomic<bool> atomic_bool;
+
+ /// atomic_char
+ typedef atomic<char> atomic_char;
+
+ /// atomic_schar
+ typedef atomic<signed char> atomic_schar;
+
+ /// atomic_uchar
+ typedef atomic<unsigned char> atomic_uchar;
+
+ /// atomic_short
+ typedef atomic<short> atomic_short;
+
+ /// atomic_ushort
+ typedef atomic<unsigned short> atomic_ushort;
+
+ /// atomic_int
+ typedef atomic<int> atomic_int;
+
+ /// atomic_uint
+ typedef atomic<unsigned int> atomic_uint;
+
+ /// atomic_long
+ typedef atomic<long> atomic_long;
+
+ /// atomic_ulong
+ typedef atomic<unsigned long> atomic_ulong;
+
+ /// atomic_llong
+ typedef atomic<long long> atomic_llong;
+
+ /// atomic_ullong
+ typedef atomic<unsigned long long> atomic_ullong;
+
+ /// atomic_wchar_t
+ typedef atomic<wchar_t> atomic_wchar_t;
+
+ /// atomic_char16_t
+ typedef atomic<char16_t> atomic_char16_t;
+
+ /// atomic_char32_t
+ typedef atomic<char32_t> atomic_char32_t;
+
+
+ /// atomic_int_least8_t
+ typedef atomic<int_least8_t> atomic_int_least8_t;
+
+ /// atomic_uint_least8_t
+ typedef atomic<uint_least8_t> atomic_uint_least8_t;
+
+ /// atomic_int_least16_t
+ typedef atomic<int_least16_t> atomic_int_least16_t;
+
+ /// atomic_uint_least16_t
+ typedef atomic<uint_least16_t> atomic_uint_least16_t;
+
+ /// atomic_int_least32_t
+ typedef atomic<int_least32_t> atomic_int_least32_t;
+
+ /// atomic_uint_least32_t
+ typedef atomic<uint_least32_t> atomic_uint_least32_t;
+
+ /// atomic_int_least64_t
+ typedef atomic<int_least64_t> atomic_int_least64_t;
+
+ /// atomic_uint_least64_t
+ typedef atomic<uint_least64_t> atomic_uint_least64_t;
+
+
+ /// atomic_int_fast8_t
+ typedef atomic<int_fast8_t> atomic_int_fast8_t;
+
+ /// atomic_uint_fast8_t
+ typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
+
+ /// atomic_int_fast16_t
+ typedef atomic<int_fast16_t> atomic_int_fast16_t;
+
+ /// atomic_uint_fast16_t
+ typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
+
+ /// atomic_int_fast32_t
+ typedef atomic<int_fast32_t> atomic_int_fast32_t;
+
+ /// atomic_uint_fast32_t
+ typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
+
+ /// atomic_int_fast64_t
+ typedef atomic<int_fast64_t> atomic_int_fast64_t;
+
+ /// atomic_uint_fast64_t
+ typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
+
+
+ /// atomic_intptr_t
+ typedef atomic<intptr_t> atomic_intptr_t;
+
+ /// atomic_uintptr_t
+ typedef atomic<uintptr_t> atomic_uintptr_t;
+
+ /// atomic_size_t
+ typedef atomic<size_t> atomic_size_t;
+
+ /// atomic_intmax_t
+ typedef atomic<intmax_t> atomic_intmax_t;
+
+ /// atomic_uintmax_t
+ typedef atomic<uintmax_t> atomic_uintmax_t;
+
+ /// atomic_ptrdiff_t
+ typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
+
+
// Function definitions, atomic_flag operations.
inline bool
atomic_flag_test_and_set_explicit(atomic_flag* __a,
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc b/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc
index 079434f42fe..b59c6ba064a 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc
@@ -27,4 +27,4 @@ struct X {
char stuff[0]; // GNU extension, type has zero size
};
-std::atomic<X> a; // { dg-error "not supported" "" { target *-*-* } 169 }
+std::atomic<X> a; // { dg-error "not supported" "" { target *-*-* } 173 }
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_integral/60940.cc b/libstdc++-v3/testsuite/29_atomics/atomic_integral/60940.cc
new file mode 100644
index 00000000000..ef31f7e5d87
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_integral/60940.cc
@@ -0,0 +1,38 @@
+// Copyright (C) 2015 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.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <atomic>
+#include <testsuite_common_types.h>
+
+struct Test
+{
+ template<typename T>
+ void operator()(T&& t)
+ {
+ auto val = atomic_load(&t);
+ atomic_store(&t, val);
+ }
+} test;
+
+int
+main()
+{
+ __gnu_cxx::typelist::apply(test, __gnu_test::atomic_integrals::type());
+}