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.
This commit is contained in:
Augustin Cavalier 2022-11-29 16:14:13 -05:00
parent 7255d28854
commit 5f40b96c35

View File

@ -23,6 +23,7 @@
#define _HEAP_H_
#include <OS.h>
#include <cstddef>
#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.