@@ -300,6 +300,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
} _GLIBCXX11_DEPRECATED;
#if __cplusplus >= 201103L
+#if _GLIBCXX_HOSTED
template<_Lock_policy _Lp>
template<typename _Tp>
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<typename _Tp, typename _Dp>
template<typename _Up, typename>
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
@@ -33,9 +33,11 @@
#include <bits/stl_construct.h>
#include <bits/memoryfwd.h>
#if __cplusplus >= 201103L
-# include <bits/allocator.h>
# include <bits/ptr_traits.h>
# include <ext/numeric_traits.h>
+# if _GLIBCXX_HOSTED
+# include <bits/allocator.h>
+# 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<typename _Tp>
struct __is_copy_insertable<allocator<_Tp>>
: 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<typename _Tp>
struct __is_move_insertable<allocator<_Tp>>
: is_move_constructible<_Tp>
{ };
+#endif
// Trait to detect Allocator-like types.
template<typename _Alloc, typename = void>
@@ -893,6 +902,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
}
+#if _GLIBCXX_HOSTED
template<typename _ForwardIterator, typename _Tp>
_GLIBCXX20_CONSTEXPR
inline void
@@ -901,6 +911,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
_Destroy(__first, __last);
}
+#endif
/// @endcond
_GLIBCXX_END_NAMESPACE_VERSION
@@ -60,11 +60,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @{
*/
+#if _GLIBCXX_HOSTED
template<typename>
class allocator;
template<>
class allocator<void>;
+#endif
#if __cplusplus >= 201103L
/// Declare uses_allocator so it can be specialized in `<queue>` etc.
@@ -59,15 +59,17 @@
#include <bits/algorithmfwd.h>
#include <bits/stl_algobase.h>
#include <bits/stl_heap.h>
-#include <bits/stl_tempbuf.h> // for _Temporary_buffer
#include <bits/predefined_ops.h>
#if __cplusplus >= 201103L
#include <bits/uniform_int_dist.h>
#endif
-#if _GLIBCXX_HOSTED && (__cplusplus <= 201103L || _GLIBCXX_USE_DEPRECATED)
-#include <cstdlib> // for rand
+#if _GLIBCXX_HOSTED
+# include <bits/stl_tempbuf.h> // for _Temporary_buffer
+# if (__cplusplus <= 201103L || _GLIBCXX_USE_DEPRECATED)
+# include <cstdlib> // 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
}
/**
@@ -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 <iosfwd>, relatively large.
template<typename _CharT>
@@ -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<bool _IsMove, typename _II, typename _OI>
_GLIBCXX20_CONSTEXPR
@@ -574,6 +576,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
return __result;
}
+#if _GLIBCXX_HOSTED
template<typename _CharT, typename _Size>
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.
@@ -359,6 +359,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
}
+#if _GLIBCXX_HOSTED
template<typename _InputIterator, typename _ForwardIterator, typename _Tp>
_GLIBCXX20_CONSTEXPR
inline _ForwardIterator
@@ -371,6 +372,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
return std::uninitialized_copy(__first, __last, __result);
}
+#endif
template<typename _InputIterator, typename _ForwardIterator,
typename _Allocator>
@@ -418,6 +420,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
}
+#if _GLIBCXX_HOSTED
template<typename _ForwardIterator, typename _Tp, typename _Tp2>
_GLIBCXX20_CONSTEXPR
inline void
@@ -430,6 +433,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
std::uninitialized_fill(__first, __last, __x);
}
+#endif
template<typename _ForwardIterator, typename _Size, typename _Tp,
typename _Allocator>
@@ -453,6 +457,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
}
+#if _GLIBCXX_HOSTED
template<typename _ForwardIterator, typename _Size, typename _Tp,
typename _Tp2>
_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<typename _ForwardIterator, typename _Tp>
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<typename _ForwardIterator, typename _Size, typename _Tp>
@@ -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<bool _TrivialValueType>
struct __uninitialized_default_novalue_1
@@ -1094,6 +1102,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __cur;
}
+#if _GLIBCXX_HOSTED
template <typename _Tp, typename _Up>
_GLIBCXX20_CONSTEXPR
inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp*>
@@ -1118,7 +1127,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
return __result + __count;
}
-
+#endif
template <typename _InputIterator, typename _ForwardIterator,
typename _Allocator>
@@ -1136,7 +1145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
/// @endcond
-#endif
+#endif // C++11
/// @} group memory
@@ -36,9 +36,11 @@
#include <tuple>
#include <bits/stl_function.h>
#include <bits/functional_hash.h>
-#if __cplusplus > 201703L
+#if __cplusplus >= 202002L
# include <compare>
-# include <ostream>
+# if _GLIBCXX_HOSTED
+# include <ostream>
+# endif
#endif
#if __cplusplus > 202002L && __cpp_constexpr_dynamic_alloc
@@ -1031,7 +1033,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
public __uniq_ptr_hash<unique_ptr<_Tp, _Dp>>
{ };
-#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
@@ -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;
@@ -31,14 +31,6 @@
#include <bits/c++config.h>
-#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
@@ -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)
@@ -35,7 +35,7 @@
#include <type_traits>
-#if _GLIBCXX_HOSTED
+#if _GLIBCXX_HOSTED || __has_include(<ext/numeric_traits.h>)
# include <ext/numeric_traits.h>
#else
# include <limits>
@@ -56,18 +56,22 @@
#include <bits/functional_hash.h>
#include <bits/invoke.h>
#include <bits/refwrap.h> // std::reference_wrapper and _Mem_fn_traits
-#include <bits/std_function.h> // std::function
-#if __cplusplus > 201402L
-# include <unordered_map>
-# include <vector>
-# include <array>
-# include <bits/stl_algo.h>
+#if _GLIBCXX_HOSTED
+# include <bits/std_function.h> // std::function
+#endif
+#if __cplusplus >= 201703L
+# if _GLIBCXX_HOSTED
+# include <unordered_map>
+# include <vector>
+# include <array>
+# endif
+# include <bits/stl_algo.h> // std::search
#endif
#if __cplusplus > 201703L
# include <bits/ranges_cmp.h>
# include <compare>
#endif
-#if __cplusplus > 202002L
+#if __cplusplus > 202002L && _GLIBCXX_HOSTED
# include <bits/move_only_function.h>
#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<typename _Key, typename _Tp, typename _Hash, typename _Pred>
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
@@ -61,8 +61,10 @@
#include <bits/stl_iterator_base_types.h>
#include <bits/stl_iterator_base_funcs.h>
#include <bits/stl_iterator.h>
-#include <bits/stream_iterator.h>
-#include <bits/streambuf_iterator.h>
+#if _GLIBCXX_HOSTED
+# include <bits/stream_iterator.h>
+# include <bits/streambuf_iterator.h>
+#endif
#include <bits/range_access.h>
#if __cplusplus >= 201402L && ! defined _GLIBCXX_DEBUG // PR libstdc++/70303
@@ -60,7 +60,10 @@
* Smart pointers, etc.
*/
-#include <bits/allocator.h>
+#include <bits/memoryfwd.h>
+#if _GLIBCXX_HOSTED
+# include <bits/allocator.h>
+#endif
#include <bits/stl_construct.h>
#include <bits/stl_uninitialized.h>
#include <bits/stl_tempbuf.h>
@@ -73,8 +76,10 @@
# include <bits/alloc_traits.h>
# include <debug/debug.h>
# include <bits/unique_ptr.h>
+# if _GLIBCXX_HOSTED
# include <bits/shared_ptr.h>
# include <bits/shared_ptr_atomic.h>
+# endif
#endif
#if __cplusplus < 201103L || _GLIBCXX_USE_DEPRECATED
@@ -86,7 +91,7 @@
# include <bits/uses_allocator_args.h>
#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 <execution> has already been included, pull in implementations
@@ -701,6 +701,7 @@ namespace views
inline constexpr _Iota iota{};
} // namespace views
+#if _GLIBCXX_HOSTED
namespace __detail
{
template<typename _Val, typename _CharT, typename _Traits>
@@ -804,6 +805,7 @@ namespace views
template<typename _Tp>
inline constexpr _Istream<_Tp> istream;
}
+#endif // HOSTED
// C++20 24.7 [range.adaptors] Range adaptors
@@ -2234,9 +2236,11 @@ namespace views::__adaptor
template<typename _Range>
inline constexpr bool __is_basic_string_view = false;
+#if _GLIBCXX_HOSTED
template<typename _CharT, typename _Traits>
inline constexpr bool __is_basic_string_view<basic_string_view<_CharT, _Traits>>
= true;
+#endif
template<typename _Range>
inline constexpr bool __is_subrange = false;