bionic: libc: avoid -Wdeprecated-declarations via std::atomic_init
std::atomic_init is deprecated in C++20, and is slated for removal in C++26.
Replace the usage of std::atomic_init with std::atomic_store_explicit with
std::memory_ordering_relaxed.
Link: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0883r2.pdf
Link: https://github.com/llvm/llvm-project/commit/56aac567acfd696f54163e33d8df02dc2ad3a72e
Test: mmma bionic
Change-Id: Idf42aea193cfacf8dd7f8528560a396c6064468c
diff --git a/tests/stdatomic_test.cpp b/tests/stdatomic_test.cpp
index 1c51b11..8a54080 100644
--- a/tests/stdatomic_test.cpp
+++ b/tests/stdatomic_test.cpp
@@ -40,7 +40,7 @@
atomic_int v = 123;
ASSERT_EQ(123, atomic_load(&v));
- atomic_init(&v, 456);
+ atomic_store_explicit(&v, 456, memory_order_relaxed);
ASSERT_EQ(456, atomic_load(&v));
atomic_flag f = ATOMIC_FLAG_INIT;
@@ -258,9 +258,9 @@
// Run a memory ordering smoke test.
void* result;
three_atomics a;
- atomic_init(&a.x, 0ul);
- atomic_init(&a.y, 0ul);
- atomic_init(&a.z, 0ul);
+ atomic_store_explicit(&a.x, 0ul, memory_order_relaxed);
+ atomic_store_explicit(&a.y, 0ul, memory_order_relaxed);
+ atomic_store_explicit(&a.z, 0ul, memory_order_relaxed);
pthread_t t1,t2;
ASSERT_EQ(0, pthread_create(&t1, nullptr, reader, &a));
ASSERT_EQ(0, pthread_create(&t2, nullptr, writer, &a));