tests/gvariant.c: ensure posix_memalign alignment argument is correct

posix_memalign() requires the alignment to be a multiple of sizeof(void*),
and a power of 2. Passing 8 does not fulfil both of those constraints on
Arm Morello which resulted in a "posix_memalign failed" test failure.

Co-authored-by: Graeme Jenkinson <graeme@capabilitieslimited.co.uk>
This commit is contained in:
Alex Richardson 2022-12-14 23:55:20 +00:00
parent ded3099afc
commit 34236af33c

View File

@ -1340,7 +1340,9 @@ align_malloc (gsize size)
gpointer mem;
#ifdef HAVE_POSIX_MEMALIGN
if (posix_memalign (&mem, 8, size))
/* posix_memalign() requires the alignment to be a multiple of
* sizeof(void*), and a power of 2. */
if (posix_memalign (&mem, MAX (sizeof (void *), 8), size))
g_error ("posix_memalign failed");
#else
/* NOTE: there may be platforms that lack posix_memalign() and also