Revert "[libc++] Build the dylib with C++17 to allow aligned new/delete"
This reverts commit 1ac403bd145dadfa1004af29bd6c77f871caf42c, which
broke some non-libc++ build bots because they use an ancient CMake.
Cr-Mirrored-From: https://chromium.googlesource.com/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 64a9c944fc459475b3eefed423e3b593353c0cca
diff --git a/src/barrier.cpp b/src/barrier.cpp
index 9ee4769..c5e33cb 100644
--- a/src/barrier.cpp
+++ b/src/barrier.cpp
@@ -26,15 +26,21 @@
} __tickets[64];
};
- ptrdiff_t& __expected;
- unique_ptr<__state_t[]> __state;
+ ptrdiff_t& __expected;
+ unique_ptr<char[]> __state_allocation;
+ __state_t* __state;
_LIBCPP_HIDDEN
__barrier_algorithm_base(ptrdiff_t& __expected)
: __expected(__expected)
{
size_t const __count = (__expected + 1) >> 1;
- __state = unique_ptr<__state_t[]>(new __state_t[__count]);
+ 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];
}
_LIBCPP_HIDDEN
bool __arrive(__barrier_phase_t __old_phase)