⛏️ index : haiku.git

author Augustin Cavalier <waddlesplash@gmail.com> 2022-11-29 16:14:13.0 -05:00:00
committer waddlesplash <waddlesplash@gmail.com> 2022-11-29 21:16:23.0 +00:00:00
commit
a261ec2dc9810f591e32a0c46bfaa6e5ed87ddc3 [patch]
tree
806507a0ddffd88e7fdd3e19764d5961cf3065c8
parent
2f119b82171a3d65fd98f0e8bff7cd6999246bd9
download
a261ec2dc9810f591e32a0c46bfaa6e5ed87ddc3.tar.gz

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.
(cherry picked from commit 5f40b96c3509d1442cd7373894c108eeed30c2ed)

Change-Id: I85a60309585ffeec8ab558b899a7782e8da5a413
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5841
Reviewed-by: waddlesplash <waddlesplash@gmail.com>

Diff

 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 42e9eb4..4a4b49f 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 <OS.h>
#include <cstddef>

#include "config.h"

@@ -75,10 +76,10 @@
#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.