Skip to content

Commit e19e121

Browse files
committed
Make an exception to MacOs platforms, where system malloc only aligns to 8 bytes, even in ARM64.
1 parent d8620c7 commit e19e121

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

include/boost/container/detail/operator_new_helpers.hpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,18 @@ namespace dtl {
3232

3333
BOOST_CONTAINER_FORCEINLINE bool operator_new_raw_overaligned(std::size_t alignment)
3434
{
35+
//In MacOs, the default allocator can return data aligned to 8 bytes
36+
#if defined(__APPLE__)
37+
return alignment > 8u;
3538
//GCC-clang on Mingw-w64 has problems with malloc (MSVCRT / UCRT) alignment not matching
3639
//__STDCPP_DEFAULT_NEW_ALIGNMENT__, since HeapAlloc alignment is 8 for 32 bit targets
37-
#if !defined(__cpp_aligned_new) || (defined(_WIN32) && !defined(_WIN64) && !defined(_MSC_VER))
38-
return alignment > 2u*sizeof(void*);
40+
#elif !defined(__cpp_aligned_new) || (defined(_WIN32) && !defined(_WIN64) && !defined(_MSC_VER))
41+
return alignment > 2*sizeof(void*);
3942
#else
4043
return alignment > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
4144
#endif
4245
}
4346

44-
BOOST_CONTAINER_FORCEINLINE bool operator_new_raw_overaligned_tricky()
45-
{
46-
//GCC-clang on Mingw-w64 has problems with malloc (MSVCRT / UCRT) alignment not matching
47-
//__STDCPP_DEFAULT_NEW_ALIGNMENT__, since HeapAlloc alignment is 8 for 32 bit targets
48-
#if !defined(__cpp_aligned_new) || (defined(_WIN32) && !defined(_WIN64) && !defined(_MSC_VER))
49-
return true;
50-
#else
51-
return false;
52-
#endif
53-
}
54-
5547
BOOST_CONTAINER_FORCEINLINE void* operator_new_raw_allocate(const std::size_t size, const std::size_t alignment)
5648
{
5749
(void)alignment;

0 commit comments

Comments
 (0)