From patchwork Mon Oct 26 23:34:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C3=89rico_Nogueira?= X-Patchwork-Id: 40883 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABCC5394743C; Mon, 26 Oct 2020 23:35:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABCC5394743C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1603755300; bh=AYzauvuJrCcOp0ZdYgtp8/nYZPgrUrZFQB/ibwMILVg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=qInZHPUtBy3SaVh9VWVH5xmDB+iC01DLlDRbIbsmXpJlBAGcQX8z6zxWMBGpOZaA2 PCZtBxXNoTCNTFu9ISjh5o0HyLdY6N/KWWK5sDkMWysxPvxou/dUHZx3KMcfJcSsOI uBwkXN4IPGPshUjW9bmmDPlq+jysAzyl7GZA4yjA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) by sourceware.org (Postfix) with ESMTPS id CDDA5386182E; Mon, 26 Oct 2020 23:34:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CDDA5386182E Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id C0848535AE; Tue, 27 Oct 2020 00:34:56 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gWjUivjONSPm; Tue, 27 Oct 2020 00:34:55 +0100 (CET) To: libc-alpha@sourceware.org Subject: [PATCH] Allow elf header to be used when __BEGIN_DECLS and __END_DECLS aren't defined. Date: Mon, 26 Oct 2020 20:34:45 -0300 Message-Id: <20201026233445.18622-1-ericonr@disroot.org> Mime-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?=C3=89rico_Nogueira_via_Libc-alpha?= From: =?utf-8?q?=C3=89rico_Nogueira?= Reply-To: =?utf-8?q?=C3=89rico_Nogueira?= Cc: =?utf-8?q?=C3=89rico_Rolim?= , elfutils-devel@sourceware.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Érico Rolim The elf/elf.h header is shared, verbatim, by the elfutils project. However, elfutils can be used on systems with libcs other than glibc, making the presence of __BEGIN_DECLS and __END_DECLS in the file something that downstream distros have to add patches for. Per https://sourceware.org/pipermail/elfutils-devel/2020q4/002994.html , the elfutils project would prefer to keep maintenance to a minimum, which can be achieved by making this single header more portable. --- This is mostly an initial PoC, and an additional comment for why this is needed could be added to the file. I accidentally sent the wrong patch a while ago, sorry! elf/elf.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/elf/elf.h b/elf/elf.h index ff9f1dadd5..d6578e8d72 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -21,7 +21,10 @@ #include -__BEGIN_DECLS +/* C++ needs to know that types and declarations are C, not C++. */ +#ifdef __cplusplus +extern "C" { +#endif /* Standard ELF types. */ @@ -4105,6 +4108,8 @@ enum #define R_ARC_TLS_LE_S9 0x4a #define R_ARC_TLS_LE_32 0x4b -__END_DECLS +#ifdef __cplusplus +} +#endif #endif /* elf.h */