From patchwork Tue May 11 14:24:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1477159 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=hCJCWOnj; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfgDB2m82z9sWQ for ; Wed, 12 May 2021 00:24:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 06BD8398889F; Tue, 11 May 2021 14:24:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 06BD8398889F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1620743077; bh=YStVPkPphh+fCUzIrx1/rTvmXtOXNiLyO+4JXJPHhNM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=hCJCWOnj/Pi/vjzPCi8RAr3rbViAJCldKUodRYES21Twt5eTkSWq4bHYth2gL5VLR xkiRpJNo2469d8r7YVM+nKbMDwsFweY8SbyYscAmvpewqSfhBCmtQLNXZCsx9hICpJ +0aAvuQhtdfHmY4e3h3/wGr9+xGWBTqYQslFUDX8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 985E6388CC03 for ; Tue, 11 May 2021 14:24:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 985E6388CC03 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-489-OMeP4_-oNhGiw2BbvFUVlQ-1; Tue, 11 May 2021 10:24:31 -0400 X-MC-Unique: OMeP4_-oNhGiw2BbvFUVlQ-1 Received: by mail-qk1-f200.google.com with SMTP id u126-20020a3792840000b02902e769005fe1so14517682qkd.2 for ; Tue, 11 May 2021 07:24:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YStVPkPphh+fCUzIrx1/rTvmXtOXNiLyO+4JXJPHhNM=; b=KI46Krn9DCaM9/r8obP0y9n5d4Gu/LNDBHNr/mxNU9KebZwVXeoWQjHlZAg2bxjhVr gRDR8x3VduvytoMq8ZnI6sAjKQEvGR3KL/bx8YhQ40xApCXfNIe0S49nWrd8K0/NnBRg 3s37a1y/fjWw6LCrq4poOKelzfI0qLeBal/1D3tQblxvSuwCaomJN4mvGhr2Rg3+efiD I122ZiveH7/B0rBByq6Ofp/GEYl+AXHKd1CrBjpbmh3LocYEMI6OEaAgNIRUT0YKfoiR 3BWIwuwlnHrBlNn3K8PyZE18Q0A1+unNDbaWzX/vJ68jG1k8t5zxZ4+Gc+z/Jo8yIJR0 6Itw== X-Gm-Message-State: AOAM533GlPpl/I/yIyvF33jcYzlxb4i35EhbLC0COU/hE49q9gBngA+P fNVFF9n6rB9yo7HG53tj4dcWIoJVR+0TBHI+RbYUxF0dmsJCuu8Wk32YIasrM6qaqRUTtZBxdXv PTK7tTfpt4de8BAYV9i0UD9NA30hfvqU6nLEmnNQFkr3BCcu+yAeFcMuYbDpTloyf9vc= X-Received: by 2002:a37:b585:: with SMTP id e127mr28309923qkf.405.1620743070946; Tue, 11 May 2021 07:24:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMhY0frUNG6tU3sY2GB0B+Xr1AGshbEvmRW2n2O4QXbbhINLjaC3PEJmkENLwh8WNJcZlBRQ== X-Received: by 2002:a37:b585:: with SMTP id e127mr28309889qkf.405.1620743070558; Tue, 11 May 2021 07:24:30 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id x142sm4856474qkb.136.2021.05.11.07.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 07:24:30 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Remove extern "C" from Ryu sources Date: Tue, 11 May 2021 10:24:27 -0400 Message-Id: <20210511142427.221984-1-ppalka@redhat.com> X-Mailer: git-send-email 2.31.1.527.g2d677e5b15 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-16.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Cc: libstdc++@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" floating_to_chars.cc includes the Ryu sources into an anonymous namespace as a convenient way to give all its symbols internal linkage. But an entity declared extern "C" always has external linkage, even from within an anonymous namespace, so this trick doesn't work in the presence of extern "C", and it causes the Ryu function generic_to_chars to be visible from libstdc++.a. This patch removes the only use of extern "C" from our local copy of Ryu, along with some declarations for never-defined functions that GCC now warns about. Tested on x86_64-pc-linux-gnu, and also verified that generic_to_chars is not visible from libstdc++.a. Does this look OK for trunk and the 11 branch? libstdc++-v3/ChangeLog: * src/c++17/ryu/LOCAL_PATCHES: Update. * src/c++17/ryu/ryu_generic_128.h: Remove extern "C". Remove declarations for never-defined functions. --- libstdc++-v3/src/c++17/ryu/LOCAL_PATCHES | 1 + libstdc++-v3/src/c++17/ryu/ryu_generic_128.h | 21 +++----------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/libstdc++-v3/src/c++17/ryu/LOCAL_PATCHES b/libstdc++-v3/src/c++17/ryu/LOCAL_PATCHES index 51e504cb6ea..72ffad9662d 100644 --- a/libstdc++-v3/src/c++17/ryu/LOCAL_PATCHES +++ b/libstdc++-v3/src/c++17/ryu/LOCAL_PATCHES @@ -1,2 +1,3 @@ r11-6248 r11-7636 +r12-XXX diff --git a/libstdc++-v3/src/c++17/ryu/ryu_generic_128.h b/libstdc++-v3/src/c++17/ryu/ryu_generic_128.h index 2afbf274e11..6d988ab01eb 100644 --- a/libstdc++-v3/src/c++17/ryu/ryu_generic_128.h +++ b/libstdc++-v3/src/c++17/ryu/ryu_generic_128.h @@ -18,9 +18,9 @@ #define RYU_GENERIC_128_H -#ifdef __cplusplus -extern "C" { -#endif +// NOTE: These symbols are declared extern "C" upstream, but we don't want that +// because it'd override the internal linkage of the anonymous namespace into +// which this header is included. // This is a generic 128-bit implementation of float to shortest conversion // using the Ryu algorithm. It can handle any IEEE-compatible floating-point @@ -42,18 +42,6 @@ struct floating_decimal_128 { bool sign; }; -struct floating_decimal_128 float_to_fd128(float f); -struct floating_decimal_128 double_to_fd128(double d); - -// According to wikipedia (https://en.wikipedia.org/wiki/Long_double), this likely only works on -// x86 with specific compilers (clang?). May need an ifdef. -struct floating_decimal_128 long_double_to_fd128(long double d); - -// Converts the given binary floating point number to the shortest decimal floating point number -// that still accurately represents it. -struct floating_decimal_128 generic_binary_to_decimal( - const uint128_t bits, const uint32_t mantissaBits, const uint32_t exponentBits, const bool explicitLeadingBit); - // Converts the given decimal floating point number to a string, writing to result, and returning // the number characters written. Does not terminate the buffer with a 0. In the worst case, this // function can write up to 53 characters. @@ -63,8 +51,5 @@ struct floating_decimal_128 generic_binary_to_decimal( // = 1 + 39 + 1 + 1 + 1 + 10 = 53 int generic_to_chars(const struct floating_decimal_128 v, char* const result); -#ifdef __cplusplus -} -#endif #endif // RYU_GENERIC_128_H