From: Rhys Perry Date: Wed, 8 Sep 2021 15:13:01 +0000 (+0100) Subject: util/ralloc: add HEADER_ALIGN macro X-Git-Tag: upstream/22.3.5~3988 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9bd7b0b305f9075ed2fc491edec73a2a6dfa15e5;p=platform%2Fupstream%2Fmesa.git util/ralloc: add HEADER_ALIGN macro Signed-off-by: Rhys Perry Reviewed-by: Jason Ekstrand Reviewed-by: Emma Anholt Part-of: --- diff --git a/src/util/ralloc.c b/src/util/ralloc.c index 3574065..0d57a60 100644 --- a/src/util/ralloc.c +++ b/src/util/ralloc.c @@ -36,6 +36,12 @@ #define CANARY 0x5A1106 +#if defined(__LP64__) || defined(_WIN64) +#define HEADER_ALIGN alignas(16) +#else +#define HEADER_ALIGN alignas(8) +#endif + /* Align the header's size so that ralloc() allocations will return with the * same alignment as a libc malloc would have (8 on 32-bit GLIBC, 16 on * 64-bit), avoiding performance penalities on x86 and alignment faults on @@ -43,11 +49,7 @@ */ struct ralloc_header { -#if defined(__LP64__) || defined(_WIN64) - alignas(16) -#else - alignas(8) -#endif + HEADER_ALIGN #ifndef NDEBUG /* A canary value used to determine whether a pointer is ralloc'd. */ @@ -550,12 +552,7 @@ ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt, struct linear_header { - /* align first member to align struct */ -#if defined(__LP64__) || defined(_WIN64) - alignas(16) -#else - alignas(8) -#endif + HEADER_ALIGN #ifndef NDEBUG unsigned magic; /* for debugging */