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 112E5385841F for ; Tue, 4 Oct 2022 14:12:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 112E5385841F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664892749; 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=OcKLexceoE2X6Er4bQn/QDyCGGzbKbObnTWsxN4uOHk=; b=OU/cM0In/bsO23xV8hVUTsxEntnLyKAvgKhIa5MNvShhOTpTDemvZVl3vMl8ryhP31yWC3 SHxgDRA6FVtuLC+fjCwhdl3EipLhHTvwcc0prdBVPQMNDaaidM3Xxe9X4YCgpkHAmI3S3C VKEddY9+ZCn2EKAHbOEinQH0UgMR7Lg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-411-b9NalezvOM2FVk4EVq3Cfg-1; Tue, 04 Oct 2022 10:12:05 -0400 X-MC-Unique: b9NalezvOM2FVk4EVq3Cfg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6D8C882822; Tue, 4 Oct 2022 14:11:39 +0000 (UTC) Received: from localhost (unknown [10.33.36.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FE6B2027061; Tue, 4 Oct 2022 14:11:39 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Define functions for freestanding [PR107135] Date: Tue, 4 Oct 2022 15:11:35 +0100 Message-Id: <20221004141138.530214-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 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_LOW,SPF_HELO_NONE,SPF_NONE,TXREP 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 powerpc64le-linux, and x86_64-linux with -ffreestanding. Pushed to trunk. -- >8 -- We don't compile src/c++11/functexcept.cc for freestanding, so just define the functions used by freestanding entities as inline calls to std::terminate. libstdc++-v3/ChangeLog: PR libstdc++/107135 * include/bits/functexcept.h [!_GLIBCXX_HOSTED] (__throw_invalid_argument, __throw_out_of_range) (__throw_out_of_range_fmt, __throw_runtime_error) (__throw_overflow_error): Define inline. * include/std/bitset (_M_copy_from_ptr) [!_GLIBCXX_HOSTED]: Replace __builtin_abort with __throw_invalid_argument. --- libstdc++-v3/include/bits/functexcept.h | 25 +++++++++++++++++++++++++ libstdc++-v3/include/std/bitset | 8 +------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/include/bits/functexcept.h b/libstdc++-v3/include/bits/functexcept.h index a78a17b2e04..7fad4b13316 100644 --- a/libstdc++-v3/include/bits/functexcept.h +++ b/libstdc++-v3/include/bits/functexcept.h @@ -43,6 +43,7 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#if _GLIBCXX_HOSTED // Helper for exception objects in void __throw_bad_exception(void) __attribute__((__noreturn__)); @@ -112,6 +113,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void __throw_bad_function_call() __attribute__((__noreturn__)); +#else // ! HOSTED + + __attribute__((__noreturn__)) inline void + __throw_invalid_argument(const char*) + { std::__terminate(); } + + __attribute__((__noreturn__)) inline void + __throw_out_of_range(const char*) + { std::__terminate(); } + + __attribute__((__noreturn__)) inline void + __throw_out_of_range_fmt(const char*, ...) + { std::__terminate(); } + + __attribute__((__noreturn__)) inline void + __throw_runtime_error(const char*) + { std::__terminate(); } + + __attribute__((__noreturn__)) inline void + __throw_overflow_error(const char*) + { std::__terminate(); } + +#endif // HOSTED + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset index afabeb4ba01..1f3f68fefce 100644 --- a/libstdc++-v3/include/std/bitset +++ b/libstdc++-v3/include/std/bitset @@ -1514,13 +1514,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER else if (_Traits::eq(__c, __one)) _Unchecked_set(__i - 1); else - { -#if _GLIBCXX_HOSTED - __throw_invalid_argument(__N("bitset::_M_copy_from_ptr")); -#else - __builtin_abort(); -#endif - } + __throw_invalid_argument(__N("bitset::_M_copy_from_ptr")); } } -- 2.37.3