aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/latch
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include/latch')
-rw-r--r--libcxx/include/latch21
1 files changed, 11 insertions, 10 deletions
diff --git a/libcxx/include/latch b/libcxx/include/latch
index ef52c0562a7c..ad7b35579913 100644
--- a/libcxx/include/latch
+++ b/libcxx/include/latch
@@ -40,12 +40,17 @@ namespace std
*/
+#include <__config>
+
+#ifdef _LIBCPP_HAS_NO_THREADS
+# error "<latch> is not supported since libc++ has been configured without support for threads."
+#endif
+
#include <__assert> // all public C++ headers provide the assertion handler
#include <__atomic/atomic_base.h>
#include <__atomic/atomic_sync.h>
#include <__atomic/memory_order.h>
#include <__availability>
-#include <__config>
#include <cstddef>
#include <limits>
#include <version>
@@ -54,10 +59,6 @@ namespace std
# pragma GCC system_header
#endif
-#ifdef _LIBCPP_HAS_NO_THREADS
-# error "<latch> is not supported since libc++ has been configured without support for threads."
-#endif
-
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
@@ -72,11 +73,11 @@ public:
static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return numeric_limits<ptrdiff_t>::max(); }
inline _LIBCPP_HIDE_FROM_ABI constexpr explicit latch(ptrdiff_t __expected) : __a_(__expected) {
- _LIBCPP_ASSERT_UNCATEGORIZED(
+ _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
__expected >= 0,
"latch::latch(ptrdiff_t): latch cannot be "
"initialized with a negative value");
- _LIBCPP_ASSERT_UNCATEGORIZED(
+ _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
__expected <= max(),
"latch::latch(ptrdiff_t): latch cannot be "
"initialized with a value greater than max()");
@@ -87,9 +88,9 @@ public:
latch& operator=(const latch&) = delete;
inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void count_down(ptrdiff_t __update = 1) {
- _LIBCPP_ASSERT_UNCATEGORIZED(__update >= 0, "latch::count_down called with a negative value");
+ _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::count_down called with a negative value");
auto const __old = __a_.fetch_sub(__update, memory_order_release);
- _LIBCPP_ASSERT_UNCATEGORIZED(
+ _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
__update <= __old,
"latch::count_down called with a value greater "
"than the internal counter");
@@ -101,7 +102,7 @@ public:
__cxx_atomic_wait(&__a_.__a_, [this]() -> bool { return try_wait(); });
}
inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_wait(ptrdiff_t __update = 1) {
- _LIBCPP_ASSERT_UNCATEGORIZED(__update >= 0, "latch::arrive_and_wait called with a negative value");
+ _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::arrive_and_wait called with a negative value");
// other preconditions on __update are checked in count_down()
count_down(__update);