Mark libc++ internal globals with _LIBCPP_SAFE_STATIC.

This patch applies the _LIBCPP_SAFE_STATIC attribute to internal globals,
most of which are locking primitives, in order to ensure that they can
safely be used during program startup.

This patch also fixes an unsafe static init issue with the global locks
used to implement atomic operations on shared pointers. Previously the
locks were initialized using a dynamically initialized pointer, so it was
possible that the pointer was uninitialized.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@282640 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-09-28 22:08:13 +00:00
parent d5fc5ca37f
commit ff4f298780
4 changed files with 12 additions and 14 deletions

View File

@@ -32,8 +32,8 @@
#define HAVE_DEPENDENT_EH_ABI 1
#endif
#elif !defined(__GLIBCXX__) // defined(LIBCXX_BUILDING_LIBCXXABI)
static std::terminate_handler __terminate_handler;
static std::unexpected_handler __unexpected_handler;
_LIBCPP_SAFE_STATIC static std::terminate_handler __terminate_handler;
_LIBCPP_SAFE_STATIC static std::unexpected_handler __unexpected_handler;
#endif // defined(LIBCXX_BUILDING_LIBCXXABI)
namespace std