From 5f40b96c3509d1442cd7373894c108eeed30c2ed Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 29 Nov 2022 16:14:13 -0500 Subject: [PATCH] libroot: Adjust malloc_hoard2 to use max_align_t when available. Spotted while investigating #18111, but likely does not fix it. This matches the existing behavior of the runtime_loader heap. --- src/system/libroot/posix/malloc_hoard2/heap.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/system/libroot/posix/malloc_hoard2/heap.h b/src/system/libroot/posix/malloc_hoard2/heap.h index 42e9eb456e..4a4b49f521 100644 --- a/src/system/libroot/posix/malloc_hoard2/heap.h +++ b/src/system/libroot/posix/malloc_hoard2/heap.h @@ -23,6 +23,7 @@ #define _HEAP_H_ #include +#include #include "config.h" @@ -75,10 +76,10 @@ class hoardHeap { #endif // Every object is aligned so that it can always hold any type. -#ifdef __x86_64__ - enum { ALIGNMENT = 16 }; -#else - enum { ALIGNMENT = sizeof(double) }; +#if __cplusplus >= 201103L + enum { ALIGNMENT = alignof(max_align_t) }; +#else + enum { ALIGNMENT = 8 }; #endif // ANDing with this rounds to ALIGNMENT.