Make an exception to MacOs platforms, where system malloc only aligns to 8 bytes, even in ARM64.

This commit is contained in:
Ion Gaztañaga
2025-12-26 14:17:45 +01:00
parent d8620c7784
commit e19e121cf4

View File

@@ -32,26 +32,18 @@ namespace dtl {
BOOST_CONTAINER_FORCEINLINE bool operator_new_raw_overaligned(std::size_t alignment)
{
//In MacOs, the default allocator can return data aligned to 8 bytes
#if defined(__APPLE__)
return alignment > 8u;
//GCC-clang on Mingw-w64 has problems with malloc (MSVCRT / UCRT) alignment not matching
//__STDCPP_DEFAULT_NEW_ALIGNMENT__, since HeapAlloc alignment is 8 for 32 bit targets
#if !defined(__cpp_aligned_new) || (defined(_WIN32) && !defined(_WIN64) && !defined(_MSC_VER))
return alignment > 2u*sizeof(void*);
#elif !defined(__cpp_aligned_new) || (defined(_WIN32) && !defined(_WIN64) && !defined(_MSC_VER))
return alignment > 2*sizeof(void*);
#else
return alignment > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
#endif
}
BOOST_CONTAINER_FORCEINLINE bool operator_new_raw_overaligned_tricky()
{
//GCC-clang on Mingw-w64 has problems with malloc (MSVCRT / UCRT) alignment not matching
//__STDCPP_DEFAULT_NEW_ALIGNMENT__, since HeapAlloc alignment is 8 for 32 bit targets
#if !defined(__cpp_aligned_new) || (defined(_WIN32) && !defined(_WIN64) && !defined(_MSC_VER))
return true;
#else
return false;
#endif
}
BOOST_CONTAINER_FORCEINLINE void* operator_new_raw_allocate(const std::size_t size, const std::size_t alignment)
{
(void)alignment;