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.133.124]) by sourceware.org (Postfix) with ESMTPS id 9A39A385828D for ; Fri, 16 Sep 2022 22:36:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A39A385828D 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=1663367789; 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=7ajz/LlTkdsHJ8xsaVJXViAfS8V7NVMZ4xZwxFvUG2I=; b=EAAAvqlTeMtL9lpisKHLOccppYAeOwdCv51BRUZL8qIMzvGTioMTRcB79qBnFLVA4RyWhv 7ijDIAjmnhGYM+aiJKU0optB8nW4Cu086KHCiJ/1q60IAmPhorppkojISihR33BFTPgabO fRjlWTGebT4Lu7tNEhyRKt8UDcfJfas= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-274-W9RbAYgMOfWZuvjXuYy5xA-1; Fri, 16 Sep 2022 18:36:27 -0400 X-MC-Unique: W9RbAYgMOfWZuvjXuYy5xA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB7291C07823; Fri, 16 Sep 2022 22:36:26 +0000 (UTC) Received: from localhost (unknown [10.33.36.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74FA347505E; Fri, 16 Sep 2022 22:36:26 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add preprocessor conditions for freestanding [PR106953] Date: Fri, 16 Sep 2022 23:36:25 +0100 Message-Id: <20220916223625.602314-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.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=-12.8 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 x86_64-linux, pushed to trunk. This doesn't actually change anything for the freestanding build, so is effectively a no-op. _GLIBCXX_HOSTED is always defined to 1 when these headers are included. However, somebody else is working on installing the additional headers for freestanding, so this is a prerequisite for that. -- >8 -- This adds checks for _GLIBCXX_HOSTED to a number of headers which are not currently installed for freestanding, but need to be for P1642R11 support. For example, needs to be installed for C++23 freestanding mode, but without stream iterators and streambuf iterators. Similarly, needs to be installed, but without std::allocator and std::shared_ptr. This change disables the non-freestanding parts of those headers. libstdc++-v3/ChangeLog: PR libstdc++/106953 * include/backward/auto_ptr.h [!_GLIBCXX_HOSTED]: Do not define shared_ptr members. * include/bits/alloc_traits.h [!_GLIBCXX_HOSTED]: Do not declare std::allocator_traits> specializations for freestanding. * include/bits/memoryfwd.h [!_GLIBCXX_HOSTED] (allocator): Do not declare for freestanding. * include/bits/stl_algo.h [!_GLIBCXX_HOSTED] (stable_partition): Do not define for freestanding. [!_GLIBCXX_HOSTED] (merge, stable_sort): Do not use temporary buffers for freestanding. * include/bits/stl_algobase.h [!_GLIBCXX_HOSTED]: Do not declare streambuf iterators and overloaded algorithms using them. * include/bits/stl_uninitialized.h [!_GLIBCXX_HOSTED]: Do not define specialized overloads for std::allocator. * include/bits/unique_ptr.h [!_GLIBCXX_HOSTED] (make_unique) (make_unique_for_overwrite, operator<<): Do not define for freestanding. * include/c_global/cstdlib [!_GLIBCXX_HOSTED] (_Exit): Declare. Use _GLIBCXX_NOTHROW instead of throw(). * include/debug/assertions.h [!_GLIBCXX_HOSTED]: Ignore _GLIBCXX_DEBUG for freestanding. * include/debug/debug.h [!_GLIBCXX_DEBUG]: Likewise. * include/std/bit [!_GLIBCXX_HOSTED]: Do not use the custom __int_traits if is available. * include/std/functional [!_GLIBCXX_HOSTED]: Do not include headers that aren't valid for freestanding. (boyer_moore_searcher, boyer_moore_horspool_searcher): Do not define for freestanding. * include/std/iterator [!_GLIBCXX_HOSTED]: Do not include headers that aren't valid for freestanding. * include/std/memory [!_GLIBCXX_HOSTED]: Likewise. * include/std/ranges [!_GLIBCXX_HOSTED] (istream_view): Do not define for freestanding. (views::__detail::__is_basic_string_view) [!_GLIBCXX_HOSTED]: Do not define partial specialization for freestanding. --- libstdc++-v3/include/backward/auto_ptr.h | 4 ++- libstdc++-v3/include/bits/alloc_traits.h | 13 +++++++++- libstdc++-v3/include/bits/memoryfwd.h | 2 ++ libstdc++-v3/include/bits/stl_algo.h | 25 ++++++++++++++----- libstdc++-v3/include/bits/stl_algobase.h | 4 +++ libstdc++-v3/include/bits/stl_uninitialized.h | 17 ++++++++++--- libstdc++-v3/include/bits/unique_ptr.h | 14 ++++++----- libstdc++-v3/include/c_global/cstdlib | 24 ++++++++++-------- libstdc++-v3/include/debug/assertions.h | 16 ++++++------ libstdc++-v3/include/debug/debug.h | 2 +- libstdc++-v3/include/std/bit | 2 +- libstdc++-v3/include/std/functional | 22 ++++++++++------ libstdc++-v3/include/std/iterator | 6 +++-- libstdc++-v3/include/std/memory | 11 +++++--- libstdc++-v3/include/std/ranges | 4 +++ 15 files changed, 114 insertions(+), 52 deletions(-) diff --git a/libstdc++-v3/include/backward/auto_ptr.h b/libstdc++-v3/include/backward/auto_ptr.h index 184ab403466..093db5260fc 100644 --- a/libstdc++-v3/include/backward/auto_ptr.h +++ b/libstdc++-v3/include/backward/auto_ptr.h @@ -300,6 +300,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } _GLIBCXX11_DEPRECATED; #if __cplusplus >= 201103L +#if _GLIBCXX_HOSTED template<_Lock_policy _Lp> template inline @@ -325,13 +326,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Tp1>&& __r) : __shared_ptr<_Tp>(std::move(__r)) { } +#endif // HOSTED template template inline unique_ptr<_Tp, _Dp>::unique_ptr(auto_ptr<_Up>&& __u) noexcept : _M_t(__u.release(), deleter_type()) { } -#endif +#endif // C++11 #pragma GCC diagnostic pop diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h index 35bdf6ecf98..507e8f1b6b2 100644 --- a/libstdc++-v3/include/bits/alloc_traits.h +++ b/libstdc++-v3/include/bits/alloc_traits.h @@ -33,9 +33,11 @@ #include #include #if __cplusplus >= 201103L -# include # include # include +# if _GLIBCXX_HOSTED +# include +# endif #endif namespace std _GLIBCXX_VISIBILITY(default) @@ -402,6 +404,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return _S_select(__rhs, 0); } }; +#if _GLIBCXX_HOSTED + #if __cplusplus > 201703L # define __cpp_lib_constexpr_dynamic_alloc 201907L #endif @@ -660,6 +664,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION select_on_container_copy_construction(const allocator_type& __rhs) { return __rhs; } }; +#endif /// @cond undocumented #if __cplusplus < 201703L @@ -774,11 +779,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename _Alloc::value_type const&>::type { }; +#if _GLIBCXX_HOSTED // std::allocator<_Tp> just requires CopyConstructible template struct __is_copy_insertable> : is_copy_constructible<_Tp> { }; +#endif // true if _Alloc::value_type is MoveInsertable into containers using _Alloc // (might be wrong if _Alloc::construct exists but is not constrained, @@ -788,11 +795,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : __is_alloc_insertable_impl<_Alloc, typename _Alloc::value_type>::type { }; +#if _GLIBCXX_HOSTED // std::allocator<_Tp> just requires MoveConstructible template struct __is_move_insertable> : is_move_constructible<_Tp> { }; +#endif // Trait to detect Allocator-like types. template @@ -893,6 +902,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif } +#if _GLIBCXX_HOSTED template _GLIBCXX20_CONSTEXPR inline void @@ -901,6 +911,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { _Destroy(__first, __last); } +#endif /// @endcond _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/bits/memoryfwd.h b/libstdc++-v3/include/bits/memoryfwd.h index 751329c0c22..ae164fa7b5a 100644 --- a/libstdc++-v3/include/bits/memoryfwd.h +++ b/libstdc++-v3/include/bits/memoryfwd.h @@ -60,11 +60,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ +#if _GLIBCXX_HOSTED template class allocator; template<> class allocator; +#endif #if __cplusplus >= 201103L /// Declare uses_allocator so it can be specialized in `` etc. diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 9cb708ab2fd..e63fe66852e 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -59,15 +59,17 @@ #include #include #include -#include // for _Temporary_buffer #include #if __cplusplus >= 201103L #include #endif -#if _GLIBCXX_HOSTED && (__cplusplus <= 201103L || _GLIBCXX_USE_DEPRECATED) -#include // for rand +#if _GLIBCXX_HOSTED +# include // for _Temporary_buffer +# if (__cplusplus <= 201103L || _GLIBCXX_USE_DEPRECATED) +# include // for rand +# endif #endif // See concept_check.h for the __glibcxx_*_requires macros. @@ -1492,6 +1494,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) } } +#if _GLIBCXX_HOSTED // partition /// This is a helper function... @@ -1617,6 +1620,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) return std::__stable_partition(__first, __last, __gnu_cxx::__ops::__pred_iter(__pred)); } +#endif // HOSTED /// @cond undocumented @@ -2527,7 +2531,6 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) _ValueType; typedef typename iterator_traits<_BidirectionalIterator>::difference_type _DistanceType; - typedef _Temporary_buffer<_BidirectionalIterator, _ValueType> _TmpBuf; if (__first == __middle || __middle == __last) return; @@ -2535,6 +2538,8 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) const _DistanceType __len1 = std::distance(__first, __middle); const _DistanceType __len2 = std::distance(__middle, __last); +#if _GLIBCXX_HOSTED + typedef _Temporary_buffer<_BidirectionalIterator, _ValueType> _TmpBuf; // __merge_adaptive will use a buffer for the smaller of // [first,middle) and [middle,last). _TmpBuf __buf(__first, std::min(__len1, __len2)); @@ -2549,6 +2554,10 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) std::__merge_adaptive_resize (__first, __middle, __last, __len1, __len2, __buf.begin(), _DistanceType(__buf.size()), __comp); +#else + std::__merge_without_buffer + (__first, __middle, __last, __len1, __len2, __comp); +#endif } /** @@ -4585,7 +4594,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO std::iter_swap(__i, __j); } } -#endif +#endif // HOSTED /** * @brief Shuffle the elements of a sequence using a random number @@ -5017,11 +5026,12 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO _ValueType; typedef typename iterator_traits<_RandomAccessIterator>::difference_type _DistanceType; - typedef _Temporary_buffer<_RandomAccessIterator, _ValueType> _TmpBuf; if (__first == __last) return; +#if _GLIBCXX_HOSTED + typedef _Temporary_buffer<_RandomAccessIterator, _ValueType> _TmpBuf; // __stable_sort_adaptive sorts the range in two halves, // so the buffer only needs to fit half the range at once. _TmpBuf __buf(__first, (__last - __first + 1) / 2); @@ -5035,6 +5045,9 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO else std::__stable_sort_adaptive_resize(__first, __last, __buf.begin(), _DistanceType(__buf.size()), __comp); +#else + std::__inplace_stable_sort(__first, __last, __comp); +#endif } /** diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 84a1f9e98f6..ae898ed3706 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -442,6 +442,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX_END_NAMESPACE_CONTAINER +#if _GLIBCXX_HOSTED // Helpers for streambuf iterators (either istream or ostream). // NB: avoid including , relatively large. template @@ -479,6 +480,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*>); +#endif // HOSTED template _GLIBCXX20_CONSTEXPR @@ -574,6 +576,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER return __result; } +#if _GLIBCXX_HOSTED template typename __gnu_cxx::__enable_if< __is_char<_CharT>::__value, _CharT*>::__type @@ -587,6 +590,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER __copy_n_a(istreambuf_iterator<_CharT, char_traits<_CharT> >, _Size, _GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*>, bool); +#endif /** * @brief Copies the range [first,last) into result. diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h index 7ed69f53f7d..0b32074e5e9 100644 --- a/libstdc++-v3/include/bits/stl_uninitialized.h +++ b/libstdc++-v3/include/bits/stl_uninitialized.h @@ -359,6 +359,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } +#if _GLIBCXX_HOSTED template _GLIBCXX20_CONSTEXPR inline _ForwardIterator @@ -371,6 +372,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif return std::uninitialized_copy(__first, __last, __result); } +#endif template @@ -418,6 +420,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } +#if _GLIBCXX_HOSTED template _GLIBCXX20_CONSTEXPR inline void @@ -430,6 +433,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif std::uninitialized_fill(__first, __last, __x); } +#endif template @@ -453,6 +457,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } +#if _GLIBCXX_HOSTED template _GLIBCXX20_CONSTEXPR @@ -466,7 +471,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif return std::uninitialized_fill_n(__first, __n, __x); } - +#endif // Extensions: __uninitialized_copy_move, __uninitialized_move_copy, // __uninitialized_fill_move, __uninitialized_move_fill. @@ -725,13 +730,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } +#if _GLIBCXX_HOSTED template inline void __uninitialized_default_a(_ForwardIterator __first, _ForwardIterator __last, allocator<_Tp>&) { std::__uninitialized_default(__first, __last); } - +#endif // __uninitialized_default_n_a // Fills [first, first + n) with value_types constructed by the allocator @@ -756,6 +762,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } +#if _GLIBCXX_HOSTED // __uninitialized_default_n_a specialization for std::allocator, // which ignores the allocator and value-initializes the elements. template @@ -764,6 +771,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, allocator<_Tp>&) { return std::__uninitialized_default_n(__first, __n); } +#endif template struct __uninitialized_default_novalue_1 @@ -1094,6 +1102,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __cur; } +#if _GLIBCXX_HOSTED template _GLIBCXX20_CONSTEXPR inline __enable_if_t::value, _Tp*> @@ -1118,7 +1127,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } return __result + __count; } - +#endif template @@ -1136,7 +1145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } /// @endcond -#endif +#endif // C++11 /// @} group memory diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index e1ad7721a59..1086f408374 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -36,9 +36,11 @@ #include #include #include -#if __cplusplus > 201703L +#if __cplusplus >= 202002L # include -# include +# if _GLIBCXX_HOSTED +# include +# endif #endif #if __cplusplus > 202002L && __cpp_constexpr_dynamic_alloc @@ -1031,7 +1033,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION public __uniq_ptr_hash> { }; -#if __cplusplus >= 201402L +#if __cplusplus >= 201402L && _GLIBCXX_HOSTED #define __cpp_lib_make_unique 201304L /// @cond undocumented @@ -1131,9 +1133,9 @@ namespace __detail make_unique_for_overwrite(_Args&&...) = delete; #endif // C++20 -#endif // C++14 +#endif // C++14 && HOSTED -#if __cplusplus > 201703L && __cpp_concepts +#if __cplusplus > 201703L && __cpp_concepts && _GLIBCXX_HOSTED // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2948. unique_ptr does not define operator<< for stream output /// Stream output operator for unique_ptr @@ -1148,7 +1150,7 @@ namespace __detail __os << __p.get(); return __os; } -#endif // C++20 +#endif // C++20 && HOSTED /// @} group pointer_abstractions diff --git a/libstdc++-v3/include/c_global/cstdlib b/libstdc++-v3/include/c_global/cstdlib index 8a832aff0f9..0f7362e263f 100644 --- a/libstdc++-v3/include/c_global/cstdlib +++ b/libstdc++-v3/include/c_global/cstdlib @@ -51,19 +51,23 @@ #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 +#define NULL __null namespace std { - extern "C" void abort(void) throw () _GLIBCXX_NORETURN; - extern "C" int atexit(void (*)(void)) throw (); - extern "C" void exit(int) throw () _GLIBCXX_NORETURN; + extern "C" void abort(void) _GLIBCXX_NOTHROW _GLIBCXX_NORETURN; + extern "C" int atexit(void (*)(void)) _GLIBCXX_NOTHROW; + extern "C" void exit(int) _GLIBCXX_NOTHROW _GLIBCXX_NORETURN; #if __cplusplus >= 201103L # ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT - extern "C" int at_quick_exit(void (*)(void)) throw (); + extern "C" int at_quick_exit(void (*)(void)) _GLIBCXX_NOTHROW; # endif # ifdef _GLIBCXX_HAVE_QUICK_EXIT - extern "C" void quick_exit(int) throw() _GLIBCXX_NORETURN; + extern "C" void quick_exit(int) _GLIBCXX_NOTHROW_GLIBCXX_NORETURN; # endif +#if _GLIBCXX_USE_C99_STDLIB + extern "C" void _Exit(int) _GLIBCXX_NOTHROW _GLIBCXX_NORETURN; +#endif #endif } // namespace std @@ -174,7 +178,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifndef __CORRECT_ISO_CPP_STDLIB_H_PROTO inline ldiv_t - div(long __i, long __j) { return ldiv(__i, __j); } + div(long __i, long __j) _GLIBCXX_NOTHROW { return ldiv(__i, __j); } #endif @@ -200,7 +204,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using ::lldiv_t; #endif #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC - extern "C" void (_Exit)(int) throw () _GLIBCXX_NORETURN; + extern "C" void (_Exit)(int) _GLIBCXX_NOTHROW _GLIBCXX_NORETURN; #endif #if !_GLIBCXX_USE_C99_DYNAMIC using ::_Exit; @@ -217,11 +221,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC - extern "C" long long int (atoll)(const char *) throw (); + extern "C" long long int (atoll)(const char *) _GLIBCXX_NOTHROW; extern "C" long long int - (strtoll)(const char * __restrict, char ** __restrict, int) throw (); + (strtoll)(const char * __restrict, char ** __restrict, int) _GLIBCXX_NOTHROW; extern "C" unsigned long long int - (strtoull)(const char * __restrict, char ** __restrict, int) throw (); + (strtoull)(const char * __restrict, char ** __restrict, int) _GLIBCXX_NOTHROW; #endif #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC using ::atoll; diff --git a/libstdc++-v3/include/debug/assertions.h b/libstdc++-v3/include/debug/assertions.h index 57c0ab2c3cf..c3b5ad01d4f 100644 --- a/libstdc++-v3/include/debug/assertions.h +++ b/libstdc++-v3/include/debug/assertions.h @@ -31,14 +31,6 @@ #include -#ifndef _GLIBCXX_DEBUG - -# define _GLIBCXX_DEBUG_ASSERT(_Condition) -# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) -# define _GLIBCXX_DEBUG_ONLY(_Statement) - -#endif - #ifndef _GLIBCXX_ASSERTIONS # define __glibcxx_requires_non_empty_range(_First,_Last) # define __glibcxx_requires_nonempty() @@ -55,7 +47,8 @@ __glibcxx_assert(!this->empty()) #endif -#ifdef _GLIBCXX_DEBUG +#if defined _GLIBCXX_DEBUG && _GLIBCXX_HOSTED + # define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition) # ifdef _GLIBCXX_DEBUG_PEDANTIC @@ -65,6 +58,11 @@ # endif # define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement + +#else +# define _GLIBCXX_DEBUG_ASSERT(_Condition) +# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) +# define _GLIBCXX_DEBUG_ONLY(_Statement) #endif #endif // _GLIBCXX_DEBUG_ASSERTIONS diff --git a/libstdc++-v3/include/debug/debug.h b/libstdc++-v3/include/debug/debug.h index f4233760426..78546d76123 100644 --- a/libstdc++-v3/include/debug/debug.h +++ b/libstdc++-v3/include/debug/debug.h @@ -61,7 +61,7 @@ namespace __gnu_debug struct _Safe_iterator; } -#ifndef _GLIBCXX_DEBUG +#if ! defined _GLIBCXX_DEBUG || ! _GLIBCXX_HOSTED # define __glibcxx_requires_cond(_Cond,_Msg) # define __glibcxx_requires_valid_range(_First,_Last) diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit index ef19d649e32..2fd80187210 100644 --- a/libstdc++-v3/include/std/bit +++ b/libstdc++-v3/include/std/bit @@ -35,7 +35,7 @@ #include -#if _GLIBCXX_HOSTED +#if _GLIBCXX_HOSTED || __has_include() # include #else # include diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 685a3e167ee..c4f75880fd8 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -56,18 +56,22 @@ #include #include #include // std::reference_wrapper and _Mem_fn_traits -#include // std::function -#if __cplusplus > 201402L -# include -# include -# include -# include +#if _GLIBCXX_HOSTED +# include // std::function +#endif +#if __cplusplus >= 201703L +# if _GLIBCXX_HOSTED +# include +# include +# include +# endif +# include // std::search #endif #if __cplusplus > 201703L # include # include #endif -#if __cplusplus > 202002L +#if __cplusplus > 202002L && _GLIBCXX_HOSTED # include #endif @@ -238,7 +242,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @brief Trait that identifies a bind expression. - * + * * Determines if the given type `_Tp` is a function object that * should be treated as a subexpression when evaluating calls to * function objects returned by `std::bind`. @@ -1117,6 +1121,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION tuple<_ForwardIterator1, _ForwardIterator1, _BinaryPredicate> _M_m; }; +#if _GLIBCXX_HOSTED template struct __boyer_moore_map_base { @@ -1359,6 +1364,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } return std::make_pair(__last, __last); } +#endif // HOSTED #endif // C++17 #endif // C++14 diff --git a/libstdc++-v3/include/std/iterator b/libstdc++-v3/include/std/iterator index 2da2fb6e4a3..fb2a47c0dbb 100644 --- a/libstdc++-v3/include/std/iterator +++ b/libstdc++-v3/include/std/iterator @@ -61,8 +61,10 @@ #include #include #include -#include -#include +#if _GLIBCXX_HOSTED +# include +# include +#endif #include #if __cplusplus >= 201402L && ! defined _GLIBCXX_DEBUG // PR libstdc++/70303 diff --git a/libstdc++-v3/include/std/memory b/libstdc++-v3/include/std/memory index 20a55020a36..3eff12108f1 100644 --- a/libstdc++-v3/include/std/memory +++ b/libstdc++-v3/include/std/memory @@ -60,7 +60,10 @@ * Smart pointers, etc. */ -#include +#include +#if _GLIBCXX_HOSTED +# include +#endif #include #include #include @@ -73,8 +76,10 @@ # include # include # include +# if _GLIBCXX_HOSTED # include # include +# endif #endif #if __cplusplus < 201103L || _GLIBCXX_USE_DEPRECATED @@ -86,7 +91,7 @@ # include #endif -#if __cplusplus >= 201103L && __cplusplus <= 202002L +#if __cplusplus >= 201103L && __cplusplus <= 202002L && _GLIBCXX_HOSTED namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -133,7 +138,7 @@ _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // C++11 to C++20 -#if __cplusplus >= 201703L +#if __cplusplus >= 201703L && _GLIBCXX_HOSTED // Parallel STL algorithms # if _PSTL_EXECUTION_POLICIES_DEFINED // If has already been included, pull in implementations diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 53093a3762f..c2eacdebe28 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -701,6 +701,7 @@ namespace views inline constexpr _Iota iota{}; } // namespace views +#if _GLIBCXX_HOSTED namespace __detail { template @@ -804,6 +805,7 @@ namespace views template inline constexpr _Istream<_Tp> istream; } +#endif // HOSTED // C++20 24.7 [range.adaptors] Range adaptors @@ -2234,9 +2236,11 @@ namespace views::__adaptor template inline constexpr bool __is_basic_string_view = false; +#if _GLIBCXX_HOSTED template inline constexpr bool __is_basic_string_view> = true; +#endif template inline constexpr bool __is_subrange = false; -- 2.37.3