[cfe-commits] [libcxx] r115577 - /libcxx/trunk/include/atomic

Howard Hinnant hhinnant at apple.com
Mon Oct 4 16:55:35 PDT 2010


Author: hhinnant
Date: Mon Oct  4 18:55:35 2010
New Revision: 115577

URL: http://llvm.org/viewvc/llvm-project?rev=115577&view=rev
Log:
Filling out the infrastructure in <atomic>

Modified:
    libcxx/trunk/include/atomic

Modified: libcxx/trunk/include/atomic
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?rev=115577&r1=115576&r2=115577&view=diff
==============================================================================
--- libcxx/trunk/include/atomic (original)
+++ libcxx/trunk/include/atomic Mon Oct  4 18:55:35 2010
@@ -2439,7 +2439,7 @@
 
 template <class _Tp>
 _Tp
-__load_seq_cst(const volatile _Tp* __obj)
+__load_seq_cst(_Tp const volatile* __obj)
 {
     unique_lock<mutex> _(__not_atomic_mut());
     return *__obj;
@@ -2449,7 +2449,7 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_load_seq_cst(const volatile bool* __obj)
+__choose_load_seq_cst(bool const volatile* __obj)
 {
 #if __has_feature(__atomic_load_seq_cst_b)
     return __atomic_load_seq_cst(__obj);
@@ -2460,7 +2460,7 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_load_acquire(const volatile bool* __obj)
+__choose_load_acquire(bool const volatile* __obj)
 {
 #if __has_feature(__atomic_load_acquire_b)
     return __atomic_load_acquire(__obj);
@@ -2471,7 +2471,7 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_load_consume(const volatile bool* __obj)
+__choose_load_consume(bool const volatile* __obj)
 {
 #if __has_feature(__atomic_load_consume_b)
     return __atomic_load_consume(__obj);
@@ -2482,7 +2482,7 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_load_relaxed(const volatile bool* __obj)
+__choose_load_relaxed(bool const volatile* __obj)
 {
 #if __has_feature(__atomic_load_relaxed_b)
     return __atomic_load_relaxed(__obj);
@@ -2491,170 +2491,9415 @@
 #endif
 }
 
+// load char
+
+inline _LIBCPP_INLINE_VISIBILITY
+char
+__choose_load_seq_cst(char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_c)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char
+__choose_load_acquire(char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_c)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char
+__choose_load_consume(char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_c)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char
+__choose_load_relaxed(char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_c)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load signed char
+
+inline _LIBCPP_INLINE_VISIBILITY
+signed char
+__choose_load_seq_cst(signed char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_a)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+signed char
+__choose_load_acquire(signed char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_a)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+signed char
+__choose_load_consume(signed char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_a)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+signed char
+__choose_load_relaxed(signed char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_a)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load unsigned char
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned char
+__choose_load_seq_cst(unsigned char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_h)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned char
+__choose_load_acquire(unsigned char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_h)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned char
+__choose_load_consume(unsigned char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_h)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned char
+__choose_load_relaxed(unsigned char const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_h)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// load char16_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t
+__choose_load_seq_cst(char16_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_Ds)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t
+__choose_load_acquire(char16_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_Ds)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t
+__choose_load_consume(char16_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_Ds)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t
+__choose_load_relaxed(char16_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_Ds)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load char32_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t
+__choose_load_seq_cst(char32_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_Di)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t
+__choose_load_acquire(char32_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_Di)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t
+__choose_load_consume(char32_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_Di)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t
+__choose_load_relaxed(char32_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_Di)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// load wchar_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t
+__choose_load_seq_cst(wchar_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_w)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t
+__choose_load_acquire(wchar_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_w)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t
+__choose_load_consume(wchar_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_w)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t
+__choose_load_relaxed(wchar_t const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_w)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load short
+
+inline _LIBCPP_INLINE_VISIBILITY
+short
+__choose_load_seq_cst(short const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_s)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+short
+__choose_load_acquire(short const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_s)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+short
+__choose_load_consume(short const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_s)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+short
+__choose_load_relaxed(short const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_s)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load unsigned short
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned short
+__choose_load_seq_cst(unsigned short const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_t)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned short
+__choose_load_acquire(unsigned short const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_t)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned short
+__choose_load_consume(unsigned short const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_t)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned short
+__choose_load_relaxed(unsigned short const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_t)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load int
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+__choose_load_seq_cst(int const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_i)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+__choose_load_acquire(int const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_i)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+__choose_load_consume(int const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_i)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+__choose_load_relaxed(int const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_i)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load unsigned int
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned int
+__choose_load_seq_cst(unsigned int const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_j)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned int
+__choose_load_acquire(unsigned int const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_j)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned int
+__choose_load_consume(unsigned int const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_j)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned int
+__choose_load_relaxed(unsigned int const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_j)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load long
+
+inline _LIBCPP_INLINE_VISIBILITY
+long
+__choose_load_seq_cst(long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_l)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long
+__choose_load_acquire(long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_l)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long
+__choose_load_consume(long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_l)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long
+__choose_load_relaxed(long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_l)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load unsigned long
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__choose_load_seq_cst(unsigned long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_m)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__choose_load_acquire(unsigned long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_m)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__choose_load_consume(unsigned long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_m)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__choose_load_relaxed(unsigned long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_m)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load long long
+
+inline _LIBCPP_INLINE_VISIBILITY
+long long
+__choose_load_seq_cst(long long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_x)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long long
+__choose_load_acquire(long long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_x)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long long
+__choose_load_consume(long long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_x)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long long
+__choose_load_relaxed(long long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_x)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load unsigned long long
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__choose_load_seq_cst(unsigned long long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_y)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__choose_load_acquire(unsigned long long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_y)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__choose_load_consume(unsigned long long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_y)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__choose_load_relaxed(unsigned long long const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_y)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
+// load void*
+
+inline _LIBCPP_INLINE_VISIBILITY
+void*
+__choose_load_seq_cst(void* const volatile* __obj)
+{
+#if __has_feature(__atomic_load_seq_cst_Py)
+    return __atomic_load_seq_cst(__obj);
+#else
+    return __load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void*
+__choose_load_acquire(void* const volatile* __obj)
+{
+#if __has_feature(__atomic_load_acquire_Py)
+    return __atomic_load_acquire(__obj);
+#else
+    return __choose_load_seq_cst(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void*
+__choose_load_consume(void* const volatile* __obj)
+{
+#if __has_feature(__atomic_load_consume_Py)
+    return __atomic_load_consume(__obj);
+#else
+    return __choose_load_acquire(__obj);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void*
+__choose_load_relaxed(void* const volatile* __obj)
+{
+#if __has_feature(__atomic_load_relaxed_Py)
+    return __atomic_load_relaxed(__obj);
+#else
+    return __choose_load_consume(__obj);
+#endif
+}
+
 // store
 
-template <class _Tp>
-void
-__store_seq_cst(volatile _Tp* __obj, _Tp __desr)
+template <class _Tp>
+void
+__store_seq_cst(_Tp volatile* __obj, _Tp __desr)
+{
+    unique_lock<mutex> _(__not_atomic_mut());
+    *__obj = __desr;
+}
+
+// store bool
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(bool volatile* __obj, bool __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_b)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(bool volatile* __obj, bool __desr)
+{
+#if __has_feature(__atomic_store_release_b)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(bool volatile* __obj, bool __desr)
+{
+#if __has_feature(__atomic_store_relaxed_b)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store char
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(char volatile* __obj, char __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_c)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(char volatile* __obj, char __desr)
+{
+#if __has_feature(__atomic_store_release_c)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(char volatile* __obj, char __desr)
+{
+#if __has_feature(__atomic_store_relaxed_c)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store signed char
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(signed char volatile* __obj, signed char __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_a)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(signed char volatile* __obj, signed char __desr)
+{
+#if __has_feature(__atomic_store_release_a)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(signed char volatile* __obj, signed char __desr)
+{
+#if __has_feature(__atomic_store_relaxed_a)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store unsigned char
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(unsigned char volatile* __obj, unsigned char __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_h)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(unsigned char volatile* __obj, unsigned char __desr)
+{
+#if __has_feature(__atomic_store_release_h)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(unsigned char volatile* __obj, unsigned char __desr)
+{
+#if __has_feature(__atomic_store_relaxed_h)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// store char16_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(char16_t volatile* __obj, char16_t __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_Ds)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(char16_t volatile* __obj, char16_t __desr)
+{
+#if __has_feature(__atomic_store_release_Ds)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(char16_t volatile* __obj, char16_t __desr)
+{
+#if __has_feature(__atomic_store_relaxed_Ds)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store char32_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(char32_t volatile* __obj, char32_t __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_Di)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(char32_t volatile* __obj, char32_t __desr)
+{
+#if __has_feature(__atomic_store_release_Di)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(char32_t volatile* __obj, char32_t __desr)
+{
+#if __has_feature(__atomic_store_relaxed_Di)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// store wchar_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(wchar_t volatile* __obj, wchar_t __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_w)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(wchar_t volatile* __obj, wchar_t __desr)
+{
+#if __has_feature(__atomic_store_release_w)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(wchar_t volatile* __obj, wchar_t __desr)
+{
+#if __has_feature(__atomic_store_relaxed_w)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store short
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(short volatile* __obj, short __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_s)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(short volatile* __obj, short __desr)
+{
+#if __has_feature(__atomic_store_release_s)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(short volatile* __obj, short __desr)
+{
+#if __has_feature(__atomic_store_relaxed_s)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store unsigned short
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(unsigned short volatile* __obj, unsigned short __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_t)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(unsigned short volatile* __obj, unsigned short __desr)
+{
+#if __has_feature(__atomic_store_release_t)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(unsigned short volatile* __obj, unsigned short __desr)
+{
+#if __has_feature(__atomic_store_relaxed_t)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store int
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(int volatile* __obj, int __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_i)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(int volatile* __obj, int __desr)
+{
+#if __has_feature(__atomic_store_release_i)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(int volatile* __obj, int __desr)
+{
+#if __has_feature(__atomic_store_relaxed_i)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store unsigned int
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(unsigned int volatile* __obj, unsigned int __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_j)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(unsigned int volatile* __obj, unsigned int __desr)
+{
+#if __has_feature(__atomic_store_release_j)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(unsigned int volatile* __obj, unsigned int __desr)
+{
+#if __has_feature(__atomic_store_relaxed_j)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store long
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(long volatile* __obj, long __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_l)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(long volatile* __obj, long __desr)
+{
+#if __has_feature(__atomic_store_release_l)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(long volatile* __obj, long __desr)
+{
+#if __has_feature(__atomic_store_relaxed_l)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store unsigned long
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(unsigned long volatile* __obj, unsigned long __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_m)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(unsigned long volatile* __obj, unsigned long __desr)
+{
+#if __has_feature(__atomic_store_release_m)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(unsigned long volatile* __obj, unsigned long __desr)
+{
+#if __has_feature(__atomic_store_relaxed_m)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store long long
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(long long volatile* __obj, long long __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_x)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(long long volatile* __obj, long long __desr)
+{
+#if __has_feature(__atomic_store_release_x)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(long long volatile* __obj, long long __desr)
+{
+#if __has_feature(__atomic_store_relaxed_x)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store unsigned long long
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(unsigned long long volatile* __obj, unsigned long long __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_y)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(unsigned long long volatile* __obj, unsigned long long __desr)
+{
+#if __has_feature(__atomic_store_release_y)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(unsigned long long volatile* __obj, unsigned long long __desr)
+{
+#if __has_feature(__atomic_store_relaxed_y)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// store void*
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_seq_cst(void* volatile* __obj, void* __desr)
+{
+#if __has_feature(__atomic_store_seq_cst_Py)
+    __atomic_store_seq_cst(__obj, __desr);
+#else
+    __store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_release(void* volatile* __obj, void* __desr)
+{
+#if __has_feature(__atomic_store_release_Py)
+    __atomic_store_release(__obj, __desr);
+#else
+    __choose_store_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__choose_store_relaxed(void* volatile* __obj, void* __desr)
+{
+#if __has_feature(__atomic_store_relaxed_Py)
+    __atomic_store_relaxed(__obj, __desr);
+#else
+    __choose_store_release(__obj, __desr);
+#endif
+}
+
+// exchange
+
+template <class _Tp>
+_Tp
+__exchange_seq_cst(_Tp volatile* __obj, _Tp __desr)
+{
+    unique_lock<mutex> _(__not_atomic_mut());
+    _Tp __r = *__obj;
+    *__obj = __desr;
+    return __r;
+}
+
+// exchange bool
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_exchange_seq_cst(bool volatile* __obj, bool __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_b)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_exchange_acq_rel(bool volatile* __obj, bool __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_b)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_exchange_release(bool volatile* __obj, bool __desr)
+{
+#if __has_feature(__atomic_exchange_release_b)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_exchange_acquire(bool volatile* __obj, bool __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_b)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_exchange_consume(bool volatile* __obj, bool __desr)
+{
+#if __has_feature(__atomic_exchange_consume_b)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_exchange_relaxed(bool volatile* __obj, bool __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_b)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange char
+
+inline _LIBCPP_INLINE_VISIBILITY
+char
+__choose_exchange_seq_cst(char volatile* __obj, char __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_c)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char
+__choose_exchange_acq_rel(char volatile* __obj, char __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_c)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char
+__choose_exchange_release(char volatile* __obj, char __desr)
+{
+#if __has_feature(__atomic_exchange_release_c)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char
+__choose_exchange_acquire(char volatile* __obj, char __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_c)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char
+__choose_exchange_consume(char volatile* __obj, char __desr)
+{
+#if __has_feature(__atomic_exchange_consume_c)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char
+__choose_exchange_relaxed(char volatile* __obj, char __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_c)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange signed char
+
+inline _LIBCPP_INLINE_VISIBILITY
+signed char
+__choose_exchange_seq_cst(signed char volatile* __obj, signed char __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_a)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+signed char
+__choose_exchange_acq_rel(signed char volatile* __obj, signed char __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_a)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+signed char
+__choose_exchange_release(signed char volatile* __obj, signed char __desr)
+{
+#if __has_feature(__atomic_exchange_release_a)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+signed char
+__choose_exchange_acquire(signed char volatile* __obj, signed char __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_a)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+signed char
+__choose_exchange_consume(signed char volatile* __obj, signed char __desr)
+{
+#if __has_feature(__atomic_exchange_consume_a)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+signed char
+__choose_exchange_relaxed(signed char volatile* __obj, signed char __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_a)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange unsigned char
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned char
+__choose_exchange_seq_cst(unsigned char volatile* __obj, unsigned char __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_h)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned char
+__choose_exchange_acq_rel(unsigned char volatile* __obj, unsigned char __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_h)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned char
+__choose_exchange_release(unsigned char volatile* __obj, unsigned char __desr)
+{
+#if __has_feature(__atomic_exchange_release_h)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned char
+__choose_exchange_acquire(unsigned char volatile* __obj, unsigned char __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_h)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned char
+__choose_exchange_consume(unsigned char volatile* __obj, unsigned char __desr)
+{
+#if __has_feature(__atomic_exchange_consume_h)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned char
+__choose_exchange_relaxed(unsigned char volatile* __obj, unsigned char __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_h)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// exchange char16_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t
+__choose_exchange_seq_cst(char16_t volatile* __obj, char16_t __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_Ds)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t
+__choose_exchange_acq_rel(char16_t volatile* __obj, char16_t __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_Ds)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t
+__choose_exchange_release(char16_t volatile* __obj, char16_t __desr)
+{
+#if __has_feature(__atomic_exchange_release_Ds)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t
+__choose_exchange_acquire(char16_t volatile* __obj, char16_t __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_Ds)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t
+__choose_exchange_consume(char16_t volatile* __obj, char16_t __desr)
+{
+#if __has_feature(__atomic_exchange_consume_Ds)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t
+__choose_exchange_relaxed(char16_t volatile* __obj, char16_t __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_Ds)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange char32_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t
+__choose_exchange_seq_cst(char32_t volatile* __obj, char32_t __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_Di)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t
+__choose_exchange_acq_rel(char32_t volatile* __obj, char32_t __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_Di)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t
+__choose_exchange_release(char32_t volatile* __obj, char32_t __desr)
+{
+#if __has_feature(__atomic_exchange_release_Di)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t
+__choose_exchange_acquire(char32_t volatile* __obj, char32_t __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_Di)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t
+__choose_exchange_consume(char32_t volatile* __obj, char32_t __desr)
+{
+#if __has_feature(__atomic_exchange_consume_Di)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t
+__choose_exchange_relaxed(char32_t volatile* __obj, char32_t __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_Di)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// exchange wchar_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t
+__choose_exchange_seq_cst(wchar_t volatile* __obj, wchar_t __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_w)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t
+__choose_exchange_acq_rel(wchar_t volatile* __obj, wchar_t __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_w)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t
+__choose_exchange_release(wchar_t volatile* __obj, wchar_t __desr)
+{
+#if __has_feature(__atomic_exchange_release_w)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t
+__choose_exchange_acquire(wchar_t volatile* __obj, wchar_t __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_w)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t
+__choose_exchange_consume(wchar_t volatile* __obj, wchar_t __desr)
+{
+#if __has_feature(__atomic_exchange_consume_w)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+wchar_t
+__choose_exchange_relaxed(wchar_t volatile* __obj, wchar_t __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_w)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange short
+
+inline _LIBCPP_INLINE_VISIBILITY
+short
+__choose_exchange_seq_cst(short volatile* __obj, short __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_s)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+short
+__choose_exchange_acq_rel(short volatile* __obj, short __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_s)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+short
+__choose_exchange_release(short volatile* __obj, short __desr)
+{
+#if __has_feature(__atomic_exchange_release_s)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+short
+__choose_exchange_acquire(short volatile* __obj, short __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_s)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+short
+__choose_exchange_consume(short volatile* __obj, short __desr)
+{
+#if __has_feature(__atomic_exchange_consume_s)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+short
+__choose_exchange_relaxed(short volatile* __obj, short __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_s)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange unsigned short
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned short
+__choose_exchange_seq_cst(unsigned short volatile* __obj, unsigned short __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_t)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned short
+__choose_exchange_acq_rel(unsigned short volatile* __obj, unsigned short __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_t)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned short
+__choose_exchange_release(unsigned short volatile* __obj, unsigned short __desr)
+{
+#if __has_feature(__atomic_exchange_release_t)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned short
+__choose_exchange_acquire(unsigned short volatile* __obj, unsigned short __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_t)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned short
+__choose_exchange_consume(unsigned short volatile* __obj, unsigned short __desr)
+{
+#if __has_feature(__atomic_exchange_consume_t)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned short
+__choose_exchange_relaxed(unsigned short volatile* __obj, unsigned short __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_t)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange int
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+__choose_exchange_seq_cst(int volatile* __obj, int __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_i)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+__choose_exchange_acq_rel(int volatile* __obj, int __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_i)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+__choose_exchange_release(int volatile* __obj, int __desr)
+{
+#if __has_feature(__atomic_exchange_release_i)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+__choose_exchange_acquire(int volatile* __obj, int __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_i)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+__choose_exchange_consume(int volatile* __obj, int __desr)
+{
+#if __has_feature(__atomic_exchange_consume_i)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+__choose_exchange_relaxed(int volatile* __obj, int __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_i)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange unsigned int
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned int
+__choose_exchange_seq_cst(unsigned int volatile* __obj, unsigned int __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_j)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned int
+__choose_exchange_acq_rel(unsigned int volatile* __obj, unsigned int __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_j)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned int
+__choose_exchange_release(unsigned int volatile* __obj, unsigned int __desr)
+{
+#if __has_feature(__atomic_exchange_release_j)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned int
+__choose_exchange_acquire(unsigned int volatile* __obj, unsigned int __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_j)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned int
+__choose_exchange_consume(unsigned int volatile* __obj, unsigned int __desr)
+{
+#if __has_feature(__atomic_exchange_consume_j)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned int
+__choose_exchange_relaxed(unsigned int volatile* __obj, unsigned int __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_j)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange long
+
+inline _LIBCPP_INLINE_VISIBILITY
+long
+__choose_exchange_seq_cst(long volatile* __obj, long __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_l)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long
+__choose_exchange_acq_rel(long volatile* __obj, long __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_l)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long
+__choose_exchange_release(long volatile* __obj, long __desr)
+{
+#if __has_feature(__atomic_exchange_release_l)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long
+__choose_exchange_acquire(long volatile* __obj, long __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_l)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long
+__choose_exchange_consume(long volatile* __obj, long __desr)
+{
+#if __has_feature(__atomic_exchange_consume_l)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long
+__choose_exchange_relaxed(long volatile* __obj, long __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_l)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange unsigned long
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__choose_exchange_seq_cst(unsigned long volatile* __obj, unsigned long __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_m)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__choose_exchange_acq_rel(unsigned long volatile* __obj, unsigned long __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_m)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__choose_exchange_release(unsigned long volatile* __obj, unsigned long __desr)
+{
+#if __has_feature(__atomic_exchange_release_m)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__choose_exchange_acquire(unsigned long volatile* __obj, unsigned long __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_m)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__choose_exchange_consume(unsigned long volatile* __obj, unsigned long __desr)
+{
+#if __has_feature(__atomic_exchange_consume_m)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__choose_exchange_relaxed(unsigned long volatile* __obj, unsigned long __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_m)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange long long
+
+inline _LIBCPP_INLINE_VISIBILITY
+long long
+__choose_exchange_seq_cst(long long volatile* __obj, long long __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_x)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long long
+__choose_exchange_acq_rel(long long volatile* __obj, long long __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_x)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long long
+__choose_exchange_release(long long volatile* __obj, long long __desr)
+{
+#if __has_feature(__atomic_exchange_release_x)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long long
+__choose_exchange_acquire(long long volatile* __obj, long long __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_x)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long long
+__choose_exchange_consume(long long volatile* __obj, long long __desr)
+{
+#if __has_feature(__atomic_exchange_consume_x)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long long
+__choose_exchange_relaxed(long long volatile* __obj, long long __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_x)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange unsigned long long
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__choose_exchange_seq_cst(unsigned long long volatile* __obj, unsigned long long __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_y)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__choose_exchange_acq_rel(unsigned long long volatile* __obj, unsigned long long __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_y)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__choose_exchange_release(unsigned long long volatile* __obj, unsigned long long __desr)
+{
+#if __has_feature(__atomic_exchange_release_y)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__choose_exchange_acquire(unsigned long long volatile* __obj, unsigned long long __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_y)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__choose_exchange_consume(unsigned long long volatile* __obj, unsigned long long __desr)
+{
+#if __has_feature(__atomic_exchange_consume_y)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__choose_exchange_relaxed(unsigned long long volatile* __obj, unsigned long long __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_y)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// exchange void*
+
+inline _LIBCPP_INLINE_VISIBILITY
+void*
+__choose_exchange_seq_cst(void* volatile* __obj, void* __desr)
+{
+#if __has_feature(__atomic_exchange_seq_cst_Py)
+    return __atomic_exchange_seq_cst(__obj, __desr);
+#else
+    return __exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void*
+__choose_exchange_acq_rel(void* volatile* __obj, void* __desr)
+{
+#if __has_feature(__atomic_exchange_acq_rel_Py)
+    return __atomic_exchange_acq_rel(__obj, __desr);
+#else
+    return __choose_exchange_seq_cst(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void*
+__choose_exchange_release(void* volatile* __obj, void* __desr)
+{
+#if __has_feature(__atomic_exchange_release_Py)
+    return __atomic_exchange_release(__obj, __desr);
+#else
+    return __choose_exchange_acq_rel(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void*
+__choose_exchange_acquire(void* volatile* __obj, void* __desr)
+{
+#if __has_feature(__atomic_exchange_acquire_Py)
+    return __atomic_exchange_acquire(__obj, __desr);
+#else
+    return __choose_exchange_release(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void*
+__choose_exchange_consume(void* volatile* __obj, void* __desr)
+{
+#if __has_feature(__atomic_exchange_consume_Py)
+    return __atomic_exchange_consume(__obj, __desr);
+#else
+    return __choose_exchange_acquire(__obj, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void*
+__choose_exchange_relaxed(void* volatile* __obj, void* __desr)
+{
+#if __has_feature(__atomic_exchange_relaxed_Py)
+    return __atomic_exchange_relaxed(__obj, __desr);
+#else
+    return __choose_exchange_consume(__obj, __desr);
+#endif
+}
+
+// compare_exchange_strong
+
+template <class _Tp>
+bool
+__compare_exchange_strong_seq_cst_seq_cst(_Tp volatile* __obj, _Tp* __exp,
+                                                                     _Tp __desr)
+{
+    unique_lock<mutex> _(__not_atomic_mut());
+    if (_STD::memcmp(const_cast<_Tp*>(__obj), __exp, sizeof(_Tp)) == 0)
+    {
+        _STD::memcpy(const_cast<_Tp*>(__obj), &__desr, sizeof(_Tp));
+        return true;
+    }
+    _STD::memcpy(__exp, const_cast<_Tp*>(__obj), sizeof(_Tp));
+    return false;
+}
+
+// compare_exchange_strong bool
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_b)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_b)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_b)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_b)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_b)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_b)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_b)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_b)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_b)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_b)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_b)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_b)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_b)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_b)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_b)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(bool volatile* __obj,
+                                                 bool* __exp,
+                                                 bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_b)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong char
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_c)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_c)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_c)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_c)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_c)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_c)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_c)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_c)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_c)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_c)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_c)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_c)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_c)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_c)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_c)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(char volatile* __obj,
+                                                 char* __exp,
+                                                 char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_c)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong signed char
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_a)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_a)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_a)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_a)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_a)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_a)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_a)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_a)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_a)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_a)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_a)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_a)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_a)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_a)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_a)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(signed char volatile* __obj,
+                                                 signed char* __exp,
+                                                 signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_a)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong unsigned char
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_h)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_h)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_h)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_h)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_h)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_h)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_h)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_h)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_h)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_h)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_h)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_h)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_h)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_h)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_h)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(unsigned char volatile* __obj,
+                                                 unsigned char* __exp,
+                                                 unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_h)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// compare_exchange_strong char16_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_Ds)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_Ds)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_Ds)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_Ds)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_Ds)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_Ds)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_Ds)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_Ds)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_Ds)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_Ds)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_Ds)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_Ds)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_Ds)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_Ds)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_Ds)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(char16_t volatile* __obj,
+                                                 char16_t* __exp,
+                                                 char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_Ds)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong char32_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_Di)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_Di)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_Di)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_Di)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_Di)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_Di)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_Di)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_Di)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_Di)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_Di)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_Di)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_Di)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_Di)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_Di)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_Di)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(char32_t volatile* __obj,
+                                                 char32_t* __exp,
+                                                 char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_Di)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// compare_exchange_strong wchar_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_w)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_w)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_w)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_w)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_w)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_w)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_w)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_w)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_w)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_w)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_w)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_w)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_w)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_w)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_w)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(wchar_t volatile* __obj,
+                                                 wchar_t* __exp,
+                                                 wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_w)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong short
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_s)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_s)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_s)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_s)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_s)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_s)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_s)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_s)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_s)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_s)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_s)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_s)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_s)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_s)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_s)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(short volatile* __obj,
+                                                 short* __exp,
+                                                 short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_s)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong unsigned short
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_t)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_t)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_t)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_t)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_t)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_t)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_t)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_t)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_t)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_t)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_t)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_t)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_t)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_t)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_t)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(unsigned short volatile* __obj,
+                                                 unsigned short* __exp,
+                                                 unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_t)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong int
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_i)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_i)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_i)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_i)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_i)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_i)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_i)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_i)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_i)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_i)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_i)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_i)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_i)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_i)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_i)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(int volatile* __obj,
+                                                 int* __exp,
+                                                 int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_i)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong unsigned int
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_j)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_j)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_j)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_j)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_j)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_j)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_j)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_j)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_j)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_j)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_j)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_j)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_j)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_j)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_j)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(unsigned int volatile* __obj,
+                                                 unsigned int* __exp,
+                                                 unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_j)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong long
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_l)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_l)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_l)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_l)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_l)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_l)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_l)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_l)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_l)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_l)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_l)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_l)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_l)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_l)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_l)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(long volatile* __obj,
+                                                 long* __exp,
+                                                 long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_l)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong unsigned long
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_m)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_m)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_m)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_m)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_m)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_m)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_m)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_m)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_m)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_m)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_m)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_m)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_m)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_m)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_m)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(unsigned long volatile* __obj,
+                                                 unsigned long* __exp,
+                                                 unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_m)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong long long
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_x)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_x)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_x)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_x)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_x)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_x)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_x)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_x)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_x)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_x)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_x)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_x)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_x)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_x)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_x)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(long long volatile* __obj,
+                                                 long long* __exp,
+                                                 long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_x)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong unsigned long long
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_y)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_y)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_y)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_y)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_y)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_y)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_y)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_y)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_y)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_y)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_y)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_y)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_y)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_y)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_y)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(unsigned long long volatile* __obj,
+                                                 unsigned long long* __exp,
+                                                 unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_y)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_strong void*
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_seq_cst(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_Py)
+    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_acquire(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_Py)
+    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_consume(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_Py)
+    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_seq_cst_relaxed(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_Py)
+    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_acquire(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_Py)
+    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_consume(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_Py)
+    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acq_rel_relaxed(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_Py)
+    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_acquire(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_acquire_Py)
+    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_consume(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_consume_Py)
+    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_release_relaxed(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_Py)
+    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_acquire(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_Py)
+    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_consume(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_Py)
+    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_acquire_relaxed(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_Py)
+    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_consume(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_consume_Py)
+    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_consume_relaxed(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_Py)
+    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_strong_relaxed_relaxed(void* volatile* __obj,
+                                                 void** __exp,
+                                                 void* __desr)
+{
+#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_Py)
+    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak bool
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_b)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_b)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_b)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_b)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_b)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_b)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_b)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_b)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_b)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_b)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_b)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_b)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_b)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_b)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_b)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(bool volatile* __obj,
+                                               bool* __exp,
+                                               bool __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_b)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak signed char
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_a)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_a)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_a)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_a)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_a)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_a)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_a)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_a)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_a)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_a)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_a)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_a)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_a)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_a)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_a)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(signed char volatile* __obj,
+                                               signed char* __exp,
+                                               signed char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_a)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak unsigned char
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_h)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_h)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_h)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_h)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_h)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_h)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_h)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_h)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_h)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_h)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_h)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_h)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_h)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_h)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_h)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(unsigned char volatile* __obj,
+                                               unsigned char* __exp,
+                                               unsigned char __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_h)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// compare_exchange_weak char16_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_Ds)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_Ds)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_Ds)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_Ds)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_Ds)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_Ds)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_Ds)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_Ds)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_Ds)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_Ds)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_Ds)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_Ds)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_Ds)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_Ds)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_Ds)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(char16_t volatile* __obj,
+                                               char16_t* __exp,
+                                               char16_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_Ds)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak char32_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_Di)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_Di)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_Di)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_Di)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_Di)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_Di)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_Di)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_Di)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_Di)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_Di)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_Di)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_Di)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_Di)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_Di)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_Di)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(char32_t volatile* __obj,
+                                               char32_t* __exp,
+                                               char32_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_Di)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// compare_exchange_weak wchar_t
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_w)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_w)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_w)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_w)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_w)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_w)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_w)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_w)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_w)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_w)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_w)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_w)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_w)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_w)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_w)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(wchar_t volatile* __obj,
+                                               wchar_t* __exp,
+                                               wchar_t __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_w)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak short
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_s)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_s)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_s)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_s)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_s)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_s)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_s)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_s)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_s)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_s)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_s)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_s)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_s)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_s)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_s)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(short volatile* __obj,
+                                               short* __exp,
+                                               short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_s)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak unsigned short
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_t)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_t)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_t)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_t)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_t)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_t)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_t)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_t)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_t)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_t)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_t)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_t)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_t)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_t)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_t)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(unsigned short volatile* __obj,
+                                               unsigned short* __exp,
+                                               unsigned short __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_t)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak int
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_i)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_i)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_i)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_i)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_i)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_i)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_i)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_i)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_i)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_i)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_i)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_i)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_i)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_i)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_i)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(int volatile* __obj,
+                                               int* __exp,
+                                               int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_i)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak unsigned int
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_j)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_j)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_j)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_j)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_j)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_j)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_j)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_j)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_j)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_j)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_j)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_j)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_j)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_j)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_j)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(unsigned int volatile* __obj,
+                                               unsigned int* __exp,
+                                               unsigned int __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_j)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak long
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_l)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_l)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_l)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_l)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_l)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_l)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_l)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_l)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_l)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_l)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_l)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_l)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_l)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_l)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_l)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(long volatile* __obj,
+                                               long* __exp,
+                                               long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_l)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak unsigned long
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_m)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_m)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_consume(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_m)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_m)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_m)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_m)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_relaxed(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_m)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_acquire(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_m)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_consume(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_m)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_release_relaxed(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_m)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_acquire(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_m)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_consume(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_m)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_m)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_consume(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_m)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
 {
-    unique_lock<mutex> _(__not_atomic_mut());
-    *__obj = __desr;
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_m)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
 }
 
