From patchwork Fri Mar 18 13:23:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 552617 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp2082733mag; Fri, 18 Mar 2022 06:38:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYPfn3yJ2zBzYJtkCXsiI99Bb2PpIvBHZvoCsYKzQNJ2T1GSqGFvfVVDhUCBOaHBlMCTWn X-Received: by 2002:ad4:4eeb:0:b0:435:b435:81f4 with SMTP id dv11-20020ad44eeb000000b00435b43581f4mr6990363qvb.35.1647610703927; Fri, 18 Mar 2022 06:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647610703; cv=none; d=google.com; s=arc-20160816; b=zasllCbN0w3PYvMEsHZvAyGRU2D0r11JSr6k0cRDZYPEue0zSelAuzjzuXbxqHsa/3 +PPAHkrHUQ3Sl8MKfBX1t7GAOEQQEyTZ2XkJE801XHjhgk+Gh1aF33selCeAnxFfTO3q LgENzRhZr416fGPxZ5uzPG1HnGgeoE3tnF0Q2vVyaTveunshAKE9fn5jbhelJmtQPjVJ T0eAfp2JB7KW5qkMBdDMlegsxT22rIobwHsNrbYpaU1AXrxIFm2VJzEiILteOj5d94f4 NSRc7tX6i3GO7ctkXKSR5vliRa82HFM2eRwUOL2WnHGic5/E0RPS3qpOFbsgXgIe8HPW j47Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=n35AFs9v+Ihl4A7Mb9rzofI88nppswgEUkv1KZhYPHc=; b=EmgGW5Q5w3Bz6tyPWTbOPKFRpxpCNN4FTavLDP/4byjOxdb4Gok8dgiLkqJspWIDtR VxCADt+7WCWSAKM9VBffNCXDn/ijD48UoaxGh4dx2eNP8rfygTr0/jtWPZrCJ640+P/+ Ds+mJicgCL/YumavG7c92nAIlWl+gWV8ipqRKoOq6z4SmBA4I6wpLLSU8UFr1/m5srSy btXaqUF7fQV4Yo4SALNzlJ92rgcx62E1uUegQycVYlgKwnYz9693HM17sJwliYmMW5XN 18ukbxf2OUFcEqMCqE+jIFmAyK/Ons4gNYy281w8njSkdrk5JM5rv7A8vVPBch11SVSI crkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MF0qHKz6; 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=pass (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 p73-20020a37a64c000000b0067d31bf0fd7si2271498qke.226.2022.03.18.06.38.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Mar 2022 06:38:23 -0700 (PDT) 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=pass header.i=@linaro.org header.s=google header.b=MF0qHKz6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVCoB-0006HZ-Gs for patch@linaro.org; Fri, 18 Mar 2022 09:38:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVCZn-00070A-GK for qemu-devel@nongnu.org; Fri, 18 Mar 2022 09:23:31 -0400 Received: from [2a00:1450:4864:20::42e] (port=44827 helo=mail-wr1-x42e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVCZl-0002DZ-Jf for qemu-devel@nongnu.org; Fri, 18 Mar 2022 09:23:31 -0400 Received: by mail-wr1-x42e.google.com with SMTP id b19so11707093wrh.11 for ; Fri, 18 Mar 2022 06:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=n35AFs9v+Ihl4A7Mb9rzofI88nppswgEUkv1KZhYPHc=; b=MF0qHKz6LZjiTfC6dZiKNhrdfrgYHVsQWEPeTP56KL9TgZZR7CvLyOZ9kyZKH8m1p/ ThfcQ0AMMnw1TDV9fPOeSqUcXlqSyqkEhPCXohORxJKhycdsroyoQgNovPz1Lsdc5KAJ l2LXcA0IwJELwuJruhczv01RdFBzVasylMhs3J5sAza/9S37T4pzL7QzNMJCrFk4z4HU pfB8gnwkdk9wXTRbGb3mJN3wicmZuZXJSNI1bzih5cxMKgkGo1KNIc58NgTe1398T90J IoDjjnTnuZOytl8nxeUGXlFNuWUs+bXW2LzFIpnKcDMBZf6mFG5lQQaiUJz+zKkrIK/b uzuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n35AFs9v+Ihl4A7Mb9rzofI88nppswgEUkv1KZhYPHc=; b=fg7yWC4qFi+Vw6cCfIUdGsHoSnlSJXUfZD+cRTdwb46BApsxoLVJGB/Vlbul0hh1cF ss5XDxOMrViXK3Ci9Acj828zC6lk2dweb3p3Q90GMOnM/k0rh5zHUXp0MGqJlM3e49QF 1WoAGiCHpPpPj06nYu3cG/+A2aKhLVpt0rvXXpBtZMMBLFz1qeHenaWtgxSkutlPMcVX WSbNP3MBV+Yf6LmPnHKj40720BqtXCFaKkTn2HJrTQf5E+1YdIdT3T5N/HgUqb6zveQM nD0SvbFBtl06uRcpzfXlFIjMQEiEbV3cIdJEIh6SQ00qWWuMLLHooF4tNLtxqVEqtL+S E7DQ== X-Gm-Message-State: AOAM530KFB/2h14oxMaKHYhyJviJt33/O/j6pKCJ33tVamd6WKp0JLJV FCwFITs/adnFY/0OZRVNswzFQ0OuYqG/fw== X-Received: by 2002:adf:9d8f:0:b0:1f1:e72e:72c with SMTP id p15-20020adf9d8f000000b001f1e72e072cmr7869784wre.561.1647609808264; Fri, 18 Mar 2022 06:23:28 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id y15-20020a05600015cf00b00203e324347bsm6316599wry.102.2022.03.18.06.23.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Mar 2022 06:23:27 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 19/21] util/osdep: Avoid madvise proto on modern Solaris Date: Fri, 18 Mar 2022 13:23:04 +0000 Message-Id: <20220318132306.3254960-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220318132306.3254960-1-peter.maydell@linaro.org> References: <20220318132306.3254960-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42e (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Andrew Deason On older Solaris releases (before Solaris 11), we didn't get a prototype for madvise, and so util/osdep.c provides its own prototype. Some time between the public Solaris 11.4 release and Solaris 11.4.42 CBE, we started getting an madvise prototype that looks like this: extern int madvise(void *, size_t, int); which conflicts with the prototype in util/osdeps.c. Instead of always declaring this prototype, check if we're missing the madvise() prototype, and only declare it ourselves if the prototype is missing. Move the prototype to include/qemu/osdep.h, the normal place to handle platform-specific header quirks. The 'missing_madvise_proto' meson check contains an obviously wrong prototype for madvise. So if that code compiles and links, we must be missing the actual prototype for madvise. Signed-off-by: Andrew Deason Message-id: 20220316035227.3702-2-adeason@sinenomine.net Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- meson.build | 23 +++++++++++++++++++++-- include/qemu/osdep.h | 8 ++++++++ util/osdep.c | 3 --- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index bae62efc9c3..282e7c46505 100644 --- a/meson.build +++ b/meson.build @@ -1715,11 +1715,30 @@ config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + ''' #error Not supported #endif }''')) -config_host_data.set('CONFIG_MADVISE', cc.links(gnu_source_prefix + ''' + +has_madvise = cc.links(gnu_source_prefix + ''' #include #include #include - int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }''')) + int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }''') +missing_madvise_proto = false +if has_madvise + # Some platforms (illumos and Solaris before Solaris 11) provide madvise() + # but forget to prototype it. In this case, has_madvise will be true (the + # test program links despite a compile warning). To detect the + # missing-prototype case, we try again with a definitely-bogus prototype. + # This will only compile if the system headers don't provide the prototype; + # otherwise the conflicting prototypes will cause a compiler error. + missing_madvise_proto = cc.links(gnu_source_prefix + ''' + #include + #include + #include + extern int madvise(int); + int main(void) { return madvise(0); }''') +endif +config_host_data.set('CONFIG_MADVISE', has_madvise) +config_host_data.set('HAVE_MADVISE_WITHOUT_PROTOTYPE', missing_madvise_proto) + config_host_data.set('CONFIG_MEMFD', cc.links(gnu_source_prefix + ''' #include int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }''')) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 322103aadbd..f2274b24cbf 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -400,6 +400,14 @@ void qemu_anon_ram_free(void *ptr, size_t size); #define SIGIO SIGPOLL #endif +#ifdef HAVE_MADVISE_WITHOUT_PROTOTYPE +/* + * See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for discussion + * about Solaris missing the madvise() prototype. + */ +extern int madvise(char *, size_t, int); +#endif + #if defined(CONFIG_LINUX) #ifndef BUS_MCEERR_AR #define BUS_MCEERR_AR 4 diff --git a/util/osdep.c b/util/osdep.c index 7c4deda6feb..1825399bcf5 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -28,9 +28,6 @@ #ifdef CONFIG_SOLARIS #include -/* See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for - discussion about Solaris header problems */ -extern int madvise(char *, size_t, int); #endif #include "qemu-common.h"