From nobody Mon Feb 9 06:01:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1611346609; cv=none; d=zohomail.com; s=zohoarc; b=izuUJ1+npIysYkboBIdKiI9HtF/mOpxFDSkVDBqtlEXch5QpA5ybb2FBCwHpjDydqXUJXu2Wgos9r40Z/oxgg8/PU9qTYgSRuFXm0xGbAPe/ndCBl96oMZKD7698cJ/CCWFN0arzglDtgDq2Jp5l8TRpbwIQ9QCdxKuuTi+0HWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611346609; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B3bgTvyMVaMNKOvbfkCeAjPnu2P94ObpQ3L4Z8LkPIk=; b=kHbQjkQXZvqKeL8CJGBFFu734U06/UwcruLnNS/gl0X1x09Kbx4KPdApQRM88QncCSs101v1dibLqbmliyjs2o+vImaqEQMf+fWvKfHiuHZF41BMu4mW8v9GbNnU0vMdAqFuxCWcZraCqvgKHXxpPtDs436XprSRtGWuKLb4Vls= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1611346609819557.9761208244967; Fri, 22 Jan 2021 12:16:49 -0800 (PST) Received: from localhost ([::1]:59324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l32rQ-00034D-HL for importer@patchew.org; Fri, 22 Jan 2021 15:16:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l32mG-000511-Bi; Fri, 22 Jan 2021 15:11:28 -0500 Received: from mail-pf1-f182.google.com ([209.85.210.182]:40943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l32mE-0004cv-QX; Fri, 22 Jan 2021 15:11:28 -0500 Received: by mail-pf1-f182.google.com with SMTP id i63so4549951pfg.7; Fri, 22 Jan 2021 12:11:26 -0800 (PST) Received: from localhost.localdomain ([73.93.152.129]) by smtp.gmail.com with ESMTPSA id u12sm8741839pgi.91.2021.01.22.12.11.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jan 2021 12:11:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B3bgTvyMVaMNKOvbfkCeAjPnu2P94ObpQ3L4Z8LkPIk=; b=Y0J4RsFAifHC2lIaWdIBucyYGnMM5ATHnp9xlJsOMyzXElk8htBtXtGc8dPzIYQbBJ iTyma/aliTf24pBt2CWPlvPUedIumRZrUGcy8PTk2rDN2iZXGUtnwKg7mIF68KnJ+eg9 YDGxJsbnVA+7R5cog1uiLJ7EpqLpbXcvj8cqT4HqvDWxJmoQcmkQHROrIb6McWfiAef8 /UIRl4SixaeYA75z4NXxYfa15LS1bfyljmN7paVydfInt8abw7YWBiZMMc1EeYlCotNd 7/CV8Yq0RntoQXaqxiuFQswz12wFtaVMxsGSDBWVTLsEzgh633Qzpz14BqZEZYXJS+fg tUgg== X-Gm-Message-State: AOAM533TSvR28oJ51wyvCZ7HvTfEoxptVQaP09Qu/zrJED4WDZ3LUIEZ r0H63nhcN2V7Qz3tjGpJwAICgoyZd0U= X-Google-Smtp-Source: ABdhPJxBrXNtWSd3gd/yJoTymIBbNHd6W04dZW2VpE6niu6fkfTktaNFOPMSuEyTG/zGiyXI8K+QGg== X-Received: by 2002:a63:749:: with SMTP id 70mr6469704pgh.182.1611346284972; Fri, 22 Jan 2021 12:11:24 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v7 09/11] block: check availablity for preadv/pwritev on mac Date: Fri, 22 Jan 2021 12:11:11 -0800 Message-Id: <20210122201113.63788-10-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210122201113.63788-1-j@getutm.app> References: <20210122201113.63788-1-j@getutm.app> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=209.85.210.182; envelope-from=osy86github@gmail.com; helo=mail-pf1-f182.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Joelle van Dyne , "open list:raw" , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" macOS 11/iOS 14 added preadv/pwritev APIs. Due to weak linking, configure will succeed with CONFIG_PREADV even when targeting a lower OS version. We therefore need to check at run time if we can actually use these APIs. Signed-off-by: Joelle van Dyne --- block/file-posix.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index 666d3e7504..6473f84db8 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1386,17 +1386,50 @@ static int handle_aiocb_flush(void *opaque) #ifdef CONFIG_PREADV =20 static bool preadv_present =3D true; +static bool preadv_checked; =20 static ssize_t qemu_preadv(int fd, const struct iovec *iov, int nr_iov, off_t offset) { +#ifdef CONFIG_DARWIN /* preadv introduced in macOS 11 */ + if (unlikely(!preadv_checked)) { + if (__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) { + preadv_checked =3D true; + } else { + preadv_present =3D false; + return -ENOSYS; + } + } + /* Now we suppress the availability warning since we use the cached ch= eck */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability-new" + return preadv(fd, iov, nr_iov, offset); +#pragma clang diagnostic pop +#else /* CONFIG_DARWIN */ return preadv(fd, iov, nr_iov, offset); +#endif } =20 static ssize_t qemu_pwritev(int fd, const struct iovec *iov, int nr_iov, off_t offset) { +#ifdef CONFIG_DARWIN /* preadv introduced in macOS 11 */ + if (unlikely(!preadv_checked)) { + if (__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) { + preadv_checked =3D true; + } else { + preadv_present =3D false; + return -ENOSYS; + } + } + /* Now we suppress the availability warning since we use the cached ch= eck */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability-new" + return pwritev(fd, iov, nr_iov, offset); +#pragma clang diagnostic pop +#else /* CONFIG_DARWIN */ return pwritev(fd, iov, nr_iov, offset); +#endif } =20 #else --=20 2.28.0