-// store bool
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(unsigned long volatile* __obj,
+                                               unsigned long* __exp,
+                                               unsigned long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_m)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak long long
 
 inline _LIBCPP_INLINE_VISIBILITY
-void
-__choose_store_seq_cst(volatile bool* __obj, bool __desr)
+bool
+__choose_compare_exchange_weak_seq_cst_seq_cst(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-#if __has_feature(__atomic_store_seq_cst_b)
-    __atomic_store_seq_cst(__obj, __desr);
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_x)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
 #else
-    __store_seq_cst(__obj, __desr);
+    return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+                                                                        __desr);
 #endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
-void
-__choose_store_release(volatile bool* __obj, bool __desr)
+bool
+__choose_compare_exchange_weak_seq_cst_acquire(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-#if __has_feature(__atomic_store_release_b)
-    __atomic_store_release(__obj, __desr);
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_x)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
 #else
-    __choose_store_seq_cst(__obj, __desr);
+    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+                                                                        __desr);
 #endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
-void
-__choose_store_relaxed(volatile bool* __obj, bool __desr)
+bool
+__choose_compare_exchange_weak_seq_cst_consume(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-#if __has_feature(__atomic_store_relaxed_b)
-    __atomic_store_relaxed(__obj, __desr);
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_x)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
 #else
