From patchwork Fri Mar 4 11:21:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548106 Delivered-To: patch@linaro.org Received: by 2002:ac0:f585:0:0:0:0:0 with SMTP id s5csp1251imq; Fri, 4 Mar 2022 03:28:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjIc7Np4jddLI0sIbhddq0HOr4P0cnL5fV+L+b3VVdMLpDn5ZgQyEYUuxVunDEl5ID0hK5 X-Received: by 2002:a25:f306:0:b0:628:9a03:9ab8 with SMTP id c6-20020a25f306000000b006289a039ab8mr12329214ybs.622.1646393285784; Fri, 04 Mar 2022 03:28:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646393285; cv=none; d=google.com; s=arc-20160816; b=mEn7VjOEsR5TKvQ0D7Q8RtKwN6jLBeWyt5/WgMIh4SY9Vql89HElNotX5eQm5bp/lm f0HBIlVs8KJEl4yehlj9WxBptNh/vRka22C4XKObW8L2mdcZNL1mZAORYxeiRsnK8gUk bGA5soAhfj2bbdW4fEvyp8c8YzFRWPU4jy991pOls25xxZXEC3C/Lq+BH0Kbq8kqYEmk lt01DDuv1jEZuBtjLmCAcsyYMCKv/+aEWQBKD8il8MImwsgVnNs3vKWOeXAwQFmT6v4A 0iJowRPmXcdYYYwhe62ckSswzv6it4bVQyuBoD4GNu2qzP8eCSdsMnHiAyQQ/DXjs6r1 uO4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=G4AbYvV6pM/kHUjvkC09aZIGxcMx4nP3w1jg109SqVs=; b=T3KPPyhfutCEiU/ZWzOKkGujYpF12m35zGy+sryKe1E0gll/iuzBqSOCxoXrrek+ex L6QNIlPzc4GWvNmI1z9Wuc/VsC2P2XnPeJQKOmnOh3rS/D9Kvvyk99wYQeoJUE0WcRX3 wlvPc9Lp2SQFqk+8/7Ckrcw8tWB5t8NBULoPCnb3hOi8+230C7Yk17d40O+SPhJoetRX Y9y95HPnvpJEfUM+RgtFIoxzYHT07jWJmoYHLoGgOz3cxGFXDEHaGUqL4PRfHrAmXsi0 E81B1HzN0AStECM8sCiWT17IFFWvXiAoFUl5/cnAtg1uwmDpoyF+HbKIFU7wRnyVnUys 2fpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="P+/pcj2o"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o62-20020a0dfe41000000b002d6fa4d2e52si3559608ywf.335.2022.03.04.03.28.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Mar 2022 03:28:05 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="P+/pcj2o"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ66O-0000k1-Qm for patch@linaro.org; Fri, 04 Mar 2022 06:28:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ60B-0002jq-HM for qemu-devel@nongnu.org; Fri, 04 Mar 2022 06:21:39 -0500 Received: from [2a00:1450:4864:20::32e] (port=40662 helo=mail-wm1-x32e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nQ60A-0004gV-0F for qemu-devel@nongnu.org; Fri, 04 Mar 2022 06:21:39 -0500 Received: by mail-wm1-x32e.google.com with SMTP id bi14-20020a05600c3d8e00b00386f2897400so1249366wmb.5 for ; Fri, 04 Mar 2022 03:21:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G4AbYvV6pM/kHUjvkC09aZIGxcMx4nP3w1jg109SqVs=; b=P+/pcj2oHiPJDuXoicx3lK81eT2PqAkzr6VG2BQZOb3ZVzj1DxDhTsHlArijviaU8B 6pKfqsNYp+yZYKKn7fgQIDIlTmRv1k9yY1ySbcFJFoEg1Ogif3z2FkCBC2dJqfXSusq3 urxo+lVfkw26yyb7LjinazNALrB8/N3+e+q2OixCFuNrW1LHV16335wltPxtJqLyZiCw nuFNhnMeEhIEHmr/MOAyhGePyvofFBLMo2Hk5obcZoDXsUMJNqsfTAXs7G5bpaRMS14O EeTTrXOkpAQ4Xtv8SHTtXi8U0HZJamB5Krjj//G5NELbt5+iTA73n6XT+y/lvJjEgc6x a9sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G4AbYvV6pM/kHUjvkC09aZIGxcMx4nP3w1jg109SqVs=; b=gw4Ox8V4gkOx8b1mVw3KhhZKyonI8jCC3ge/zPRPjxTwYek1eLtnx/voBreIV1Q04d r1k/z30amXMV36g5kWEcR4IHzw7idLh2XJ6Gyalhel/7lYYnh9KRqk/ixSjBWVbTKKfi aGw7NobFJkuDQgQRmt0AgUNutqCrtnAGqfxufR8mqjqoc9SE59ZVtuUXutis2XcO3jDR WDHDicXWFg3uKZpuzi6AYL/mXKCi0pY7DR6oKxWnADBA3O6lt0VLU1VSde3tHUXjDN/+ M5VqKYOq0y1/Jt+GcS2mecNYKBdT3MxqLlAalW0bWnfRdqQHiGVgFy/zgseRU1o8qXl/ FU7Q== X-Gm-Message-State: AOAM533liE2bhrRBJ+LZrwFqYWJy4xr1BLpYYIRIRH6iT2SNp3Csei8M Okpdvq1DjjODDGA3ZtN2QGketNjyviY9Ow== X-Received: by 2002:a05:600c:3596:b0:381:751a:f0a6 with SMTP id p22-20020a05600c359600b00381751af0a6mr7344601wmq.168.1646392896779; Fri, 04 Mar 2022 03:21:36 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id u14-20020adfed4e000000b001e3323611e5sm4148651wro.26.2022.03.04.03.21.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 03:21:36 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH v2 7/9] util: Use meson checks for valloc() and memalign() presence Date: Fri, 4 Mar 2022 11:21:24 +0000 Message-Id: <20220304112126.2261039-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220304112126.2261039-1-peter.maydell@linaro.org> References: <20220304112126.2261039-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32e (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Richard Henderson , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Instead of assuming that all CONFIG_BSD have valloc() and anything else is memalign(), explicitly check for those functions in meson.build and use the "is the function present" define. Tests for specific functionality are better than which-OS checks; this also lets us give a helpful error message if somehow there's no usable function present. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20220226180723.1706285-8-peter.maydell@linaro.org --- meson.build | 2 ++ util/memalign.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index eae0e4febb3..74f4e05c82b 100644 --- a/meson.build +++ b/meson.build @@ -1623,6 +1623,8 @@ config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate' # thinking that Windows has posix_memalign() config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign', prefix: '#include ')) config_host_data.set('CONFIG_ALIGNED_MALLOC', cc.has_function('_aligned_malloc')) +config_host_data.set('CONFIG_VALLOC', cc.has_function('valloc')) +config_host_data.set('CONFIG_MEMALIGN', cc.has_function('memalign')) config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll')) config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include ')) config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads)) diff --git a/util/memalign.c b/util/memalign.c index c3280528d24..2a139a5695d 100644 --- a/util/memalign.c +++ b/util/memalign.c @@ -56,10 +56,12 @@ void *qemu_try_memalign(size_t alignment, size_t size) } #elif defined(CONFIG_ALIGNED_MALLOC) ptr = _aligned_malloc(size, alignment); -#elif defined(CONFIG_BSD) +#elif defined(CONFIG_VALLOC) ptr = valloc(size); -#else +#elif defined(CONFIG_MEMALIGN) ptr = memalign(alignment, size); +#else + #error No function to allocate aligned memory available #endif trace_qemu_memalign(alignment, size, ptr); return ptr;