Define std::atomic<T>::is_always_lock_free for C++17
* include/std/atomic (atomic::is_always_lock_free): Define. * testsuite/29_atomics/atomic/60695.cc: Adjust dg-error lineno. * testsuite/29_atomics/atomic/is_always_lock_free.cc: New. * testsuite/29_atomics/atomic_integral/is_always_lock_free.cc: New. * doc/xml/manual/status_cxx2017.xml: Update status. * doc/html/*: Regenerate. From-SVN: r239622
This commit is contained in:
parent
285ee2fb11
commit
387edf83a0
7 changed files with 159 additions and 5 deletions
|
@ -1,5 +1,12 @@
|
|||
2016-08-19 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
* include/std/atomic (atomic::is_always_lock_free): Define.
|
||||
* testsuite/29_atomics/atomic/60695.cc: Adjust dg-error lineno.
|
||||
* testsuite/29_atomics/atomic/is_always_lock_free.cc: New.
|
||||
* testsuite/29_atomics/atomic_integral/is_always_lock_free.cc: New.
|
||||
* doc/xml/manual/status_cxx2017.xml: Update status.
|
||||
* doc/html/*: Regenerate.
|
||||
|
||||
* include/experimental/tuple (apply): Qualify call to __apply_impl.
|
||||
* include/std/tuple (apply): Likewise.
|
||||
* testsuite/experimental/system_error/value.cc: Fix ambiguities in
|
||||
|
|
|
@ -718,11 +718,11 @@ Feature-testing recommendations for C++</a>.
|
|||
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0392r0.pdf" target="_top">
|
||||
P0392R0
|
||||
</a>
|
||||
</td><td align="center"> No </td><td align="left"> </td></tr><tr bgcolor="#C8B0B0"><td align="left"> constexpr <code class="code">atomic<T>::is_always_lock_free</code> </td><td align="left">
|
||||
</td><td align="center"> No </td><td align="left"> </td></tr><tr><td align="left"> constexpr <code class="code">atomic<T>::is_always_lock_free</code> </td><td align="left">
|
||||
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0152r1.html" target="_top">
|
||||
P0152R1
|
||||
</a>
|
||||
</td><td align="center"> No </td><td align="left"><code class="code"> __cpp_lib_atomic_is_always_lock_free >= 201603 </code></td></tr><tr><td align="left">A proposal to add <code class="code">shared_mutex</code> (untimed) (Revision 4)</td><td align="left">
|
||||
</td><td align="center"> 7 </td><td align="left"><code class="code"> __cpp_lib_atomic_is_always_lock_free >= 201603 </code></td></tr><tr><td align="left">A proposal to add <code class="code">shared_mutex</code> (untimed) (Revision 4)</td><td align="left">
|
||||
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4508.html" target="_top">
|
||||
N4508
|
||||
</a>
|
||||
|
|
|
@ -699,14 +699,13 @@ Feature-testing recommendations for C++</link>.
|
|||
</row>
|
||||
|
||||
<row>
|
||||
<?dbhtml bgcolor="#C8B0B0" ?>
|
||||
<entry> constexpr <code>atomic<T>::is_always_lock_free</code> </entry>
|
||||
<entry>
|
||||
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0152r1.html">
|
||||
P0152R1
|
||||
</link>
|
||||
</entry>
|
||||
<entry align="center"> No </entry>
|
||||
<entry align="center"> 7 </entry>
|
||||
<entry><code> __cpp_lib_atomic_is_always_lock_free >= 201603 </code></entry>
|
||||
</row>
|
||||
|
||||
|
|
|
@ -50,6 +50,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
* @{
|
||||
*/
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
# define __cpp_lib_atomic_is_always_lock_free 201603
|
||||
#endif
|
||||
|
||||
template<typename _Tp>
|
||||
struct atomic;
|
||||
|
||||
|
@ -90,6 +94,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
bool
|
||||
is_lock_free() const volatile noexcept { return _M_base.is_lock_free(); }
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_BOOL_LOCK_FREE == 2;
|
||||
#endif
|
||||
|
||||
void
|
||||
store(bool __i, memory_order __m = memory_order_seq_cst) noexcept
|
||||
{ _M_base.store(__i, __m); }
|
||||
|
@ -221,6 +229,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
reinterpret_cast<void *>(-__alignof(_M_i)));
|
||||
}
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free
|
||||
= __atomic_always_lock_free(sizeof(_M_i), 0);
|
||||
#endif
|
||||
|
||||
void
|
||||
store(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept
|
||||
{ __atomic_store(std::__addressof(_M_i), std::__addressof(__i), __m); }
|
||||
|
@ -416,6 +429,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
is_lock_free() const volatile noexcept
|
||||
{ return _M_b.is_lock_free(); }
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_POINTER_LOCK_FREE == 2;
|
||||
#endif
|
||||
|
||||
void
|
||||
store(__pointer_type __p,
|
||||
memory_order __m = memory_order_seq_cst) noexcept
|
||||
|
@ -537,6 +554,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for signed char.
|
||||
|
@ -556,6 +577,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for unsigned char.
|
||||
|
@ -575,6 +600,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for short.
|
||||
|
@ -594,6 +623,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for unsigned short.
|
||||
|
@ -613,6 +646,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for int.
|
||||
|
@ -632,6 +669,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for unsigned int.
|
||||
|
@ -651,6 +692,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for long.
|
||||
|
@ -670,6 +715,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for unsigned long.
|
||||
|
@ -689,6 +738,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for long long.
|
||||
|
@ -708,6 +761,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for unsigned long long.
|
||||
|
@ -727,6 +784,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for wchar_t.
|
||||
|
@ -746,6 +807,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_WCHAR_T_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for char16_t.
|
||||
|
@ -765,6 +830,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_CHAR16_T_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Explicit specialization for char32_t.
|
||||
|
@ -784,6 +853,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
using __base_type::operator __integral_type;
|
||||
using __base_type::operator=;
|
||||
|
||||
#if __cplusplus > 201402L
|
||||
static constexpr bool is_always_lock_free = ATOMIC_CHAR32_T_LOCK_FREE == 2;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -27,4 +27,4 @@ struct X {
|
|||
char stuff[0]; // GNU extension, type has zero size
|
||||
};
|
||||
|
||||
std::atomic<X> a; // { dg-error "not supported" "" { target *-*-* } 182 }
|
||||
std::atomic<X> a; // { dg-error "not supported" "" { target *-*-* } 190 }
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2016 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++17" }
|
||||
// { dg-do compile }
|
||||
|
||||
#include <atomic>
|
||||
|
||||
struct S { int s[64]; };
|
||||
|
||||
constexpr bool b1 = std::atomic<S>::is_always_lock_free;
|
||||
constexpr const bool* cktype1 = &std::atomic<S>::is_always_lock_free;
|
||||
|
||||
constexpr bool b2 = std::atomic<int*>::is_always_lock_free;
|
||||
constexpr const bool* cktype2 = &std::atomic<int*>::is_always_lock_free;
|
||||
|
||||
static_assert( std::atomic<int*>::is_always_lock_free
|
||||
== (ATOMIC_POINTER_LOCK_FREE == 2) );
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright (C) 2016 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++17" }
|
||||
// { dg-do compile }
|
||||
|
||||
#include <atomic>
|
||||
|
||||
using std::atomic;
|
||||
|
||||
template<typename T>
|
||||
constexpr bool check(int macro)
|
||||
{
|
||||
return std::atomic<T>::is_always_lock_free == (macro == 2);
|
||||
}
|
||||
|
||||
static_assert( check<bool>(ATOMIC_BOOL_LOCK_FREE) );
|
||||
static_assert( check<char>(ATOMIC_CHAR_LOCK_FREE) );
|
||||
static_assert( check<signed char>(ATOMIC_CHAR_LOCK_FREE) );
|
||||
static_assert( check<unsigned char>(ATOMIC_CHAR_LOCK_FREE) );
|
||||
static_assert( check<int>(ATOMIC_INT_LOCK_FREE) );
|
||||
static_assert( check<unsigned int>(ATOMIC_INT_LOCK_FREE) );
|
||||
static_assert( check<long>(ATOMIC_LONG_LOCK_FREE) );
|
||||
static_assert( check<unsigned long>(ATOMIC_LONG_LOCK_FREE) );
|
||||
static_assert( check<long long>(ATOMIC_LLONG_LOCK_FREE) );
|
||||
static_assert( check<unsigned long long>(ATOMIC_LLONG_LOCK_FREE) );
|
||||
static_assert( check<wchar_t>(ATOMIC_WCHAR_T_LOCK_FREE) );
|
||||
static_assert( check<char16_t>(ATOMIC_CHAR16_T_LOCK_FREE) );
|
||||
static_assert( check<char32_t>(ATOMIC_CHAR32_T_LOCK_FREE) );
|
Loading…
Add table
Reference in a new issue