From: Jonathan Wakely Date: Sat, 17 Jan 2015 01:23:28 +0000 (+0000) Subject: re PR libstdc++/60940 (general operations on atomic types do not work with atomic... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d31b87976f1722476ae6bfa8e6bcbf78f5350867;p=gcc.git re PR libstdc++/60940 (general operations on atomic types do not work with atomic integral typedefs) PR libstdc++/60940 * include/bits/atomic_base.h: Remove atomic integral typedefs as synonyms for __atomic_base etc. * include/std/atomic: Make atomic_int a synonym for atomic 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. From-SVN: r219790 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ae4f3cc8e1a..1dc68e7f5e0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2015-01-17 Jonathan Wakely + + PR libstdc++/60940 + * include/bits/atomic_base.h: Remove atomic integral typedefs as + synonyms for __atomic_base etc. + * include/std/atomic: Make atomic_int a synonym for atomic 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 PR libstdc++/56785 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 struct __atomic_base; - /// atomic_char - typedef __atomic_base atomic_char; - - /// atomic_schar - typedef __atomic_base atomic_schar; - - /// atomic_uchar - typedef __atomic_base atomic_uchar; - - /// atomic_short - typedef __atomic_base atomic_short; - - /// atomic_ushort - typedef __atomic_base atomic_ushort; - - /// atomic_int - typedef __atomic_base atomic_int; - - /// atomic_uint - typedef __atomic_base atomic_uint; - - /// atomic_long - typedef __atomic_base atomic_long; - - /// atomic_ulong - typedef __atomic_base atomic_ulong; - - /// atomic_llong - typedef __atomic_base atomic_llong; - - /// atomic_ullong - typedef __atomic_base atomic_ullong; - - /// atomic_wchar_t - typedef __atomic_base atomic_wchar_t; - - /// atomic_char16_t - typedef __atomic_base atomic_char16_t; - - /// atomic_char32_t - typedef __atomic_base atomic_char32_t; - - /// atomic_char32_t - typedef __atomic_base atomic_char32_t; - - - /// atomic_int_least8_t - typedef __atomic_base atomic_int_least8_t; - - /// atomic_uint_least8_t - typedef __atomic_base atomic_uint_least8_t; - - /// atomic_int_least16_t - typedef __atomic_base atomic_int_least16_t; - - /// atomic_uint_least16_t - typedef __atomic_base atomic_uint_least16_t; - - /// atomic_int_least32_t - typedef __atomic_base atomic_int_least32_t; - - /// atomic_uint_least32_t - typedef __atomic_base atomic_uint_least32_t; - - /// atomic_int_least64_t - typedef __atomic_base atomic_int_least64_t; - - /// atomic_uint_least64_t - typedef __atomic_base atomic_uint_least64_t; - - - /// atomic_int_fast8_t - typedef __atomic_base atomic_int_fast8_t; - - /// atomic_uint_fast8_t - typedef __atomic_base atomic_uint_fast8_t; - - /// atomic_int_fast16_t - typedef __atomic_base atomic_int_fast16_t; - - /// atomic_uint_fast16_t - typedef __atomic_base atomic_uint_fast16_t; - - /// atomic_int_fast32_t - typedef __atomic_base atomic_int_fast32_t; - - /// atomic_uint_fast32_t - typedef __atomic_base atomic_uint_fast32_t; - - /// atomic_int_fast64_t - typedef __atomic_base atomic_int_fast64_t; - - /// atomic_uint_fast64_t - typedef __atomic_base atomic_uint_fast64_t; - - - /// atomic_intptr_t - typedef __atomic_base atomic_intptr_t; - - /// atomic_uintptr_t - typedef __atomic_base atomic_uintptr_t; - - /// atomic_size_t - typedef __atomic_base atomic_size_t; - - /// atomic_intmax_t - typedef __atomic_base atomic_intmax_t; - - /// atomic_uintmax_t - typedef __atomic_base atomic_uintmax_t; - - /// atomic_ptrdiff_t - typedef __atomic_base 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 + struct atomic; + + /// atomic // NB: No operators or fetch-operations for this type. - struct atomic_bool + template<> + struct atomic { private: __atomic_base _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 : 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 : public atomic_char + struct atomic : __atomic_base { typedef char __integral_type; - typedef atomic_char __base_type; + typedef __atomic_base __base_type; atomic() noexcept = default; ~atomic() noexcept = default; @@ -525,10 +510,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for signed char. template<> - struct atomic : public atomic_schar + struct atomic : __atomic_base { typedef signed char __integral_type; - typedef atomic_schar __base_type; + typedef __atomic_base __base_type; atomic() noexcept= default; ~atomic() noexcept = default; @@ -544,10 +529,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for unsigned char. template<> - struct atomic : public atomic_uchar + struct atomic : __atomic_base { typedef unsigned char __integral_type; - typedef atomic_uchar __base_type; + typedef __atomic_base __base_type; atomic() noexcept= default; ~atomic() noexcept = default; @@ -563,10 +548,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for short. template<> - struct atomic : public atomic_short + struct atomic : __atomic_base { typedef short __integral_type; - typedef atomic_short __base_type; + typedef __atomic_base __base_type; atomic() noexcept = default; ~atomic() noexcept = default; @@ -582,10 +567,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for unsigned short. template<> - struct atomic : public atomic_ushort + struct atomic : __atomic_base { typedef unsigned short __integral_type; - typedef atomic_ushort __base_type; + typedef __atomic_base __base_type; atomic() noexcept = default; ~atomic() noexcept = default; @@ -601,10 +586,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for int. template<> - struct atomic : atomic_int + struct atomic : __atomic_base { typedef int __integral_type; - typedef atomic_int __base_type; + typedef __atomic_base __base_type; atomic() noexcept = default; ~atomic() noexcept = default; @@ -620,10 +605,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for unsigned int. template<> - struct atomic : public atomic_uint + struct atomic : __atomic_base { typedef unsigned int __integral_type; - typedef atomic_uint __base_type; + typedef __atomic_base __base_type; atomic() noexcept = default; ~atomic() noexcept = default; @@ -639,10 +624,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for long. template<> - struct atomic : public atomic_long + struct atomic : __atomic_base { typedef long __integral_type; - typedef atomic_long __base_type; + typedef __atomic_base __base_type; atomic() noexcept = default; ~atomic() noexcept = default; @@ -658,10 +643,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for unsigned long. template<> - struct atomic : public atomic_ulong + struct atomic : __atomic_base { typedef unsigned long __integral_type; - typedef atomic_ulong __base_type; + typedef __atomic_base __base_type; atomic() noexcept = default; ~atomic() noexcept = default; @@ -677,10 +662,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for long long. template<> - struct atomic : public atomic_llong + struct atomic : __atomic_base { typedef long long __integral_type; - typedef atomic_llong __base_type; + typedef __atomic_base __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 : public atomic_ullong + struct atomic : __atomic_base { typedef unsigned long long __integral_type; - typedef atomic_ullong __base_type; + typedef __atomic_base __base_type; atomic() noexcept = default; ~atomic() noexcept = default; @@ -715,10 +700,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for wchar_t. template<> - struct atomic : public atomic_wchar_t + struct atomic : __atomic_base { typedef wchar_t __integral_type; - typedef atomic_wchar_t __base_type; + typedef __atomic_base __base_type; atomic() noexcept = default; ~atomic() noexcept = default; @@ -734,10 +719,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for char16_t. template<> - struct atomic : public atomic_char16_t + struct atomic : __atomic_base { typedef char16_t __integral_type; - typedef atomic_char16_t __base_type; + typedef __atomic_base __base_type; atomic() noexcept = default; ~atomic() noexcept = default; @@ -753,10 +738,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Explicit specialization for char32_t. template<> - struct atomic : public atomic_char32_t + struct atomic : __atomic_base { typedef char32_t __integral_type; - typedef atomic_char32_t __base_type; + typedef __atomic_base __base_type; atomic() noexcept = default; ~atomic() noexcept = default; @@ -771,6 +756,121 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; + /// atomic_bool + typedef atomic atomic_bool; + + /// atomic_char + typedef atomic atomic_char; + + /// atomic_schar + typedef atomic atomic_schar; + + /// atomic_uchar + typedef atomic atomic_uchar; + + /// atomic_short + typedef atomic atomic_short; + + /// atomic_ushort + typedef atomic atomic_ushort; + + /// atomic_int + typedef atomic atomic_int; + + /// atomic_uint + typedef atomic atomic_uint; + + /// atomic_long + typedef atomic atomic_long; + + /// atomic_ulong + typedef atomic atomic_ulong; + + /// atomic_llong + typedef atomic atomic_llong; + + /// atomic_ullong + typedef atomic atomic_ullong; + + /// atomic_wchar_t + typedef atomic atomic_wchar_t; + + /// atomic_char16_t + typedef atomic atomic_char16_t; + + /// atomic_char32_t + typedef atomic atomic_char32_t; + + + /// atomic_int_least8_t + typedef atomic atomic_int_least8_t; + + /// atomic_uint_least8_t + typedef atomic atomic_uint_least8_t; + + /// atomic_int_least16_t + typedef atomic atomic_int_least16_t; + + /// atomic_uint_least16_t + typedef atomic atomic_uint_least16_t; + + /// atomic_int_least32_t + typedef atomic atomic_int_least32_t; + + /// atomic_uint_least32_t + typedef atomic atomic_uint_least32_t; + + /// atomic_int_least64_t + typedef atomic atomic_int_least64_t; + + /// atomic_uint_least64_t + typedef atomic atomic_uint_least64_t; + + + /// atomic_int_fast8_t + typedef atomic atomic_int_fast8_t; + + /// atomic_uint_fast8_t + typedef atomic atomic_uint_fast8_t; + + /// atomic_int_fast16_t + typedef atomic atomic_int_fast16_t; + + /// atomic_uint_fast16_t + typedef atomic atomic_uint_fast16_t; + + /// atomic_int_fast32_t + typedef atomic atomic_int_fast32_t; + + /// atomic_uint_fast32_t + typedef atomic atomic_uint_fast32_t; + + /// atomic_int_fast64_t + typedef atomic atomic_int_fast64_t; + + /// atomic_uint_fast64_t + typedef atomic atomic_uint_fast64_t; + + + /// atomic_intptr_t + typedef atomic atomic_intptr_t; + + /// atomic_uintptr_t + typedef atomic atomic_uintptr_t; + + /// atomic_size_t + typedef atomic atomic_size_t; + + /// atomic_intmax_t + typedef atomic atomic_intmax_t; + + /// atomic_uintmax_t + typedef atomic atomic_uintmax_t; + + /// atomic_ptrdiff_t + typedef atomic 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 a; // { dg-error "not supported" "" { target *-*-* } 169 } +std::atomic 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 +// . + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include +#include + +struct Test +{ + template + 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()); +}