-    __choose_store_release(__obj, __desr);
+    return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+                                                                        __desr);
 #endif
 }
 
-// exchange
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_seq_cst_relaxed(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_x)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
 
-template <class _Tp>
-_Tp
-__exchange_seq_cst(volatile _Tp* __obj, _Tp __desr)
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_acquire(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-    unique_lock<mutex> _(__not_atomic_mut());
-    _Tp __r = *__obj;
-    *__obj = __desr;
-    return __r;
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_x)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+                                                                        __desr);
+#endif
 }
 
-// exchange bool
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acq_rel_consume(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_x)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+                                                                        __desr);
+#endif
+}
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_exchange_seq_cst(volatile bool* __obj, bool __desr)
+__choose_compare_exchange_weak_acq_rel_relaxed(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-#if __has_feature(__atomic_exchange_seq_cst_b)
-    return __atomic_exchange_seq_cst(__obj, __desr);
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_x)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
 #else
-    return __exchange_seq_cst(__obj, __desr);
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+                                                                        __desr);
 #endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_exchange_acq_rel(volatile bool* __obj, bool __desr)
+__choose_compare_exchange_weak_release_acquire(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-#if __has_feature(__atomic_exchange_acq_rel_b)
-    return __atomic_exchange_acq_rel(__obj, __desr);
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_x)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
+                                                                        __desr);
 #else
