[libcxx-commits] [PATCH] D91706: [libc++] [P0482] [C++20] Implement missing bits for atomic: ATOMIC_CHAR8_T_LOCK_FREE.

Marek Kurdej via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 18 06:21:04 PST 2020


curdeius created this revision.
curdeius added a reviewer: ldionne.
Herald added a reviewer: jfb.
Herald added subscribers: libcxx-commits, jfb.
Herald added a project: libc++.
Herald added a reviewer: libc++.
curdeius requested review of this revision.

http://wg21.link/P0482


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91706

Files:
  libcxx/include/atomic
  libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
  libcxx/test/std/atomics/atomics.lockfree/lockfree.pass.cpp


Index: libcxx/test/std/atomics/atomics.lockfree/lockfree.pass.cpp
===================================================================
--- libcxx/test/std/atomics/atomics.lockfree/lockfree.pass.cpp
+++ libcxx/test/std/atomics/atomics.lockfree/lockfree.pass.cpp
@@ -12,6 +12,7 @@
 
 // #define ATOMIC_BOOL_LOCK_FREE unspecified
 // #define ATOMIC_CHAR_LOCK_FREE unspecified
+// #define ATOMIC_CHAR8_T_LOCK_FREE unspecified // C++20
 // #define ATOMIC_CHAR16_T_LOCK_FREE unspecified
 // #define ATOMIC_CHAR32_T_LOCK_FREE unspecified
 // #define ATOMIC_WCHAR_T_LOCK_FREE unspecified
@@ -34,6 +35,11 @@
     assert(ATOMIC_CHAR_LOCK_FREE == 0 ||
            ATOMIC_CHAR_LOCK_FREE == 1 ||
            ATOMIC_CHAR_LOCK_FREE == 2);
+#if TEST_STD_VER > 17
+    assert(ATOMIC_CHAR8_T_LOCK_FREE == 0 ||
+           ATOMIC_CHAR8_T_LOCK_FREE == 1 ||
+           ATOMIC_CHAR8_T_LOCK_FREE == 2);
+#endif
     assert(ATOMIC_CHAR16_T_LOCK_FREE == 0 ||
            ATOMIC_CHAR16_T_LOCK_FREE == 1 ||
            ATOMIC_CHAR16_T_LOCK_FREE == 2);
Index: libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
===================================================================
--- libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
+++ libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
@@ -74,6 +74,9 @@
     CHECK_ALWAYS_LOCK_FREE(char);
     CHECK_ALWAYS_LOCK_FREE(signed char);
     CHECK_ALWAYS_LOCK_FREE(unsigned char);
+#if TEST_STD_VER > 17
+    CHECK_ALWAYS_LOCK_FREE(char8_t);
+#endif
     CHECK_ALWAYS_LOCK_FREE(char16_t);
     CHECK_ALWAYS_LOCK_FREE(char32_t);
     CHECK_ALWAYS_LOCK_FREE(wchar_t);
@@ -122,6 +125,9 @@
     static_assert(std::atomic<char>::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE), "");
     static_assert(std::atomic<signed char>::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE), "");
     static_assert(std::atomic<unsigned char>::is_always_lock_free == (2 == ATOMIC_CHAR_LOCK_FREE), "");
+#if TEST_STD_VER > 17
+    static_assert(std::atomic<char8_t>::is_always_lock_free == (2 == ATOMIC_CHAR8_T_LOCK_FREE), "");
+#endif
     static_assert(std::atomic<char16_t>::is_always_lock_free == (2 == ATOMIC_CHAR16_T_LOCK_FREE), "");
     static_assert(std::atomic<char32_t>::is_always_lock_free == (2 == ATOMIC_CHAR32_T_LOCK_FREE), "");
     static_assert(std::atomic<wchar_t>::is_always_lock_free == (2 == ATOMIC_WCHAR_T_LOCK_FREE), "");
Index: libcxx/include/atomic
===================================================================
--- libcxx/include/atomic
+++ libcxx/include/atomic
@@ -48,6 +48,7 @@
 
 #define ATOMIC_BOOL_LOCK_FREE unspecified
 #define ATOMIC_CHAR_LOCK_FREE unspecified
+#define ATOMIC_CHAR8_T_LOCK_FREE unspecified // C++20
 #define ATOMIC_CHAR16_T_LOCK_FREE unspecified
 #define ATOMIC_CHAR32_T_LOCK_FREE unspecified
 #define ATOMIC_WCHAR_T_LOCK_FREE unspecified
@@ -1125,6 +1126,9 @@
 #if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE)
 # define ATOMIC_BOOL_LOCK_FREE      __CLANG_ATOMIC_BOOL_LOCK_FREE
 # define ATOMIC_CHAR_LOCK_FREE      __CLANG_ATOMIC_CHAR_LOCK_FREE
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+# define ATOMIC_CHAR8_T_LOCK_FREE   __CLANG_ATOMIC_CHAR8_T_LOCK_FREE
+#endif
 # define ATOMIC_CHAR16_T_LOCK_FREE  __CLANG_ATOMIC_CHAR16_T_LOCK_FREE
 # define ATOMIC_CHAR32_T_LOCK_FREE  __CLANG_ATOMIC_CHAR32_T_LOCK_FREE
 # define ATOMIC_WCHAR_T_LOCK_FREE   __CLANG_ATOMIC_WCHAR_T_LOCK_FREE
@@ -1136,6 +1140,9 @@
 #elif defined(__GCC_ATOMIC_BOOL_LOCK_FREE)
 # define ATOMIC_BOOL_LOCK_FREE      __GCC_ATOMIC_BOOL_LOCK_FREE
 # define ATOMIC_CHAR_LOCK_FREE      __GCC_ATOMIC_CHAR_LOCK_FREE
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+# define ATOMIC_CHAR8_T_LOCK_FREE   __GCC_ATOMIC_CHAR8_T_LOCK_FREE
+#endif
 # define ATOMIC_CHAR16_T_LOCK_FREE  __GCC_ATOMIC_CHAR16_T_LOCK_FREE
 # define ATOMIC_CHAR32_T_LOCK_FREE  __GCC_ATOMIC_CHAR32_T_LOCK_FREE
 # define ATOMIC_WCHAR_T_LOCK_FREE   __GCC_ATOMIC_WCHAR_T_LOCK_FREE
@@ -1450,6 +1457,9 @@
 template<> struct __cxx_is_always_lock_free<char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
 template<> struct __cxx_is_always_lock_free<signed char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
 template<> struct __cxx_is_always_lock_free<unsigned char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
+#ifndef _LIBCPP_NO_HAS_CHAR8_T
+template<> struct __cxx_is_always_lock_free<char8_t> { enum { __value = 2 == ATOMIC_CHAR8_T_LOCK_FREE }; };
+#endif
 template<> struct __cxx_is_always_lock_free<char16_t> { enum { __value = 2 == ATOMIC_CHAR16_T_LOCK_FREE }; };
 template<> struct __cxx_is_always_lock_free<char32_t> { enum { __value = 2 == ATOMIC_CHAR32_T_LOCK_FREE }; };
 template<> struct __cxx_is_always_lock_free<wchar_t> { enum { __value = 2 == ATOMIC_WCHAR_T_LOCK_FREE }; };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91706.306088.patch
Type: text/x-patch
Size: 4709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201118/bd6c2637/attachment.bin>


More information about the libcxx-commits mailing list