From nobody Mon Feb 9 09:34:27 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=1611625083; cv=none; d=zohomail.com; s=zohoarc; b=asgstz5KK/ewDJDQ2UJe8sDxbazoIe1EPLLe3A9MkxgNuyH07M9my42yX9GF1ewlm4//M4AHiq+erkx9KmZiuN15uMso9ivv7vs0t87hFvWBc0oZCCOTub9bPWohaQWCst4sQNtjF67jjQdw+GyqNM3J+mMzwRXTwiqCleaNzv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611625083; 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=ZzmHFyXlP5/KrRaHfZyIdZ8AtHEAE4XS8ZnHs3BGWFho+wYR6IwZkvAkc/LTFEpnhtBHUsxeKPIS9iOWUPF4gC3UbA9SM19L6edY+UupZze5iH03Nt0+xJzkUJ5lxFYqHSHsCVFJRt7jwK6YAP/i7W/YHgDuV5OKSzaWDBYxSmY= 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 1611625083794823.6627023563462; Mon, 25 Jan 2021 17:38:03 -0800 (PST) Received: from localhost ([::1]:59236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4DIw-0006XM-7C for importer@patchew.org; Mon, 25 Jan 2021 20:38:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4D6Z-0005gR-9H; Mon, 25 Jan 2021 20:25:23 -0500 Received: from mail-pl1-f177.google.com ([209.85.214.177]:42719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l4D6V-0006Am-GA; Mon, 25 Jan 2021 20:25:14 -0500 Received: by mail-pl1-f177.google.com with SMTP id s15so8752881plr.9; Mon, 25 Jan 2021 17:25:09 -0800 (PST) Received: from Yifans-Mac-Mini.hsd1.ca.comcast.net. ([98.35.5.7]) by smtp.gmail.com with ESMTPSA id o14sm536921pjf.12.2021.01.25.17.25.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jan 2021 17:25:08 -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=SYnXUtKRB7/LC1fOxpyz84XTZ/oSDUqH0qLueMEyrOoRg5/eus797NHb+4k02JJMit 1sMSmUQa/hE4PmGXxVXE2GeZRBtj/J/zf8GuZmdXw/bfObAU1PNL1szScE0ZMAgGe+39 N+oYxgGxdlF87rrkgoZCT+8JH/B8dZCL5QkKbIZJKyDPBw3fCBPNYfdAG21fsLQiTJPz BuSb6+WmFmwB/Xmt6ecDrbSTF83WO1r0RXjBWxTsI9ordgQ2mOBaqnP+QkYsGmd1N7/B u45VW2sdK7fQq1ZuCvYZLvlP85XNTOV4WHRQS9GyIC6iUO/Sszj/WztlIskM55zMUcy4 Alzw== X-Gm-Message-State: AOAM530nw+KIKymNI9vxMdabG/40aJXYclTk5mqW0uZa2mHDQYmAl+xE XtbTNbhLTl7osXUPP02r8HDjH3GrUMI= X-Google-Smtp-Source: ABdhPJyKKMRn0HYFtKap+uZVeCjOIwGAZolK2QJ18x5mqYpRdFw1dEpjbuixpWXJ54LThVzzo5gxrA== X-Received: by 2002:a17:90b:224f:: with SMTP id hk15mr3161546pjb.31.1611624308711; Mon, 25 Jan 2021 17:25:08 -0800 (PST) From: Joelle van Dyne To: qemu-devel@nongnu.org Subject: [PATCH v9 09/11] block: check availablity for preadv/pwritev on mac Date: Mon, 25 Jan 2021 17:24:55 -0800 Message-Id: <20210126012457.39046-10-j@getutm.app> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210126012457.39046-1-j@getutm.app> References: <20210126012457.39046-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.214.177; envelope-from=osy86github@gmail.com; helo=mail-pl1-f177.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.25, 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