mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00

The main multiarch tests should compile for any POSIX system, however test-vma's usage of MAP_NORESERVE makes it a linux-only test. Simply moving the source file is enough for the build logic to skip on BSD's. Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20250304222439.2035603-14-alex.bennee@linaro.org>
22 lines
557 B
C
22 lines
557 B
C
/*
|
|
* Test very large vma allocations.
|
|
* The qemu out-of-memory condition was within the mmap syscall itself.
|
|
* If the syscall actually returns with MAP_FAILED, the test succeeded.
|
|
*/
|
|
#include <sys/mman.h>
|
|
|
|
int main()
|
|
{
|
|
int n = sizeof(size_t) == 4 ? 32 : 45;
|
|
|
|
for (int i = 28; i < n; i++) {
|
|
size_t l = (size_t)1 << i;
|
|
void *p = mmap(0, l, PROT_NONE,
|
|
MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
|
|
if (p == MAP_FAILED) {
|
|
break;
|
|
}
|
|
munmap(p, l);
|
|
}
|
|
return 0;
|
|
}
|