diff --git a/include/stddef.h b/include/stddef.h index a597c9bb..8983a320 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 Danny Milosavljevic * * This file is part of GNU Mes. * @@ -37,6 +38,10 @@ #endif // !__MESC__ #endif // offsetof +/* Note: on banana gcc, max_align_t is 16 Byte big instead! */ + +typedef double max_align_t; + #endif // ! SYSTEM_LIBC #endif // __MES_STDDEF_H diff --git a/lib/stdlib/malloc.c b/lib/stdlib/malloc.c index f4be4de1..54f89af4 100644 --- a/lib/stdlib/malloc.c +++ b/lib/stdlib/malloc.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 Danny Milosavljevic * * This file is part of GNU Mes. * @@ -20,6 +21,8 @@ #include #include +#include +#include /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. Therfore we cannot remove stdlib/malloc from libc_SOURCES, which is @@ -37,6 +40,9 @@ malloc (size_t size) { if (!__brk) __brk = (char *) brk (0); + /* align what we give back. */ + __brk = (char*) (((uintptr_t) __brk + + sizeof (max_align_t) - 1) & -sizeof (max_align_t)); if (brk (__brk + size) == -1) return 0; char *p = __brk;