1
0
Fork 0
mirror of https://github.com/yuzu-emu/unicorn.git synced 2025-04-01 17:36:51 +00:00

oslib-posix: check for posix_memalign in configure script

Check for the presence of posix_memalign() in the configure script,
not using "defined(_POSIX_C_SOURCE) && !defined(__sun__)". This
lets qemu use posix_memalign() on NetBSD versions that have it,
instead of falling back to valloc() which is wasteful when the
required alignment is smaller than a page.

Backports commit 9bc5a7193fb422ee53187601eba577ee5d195522 from qemu
This commit is contained in:
Andreas Gustafsson 2018-03-08 08:55:22 -05:00 committed by Lioncash
parent 6a71ff06ca
commit 53dd82a7ca
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 16 additions and 1 deletions

15
qemu/configure vendored
View file

@ -1196,6 +1196,21 @@ if test "$sanitizers" = "yes" ; then
fi
fi
##########################################
# check if we have posix_memalign()
posix_memalign=no
cat > $TMPC << EOF
#include <stdlib.h>
int main(void) {
void *p;
return posix_memalign(&p, 8, 8);
}
EOF
if compile_prog "" "" ; then
posix_memalign=yes
fi
##########################################
# End of CC checks
# After here, no more $cc or $ld runs

View file

@ -84,7 +84,7 @@ void *qemu_try_memalign(size_t alignment, size_t size)
alignment = sizeof(void*);
}
#if defined(_POSIX_C_SOURCE) && !defined(__sun__)
#if defined(CONFIG_POSIX_MEMALIGN)
int ret;
ret = posix_memalign(&ptr, alignment, size);
if (ret != 0) {