-    return __choose_exchange_seq_cst(__obj, __desr);
+    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+                                                                        __desr);
 #endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_exchange_release(volatile bool* __obj, bool __desr)
+__choose_compare_exchange_weak_release_consume(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-#if __has_feature(__atomic_exchange_release_b)
-    return __atomic_exchange_release(__obj, __desr);
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_x)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
+                                                                        __desr);
 #else
-    return __choose_exchange_acq_rel(__obj, __desr);
+    return __choose_compare_exchange_strong_release_consume(__obj, __exp,
+                                                                        __desr);
 #endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_exchange_acquire(volatile bool* __obj, bool __desr)
+__choose_compare_exchange_weak_release_relaxed(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-#if __has_feature(__atomic_exchange_acquire_b)
-    return __atomic_exchange_acquire(__obj, __desr);
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_x)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
+                                                                        __desr);
 #else
-    return __choose_exchange_release(__obj, __desr);
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
+                                                                        __desr);
 #endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_exchange_consume(volatile bool* __obj, bool __desr)
+__choose_compare_exchange_weak_acquire_acquire(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-#if __has_feature(__atomic_exchange_consume_b)
-    return __atomic_exchange_consume(__obj, __desr);
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_x)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
+                                                                        __desr);
 #else
-    return __choose_exchange_acquire(__obj, __desr);
+    return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
+                                                                        __desr);
 #endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_exchange_relaxed(volatile bool* __obj, bool __desr)
