aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Dionne <ldionne@apple.com>2020-02-27 08:14:38 -0500
committerLouis Dionne <ldionne@apple.com>2020-03-24 17:48:46 -0400
commit1ac403bd145dadfa1004af29bd6c77f871caf42c (patch)
treebfec55d615b427ef9cd0e3505e942465b6630198
parenta4e8d89704d2584d5c56cb27745beab25c7b9b36 (diff)
downloadllvm-1ac403bd145dadfa1004af29bd6c77f871caf42c.zip
llvm-1ac403bd145dadfa1004af29bd6c77f871caf42c.tar.gz
llvm-1ac403bd145dadfa1004af29bd6c77f871caf42c.tar.bz2
[libc++] Build the dylib with C++17 to allow aligned new/delete
This allows simplifying the implementation of barriers. Differential Revision: https://reviews.llvm.org/D75243
-rw-r--r--libcxx/CMakeLists.txt6
-rw-r--r--libcxx/src/barrier.cpp12
2 files changed, 6 insertions, 12 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index f6097a3..6b2c471 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -519,10 +519,10 @@ remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
# Required flags ==============================================================
function(cxx_add_basic_build_flags target)
- # Require C++14 for all targets. C++14 is needed to ensure constant
- # initialization for certain globals (ex global memory resources).
+ # Require C++17 for all targets. C++17 is needed to use aligned allocation
+ # in the dylib.
set_target_properties(${target} PROPERTIES
- CXX_STANDARD 14
+ CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO)
diff --git a/libcxx/src/barrier.cpp b/libcxx/src/barrier.cpp
index c5e33cb..9ee4769 100644
--- a/libcxx/src/barrier.cpp
+++ b/libcxx/src/barrier.cpp
@@ -26,21 +26,15 @@ public:
} __tickets[64];
};
- ptrdiff_t& __expected;
- unique_ptr<char[]> __state_allocation;
- __state_t* __state;
+ ptrdiff_t& __expected;
+ unique_ptr<__state_t[]> __state;
_LIBCPP_HIDDEN
__barrier_algorithm_base(ptrdiff_t& __expected)
: __expected(__expected)
{
size_t const __count = (__expected + 1) >> 1;
- size_t const __size = sizeof(__state_t) * __count;
- size_t __allocation_size = __size + alignof(__state_t);
- __state_allocation = unique_ptr<char[]>(new char[__allocation_size]);
- void* __allocation = __state_allocation.get();
- void* const __state_ = align(alignof(__state_t), __size, __allocation, __allocation_size);
- __state = new (__state_) __barrier_algorithm_base::__state_t[__count];
+ __state = unique_ptr<__state_t[]>(new __state_t[__count]);
}
_LIBCPP_HIDDEN
bool __arrive(__barrier_phase_t __old_phase)