[libcxx-commits] [PATCH] D132715: [libc++] Clean up `_LIBCPP_HAS_NO_PLATFORM_WAIT` macro

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 25 20:33:19 PDT 2022


jloser created this revision.
jloser added reviewers: ldionne, Mordante, var-const, philnik.
Herald added a project: All.
jloser requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

As the comment suggests, `_LIBCPP_HAS_NO_PLATFORM_WAIT` is not documented or
defined anywhere internally in the build system. It's a direct define in terms
of `_LIBCPP_HAS_NO_THREADS`. So, remove `_LIBCPP_HAS_NO_PLATFORM_WAIT` and use
`_LIBCPP_HAS_NO_THREADS` instead to control the desired behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132715

Files:
  libcxx/include/atomic


Index: libcxx/include/atomic
===================================================================
--- libcxx/include/atomic
+++ libcxx/include/atomic
@@ -1463,17 +1463,7 @@
 
 using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>;
 
-#if defined(_LIBCPP_HAS_NO_THREADS)
-#   define _LIBCPP_HAS_NO_PLATFORM_WAIT
-#endif
-
-// TODO:
-// _LIBCPP_HAS_NO_PLATFORM_WAIT is currently a "dead" macro, in the sense that
-// it is not tied anywhere into the build system or even documented. We should
-// clean it up because it is technically never defined except when threads are
-// disabled. We should clean it up in its own changeset in case we break "bad"
-// users.
-#ifndef _LIBCPP_HAS_NO_PLATFORM_WAIT
+#ifndef _LIBCPP_HAS_NO_THREADS
 
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*);
 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*);
@@ -1515,7 +1505,7 @@
     return __libcpp_thread_poll_with_backoff(__test_fn, __backoff_fn);
 }
 
-#else // _LIBCPP_HAS_NO_PLATFORM_WAIT
+#else // _LIBCPP_HAS_NO_THREADS
 
 template <class _Tp>
 _LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_all(__cxx_atomic_impl<_Tp> const volatile*) { }
@@ -1524,15 +1514,10 @@
 template <class _Atp, class _Fn>
 _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp*, _Fn && __test_fn)
 {
-#if defined(_LIBCPP_HAS_NO_THREADS)
-    using _Policy = __spinning_backoff_policy;
-#else
-    using _Policy = __libcpp_timed_backoff_policy;
-#endif
-    return __libcpp_thread_poll_with_backoff(__test_fn, _Policy());
+    return __libcpp_thread_poll_with_backoff(__test_fn, __spinning_backoff_policy());
 }
 
-#endif // _LIBCPP_HAS_NO_PLATFORM_WAIT
+#endif // _LIBCPP_HAS_NO_THREADS
 
 template <class _Atp, class _Tp>
 struct __cxx_atomic_wait_test_fn_impl {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132715.455783.patch
Type: text/x-patch
Size: 1856 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220826/f7bb5419/attachment.bin>


More information about the libcxx-commits mailing list