EricWF created this revision.
EricWF added reviewers: mclow.lists, rmaprath.
EricWF added a subscriber: cfe-commits.
Currently the implementation of [util.smartptr.shared.atomic] is provided only
when using Clang, and not with GCC. This is a relic of not having a GCC
implementation of , even though isn't actually used in the
implementation. This patch enables support for atomic shared_ptr functions when
using GCC.
Note that this is not a header only change. Previously only Clang builds of
libc++.so would provide the required symbols. There is no reason for this
restriction.
After this change both Clang and GCC builds should be binary compatible with
each other WRT these symbols.
http://reviews.llvm.org/D21407
Files:
include/memory
src/memory.cpp
Index: src/memory.cpp
===
--- src/memory.cpp
+++ src/memory.cpp
@@ -124,7 +124,7 @@
#endif // _LIBCPP_NO_RTTI
-#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
+#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
static const std::size_t __sp_mut_count = 16;
static __libcpp_mutex_t mut_back_imp[__sp_mut_count] =
@@ -177,7 +177,7 @@
return muts[hash()(p) & (__sp_mut_count-1)];
}
-#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
+#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
void
declare_reachable(void*)
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -5464,9 +5464,8 @@
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
-// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
-// enabled with clang.
-#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
+
+#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
class _LIBCPP_TYPE_VIS __sp_mut
{
@@ -5595,7 +5594,7 @@
return atomic_compare_exchange_weak(__p, __v, __w);
}
-#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) &&
!defined(_LIBCPP_HAS_NO_THREADS)
+#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
//enum class
struct _LIBCPP_TYPE_VIS pointer_safety
Index: src/memory.cpp
===
--- src/memory.cpp
+++ src/memory.cpp
@@ -124,7 +124,7 @@
#endif // _LIBCPP_NO_RTTI
-#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
+#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
static const std::size_t __sp_mut_count = 16;
static __libcpp_mutex_t mut_back_imp[__sp_mut_count] =
@@ -177,7 +177,7 @@
return muts[hash()(p) & (__sp_mut_count-1)];
}
-#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
+#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
void
declare_reachable(void*)
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -5464,9 +5464,8 @@
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
-// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
-// enabled with clang.
-#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
+
+#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
class _LIBCPP_TYPE_VIS __sp_mut
{
@@ -5595,7 +5594,7 @@
return atomic_compare_exchange_weak(__p, __v, __w);
}
-#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
+#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
//enum class
struct _LIBCPP_TYPE_VIS pointer_safety
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits