diff options
| author | Eric Fiselier <eric@efcs.ca> | 2016-09-03 00:11:33 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2016-09-03 00:11:33 +0000 |
| commit | 4efaa30934e8143cab9c47563ef49678aa9f635a (patch) | |
| tree | c81d53e2c603682c579f250b2af8896d4ab9ed0e /libcxx/src | |
| parent | 28842b96f3c30f34486d9feb32693e2ec2dc37ca (diff) | |
| download | bcm5719-llvm-4efaa30934e8143cab9c47563ef49678aa9f635a.tar.gz bcm5719-llvm-4efaa30934e8143cab9c47563ef49678aa9f635a.zip | |
Define _LIBCPP_SAFE_STATIC __attribute__((require_constant_initialization)), and apply it to memory_resource
llvm-svn: 280561
Diffstat (limited to 'libcxx/src')
| -rw-r--r-- | libcxx/src/experimental/memory_resource.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libcxx/src/experimental/memory_resource.cpp b/libcxx/src/experimental/memory_resource.cpp index c5de1aa00b8..c0880597537 100644 --- a/libcxx/src/experimental/memory_resource.cpp +++ b/libcxx/src/experimental/memory_resource.cpp @@ -70,7 +70,12 @@ union ResourceInitHelper { }; // When compiled in C++14 this initialization should be a constant expression. // Only in C++11 is "init_priority" needed to ensure initialization order. -ResourceInitHelper res_init __attribute__((init_priority (101))); +#if _LIBCPP_STD_VER > 11 +_LIBCPP_SAFE_STATIC +#else + __attribute__((init_priority (101))) +#endif +ResourceInitHelper res_init; } // end namespace @@ -89,7 +94,7 @@ static memory_resource * __default_memory_resource(bool set = false, memory_resource * new_res = nullptr) _NOEXCEPT { #ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER - static atomic<memory_resource*> __res = + _LIBCPP_SAFE_STATIC static atomic<memory_resource*> __res = ATOMIC_VAR_INIT(&res_init.resources.new_delete_res); if (set) { new_res = new_res ? new_res : new_delete_resource(); @@ -102,7 +107,7 @@ __default_memory_resource(bool set = false, memory_resource * new_res = nullptr) &__res, memory_order::memory_order_acquire); } #elif !defined(_LIBCPP_HAS_NO_THREADS) - static memory_resource * res = &res_init.resources.new_delete_res; + _LIBCPP_SAFE_STATIC static memory_resource * res = &res_init.resources.new_delete_res; static mutex res_lock; if (set) { new_res = new_res ? new_res : new_delete_resource(); @@ -115,7 +120,7 @@ __default_memory_resource(bool set = false, memory_resource * new_res = nullptr) return res; } #else - static memory_resource* res = &res_init.resources.new_delete_res; + _LIBCPP_SAFE_STATIC static memory_resource* res = &res_init.resources.new_delete_res; if (set) { new_res = new_res ? new_res : new_delete_resource(); memory_resource * old_res = res; |

