From patchwork Wed Feb 28 18:30:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10249299 X-Patchwork-Delegate: leon@leon.nu Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B3DB060365 for ; Wed, 28 Feb 2018 18:30:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAAF528E10 for ; Wed, 28 Feb 2018 18:30:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F66828E20; Wed, 28 Feb 2018 18:30:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC49428E10 for ; Wed, 28 Feb 2018 18:30:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932992AbeB1Sad (ORCPT ); Wed, 28 Feb 2018 13:30:33 -0500 Received: from mail-eopbgr20053.outbound.protection.outlook.com ([40.107.2.53]:48015 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932238AbeB1Saa (ORCPT ); Wed, 28 Feb 2018 13:30:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=cIY3yYIUZ1bhNmNckDTX8T2EYFhQjBQnPmmHQTxKN3M=; b=csth7bXkeK9oq1GOgrn6t/5RZME9c/UY55gN7e5nGR/3tFBQ2zIxNPnqPowhbgFZP+BYlAqi8Y3VkeNMcUzVWRx9DLtEdc2kPb6FHe+UPNITq1QtaUIhWI40haTQjZvpcp8L18AP/mB6jchTBQyRDkVUdcfGsbRMFbXhLbYfTv0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jgg@mellanox.com; Received: from mlx.ziepe.ca (70.74.179.152) by AM4PR0501MB2849.eurprd05.prod.outlook.com (2603:10a6:200:5c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.548.13; Wed, 28 Feb 2018 18:30:27 +0000 Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1er6Ug-0006Zv-CC; Wed, 28 Feb 2018 11:30:22 -0700 Date: Wed, 28 Feb 2018 11:30:22 -0700 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org, Leon Romanovsky Cc: Nicolas Morey-Chaisemartin Subject: [PATCH rdma-core] Ensure all public headers compile in C++ mode Message-ID: <20180228183022.GA25204@ziepe.ca> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [70.74.179.152] X-ClientProxiedBy: AM0PR0102CA0048.eurprd01.prod.exchangelabs.com (2603:10a6:208::25) To AM4PR0501MB2849.eurprd05.prod.outlook.com (2603:10a6:200:5c::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8a3b1b01-70e2-426d-4f8f-08d57ed95757 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:AM4PR0501MB2849; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0501MB2849; 3:lQ4QDg/eH3hR6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JJbapOqwdZ/ELQBX0QSt9kTrdQRzYq5V83Is8iLkEaOYBga4lfjTWKdX6cTZi1fuMuoekJR22ole5LHxnkFYs5Qj3LOYiyZtCrBGJ6LNYNakGTF6forXRk97oWsHufELrv8kL+slJ/KWbrLoOr4exgv5Ogu2paUlmxiGiGSuJW0Fr1UAkYuAkIZfjZSuJR4fi1hVEZwrsLQo698PQGXUDACuZdkS28wonbmDy9Y2EPl3HhUxa3tni0BEQFuBKI0MUuDCAA5uIs9fw31Rln1laQoLs1aHBh/nnIgNJ/AbkcuRwwdFDNjddn7nhMP+3C6WME72uZITvW7Fm07L1a12K+; 4:MEoxrAlPl6H0NcB/qVB9oaNMSI0NnSkd9MLkZ1QHC8aZJQRbFh0+sotcVGLcYJW7C9/uH/h3eAmWXBTxISNm04ZCupI+4n9Ugd2b7SIVcmzI4tVY0F8568dEPjsxixUEMGUt3aJINV9stajH+g1SfN/wIXasbWkkZMozwnwta2ItWHLJhgzHtbXu68/xjcnJ8kNZDDJQuQ2KrqDFWWxkuowjDi+GOBENyZx0UgFLcJMp7vtTIQDc4P8GjsCMQjYMW3z+TzwE0m0iWmuMusKTVDM1pm+7M61HVjcWCcCecjDjsrprxN7thwtnwPH9k7Bi X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(278428928389397); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231220)(944501217)(52105095)(6055026)(6041288)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:AM4PR0501MB2849; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0501MB2849; X-Forefront-PRVS: 0597911EE1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(396003)(39380400002)(376002)(346002)(39860400002)(199004)(189003)(1076002)(86362001)(575784001)(81166006)(478600001)(81156014)(4326008)(122856001)(2906002)(68736007)(5660300001)(6862004)(33656002)(8676002)(105586002)(52116002)(97736004)(9786002)(83796002)(57986006)(316002)(9746002)(58126008)(186003)(69596002)(6116002)(53936002)(50466002)(3846002)(16586007)(9686003)(7736002)(106356001)(8936002)(33896004)(26005)(6636002)(23726003)(47776003)(66066001)(386003)(305945005)(46656002)(36756003)(18370500001)(24400500001)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0501MB2849; H:mlx.ziepe.ca; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR0501MB2849; 23:w7X/FI2wmsXFF9HhaAwYld69063CDRIt5SV4JcP?= =?us-ascii?Q?aDawMpShzebbuP1BE50AT2fNsGL4HzHxTwHTTAOY7ImLNEzRlFrtgE+72DOC?= =?us-ascii?Q?oc9oc+MsW07OAhubBths2W7cDzSzZRDDTXAOOE85gnQejYZpDLIKUfcE+Wu3?= =?us-ascii?Q?c4HxCZTQ7/F0F504ryBAortKlmjWiDxZXHjHZgJ6LS3VFMz59zmww/Ogv6/H?= =?us-ascii?Q?TetJXuHQmCZjzJrIu/8VIi1542lFt6hkY3YuCfLX3BzNs2bF5q7sIl6obwd0?= =?us-ascii?Q?e4odE5p46B3qlV0lNhMZTBMcMLGTu22cB62hPVZyxROr1A/pKwSBVbsOVa7L?= =?us-ascii?Q?dQLDGYfTylgQmQjNAXkvj4yyuPr/MZMtDHd9F8uIeEd6+S6LahAOjesa3M6t?= =?us-ascii?Q?Hza8OHktA4bmbu9yBNV91k57FDyvmqYXvTjflnjC8X0EBlYzZLRALEX6/nif?= =?us-ascii?Q?IZMqktsM/JWFbIDH5pAVx3HD0E5bdB/YG5kGTZEJBzyd6FvbEHy1XzDJtImM?= =?us-ascii?Q?CEOXoyoS7gpVFq85pX+kEV7CZ65bYVRby8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XTIP3mVmY5gt1eGegd2+zYNlATnkcQ6BeeEImcdElM+Ojw6aNoZabdcONCsDqK1q5De5bEJbV1Ay4gGlXKxStCYgV/V8S47MC4Vc8kNxKN9JjlZZU6XfSNUCB5c/0cBAIxJzXU/UdTicsYC1T+2TT38cydYx7c3YjpRm7gYOjyj4mkbF8IXp4OoDwKYc1nEITzj4w3vL1JTb5gLl6LfrVwRcpgsvu6mNBHOrFAgY=; 5:5UqmVGkhAbU+74zl5CEUA+r9lazvOF9ReAmDauhN5UfKSF+RKTYd2qkAWUJjXgbnIkdrlj/1BO9hqgFbSiJy4ASwhZf419cEZaV/TmKUETJRd6eygq0vWQzS5+CUfSssl3t/AZrx3SKRLS4UWkq3/kXreo0CTHKWWS40QdUuZuo=; 24:SaCNONYrL51ToBOYC8PUtfPmpcXzvVPWwgPD2rqJTmvhhG1tr4yrje/G8acPuxNaqDiBkBXOK0VMA3ygJne2FHAX42yqapri0twAjMz0PAI=; 7:ldkxDsQEOs7CrcjKvyfz1u6+0cAbjE3I/onXMrtgjrDECF7MWumxIfWcPszFtgmGKK6iodFWL0mOkcsuugz3iejvvaBQsT62Hwyh/i5h0XINxKWLortA0IF+8CVLoWn+KWl/lwzLKE+Jwd204TU35RVjD5nwD2ll9CHsEpac6tMpovNgPlZDvXgH0sYQ4ljCxMZbBoMhzpCnmkBv9859XgFb+jS8TwHGLiTapIEPZjLMB+0E2jeVuSIaycY/r42S SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2018 18:30:27.9417 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a3b1b01-70e2-426d-4f8f-08d57ed95757 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2849 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Have check-build run them through the c++ compiler to make sure they have no compilation issues, and very roughly check that headers have the required extern "C". Fix all public headers missing the extern "C" This fixes compilation of user applications in C++ mode that use these headers. Fixes: 5160e25267ee ("mlx4: Add mlx4 direct verbs") Fixes: a2ddaca1dd75 ("mlx5: Add mlx5 direct verbs") Cc: stable@linux-rdma.org Signed-off-by: Jason Gunthorpe --- buildlib/check-build | 28 ++++++++++++++++++++++++++-- ibacm/include/infiniband/acm.h | 8 ++++++++ ibacm/include/infiniband/acm_prov.h | 8 ++++++++ providers/mlx4/mlx4dv.h | 9 +++++++++ providers/mlx5/mlx5dv.h | 8 ++++++++ 5 files changed, 59 insertions(+), 2 deletions(-) Nicholas, this should got to all the stables, but you can just drop the change to check-build when doing it. diff --git a/buildlib/check-build b/buildlib/check-build index 766db7ae46259f..86cb76fcb823aa 100755 --- a/buildlib/check-build +++ b/buildlib/check-build @@ -213,17 +213,23 @@ def get_headers(incdir): includes.add(os.path.join(root,I)); return includes; -def compile_test_headers(tmpd,incdir,includes): +def compile_test_headers(tmpd,incdir,includes,with_cxx=False): with open(os.path.join(tmpd,"build.ninja"),"wt") as F: print >> F,"rule comp"; print >> F," command = %s -Werror -c -I %s $in -o $out"%(args.CC,incdir); print >> F," description=Header check for $in"; + print >> F,"rule comp_cxx"; + print >> F," command = %s -Werror -c -I %s $in -o $out"%(args.CXX,incdir); + print >> F," description=Header C++ check for $in"; count = 0; for I in sorted(includes): if is_obsolete(I) or is_fixup(I): continue; print >> F,"build %s : comp %s"%("out%d.o"%(count),I); print >> F,"default %s"%("out%d.o"%(count)); + print >> F,"build %s : comp_cxx %s"%("outxx%d.o"%(count),I); + if with_cxx: + print >> F,"default %s"%("outxx%d.o"%(count)); count = count + 1; subprocess.check_call(["ninja"],cwd=tmpd); @@ -246,6 +252,15 @@ allowed_uapi_headers = { "rdma/ib_user_verbs.h", } +non_cxx_headers = { + "infiniband/arch.h", + "infiniband/ib.h", + "infiniband/opcode.h", + "infiniband/sa-kern-abi.h", + "infiniband/sa.h", + "rdma/rdma_cma_abi.h", +} + def test_installed_headers(args): """This test also checks that the public headers can be compiled on their own, but goes further and confirms that the public headers do not depend on any @@ -280,7 +295,14 @@ def test_installed_headers(args): with open(I,"w") as F: print >> F,'#error "Private internal header"'; - compile_test_headers(tmpd,incdir,includes); + # Roughly check that the headers have the extern "C" for C++ + # compilation. + for I in sorted(rincludes - non_cxx_headers): + with open(os.path.join(incdir,I)) as F: + if 'extern "C" {' not in F.read(): + raise ValueError("No extern C in %r"%(I)); + + compile_test_headers(tmpd,incdir,includes,with_cxx=True); # ------------------------------------------------------------------------- @@ -291,6 +313,8 @@ parser.add_argument("--src",default=None,dest="SRC", help="Top of the source tree"); parser.add_argument("--cc",default="cc",dest="CC", help="C compiler to use"); +parser.add_argument("--cxx",default="c++",dest="CXX", + help="C++ compiler to use"); args = parser.parse_args(); if args.SRC is None: diff --git a/ibacm/include/infiniband/acm.h b/ibacm/include/infiniband/acm.h index b4d677cb75ca64..0f8469997ffc23 100644 --- a/ibacm/include/infiniband/acm.h +++ b/ibacm/include/infiniband/acm.h @@ -33,6 +33,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #define ACM_VERSION 1 #define ACM_OP_MASK 0x0F @@ -153,4 +157,8 @@ struct acm_msg { }; }; +#ifdef __cplusplus +} +#endif + #endif /* ACM_H */ diff --git a/ibacm/include/infiniband/acm_prov.h b/ibacm/include/infiniband/acm_prov.h index 7dd07c75314b7c..691a00eac80b91 100644 --- a/ibacm/include/infiniband/acm_prov.h +++ b/ibacm/include/infiniband/acm_prov.h @@ -34,6 +34,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #define ACM_PROV_VERSION 1 struct acm_device { @@ -117,4 +121,8 @@ extern int acm_send_sa_mad(struct acm_sa_mad *mad); extern const char *acm_get_opts_file(void); extern void acm_increment_counter(int type); +#ifdef __cplusplus +} +#endif + #endif /* ACM_PROV_H */ diff --git a/providers/mlx4/mlx4dv.h b/providers/mlx4/mlx4dv.h index 5312a866b6e281..2c42803dc3e23b 100644 --- a/providers/mlx4/mlx4dv.h +++ b/providers/mlx4/mlx4dv.h @@ -37,6 +37,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + /* Always inline the functions */ #ifdef __GNUC__ #define MLX4DV_ALWAYS_INLINE inline __attribute__((always_inline)) @@ -529,4 +533,9 @@ enum mlx4dv_set_ctx_attr_type { int mlx4dv_set_context_attr(struct ibv_context *context, enum mlx4dv_set_ctx_attr_type attr_type, void *attr); + +#ifdef __cplusplus +} +#endif + #endif /* _MLX4DV_H_ */ diff --git a/providers/mlx5/mlx5dv.h b/providers/mlx5/mlx5dv.h index de149ab4b8dee0..6a7e1d1f67ac5e 100644 --- a/providers/mlx5/mlx5dv.h +++ b/providers/mlx5/mlx5dv.h @@ -46,6 +46,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + /* Always inline the functions */ #ifdef __GNUC__ #define MLX5DV_ALWAYS_INLINE inline __attribute__((always_inline)) @@ -864,4 +868,8 @@ static inline uint64_t mlx5dv_ts_to_ns(struct mlx5dv_clock_info *clock_info, return nsec; } +#ifdef __cplusplus +} +#endif + #endif /* _MLX5DV_H_ */