From nobody Tue Oct 28 02:12:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515087677876220.99932920463687; Thu, 4 Jan 2018 09:41:17 -0800 (PST) Received: from localhost ([::1]:55164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eX9W1-0006gf-1v for importer@patchew.org; Thu, 04 Jan 2018 12:41:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eX9Ud-0005fH-AD for qemu-devel@nongnu.org; Thu, 04 Jan 2018 12:39:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eX9UY-0002h0-Bk for qemu-devel@nongnu.org; Thu, 04 Jan 2018 12:39:51 -0500 Received: from gw01.mail.saunalahti.fi ([195.197.172.115]:53329) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eX9UY-0002cj-47 for qemu-devel@nongnu.org; Thu, 04 Jan 2018 12:39:46 -0500 Received: from guava.gson.org (a91-152-17-19.elisa-laajakaista.fi [91.152.17.19]) by gw01.mail.saunalahti.fi (Postfix) with ESMTP id 40A6140283; Thu, 4 Jan 2018 19:39:38 +0200 (EET) Received: by guava.gson.org (Postfix, from userid 101) id 21DF198B4A0; Thu, 4 Jan 2018 19:39:37 +0200 (EET) MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID: <23118.26328.811644.330716@guava.gson.org> Date: Thu, 4 Jan 2018 19:39:36 +0200 To: qemu-devel@nongnu.org From: Andreas Gustafsson X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 195.197.172.115 Subject: [Qemu-devel] [PATCH] oslib-posix: check for posix_memalign in configure script X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kamil Rytarowski Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Kamil Rytarowski Reviewed-by: Peter Maydell --- configure | 19 +++++++++++++++++++ util/oslib-posix.c | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 100309c33f..9f8580332a 100755 --- a/configure +++ b/configure @@ -4573,6 +4573,21 @@ if compile_prog "" "" ; then posix_madvise=3Dyes fi =20 +########################################## +# check if we have posix_memalign() + +posix_memalign=3Dno +cat > $TMPC << EOF +#include +int main(void) { + void *p; + return posix_memalign(&p, 8, 8); +} +EOF +if compile_prog "" "" ; then + posix_memalign=3Dyes +fi + ########################################## # check if we have posix_syslog =20 @@ -5542,6 +5557,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" @@ -6015,6 +6031,9 @@ fi if test "$posix_madvise" =3D "yes" ; then echo "CONFIG_POSIX_MADVISE=3Dy" >> $config_host_mak fi +if test "$posix_memalign" =3D "yes" ; then + echo "CONFIG_POSIX_MEMALIGN=3Dy" >> $config_host_mak +fi =20 if test "$spice" =3D "yes" ; then echo "CONFIG_SPICE=3Dy" >> $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 =3D sizeof(void*); } =20 -#if defined(_POSIX_C_SOURCE) && !defined(__sun__) +#if defined(CONFIG_POSIX_MEMALIGN) int ret; ret =3D posix_memalign(&ptr, alignment, size); if (ret !=3D 0) { --=20 2.15.1