+__choose_compare_exchange_weak_acquire_consume(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-#if __has_feature(__atomic_exchange_relaxed_b)
-    return __atomic_exchange_relaxed(__obj, __desr);
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_x)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
+                                                                        __desr);
 #else
-    return __choose_exchange_consume(__obj, __desr);
+    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+                                                                        __desr);
 #endif
 }
 
-// compare_exchange_strong
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_acquire_relaxed(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_x)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
 
-template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
 bool
-__compare_exchange_strong_seq_cst_seq_cst(volatile _Tp* __obj, _Tp* __exp,
-                                                                     _Tp __desr)
+__choose_compare_exchange_weak_consume_consume(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-    unique_lock<mutex> _(__not_atomic_mut());
-    if (_STD::memcmp(const_cast<_Tp*>(__obj), __exp, sizeof(_Tp)) == 0)
-    {
-        _STD::memcpy(const_cast<_Tp*>(__obj), &__desr, sizeof(_Tp));
-        return true;
-    }
-    _STD::memcpy(__exp, const_cast<_Tp*>(__obj), sizeof(_Tp));
-    return false;
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_x)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
+                                                                        __desr);
+#endif
 }
 
-// compare_exchange_strong bool
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_consume_relaxed(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_x)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_seq_cst_seq_cst(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_relaxed_relaxed(long long volatile* __obj,
+                                               long long* __exp,
+                                               long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_seq_cst_seq_cst_b)
-    return __atomic_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_x)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
                                                                         __desr);
 #else
