]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add preprocessor conditions for freestanding [PR106953]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 15 Sep 2022 20:02:32 +0000 (21:02 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 16 Sep 2022 20:47:19 +0000 (21:47 +0100)
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, <iterator> needs to be installed for C++23
freestanding mode, but without stream iterators and streambuf iterators.
Similarly, <memory> 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<std::allocator<T>> 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 <ext/numeric_traits.h> 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.

15 files changed:
libstdc++-v3/include/backward/auto_ptr.h
libstdc++-v3/include/bits/alloc_traits.h
libstdc++-v3/include/bits/memoryfwd.h
libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/include/bits/stl_algobase.h
libstdc++-v3/include/bits/stl_uninitialized.h
libstdc++-v3/include/bits/unique_ptr.h
libstdc++-v3/include/c_global/cstdlib
libstdc++-v3/include/debug/assertions.h
libstdc++-v3/include/debug/debug.h
libstdc++-v3/include/std/bit
libstdc++-v3/include/std/functional
libstdc++-v3/include/std/iterator
libstdc++-v3/include/std/memory
libstdc++-v3/include/std/ranges

index 184ab4034660e40dbb568446a01f133e5c615ebe..093db5260fc390dc2b27eea40aa6688a946549a1 100644 (file)
@@ -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
 
index 35bdf6ecf98e74a8fcbc4fb39bbd4655643cc0da..507e8f1b6b2dabb84fa818563cd842042ad3a9b1 100644 (file)
 #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
index 751329c0c22bb27919c6f7a85aa77b899d33b0c0..ae164fa7b5ad2af9abff40f371894e69e8970a03 100644 (file)
@@ -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.
index 9cb708ab2fd63b9c22876fe018fa657903fd19a7..e63fe66852e33db669c74c8e7cee10fe3a9c7fe0 100644 (file)
 #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
     }
 
   /**
index 84a1f9e98f645d2a0eddb1b054fb5502deac7403..ae898ed37064a568c2ecb6fb92d1ff590236a100 100644 (file)
@@ -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.
index 7ed69f53f7d8f04963303c7170f3723ab176ab9b..0b32074e5e92ff4274e25eda13ec85e61ce452c4 100644 (file)
@@ -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
 
index e1ad7721a5935828783b54154f58d80c75662bc8..1086f408374cd1688ab9ab7348ff743850726ada 100644 (file)
 #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
 
index 8a832aff0f98fd8325f691a30aad39d136626cc6..0f7362e263f64e8817d6966dbac73f0c84e0c429 100644 (file)
 
 #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;
index 57c0ab2c3cf6d714ba41fed1b1107745494ba5e2..c3b5ad01d4fb7eb86f6847565b0bcbb3d1ec3a85 100644 (file)
 
 #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
 # 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
index f4233760426e071714436ac818a70d547b124b7d..78546d76123b6e310d11b02169a9471a83cc6e1d 100644 (file)
@@ -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)
index ef19d649e32ded777c8622dd10e77b12ba208b3b..2fd80187210a5f11aaaef7f666b270f697af8f07 100644 (file)
@@ -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>
index 685a3e167ee3577e0aa2317eaee2571a5f9271ee..c4f75880fd8ba6cdba6591408bbe5d56dc3435cc 100644 (file)
 #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
index 2da2fb6e4a3a3d8eaa4b01984033e6315f97d930..fb2a47c0dbb2f2ed1fa698c1a918baddb556f25c 100644 (file)
 #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
index 20a55020a36f6d1589f077af689fe25c06829ea0..3eff12108f19bcc465e06402aa3a7c7ee9a389f7 100644 (file)
  * 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>
 #  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
index 53093a3762f999a03da54153b466051cbc33ecd6..c2eacdebe283bec9a5afae9a94b398c1720f33e5 100644 (file)
@@ -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;