From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) From: =?UTF-8?q?=C3=89rico=20Nogueira?= To: libc-alpha@sourceware.org Cc: elfutils-devel@sourceware.org, =?UTF-8?q?=C3=89rico=20Rolim?= 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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-List-Received-Date: Mon, 26 Oct 2020 23:34:59 -0000 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 */ -- 2.29.0