-    return __compare_exchange_strong_seq_cst_seq_cst(__obj, __exp, __desr);
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
 #endif
 }
 
+// compare_exchange_weak unsigned long long
+
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_seq_cst_acquire(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_seq_cst_seq_cst(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_seq_cst_acquire_b)
-    return __atomic_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_y)
+    return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
                                                                         __desr);
 #else
     return __choose_compare_exchange_strong_seq_cst_seq_cst(__obj, __exp,
@@ -2664,11 +11909,12 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_seq_cst_consume(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_seq_cst_acquire(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_seq_cst_consume_b)
-    return __atomic_compare_exchange_strong_seq_cst_consume(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_y)
+    return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
                                                                         __desr);
 #else
     return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
@@ -2678,11 +11924,12 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_seq_cst_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_seq_cst_consume(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_seq_cst_relaxed_b)
-    return __atomic_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_y)
+    return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
                                                                         __desr);
 #else
     return __choose_compare_exchange_strong_seq_cst_consume(__obj, __exp,
@@ -2692,25 +11939,27 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_acq_rel_acquire(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_seq_cst_relaxed(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_acq_rel_acquire_b)
-    return __atomic_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_y)
+    return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
                                                                         __desr);
 #else
-    return __choose_compare_exchange_strong_seq_cst_acquire(__obj, __exp,
+    return __choose_compare_exchange_strong_seq_cst_relaxed(__obj, __exp,
                                                                         __desr);
 #endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_acq_rel_consume(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acq_rel_acquire(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_acq_rel_consume_b)
-    return __atomic_compare_exchange_strong_acq_rel_consume(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_y)
+    return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
                                                                         __desr);
 #else
     return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
