From patchwork Tue Feb 27 11:42:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1905023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=i5dGZq/7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TkbNL1Ddyz1yX4 for ; Tue, 27 Feb 2024 22:48:34 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1CB1A3858436 for ; Tue, 27 Feb 2024 11:48:32 +0000 (GMT) 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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 30BA73858414 for ; Tue, 27 Feb 2024 11:45:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30BA73858414 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 30BA73858414 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=1709034338; cv=none; b=fd1/wiQLygKDEMDO1hye78rnC62Y75JItQWn6mCeo6Qfr/kjNgG/+Sg/pHUJp/4xmRdkHbvnO7m4vGCnT0lsJtd/uq/K62QyKi74dxCfO+x0QrckrK8q/3lM+rLL6k0Ybr2FBiQ1gSq6Y5RKUCJ3oAan/RRtwqccR7QBut4pTe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709034338; c=relaxed/simple; bh=JzHP5UA3x06Stdzmtp8zMJvquCj3DdFNr9UOtjD8y3o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xcq/nu3tlUj5hhoydihI2sr/Rt093nc5NnluPsubuLv3j7r8LlBqH8Gb+/OseZiy7O9JqKK3pLqS1smTIfMCkDDRaVAULcOzCNGPwPW1JybysaI49cqsgaheFmTJVMGvhmFGKtDbP1V+shJ6Xi8F0XDQViNjsCBsHZx0MMJM0bw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709034334; 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=i5dGZq/7kkMXoh8z3Argw/wdJ6fObNWHmn2fuV2flWBN16OLl7MbYEsOGKIKVqz4K02uTy V+EH/6RMSAZIVEZv/bN8WuBLM67HRfRzdAp38CB+3dJGhe6VNC9Bp4tRkpQ1Su5Dk4OlLF Nhkm7m+yDkBEsAK2BW3U5BiSAiDkYbw= 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 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=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org 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 "" }