From patchwork Tue Aug 14 12:10:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 957458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-483630-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="wTztkMFf"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41qWdh316Vz9sDG for ; Tue, 14 Aug 2018 22:10:47 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=R21RHh1yayT6lHk6SuqKP//FzC3K+Qig2G8UAFCmqEpoqUcurD1vo 1b8ZW4uvQmwMSbSyDOedkLJVHyMliONRDCUkIDmdWux+iyhMMWn9RNQJTSE8StZM 5v+Zqwka7Y4TIOodsbBmOHn9+8SHvc1g+1iyAsQZBohmobfwYPUoWk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=fprIabAM2OpJTlXti30YwAdTO8E=; b=wTztkMFfADodmFZb1Lr/ J2rblWrrEcOTrPt3x2T4TIVxorCrA255VohaOfeawfJzS0scH3dXAAQGT3qJDVTj 0ehvOUyJC3JXmrs5BgV0nkgMCs4H/sYdRT3boyTdYmathrLByMWzCS1D5uhdre8y i4Epk669CFsLD9+/tk8C+5o= Received: (qmail 69950 invoked by alias); 14 Aug 2018 12:10:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 69810 invoked by uid 89); 14 Aug 2018 12:10:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=apr, Apr X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Aug 2018 12:10:35 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 47EEF41CE2; Tue, 14 Aug 2018 12:10:34 +0000 (UTC) Received: from localhost (ovpn-117-178.phx2.redhat.com [10.3.117.178]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBD0610EE78E; Tue, 14 Aug 2018 12:10:33 +0000 (UTC) Date: Tue, 14 Aug 2018 13:10:32 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] PR libstdc++/85343 overload __throw_ios_failure to take errno Message-ID: <20180814121032.GA19048@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.2 (2017-12-15) [ios::failure] p2: "When throwing ios_base::failure exceptions, implementations should provide values of ec that identify the specific reason for the failure." This adds a new overload of __throw_ios_failure that can be passed errno, to store error_code(errno, system_category()) in the exception object. PR libstdc++/85343 * acinclude.m4 (libtool_VERSION): Bump version. * config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Add new symbol version. Export new symbol. * configure: Regenerate. * doc/xml/manual/abi.xml: Document new versions. * include/bits/fstream.tcc (basic_filebuf::underflow) (basic_filebuf::xsgetn): Pass errno to __throw_ios_failure. * include/bits/functexcept.h (__throw_ios_failure(const char*, int)): Declare new overload. * src/c++11/cxx11-ios_failure.cc (__ios_failure): Add new constructor and static member function. (__throw_ios_failure(const char*, int)): Define. * src/c++98/ios_failure.cc [!_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure(const char*, int)): Define. * testsuite/util/testsuite_abi.cc: Update known and latest versions. Tested x86_64-linux, committed to trunk. commit 204e5918142eca04dbe1cba92fbf20e2791ad7e4 Author: Jonathan Wakely Date: Wed Apr 11 13:42:34 2018 +0100 PR libstdc++/85343 overload __throw_ios_failure to take errno [ios::failure] p2: "When throwing ios_base::failure exceptions, implementations should provide values of ec that identify the specific reason for the failure." This adds a new overload of __throw_ios_failure that can be passed errno, to store error_code(errno, system_category()) in the exception object. PR libstdc++/85343 * acinclude.m4 (libtool_VERSION): Bump version. * config/abi/pre/gnu.ver (GLIBCXX_3.4.26): Add new symbol version. Export new symbol. * configure: Regenerate. * doc/xml/manual/abi.xml: Document new versions. * include/bits/fstream.tcc (basic_filebuf::underflow) (basic_filebuf::xsgetn): Pass errno to __throw_ios_failure. * include/bits/functexcept.h (__throw_ios_failure(const char*, int)): Declare new overload. * src/c++11/cxx11-ios_failure.cc (__ios_failure): Add new constructor and static member function. (__throw_ios_failure(const char*, int)): Define. * src/c++98/ios_failure.cc [!_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure(const char*, int)): Define. * testsuite/util/testsuite_abi.cc: Update known and latest versions. diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 593783da1aa..03b23200a1a 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -2046,6 +2046,9 @@ GLIBCXX_3.4.26 { _ZNSt3pmr25monotonic_buffer_resource13_M_new_bufferE[jmy][jmy]; _ZNSt3pmr25monotonic_buffer_resource18_M_release_buffersEv; + # std::__throw_ios_failure(const char*, int); + _ZSt19__throw_ios_failurePKci; + } GLIBCXX_3.4.25; # Symbols in the support library (libsupc++) have their own tag. diff --git a/libstdc++-v3/doc/xml/manual/abi.xml b/libstdc++-v3/doc/xml/manual/abi.xml index 733c803ffac..8859e965000 100644 --- a/libstdc++-v3/doc/xml/manual/abi.xml +++ b/libstdc++-v3/doc/xml/manual/abi.xml @@ -268,6 +268,7 @@ compatible. GCC 7.1.0: libstdc++.so.6.0.23 GCC 7.2.0: libstdc++.so.6.0.24 GCC 8.0.0: libstdc++.so.6.0.25 + GCC 9.0.0: libstdc++.so.6.0.26 Note 1: Error should be libstdc++.so.3.0.3. @@ -338,6 +339,7 @@ compatible. GCC 7.1.0: GLIBCXX_3.4.23, CXXABI_1.3.11 GCC 7.2.0: GLIBCXX_3.4.24, CXXABI_1.3.11 GCC 8.0.0: GLIBCXX_3.4.25, CXXABI_1.3.11 + GCC 9.0.0: GLIBCXX_3.4.26, CXXABI_1.3.11 diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc index 6205db75340..ed98f13e0e0 100644 --- a/libstdc++-v3/include/bits/fstream.tcc +++ b/libstdc++-v3/include/bits/fstream.tcc @@ -38,6 +38,7 @@ #include #include // for swap +#include namespace std _GLIBCXX_VISIBILITY(default) { @@ -471,7 +472,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "invalid byte sequence in file")); else __throw_ios_failure(__N("basic_filebuf::underflow " - "error reading the file")); + "error reading the file"), errno); } return __ret; } @@ -717,7 +718,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __len = _M_file.xsgetn(reinterpret_cast(__s), __n); if (__len == -1) __throw_ios_failure(__N("basic_filebuf::xsgetn " - "error reading the file")); + "error reading the file"), errno); if (__len == 0) break; diff --git a/libstdc++-v3/include/bits/functexcept.h b/libstdc++-v3/include/bits/functexcept.h index 6f6ffc5ee3b..9d5acdb3b55 100644 --- a/libstdc++-v3/include/bits/functexcept.h +++ b/libstdc++-v3/include/bits/functexcept.h @@ -94,9 +94,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void __throw_ios_failure(const char*) __attribute__((__noreturn__)); + void + __throw_ios_failure(const char*, int) __attribute__((__noreturn__)); + + // Helpers for exception objects in void __throw_system_error(int) __attribute__((__noreturn__)); + // Helpers for exception objects in void __throw_future_error(int) __attribute__((__noreturn__)); diff --git a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc index b1e4bfb2b44..26816fae570 100644 --- a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc +++ b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc @@ -114,6 +114,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __ios_failure(const char* s) : failure(s) { __construct_ios_failure(buf, runtime_error::what()); } + __ios_failure(const char* s, int e) : failure(s, to_error_code(e)) + { __construct_ios_failure(buf, runtime_error::what()); } + ~__ios_failure() { __destroy_ios_failure(buf); } @@ -122,6 +125,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // There are assertions in src/c++98/ios_failure.cc to ensure the size // and alignment assumptions are valid. alignas(runtime_error) unsigned char buf[sizeof(runtime_error)]; + + static error_code + to_error_code(int e) + { return e ? error_code(e, system_category()) : io_errc::stream; } }; // Custom type info for __ios_failure. @@ -161,5 +168,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __throw_ios_failure(const char* __s __attribute__((unused))) { _GLIBCXX_THROW_OR_ABORT(__ios_failure(_(__s))); } + void + __throw_ios_failure(const char* str __attribute__((unused)), + int err __attribute__((unused))) + { _GLIBCXX_THROW_OR_ABORT(__ios_failure(_(str), err)); } + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/src/c++98/ios_failure.cc b/libstdc++-v3/src/c++98/ios_failure.cc index 49d24f49620..794124b68e7 100644 --- a/libstdc++-v3/src/c++98/ios_failure.cc +++ b/libstdc++-v3/src/c++98/ios_failure.cc @@ -88,7 +88,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __throw_ios_failure(const char* __s __attribute__((unused))) { _GLIBCXX_THROW_OR_ABORT(ios::failure(_(__s))); } -#endif + void + __throw_ios_failure(const char* str, int) + { __throw_ios_failure(str); } + +#endif // _GLIBCXX_USE_DUAL_ABI _GLIBCXX_END_NAMESPACE_VERSION } // namespace