@@ -2720,11 +11969,12 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_acq_rel_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acq_rel_consume(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_acq_rel_relaxed_b)
-    return __atomic_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_y)
+    return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
                                                                         __desr);
 #else
     return __choose_compare_exchange_strong_acq_rel_consume(__obj, __exp,
@@ -2734,25 +11984,27 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_release_acquire(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acq_rel_relaxed(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_release_acquire_b)
-    return __atomic_compare_exchange_strong_release_acquire(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_y)
+    return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
                                                                         __desr);
 #else
-    return __choose_compare_exchange_strong_acq_rel_acquire(__obj, __exp,
+    return __choose_compare_exchange_strong_acq_rel_relaxed(__obj, __exp,
                                                                         __desr);
 #endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_release_consume(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_release_acquire(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_release_consume_b)
-    return __atomic_compare_exchange_strong_release_consume(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_y)
+    return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
                                                                         __desr);
 #else
     return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
@@ -2762,11 +12014,12 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_release_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_release_consume(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_release_relaxed_b)
-    return __atomic_compare_exchange_strong_release_relaxed(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_y)
+    return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
                                                                         __desr);
 #else
     return __choose_compare_exchange_strong_release_consume(__obj, __exp,
@@ -2776,25 +12029,27 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_acquire_acquire(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_release_relaxed(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_acquire_acquire_b)
-    return __atomic_compare_exchange_strong_acquire_acquire(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_y)
+    return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
                                                                         __desr);
 #else
-    return __choose_compare_exchange_strong_release_acquire(__obj, __exp,
+    return __choose_compare_exchange_strong_release_relaxed(__obj, __exp,
                                                                         __desr);
 #endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_acquire_consume(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acquire_acquire(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_acquire_consume_b)
-    return __atomic_compare_exchange_strong_acquire_consume(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_y)
+    return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
                                                                         __desr);
 #else
     return __choose_compare_exchange_strong_acquire_acquire(__obj, __exp,
@@ -2804,11 +12059,12 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_acquire_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acquire_consume(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_acquire_relaxed_b)
-    return __atomic_compare_exchange_strong_acquire_relaxed(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_y)
+    return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
                                                                         __desr);
 #else
     return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
@@ -2818,25 +12074,27 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_consume_consume(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acquire_relaxed(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_consume_consume_b)
-    return __atomic_compare_exchange_strong_consume_consume(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_y)
+    return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
                                                                         __desr);
 #else
-    return __choose_compare_exchange_strong_acquire_consume(__obj, __exp,
+    return __choose_compare_exchange_strong_acquire_relaxed(__obj, __exp,
                                                                         __desr);
 #endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_consume_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_consume_consume(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_consume_relaxed_b)
-    return __atomic_compare_exchange_strong_consume_relaxed(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_y)
+    return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
                                                                         __desr);
 #else
     return __choose_compare_exchange_strong_consume_consume(__obj, __exp,
@@ -2846,11 +12104,12 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_strong_relaxed_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_consume_relaxed(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
 {
-#if __has_feature(__atomic_compare_exchange_strong_relaxed_relaxed_b)
-    return __atomic_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_y)
+    return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
                                                                         __desr);
 #else
     return __choose_compare_exchange_strong_consume_relaxed(__obj, __exp,
@@ -2858,14 +12117,30 @@
 #endif
 }
 
-// compare_exchange_weak bool
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__choose_compare_exchange_weak_relaxed_relaxed(unsigned long long volatile* __obj,
+                                               unsigned long long* __exp,
+                                               unsigned long long __desr)
+{
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_y)
+    return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#else
+    return __choose_compare_exchange_strong_relaxed_relaxed(__obj, __exp,
+                                                                        __desr);
+#endif
+}
+
+// compare_exchange_weak void*
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_seq_cst_seq_cst(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_seq_cst_seq_cst(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_b)
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_seq_cst_Py)
     return __atomic_compare_exchange_weak_seq_cst_seq_cst(__obj, __exp,
                                                                         __desr);
 #else
@@ -2876,10 +12151,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_seq_cst_acquire(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_seq_cst_acquire(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_b)
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_acquire_Py)
     return __atomic_compare_exchange_weak_seq_cst_acquire(__obj, __exp,
                                                                         __desr);
 #else
@@ -2890,10 +12166,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_seq_cst_consume(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_seq_cst_consume(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_b)
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_consume_Py)
     return __atomic_compare_exchange_weak_seq_cst_consume(__obj, __exp,
                                                                         __desr);
 #else
@@ -2904,10 +12181,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_seq_cst_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_seq_cst_relaxed(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_b)
+#if __has_feature(__atomic_compare_exchange_weak_seq_cst_relaxed_Py)
     return __atomic_compare_exchange_weak_seq_cst_relaxed(__obj, __exp,
                                                                         __desr);
 #else
@@ -2918,10 +12196,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_acq_rel_acquire(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acq_rel_acquire(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_b)
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_acquire_Py)
     return __atomic_compare_exchange_weak_acq_rel_acquire(__obj, __exp,
                                                                         __desr);
 #else
@@ -2932,10 +12211,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_acq_rel_consume(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acq_rel_consume(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_b)
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_consume_Py)
     return __atomic_compare_exchange_weak_acq_rel_consume(__obj, __exp,
                                                                         __desr);
 #else
@@ -2946,10 +12226,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_acq_rel_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acq_rel_relaxed(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_b)
+#if __has_feature(__atomic_compare_exchange_weak_acq_rel_relaxed_Py)
     return __atomic_compare_exchange_weak_acq_rel_relaxed(__obj, __exp,
                                                                         __desr);
 #else
@@ -2960,10 +12241,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_release_acquire(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_release_acquire(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_release_acquire_b)
+#if __has_feature(__atomic_compare_exchange_weak_release_acquire_Py)
     return __atomic_compare_exchange_weak_release_acquire(__obj, __exp,
                                                                         __desr);
 #else
@@ -2974,10 +12256,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_release_consume(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_release_consume(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_release_consume_b)
+#if __has_feature(__atomic_compare_exchange_weak_release_consume_Py)
     return __atomic_compare_exchange_weak_release_consume(__obj, __exp,
                                                                         __desr);
 #else
@@ -2988,10 +12271,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_release_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_release_relaxed(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_b)
+#if __has_feature(__atomic_compare_exchange_weak_release_relaxed_Py)
     return __atomic_compare_exchange_weak_release_relaxed(__obj, __exp,
                                                                         __desr);
 #else
@@ -3002,10 +12286,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_acquire_acquire(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acquire_acquire(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_b)
+#if __has_feature(__atomic_compare_exchange_weak_acquire_acquire_Py)
     return __atomic_compare_exchange_weak_acquire_acquire(__obj, __exp,
                                                                         __desr);
 #else
@@ -3016,10 +12301,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_acquire_consume(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acquire_consume(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_b)
+#if __has_feature(__atomic_compare_exchange_weak_acquire_consume_Py)
     return __atomic_compare_exchange_weak_acquire_consume(__obj, __exp,
                                                                         __desr);
 #else
@@ -3030,10 +12316,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_acquire_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_acquire_relaxed(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_b)
+#if __has_feature(__atomic_compare_exchange_weak_acquire_relaxed_Py)
     return __atomic_compare_exchange_weak_acquire_relaxed(__obj, __exp,
                                                                         __desr);
 #else
@@ -3044,10 +12331,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_consume_consume(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_consume_consume(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_consume_consume_b)
+#if __has_feature(__atomic_compare_exchange_weak_consume_consume_Py)
     return __atomic_compare_exchange_weak_consume_consume(__obj, __exp,
                                                                         __desr);
 #else
@@ -3058,10 +12346,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_consume_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_consume_relaxed(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_b)
+#if __has_feature(__atomic_compare_exchange_weak_consume_relaxed_Py)
     return __atomic_compare_exchange_weak_consume_relaxed(__obj, __exp,
                                                                         __desr);
 #else
@@ -3072,10 +12361,11 @@
 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__choose_compare_exchange_weak_relaxed_relaxed(volatile bool* __obj,
-                                                       bool* __exp, bool __desr)
+__choose_compare_exchange_weak_relaxed_relaxed(void* volatile* __obj,
+                                               void** __exp,
+                                               void* __desr)
 {
-#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_b)
+#if __has_feature(__atomic_compare_exchange_weak_relaxed_relaxed_Py)
     return __atomic_compare_exchange_weak_relaxed_relaxed(__obj, __exp,
                                                                         __desr);
 #else





More information about the cfe-commits mailing list