From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 3198F386075C for ; Mon, 24 Jul 2023 20:06:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3198F386075C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690229203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nFdqp4eVKJRTqQ/4tG4qJ45z2aKh8GsEFqW5JgbHgKg=; b=POc7vCroPNcJ/9m/dVMF8XnfUXSFWBbu9GyvjOxBbBh4Z+sdwVeQtxX/mnnQ64ZC4P2pPK rHe6Ls5u5w9b3z1lI0jc6Gi02xzYSSj+glUPUZqQeJemHfuyLbY8zxxwUQU4zvtUe0/nHf 9CmepwMo6Iie4HNOLFKZqU3MvOwKKsw= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-mP2pFbpLONSxm-49659Mmg-1; Mon, 24 Jul 2023 16:06:40 -0400 X-MC-Unique: mP2pFbpLONSxm-49659Mmg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 060733C13501; Mon, 24 Jul 2023 20:06:40 +0000 (UTC) Received: from localhost (unknown [10.42.28.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id C376DF782D; Mon, 24 Jul 2023 20:06:39 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Reuse double overload of __convert_to_v if possible Date: Mon, 24 Jul 2023 21:05:32 +0100 Message-ID: <20230724200642.84915-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 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_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This seems like a worthwhile change. In theory we could make it even smaller by using a symbol alias, but I'm not sure that's supported on the targets where this will actually help. Any objections? -- >8 -- For targets where double and long double have the same representation we can reuse the same __convert_to_v code for both types. This will slightly reduce the size of the compiled code in the library. libstdc++-v3/ChangeLog: * config/locale/generic/c_locale.cc (__convert_to_v): Reuse double overload for long double if possible. --- libstdc++-v3/config/locale/generic/c_locale.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libstdc++-v3/config/locale/generic/c_locale.cc b/libstdc++-v3/config/locale/generic/c_locale.cc index 8849d78fdfa..866ba0361dc 100644 --- a/libstdc++-v3/config/locale/generic/c_locale.cc +++ b/libstdc++-v3/config/locale/generic/c_locale.cc @@ -187,6 +187,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err, const __c_locale&) throw() { +#if __DBL_MANT_DIG__ == __LDBL_MANT_DIG__ + double __d; + __convert_to_v(__s, __d, __err, __c_locale); + __v = __d; +#else // Assumes __s formatted for "C" locale. const char* __sav = __set_C_locale(); if (!__sav) @@ -233,6 +238,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION setlocale(LC_ALL, __sav); delete [] __sav; +#endif // __DBL_MANT_DIG__ == __LDBL_MANT_DIG__ } void -- 2.41.0