[libcxx] r192539 - LWG issue 2143: ios_base::xalloc should be thread-safe

Marshall Clow mclow.lists at gmail.com
Sat Oct 12 12:13:52 PDT 2013


Author: marshall
Date: Sat Oct 12 14:13:52 2013
New Revision: 192539

URL: http://llvm.org/viewvc/llvm-project?rev=192539&view=rev
Log:
LWG issue 2143: ios_base::xalloc should be thread-safe

Modified:
    libcxx/trunk/include/ios
    libcxx/trunk/src/ios.cpp

Modified: libcxx/trunk/include/ios
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ios?rev=192539&r1=192538&r2=192539&view=diff
==============================================================================
--- libcxx/trunk/include/ios (original)
+++ libcxx/trunk/include/ios Sat Oct 12 14:13:52 2013
@@ -216,6 +216,10 @@ storage-class-specifier const error_cate
 #include <__locale>
 #include <system_error>
 
+#if __has_feature(cxx_atomic)
+#include <atomic>     // 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<int> __xindex_;
+#else
     static int      __xindex_;
+#endif
     long*           __iarray_;
     size_t          __iarray_size_;
     size_t          __iarray_cap_;

Modified: libcxx/trunk/src/ios.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/ios.cpp?rev=192539&r1=192538&r2=192539&view=diff
==============================================================================
--- libcxx/trunk/src/ios.cpp (original)
+++ libcxx/trunk/src/ios.cpp Sat Oct 12 14:13:52 2013
@@ -149,8 +149,11 @@ ios_base::getloc() const
 }
 
 // xalloc
-
+#if __has_feature(cxx_atomic)
+atomic<int> ios_base::__xindex_ = ATOMIC_VAR_INIT(0);
+#else
 int ios_base::__xindex_ = 0;
+#endif
 
 int
 ios_base::xalloc()





More information about the cfe-commits mailing list