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 767823858C36 for ; Tue, 27 Feb 2024 11:45:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 767823858C36 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 767823858C36 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709034336; cv=none; b=idFFuCwYp+GvazI/LKqcXa1pKckZp8YaeFrwJpJngnMoXlw4EbGYau+14Bc0a75cEG9+U9MNBB2LARCvjXT6vt08S4gSmJ63UBY4NKI1JbnGOLWFLKGX7wrmmNxqOiJR2Azfsk7TnM4yaXL9K1CGRi+o/Ghk2pbnWxBB+tTqS+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709034336; c=relaxed/simple; bh=JzHP5UA3x06Stdzmtp8zMJvquCj3DdFNr9UOtjD8y3o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Q7Y7P8Vrq0V9wQIMQGOiR3J3MKjhgUZ4afXRcjuNZvo5kyPZZNQpf7mP2XHzCg3IKOq177KlhG3bp94zJx/JKSLUKVgIVRFzogVSYPZz3a5yrTQIYLUN4bNqHwIV2vKzIj42rUNaomctQZrzU5d9R3GpVLR5+XdXpXBMpTAkQNk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709034333; 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=49j1RWXwG9fp51t9o/9aCKfK0+cbXPzHmibHitJyzhM=; b=Lj/7Bd0NiUiMfIdzz50PaZtNdWoAqD/dzZaNWsQPE7aHu3y23q9BKX3C4fWQ1lczI8pnHh PU90pTIM79BHVbfem/38uL1L8eqUaV/bVol7fo+wEHdiYWoGdHSQi05BGkKKgr/2xko1Qy Umsk4C2ISCrBPZ5mRmkUl70mMAcfvik= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-U8HRc_i6OFaJVuHPLHfvfw-1; Tue, 27 Feb 2024 06:45:31 -0500 X-MC-Unique: U8HRc_i6OFaJVuHPLHfvfw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 408DB88B762; Tue, 27 Feb 2024 11:45:31 +0000 (UTC) Received: from localhost (unknown [10.42.28.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B113492BC6; Tue, 27 Feb 2024 11:45:30 +0000 (UTC) From: Jonathan Wakely 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 Message-ID: <20240227114528.1350601-3-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 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_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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