From dc8af61b5a6dbf0b3887ff09f194a38e12c5c3cc Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Sun, 5 Mar 2023 16:30:44 +0100 Subject: [PATCH] Linux musl: alligned_alloc accepts alignment of zero --- coregrind/m_replacemalloc/vg_replace_malloc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index b00d33d497..c781da5989 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -1938,6 +1938,11 @@ extern int *___errno (void) __attribute__((weak)); #define VG_ALIGNED_ALLOC_ALIGN_FACTOR_FOUR 0 #endif +#if defined(MUSL_LIBC) +#define VG_ALIGNED_ALLOC_SIZE_ZERO 0 +#else +#define VG_ALIGNED_ALLOC_SIZE_ZERO 1 +#endif #if defined (VGO_linux) && !defined(MUSL_LIBC) @@ -1979,7 +1984,7 @@ extern int *___errno (void) __attribute__((weak)); \ MALLOC_TRACE("aligned_alloc(al %llu, size %llu)", \ (ULong)alignment, (ULong)size ); \ - if (alignment == 0 \ + if (VG_ALIGNED_ALLOC_SIZE_ZERO && (alignment == 0) \ || (VG_ALIGNED_ALLOC_SIZE_MULTIPLE_ALIGN && (size % alignment != 0)) \ || (VG_ALIGNED_ALLOC_ALIGN_POWER_TWO && (alignment & (alignment - 1)) != 0) \ || (VG_ALIGNED_ALLOC_ALIGN_FACTOR_FOUR && (alignment % 4 != 0))) { \ -- 2.43.5