From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH 3/8] libstdc++: Fix std::print for Cygwin
Date: Tue, 27 Feb 2024 11:42:00 +0000 [thread overview]
Message-ID: <20240227114528.1350601-3-jwakely@redhat.com> (raw)
Tested x86_64-linux. I am unable to test this on Cygwin myself. Testing
and reviews invited.
-- >8 --
Cygwin should use std::fwrite, not WriteConsoleW. And the -lstdc++exp
library is only needed when running the tests on *-*-mingw*.
libstdc++-v3/ChangeLog:
* include/std/ostream (vprint_unicode) [__CYGWIN__]: Use POSIX
code path for Cygwin instead of Windows.
* include/std/print (vprint_unicode) [__CYGWIN__]: Likewise.
* testsuite/27_io/basic_ostream/print/1.cc: Only add -lstdc++exp
for *-*-mingw* targets.
* testsuite/27_io/print/1.cc: Likewise.
---
libstdc++-v3/include/std/ostream | 4 ++--
libstdc++-v3/include/std/print | 2 +-
libstdc++-v3/testsuite/27_io/basic_ostream/print/1.cc | 2 +-
libstdc++-v3/testsuite/27_io/print/1.cc | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream
index 7d501d67489..a136399ad0b 100644
--- a/libstdc++-v3/include/std/ostream
+++ b/libstdc++-v3/include/std/ostream
@@ -906,7 +906,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline void
vprint_unicode(ostream& __os, string_view __fmt, format_args __args)
{
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
// For most targets we don't need to do anything special to write
// Unicode to a terminal.
std::vprint_nonunicode(__os, __fmt, __args);
@@ -923,7 +923,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// If stream refers to a terminal, write a Unicode string to it.
if (auto __term = __open_terminal(__os.rdbuf()))
{
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
// For POSIX, __open_terminal(streambuf*) uses fdopen to open a
// new file, so we would need to close it here. This code is not
// actually compiled because it's inside an #ifdef _WIN32 group,
diff --git a/libstdc++-v3/include/std/print b/libstdc++-v3/include/std/print
index 492f333dfa6..d44033469de 100644
--- a/libstdc++-v3/include/std/print
+++ b/libstdc++-v3/include/std/print
@@ -64,7 +64,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline void
vprint_unicode(FILE* __stream, string_view __fmt, format_args __args)
{
-#ifndef _WIN32
+#if !defined(_WIN32) || defined(__CYGWIN__)
// For most targets we don't need to do anything special to write
// Unicode to a terminal.
std::vprint_nonunicode(__stream, __fmt, __args);
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/print/1.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/print/1.cc
index b3abc570d1e..71a4daa04c9 100644
--- a/libstdc++-v3/testsuite/27_io/basic_ostream/print/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/print/1.cc
@@ -1,4 +1,4 @@
-// { dg-options "-lstdc++exp" }
+// { dg-additional-options "-lstdc++exp" { target { *-*-mingw* } } }
// { dg-do run { target c++23 } }
// { dg-require-fileio "" }
diff --git a/libstdc++-v3/testsuite/27_io/print/1.cc b/libstdc++-v3/testsuite/27_io/print/1.cc
index 3cfdac1bb74..6a294e0454b 100644
--- a/libstdc++-v3/testsuite/27_io/print/1.cc
+++ b/libstdc++-v3/testsuite/27_io/print/1.cc
@@ -1,4 +1,4 @@
-// { dg-options "-lstdc++exp" }
+// { dg-additional-options "-lstdc++exp" { target { *-*-mingw* } } }
// { dg-do run { target c++23 } }
// { dg-require-fileio "" }
--
2.43.0
reply other threads:[~2024-02-27 11:45 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=20240227114528.1350601-3-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).