From: Mark de Wever Date: Thu, 22 Dec 2022 19:35:36 +0000 (+0100) Subject: [libc++] LWG3745 noexcept for atomic_wait. X-Git-Tag: upstream/17.0.6~22699 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83c1816224aab4a7714fa62b98292b496327d87b;p=platform%2Fupstream%2Fllvm.git [libc++] LWG3745 noexcept for atomic_wait. The noexcept was already implemented, this only updates the synposis and adds tests to validate that the functions are noexcept. This implements: - LWG3745 std::atomic_wait and its friends lack noexcept Reviewed By: #libc, philnik Differential Revision: https://reviews.llvm.org/D140575 --- diff --git a/libcxx/docs/Status/Cxx2bIssues.csv b/libcxx/docs/Status/Cxx2bIssues.csv index a793c88..3a6d2c8 100644 --- a/libcxx/docs/Status/Cxx2bIssues.csv +++ b/libcxx/docs/Status/Cxx2bIssues.csv @@ -205,7 +205,7 @@ "`3737 `__","``take_view::sentinel`` should provide ``operator-``", "November 2022","","","|ranges|" "`3738 `__","Missing preconditions for ``take_view`` constructor", "November 2022","","","|ranges|" "`3743 `__","``ranges::to``'s reserve may be ill-formed", "November 2022","","","|ranges|" -"`3745 `__","``std::atomic_wait`` and its friends lack ``noexcept``", "November 2022","","","" +"`3745 `__","``std::atomic_wait`` and its friends lack ``noexcept``", "November 2022","|Complete|","16.0","" "`3746 `__","``optional``'s spaceship with ``U`` with a type derived from optional causes infinite constraint meta-recursion", "November 2022","","","|spaceship|" "`3747 `__","``ranges::uninitialized_copy_n``, ``ranges::uninitialized_move_n``, and ``ranges::destroy_n`` should use ``std::move``", "November 2022","","","|ranges|" "`3750 `__","Too many papers bump ``__cpp_lib_format``", "November 2022","","","|format|" diff --git a/libcxx/include/atomic b/libcxx/include/atomic index 87631f3..4fc565c 100644 --- a/libcxx/include/atomic +++ b/libcxx/include/atomic @@ -377,23 +377,23 @@ template memory_order) noexcept; template - void atomic_wait(const volatile atomic*, atomic::value_type); + void atomic_wait(const volatile atomic*, atomic::value_type) noexcept; template - void atomic_wait(const atomic*, atomic::value_type); + void atomic_wait(const atomic*, atomic::value_type) noexcept; template void atomic_wait_explicit(const volatile atomic*, atomic::value_type, - memory_order); + memory_order) noexcept; template void atomic_wait_explicit(const atomic*, atomic::value_type, - memory_order); + memory_order) noexcept; template - void atomic_notify_one(volatile atomic*); + void atomic_notify_one(volatile atomic*) noexcept; template - void atomic_notify_one(atomic*); + void atomic_notify_one(atomic*) noexcept; template - void atomic_notify_all(volatile atomic*); + void atomic_notify_all(volatile atomic*) noexcept; template - void atomic_notify_all(atomic*); + void atomic_notify_all(atomic*) noexcept; // Atomics for standard typedef types @@ -2099,7 +2099,7 @@ void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT __o->notify_one(); } -// atomic_notify_one +// atomic_notify_all template _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_all.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_all.pass.cpp index 58d9772..92908bd 100644 --- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_all.pass.cpp +++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_all.pass.cpp @@ -17,11 +17,11 @@ // template // void -// atomic_notify_all(volatile atomic*); +// atomic_notify_all(volatile atomic*) noexcept; // // template // void -// atomic_notify_all(atomic*); +// atomic_notify_all(atomic*) noexcept; #include #include @@ -39,6 +39,7 @@ struct TestFn { { A a(T(1)); + static_assert(noexcept(std::atomic_notify_all(&a)), ""); auto f = [&]() { assert(std::atomic_load(&a) == T(1)); std::atomic_wait(&a, T(1)); @@ -55,6 +56,7 @@ struct TestFn { } { volatile A a(T(2)); + static_assert(noexcept(std::atomic_notify_all(&a)), ""); auto f = [&]() { assert(std::atomic_load(&a) == T(2)); std::atomic_wait(&a, T(2)); diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_one.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_one.pass.cpp index 2c18742..5f8afa8 100644 --- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_one.pass.cpp +++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_one.pass.cpp @@ -17,11 +17,11 @@ // template // void -// atomic_notify_one(volatile atomic*); +// atomic_notify_one(volatile atomic*) noexcept; // // template // void -// atomic_notify_one(atomic*); +// atomic_notify_one(atomic*) noexcept; #include #include @@ -39,6 +39,7 @@ struct TestFn { { A a(T(1)); + static_assert(noexcept(std::atomic_notify_one(&a)), ""); std::thread t = support::make_test_thread([&]() { std::atomic_store(&a, T(3)); std::atomic_notify_one(&a); @@ -49,6 +50,7 @@ struct TestFn { } { volatile A a(T(2)); + static_assert(noexcept(std::atomic_notify_one(&a)), ""); std::thread t = support::make_test_thread([&]() { std::atomic_store(&a, T(4)); std::atomic_notify_one(&a); diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_wait.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_wait.pass.cpp index 1557f41..2d4890e 100644 --- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_wait.pass.cpp +++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_wait.pass.cpp @@ -17,11 +17,11 @@ // template // void -// atomic_wait(const volatile atomic*, atomic::value_type); +// atomic_wait(const volatile atomic*, atomic::value_type) noexcept; // // template // void -// atomic_wait(const atomic*, atomic::value_type); +// atomic_wait(const atomic*, atomic::value_type) noexcept; #include #include @@ -38,6 +38,7 @@ struct TestFn { typedef std::atomic A; { A t(T(1)); + static_assert(noexcept(std::atomic_wait(&t, T(0))), ""); assert(std::atomic_load(&t) == T(1)); std::atomic_wait(&t, T(0)); std::thread t1 = support::make_test_thread([&]() { @@ -50,6 +51,7 @@ struct TestFn { } { volatile A vt(T(2)); + static_assert(noexcept(std::atomic_wait(&vt, T(0))), ""); assert(std::atomic_load(&vt) == T(2)); std::atomic_wait(&vt, T(1)); std::thread t2 = support::make_test_thread([&]() { diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_wait_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_wait_explicit.pass.cpp index 9799c77..00d1ce0 100644 --- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_wait_explicit.pass.cpp +++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_wait_explicit.pass.cpp @@ -18,12 +18,12 @@ // template // void // atomic_wait_explicit(const volatile atomic*, atomic::value_type, -// memory_order); +// memory_order) noexcept; // // template // void // atomic_wait_explicit(const volatile atomic*, atomic::value_type, -// memory_order); +// memory_order) noexcept; #include #include @@ -40,6 +40,7 @@ struct TestFn { typedef std::atomic A; { A t(T(1)); + static_assert(noexcept(std::atomic_wait_explicit(&t, T(0), std::memory_order_seq_cst)), ""); assert(std::atomic_load(&t) == T(1)); std::atomic_wait_explicit(&t, T(0), std::memory_order_seq_cst); std::thread t1 = support::make_test_thread([&]() { @@ -52,6 +53,7 @@ struct TestFn { } { volatile A vt(T(2)); + static_assert(noexcept(std::atomic_wait_explicit(&vt, T(0), std::memory_order_seq_cst)), ""); assert(std::atomic_load(&vt) == T(2)); std::atomic_wait_explicit(&vt, T(1), std::memory_order_seq_cst); std::thread t2 = support::make_test_thread([&]() {