* @{
*/
+#if __cplusplus > 201402L
+# define __cpp_lib_atomic_is_always_lock_free 201603
+#endif
+
template<typename _Tp>
struct atomic;
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); }
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); }
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
};
--- /dev/null
+// 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) );
--- /dev/null
+// 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) );