From patchwork Tue Apr 13 12:48:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 12200499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86839C43460 for ; Tue, 13 Apr 2021 12:49:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A0AD611CE for ; Tue, 13 Apr 2021 12:49:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A0AD611CE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lWIUK-0002zV-7A for qemu-devel@archiver.kernel.org; Tue, 13 Apr 2021 08:49:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lWISc-0001WA-3I for qemu-devel@nongnu.org; Tue, 13 Apr 2021 08:48:06 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:33349) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lWISa-0001pp-Ef for qemu-devel@nongnu.org; Tue, 13 Apr 2021 08:48:05 -0400 Received: by mail-ej1-x62a.google.com with SMTP id g5so19011958ejx.0 for ; Tue, 13 Apr 2021 05:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e+0DU0nssNE9Dqd2GnOeTqteOT/NqCeugXBt1xrlSO8=; b=Myr/QPM908xZ9uB0eO0WhE1EeGAeJYHtDjcGS/DJLLeO8be32IwJXECLY+7IC8LbW1 X6Uy1jpJ4RaOlwF+7kV/H4gri1AzkrM6Cb1e7B29yneXeHwJ9lZkjw8qgzKvAT6xch6X avs2gBH+RdgRCBcxfKIRLiF428r7O65l4WiyWbeLNW9eCpjeUWMFy4RS9AwDkrsT89Vu 9y0ea/09VPN5r3+HcHpLzWjkyaoMSeAmC+SedMEU2JKEW1ys0FOOhq12XAm1cOmm+VJZ sIuRt+kT52vFlem4iMbH3EGuf+BuRJJBoEPcdhbYNIv7tMzEEtAt0pOTSVgG+BK0feem PBfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=e+0DU0nssNE9Dqd2GnOeTqteOT/NqCeugXBt1xrlSO8=; b=BpaYp549Ss6559jNxxCYmJ5HuWC4S2tgkmzDbzx0kWv4Xx+Zest8KGbT2zWyEzbqMI Lx4Ll9nmMnh0veME8EfH2okY23hTWJD3Q9jEcjK9JvFd2adG0hNJzrLzVBBRMNP9lzcy SQkWOLo++d36X2lztwYChcvvHYXuhPH8myiWRcrgUIhCuCeDUXTV4sR4B4ZOvCEKG69d ugFwhjFZ8Rq3VGVJeiSbnP6VH45W0jBywpDXYhlXNAQ9kH24IJhTvaIS3ol6EoAEDZmT mYZLRelJ4mdrAyuGxW8rkmpMJ4SPpvakWhyTWhHySdH+JyF/SD3M9EClh2yMvy4VeoDc i5EQ== X-Gm-Message-State: AOAM530aqCIH5kPff3ZRSS4dJnjIkS1Wcd+BNPdOBUe7m4mnBJ9Xsc6+ BNZqCqwMc8XXCqhMTaRnp8IuDfQ9C3U= X-Google-Smtp-Source: ABdhPJzR367tlnlugoj9j4F8s6uadtsWQ1pW/GRPIqF6Hxx9rerK6zNgWzlxWK3tw4B4MMRmyxHwNw== X-Received: by 2002:a17:906:a45a:: with SMTP id cb26mr6591680ejb.537.1618318083149; Tue, 13 Apr 2021 05:48:03 -0700 (PDT) Received: from avogadro.redhat.com ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id s9sm8635961edd.16.2021.04.13.05.48.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 05:48:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 2/2] osdep: protect qemu/osdep.h with extern "C" Date: Tue, 13 Apr 2021 14:48:00 +0200 Message-Id: <20210413124800.216095-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210413124800.216095-1-pbonzini@redhat.com> References: <20210413124800.216095-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" System headers may include templates if compiled with a C++ compiler, which cause the compiler to complain if qemu/osdep.h is included within a C++ source file's 'extern "C"' block. Add an 'extern "C"' block directly to qemu/osdep.h, so that system headers can be kept out of it. There is a stray declaration early in qemu/osdep.h, which needs to be special cased. Add a definition in qemu/compiler.h to make it look nice. config-host.h, CONFIG_TARGET, exec/poison.h and qemu/compiler.h are included outside the 'extern "C"' block; that is not an issue because they consist entirely of preprocessor directives. Signed-off-by: Paolo Bonzini --- disas/nanomips.cpp | 2 +- include/qemu/compiler.h | 6 ++++++ include/qemu/osdep.h | 10 +++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp index 2b09655271..8ddef897f0 100644 --- a/disas/nanomips.cpp +++ b/disas/nanomips.cpp @@ -27,8 +27,8 @@ * Reference Manual", Revision 01.01, April 27, 2018 */ -extern "C" { #include "qemu/osdep.h" +extern "C" { #include "disas/dis-asm.h" } diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index cf28bb2bcd..091c45248b 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -11,6 +11,12 @@ #define QEMU_STATIC_ANALYSIS 1 #endif +#ifdef __cplusplus +#define QEMU_EXTERN_C extern "C" +#else +#define QEMU_EXTERN_C extern +#endif + #define QEMU_NORETURN __attribute__ ((__noreturn__)) #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index b67b0a1e8c..3f8785a471 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -57,7 +57,7 @@ #define daemon qemu_fake_daemon_function #include #undef daemon -extern int daemon(int, int); +QEMU_EXTERN_C int daemon(int, int); #endif #ifdef _WIN32 @@ -113,6 +113,10 @@ extern int daemon(int, int); #include "glib-compat.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifdef _WIN32 #include "sysemu/os-win32.h" #endif @@ -723,4 +727,8 @@ static inline int platform_does_not_support_system(const char *command) } #endif /* !HAVE_SYSTEM_FUNCTION */ +#ifdef __cplusplus +} +#endif + #endif