[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PULL 11/17] oslib-posix: check for posix_memalign in con
From: |
Michael Tokarev |
Subject: |
[Qemu-trivial] [PULL 11/17] oslib-posix: check for posix_memalign in configure script |
Date: |
Sat, 10 Feb 2018 10:55:06 +0300 |
From: Andreas Gustafsson <address@hidden>
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.
Signed-off-by: Andreas Gustafsson <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
Reviewed-by: Kamil Rytarowski <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
---
configure | 19 +++++++++++++++++++
util/oslib-posix.c | 2 +-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index c1bbf17559..fe9eea9218 100755
--- a/configure
+++ b/configure
@@ -4659,6 +4659,21 @@ if compile_prog "" "" ; then
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
+
+##########################################
# check if we have posix_syslog
posix_syslog=no
@@ -5746,6 +5761,7 @@ echo "preadv support $preadv"
echo "fdatasync $fdatasync"
echo "madvise $madvise"
echo "posix_madvise $posix_madvise"
+echo "posix_memalign $posix_memalign"
echo "libcap-ng support $cap_ng"
echo "vhost-net support $vhost_net"
echo "vhost-scsi support $vhost_scsi"
@@ -6232,6 +6248,9 @@ fi
if test "$posix_madvise" = "yes" ; then
echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
fi
+if test "$posix_memalign" = "yes" ; then
+ echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
+fi
if test "$spice" = "yes" ; then
echo "CONFIG_SPICE=y" >> $config_host_mak
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 77369c92ce..4655bc1f89 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -105,7 +105,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) {
--
2.11.0
- [Qemu-trivial] [PULL 02/17] scripts/argparse.py: spelling (independant), (continued)
- [Qemu-trivial] [PULL 02/17] scripts/argparse.py: spelling (independant), Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 01/17] qapi-schema.json: spelling (independant comparation), Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 05/17] mailmap: set preferred spelling for Daniel Berrangé, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 03/17] machine: Polish -machine xxx,help, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 06/17] qemu-options.hx: Remove confusing spaces in parameter listings, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 15/17] tests/hbitmap: use ARRAY_SIZE macro, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 17/17] tests/qapi: use ARRAY_SIZE macro, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 16/17] tests/qapi: use QEMU_IS_ALIGNED macro, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 10/17] maint: Mention web site maintenance in README, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 13/17] qga: use ARRAY_SIZE macro, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 11/17] oslib-posix: check for posix_memalign in configure script,
Michael Tokarev <=
- [Qemu-trivial] [PULL 12/17] MAINTAINERS: Add qemu-binfmt-conf.sh script, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 09/17] build: fix typo in error message, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 14/17] async: use ARRAY_SIZE macro, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 08/17] configure: Allow capstone=git only if git update is not disabled, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 07/17] scripts/make-release: Don't archive .git files, Michael Tokarev, 2018/02/10
- [Qemu-trivial] [PULL 04/17] Drop unneeded system header includes, Michael Tokarev, 2018/02/10
- Re: [Qemu-trivial] [Qemu-devel] [PULL 00/17] Trivial patches for 2018-02-10, Peter Maydell, 2018/02/12