public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Ensure std::to_chars overloads all declared in <format> [PR107720]
Date: Thu, 17 Nov 2022 00:35:08 +0000	[thread overview]
Message-ID: <20221117003508.1432092-1-jwakely@redhat.com> (raw)

Tested powerpc64le-linux. Pushed to trunk.

-- >8 --

For powerpc64le we need to be able to format both of __ieee128 and
__ibm128, so we need the std::to_chars overloads for both types to be
visible at once. The __ieee128 overloads are always visible in C++23
mode, because they're used to implement the _Float128 overloads. The
__ibm128 overloads are only visible when long double is __ibm128.

libstdc++-v3/ChangeLog:

	PR libstdc++/107720
	* include/std/format [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT]:
	Declare overloads of std::to_chars for the alternative long
	double type.
---
 libstdc++-v3/include/std/format | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 1afcd042bc2..f4fc85a16d2 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -1237,6 +1237,34 @@ namespace __format
   using __float128_t = __ieee128;
 # define _GLIBCXX_FORMAT_F128 1
 
+#ifdef __LONG_DOUBLE_IEEE128__
+  // These overloads exist in the library, but are not declared.
+  // Make them available as std::__format::to_chars.
+  to_chars_result
+  to_chars(char*, char*, __ibm128) noexcept
+    __asm("_ZSt8to_charsPcS_e");
+
+  to_chars_result
+  to_chars(char*, char*, __ibm128, chars_format) noexcept
+    __asm("_ZSt8to_charsPcS_eSt12chars_format");
+
+  to_chars_result
+  to_chars(char*, char*, __ibm128, chars_format, int) noexcept
+    __asm("_ZSt8to_charsPcS_eSt12chars_formati");
+#elif __cplusplus == 202002L
+  to_chars_result
+  to_chars(char*, char*, __ieee128) noexcept
+    __asm("_ZSt8to_charsPcS_u9__ieee128");
+
+  to_chars_result
+  to_chars(char*, char*, __ieee128, chars_format) noexcept
+    __asm("_ZSt8to_charsPcS_u9__ieee128St12chars_format");
+
+  to_chars_result
+  to_chars(char*, char*, __ieee128, chars_format, int) noexcept
+    __asm("_ZSt8to_charsPcS_u9__ieee128St12chars_formati");
+#endif
+
 #elif defined _GLIBCXX_LDOUBLE_IS_IEEE_BINARY128
 
   // Format 128-bit floating-point types using long double.
-- 
2.38.1


                 reply	other threads:[~2022-11-17  0:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221117003508.1432092-1-jwakely@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).