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/libc/system_properties/prop_info.cpp b/libc/system_properties/prop_info.cpp
index c3bf177..499b36a 100644
--- a/libc/system_properties/prop_info.cpp
+++ b/libc/system_properties/prop_info.cpp
@@ -38,7 +38,7 @@
prop_info::prop_info(const char* name, uint32_t namelen, const char* value, uint32_t valuelen) {
memcpy(this->name, name, namelen);
this->name[namelen] = '\0';
- atomic_init(&this->serial, valuelen << 24);
+ atomic_store_explicit(&this->serial, valuelen << 24, memory_order_relaxed);
memcpy(this->value, value, valuelen);
this->value[valuelen] = '\0';
}
@@ -48,7 +48,7 @@
this->name[namelen] = '\0';
auto error_value_len = sizeof(kLongLegacyError) - 1;
- atomic_init(&this->serial, error_value_len << 24 | kLongFlag);
+ atomic_store_explicit(&this->serial, error_value_len << 24 | kLongFlag, memory_order_relaxed);
memcpy(this->long_property.error_message, kLongLegacyError, sizeof(kLongLegacyError));
this->long_property.offset = long_offset;