diff --git a/libcxx/include/ios b/libcxx/include/ios index 5c96a9543e0c..227e39221a98 100644 --- a/libcxx/include/ios +++ b/libcxx/include/ios @@ -216,6 +216,10 @@ storage-class-specifier const error_category& iostream_category; #include <__locale> #include +#if __has_feature(cxx_atomic) +#include // for __xindex_ +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -363,7 +367,11 @@ private: int* __index_; size_t __event_size_; size_t __event_cap_; +#if __has_feature(cxx_atomic) + static atomic __xindex_; +#else static int __xindex_; +#endif long* __iarray_; size_t __iarray_size_; size_t __iarray_cap_; diff --git a/libcxx/src/ios.cpp b/libcxx/src/ios.cpp index 754c2c956822..e79b3284cc23 100644 --- a/libcxx/src/ios.cpp +++ b/libcxx/src/ios.cpp @@ -149,8 +149,11 @@ ios_base::getloc() const } // xalloc - +#if __has_feature(cxx_atomic) +atomic ios_base::__xindex_ = ATOMIC_VAR_INIT(0); +#else int ios_base::__xindex_ = 0; +#endif int ios_base::xalloc()