summaryrefslogtreecommitdiffstats
path: root/libcxx/include
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-01-05 01:15:42 +0000
committerEric Fiselier <eric@efcs.ca>2017-01-05 01:15:42 +0000
commit528600c41ffb6afc9d95f5ba808ed5e6b348d7a3 (patch)
tree4c29d45e1c7949c1e587c33e257810c52099d8eb /libcxx/include
parent61195e12fc5cc128e5908cfb76a91ee6860659e5 (diff)
downloadbcm5719-llvm-528600c41ffb6afc9d95f5ba808ed5e6b348d7a3.tar.gz
bcm5719-llvm-528600c41ffb6afc9d95f5ba808ed5e6b348d7a3.zip
Fix std::pointer_safety type in ABI v2
In the C++ standard `std::pointer_safety` is defined as a C++11 strongly typed enum. However libc++ currently defines it as a class type which simulates a C++11 enumeration. This can be detected in valid C++ code. This patch introduces an the _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE ABI option. When defined `std::pointer_safety` is implemented as an enum type. Unfortunatly this also means it can no longer be provided as an extension in C++03. Additionally this patch moves the definition for `get_pointer_safety()` out of the dylib, and into the headers. New usages of `get_pointer_safety()` will now use the inline version instead of the dylib version. However in order to keep the dylib ABI compatible the old definition is explicitly compiled into it. llvm-svn: 291046
Diffstat (limited to 'libcxx/include')
-rw-r--r--libcxx/include/__config5
-rw-r--r--libcxx/include/memory25
2 files changed, 29 insertions, 1 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 08ca88bd773..ffd37c1fbc1 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -52,6 +52,11 @@
// provided under the alternate keyword __nullptr, which changes the mangling
// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
#define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
+// Define the `pointer_safety` enum as a C++11 strongly typed enumeration
+// instead of as a class simulating an enum. If this option is enabled
+// `pointer_safety` and `get_pointer_safety()` will no longer be available
+// in C++03.
+#define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE
#elif _LIBCPP_ABI_VERSION == 1
#if !defined(_WIN32)
// Enable compiling a definition of error_category() into the libc++ dylib.
diff --git a/libcxx/include/memory b/libcxx/include/memory
index d851295e0b7..3ea9a77d0d4 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -5616,6 +5616,15 @@ atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v
#endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
//enum class
+#if defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE)
+# ifndef _LIBCPP_CXX03_LANG
+enum class pointer_safety : unsigned char {
+ relaxed,
+ preferred,
+ strict
+};
+# endif
+#else
struct _LIBCPP_TYPE_VIS pointer_safety
{
enum __lx
@@ -5632,11 +5641,25 @@ struct _LIBCPP_TYPE_VIS pointer_safety
_LIBCPP_INLINE_VISIBILITY
operator int() const {return __v_;}
};
+#endif
+
+#if !defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE) && \
+ defined(_LIBCPP_BUILDING_MEMORY)
+_LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT;
+#else
+// This function is only offered in C++03 under ABI v1.
+# if !defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE) || !defined(_LIBCPP_CXX03_LANG)
+inline _LIBCPP_INLINE_VISIBILITY
+pointer_safety get_pointer_safety() _NOEXCEPT {
+ return pointer_safety::relaxed;
+}
+# endif
+#endif
+
_LIBCPP_FUNC_VIS void declare_reachable(void* __p);
_LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n);
_LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n);
-_LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT;
_LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p);
template <class _Tp>
OpenPOWER on IntegriCloud