[libcxx-commits] [PATCH] D154425: [libc++] add basic runtime assertions to <latch>
Edo via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 4 02:51:56 PDT 2023
diamante0018 updated this revision to Diff 537014.
diamante0018 added a comment.
I am learning how to use this differential tool and it appears the previous patch undid the changes I actually intended to commit instead of removing just the "one" offending line.
Sorry
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154425/new/
https://reviews.llvm.org/D154425
Files:
libcxx/include/latch
Index: libcxx/include/latch
===================================================================
--- libcxx/include/latch
+++ libcxx/include/latch
@@ -75,7 +75,11 @@
}
inline _LIBCPP_INLINE_VISIBILITY
- constexpr explicit latch(ptrdiff_t __expected) : __a_(__expected) { }
+ constexpr explicit latch(ptrdiff_t __expected) : __a_(__expected)
+ {
+ _LIBCPP_ASSERT_UNCATEGORIZED(__expected >= 0,
+ "__expected cannot be negative");
+ }
_LIBCPP_HIDE_FROM_ABI ~latch() = default;
latch(const latch&) = delete;
@@ -84,6 +88,8 @@
inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void count_down(ptrdiff_t __update = 1)
{
+ _LIBCPP_ASSERT_UNCATEGORIZED(
+ __update >= 0, "latch::count_down called with a negative value");
auto const __old = __a_.fetch_sub(__update, memory_order_release);
if(__old == __update)
__a_.notify_all();
@@ -103,6 +109,8 @@
inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY
void arrive_and_wait(ptrdiff_t __update = 1)
{
+ _LIBCPP_ASSERT_UNCATEGORIZED(
+ __update >= 0, "latch::arrive_and_wait called with a negative value");
count_down(__update);
wait();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154425.537014.patch
Type: text/x-patch
Size: 1293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230704/e4c73015/attachment.bin>
More information about the libcxx-commits
mailing list