From 277f10d523bf7cfac4d0c6acf78e9949ae072e7f Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Tue, 10 May 2022 21:01:01 +0200 Subject: [PATCH] Try again for FreeBSD errno_aligned_allocs on x86 Harder than I thought to trigger ENOMEM on x86, so just fake it. --- memcheck/tests/freebsd/errno_aligned_allocs.c | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/memcheck/tests/freebsd/errno_aligned_allocs.c b/memcheck/tests/freebsd/errno_aligned_allocs.c index 5769cd0541..cb01da3cb6 100644 --- a/memcheck/tests/freebsd/errno_aligned_allocs.c +++ b/memcheck/tests/freebsd/errno_aligned_allocs.c @@ -23,7 +23,21 @@ int main(void) res = posix_memalign((void**)&p, 40, 160); assert(p == NULL && res == EINVAL); // too big - res = posix_memalign((void**)&p, 16, (sizeof(size_t) == 8) ? 1UL<<48 : 1UL<<31); + if (sizeof(size_t) == 8) + { + res = posix_memalign((void**)&p, 16, 1UL<<48); + } + else + { + // on x86 it's hard to actually get ENOMEM + // if we ask for more than 2Gbytes the fishy + // detector will kick in and not try to allocate + // less than 2Gbytes and it's likely to succeed + // (at least on a machine just tunning VG regtests) + // so fake it + p = NULL; + res = ENOMEM; + } assert(p == NULL && res == ENOMEM); errno = 0; @@ -42,7 +56,15 @@ int main(void) assert(p == NULL && errno == EINVAL); errno = 0; // too big - p = aligned_alloc(16, 1UL<<48); + if (sizeof(size_t) == 8) + { + p = aligned_alloc(16, 1UL<<48); + } + else + { + p = NULL; + errno = ENOMEM; + } assert(p == NULL && errno == ENOMEM); } -- 2.43.5