Hello
I've made an implementation of P0829 and tested it with gcc for avr.
I've included the patch and I believe it might need some modification.
Should I rather just maintain my own fork until P0829 is a bit
further? (It is currently being split into smaller proposals).
I have not included further tests, nor actually run the tests since
everything is in header files is only includes of already existing
libstdc++ code.

Best regards

Paul M. Bendixen
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index bc475c6dd90..3feed5b3bff 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -1886,18 +1886,62 @@ install-freestanding-headers:
 	$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/bits
 	for file in c++0x_warning.h atomic_base.h concept_check.h move.h; do \
 	  $(INSTALL_DATA) ${glibcxx_srcdir}/include/bits/$${file} $(DESTDIR)${gxx_include_dir}/bits; done
+	# P0829 headers
+	for file in algorithmfwd.h alloc_traits.h boost_concept_check.h char_traits.h \
+          concept_check.h cpp_type_traits.h functexcept.h functional_hash.h \
+          hash_byte.h invoke.h memoryfwd.h parse_numbers.h postypes.h predefined_ops.h \
+	  ptr_traits.h random.h random.tcc range_access.h refwrap.h std_abs.h stl_algo.h \
+	  stl_algobase.h stl_construct.h stl_function.h stl_heap.h stl_iterator.h \
+	  stl_iterator_base_funcs.h  stl_iterator_base_types.h \
+	  stl_numeric.h stl_pair.h stl_relops.h stl_uninitialized.h unique_ptr.h \
+          uniform_int_dist.h uses_allocator.h ; do \
+	  $(INSTALL_DATA) ${glibcxx_srcdir}/include/bits/$${file} $(DESTDIR)${gxx_include_dir}/bits; done
 	$(mkinstalldirs) $(DESTDIR)${host_installdir}
 	for file in ${host_srcdir}/os_defines.h ${host_builddir}/c++config.h \
 	  ${glibcxx_srcdir}/$(ABI_TWEAKS_SRCDIR)/cxxabi_tweaks.h \
+	  ${glibcxx_srcdir}/$(ERROR_CONSTANTS_SRCDIR)/error_constants.h \
 	  ${glibcxx_srcdir}/$(CPU_DEFINES_SRCDIR)/cpu_defines.h; do \
 	  $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done
 	$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir}
 	for file in limits type_traits atomic bit version; do \
 	  $(INSTALL_DATA) ${std_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${std_builddir}; done
+	#P0829 headers
+	# Remaining headers:
+	#	cwchar memory ranges variant
+	# Will not be implemented:
+	#	cinttypes 
+	for file in algorithm array bitset chrono charconv functional iterator \
+          memory numeric optional random ratio string string_view system_error \
+          utility tuple ; do \
+	  $(INSTALL_DATA) ${std_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${std_builddir}; done
 	$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir}
 	for file in ciso646 cstddef cfloat climits cstdint cstdlib \
 	  cstdalign cstdarg cstdbool; do \
 	  $(INSTALL_DATA) ${c_base_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done
+	#P0829 headers
+	for file in csetjmp cwchar cerrno cmath ctime cctype cstring; do \
+	  $(INSTALL_DATA) ${c_base_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done
+	$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${ext_builddir}
+	for file in type_traits.h numeric_traits.h; do \
+	  $(INSTALL_DATA) ${ext_srcdir}/$${file} $(DESTDIR)${gxx_include_dir}/${ext_builddir}; done
+	#P0829 headers ext
+	for file in alloc_traits.h; do \
+	  $(INSTALL_DATA) ${ext_srcdir}/$${file} $(DESTDIR)${gxx_include_dir}/${ext_builddir}; done
+	$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${debug_builddir}
+	for file in array debug.h assertions.h; do \
+	  $(INSTALL_DATA) ${debug_srcdir}/$${file} $(DESTDIR)${gxx_include_dir}/${debug_builddir}; done
+	#P0829
+	$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${backward_builddir}
+	for file in binders.h ; do \
+	  $(INSTALL_DATA) ${backward_srcdir}/$${file} $(DESTDIR)${gxx_include_dir}/${backward_builddir}; done
+	$(mkinstalldirs) $(DESTDIR)${host_installdir}
+	for file in ${host_headers} ${bits_host_headers} ${host_headers_extra} \
+	 ${thread_host_headers}; do \
+	  $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done
+	$(mkinstalldirs) $(DESTDIR)${host_installdir}/../ext
+	for file in ${ext_host_headers}; do \
+	  $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}/../ext; done
+
 
 # The real deal.
 install-headers:
diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h
index 40e051aa9e3..ebf6bd5610d 100644
--- a/libstdc++-v3/include/bits/algorithmfwd.h
+++ b/libstdc++-v3/include/bits/algorithmfwd.h
@@ -289,6 +289,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     bool
     includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare);
 
+#if _GLIBCXX_HOSTED
   template<typename _BIter>
     void
     inplace_merge(_BIter, _BIter, _BIter);
@@ -296,6 +297,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _BIter, typename _Compare>
     void
     inplace_merge(_BIter, _BIter, _BIter, _Compare);
+#endif // _GLIBCXX_HOSTED
 
 #if __cplusplus >= 201103L
   template<typename _RAIter>
@@ -575,9 +577,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     void
     sort_heap(_RAIter, _RAIter, _Compare);
 
+#if _GLIBCXX_HOSTED
   template<typename _BIter, typename _Predicate>
     _BIter
     stable_partition(_BIter, _BIter, _Predicate);
+#endif // _GLIBCXX_HOSTED
 
 #if __cplusplus < 201103L
   // For C++11 swap() is declared in <type_traits>.
@@ -817,6 +821,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
     void
     sort(_RAIter, _RAIter, _Compare);
 
+#if _GLIBCXX_HOSTED
   template<typename _RAIter>
     void
     stable_sort(_RAIter, _RAIter);
@@ -824,6 +829,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
   template<typename _RAIter, typename _Compare>
     void
     stable_sort(_RAIter, _RAIter, _Compare);
+#endif // _GLIBCXX_HOSTED
 
   template<typename _IIter, typename _OIter, typename _UnaryOperation>
     _OIter
diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h
index cda768bf391..a3dfd578cbf 100644
--- a/libstdc++-v3/include/bits/alloc_traits.h
+++ b/libstdc++-v3/include/bits/alloc_traits.h
@@ -388,6 +388,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
   /// Partial specialization for std::allocator.
+#if _GLIBCXX_HOSTED
   template<typename _Tp>
     struct allocator_traits<allocator<_Tp>>
     {
@@ -514,6 +515,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       select_on_container_copy_construction(const allocator_type& __rhs)
       { return __rhs; }
     };
+#endif // _GLIBCXX_HOSTED
 
 
   template<typename _Alloc>
@@ -601,10 +603,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { };
 
   // std::allocator<_Tp> just requires CopyConstructible
+#if _GLIBCXX_HOSTED
   template<typename _Tp>
     struct __is_copy_insertable<allocator<_Tp>>
     : is_copy_constructible<_Tp>
     { };
+#endif // _GLIBCXX_HOSTED
 
   // true if _Alloc::value_type is MoveInsertable into containers using _Alloc
   // (might be wrong if _Alloc::construct exists but is not constrained,
@@ -615,10 +619,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { };
 
   // std::allocator<_Tp> just requires MoveConstructible
+#if _GLIBCXX_HOSTED
   template<typename _Tp>
     struct __is_move_insertable<allocator<_Tp>>
     : is_move_constructible<_Tp>
     { };
+#endif // _GLIBCXX_HOSTED
 
   // Trait to detect Allocator-like types.
   template<typename _Alloc, typename = void>
diff --git a/libstdc++-v3/include/bits/memoryfwd.h b/libstdc++-v3/include/bits/memoryfwd.h
index 8b1664a398d..fa6d2d23eea 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<typename>
     class allocator;
 
   template<>
     class allocator<void>;
+#endif // _GLIBCXX_HOSTED
 
   /// Declare uses_allocator so it can be specialized in \<queue\> etc.
   template<typename, typename>
diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h
index 2b1df4cb59e..1b618a5d9ac 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -31,7 +31,9 @@
 #ifndef _RANDOM_H
 #define _RANDOM_H 1
 
+#if _GLIBCXX_HOSTED
 #include <vector>
+#endif // _GLIBCXX_HOSTED
 #include <bits/uniform_int_dist.h>
 
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -366,6 +368,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		 const linear_congruential_engine& __rhs)
       { return __lhs._M_x == __rhs._M_x; }
 
+#if _GLIBCXX_HOSTED
       /**
        * @brief Writes the textual representation of the state x(i) of x to
        *        @p __os.
@@ -400,6 +403,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	operator>>(std::basic_istream<_CharT, _Traits>& __is,
 		   std::linear_congruential_engine<_UIntType1, __a1,
 		   __c1, __m1>& __lcr);
+#endif // _GLIBCXX_HOSTED
 
     private:
       _UIntType _M_x;
@@ -578,6 +582,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { return (std::equal(__lhs._M_x, __lhs._M_x + state_size, __rhs._M_x)
 		&& __lhs._M_p == __rhs._M_p); }
 
+#if _GLIBCXX_HOSTED
       /**
        * @brief Inserts the current state of a % mersenne_twister_engine
        *        random number generator engine @p __x into the output stream
@@ -629,6 +634,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		   std::mersenne_twister_engine<_UIntType1, __w1, __n1, __m1,
 		   __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1,
 		   __l1, __f1>& __x);
+#endif // _GLIBCXX_HOSTED
 
     private:
       void _M_gen_rand();
@@ -797,6 +803,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		&& __lhs._M_carry == __rhs._M_carry
 		&& __lhs._M_p == __rhs._M_p); }
 
+#if _GLIBCXX_HOSTED
       /**
        * @brief Inserts the current state of a % subtract_with_carry_engine
        *        random number generator engine @p __x into the output stream
@@ -834,6 +841,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	operator>>(std::basic_istream<_CharT, _Traits>& __is,
 		   std::subtract_with_carry_engine<_UIntType1, __w1,
 		   __s1, __r1>& __x);
+#endif // _GLIBCXX_HOSTED
 
     private:
       /// The state of the generator.  This is a ring buffer.
@@ -1025,6 +1033,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		 const discard_block_engine& __rhs)
       { return __lhs._M_b == __rhs._M_b && __lhs._M_n == __rhs._M_n; }
 
+#if _GLIBCXX_HOSTED
       /**
        * @brief Inserts the current state of a %discard_block_engine random
        *        number generator engine @p __x into the output stream
@@ -1060,6 +1069,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	operator>>(std::basic_istream<_CharT, _Traits>& __is,
 		   std::discard_block_engine<_RandomNumberEngine1,
 		   __p1, __r1>& __x);
+#endif // _GLIBCXX_HOSTED
 
     private:
       _RandomNumberEngine _M_b;
@@ -1236,6 +1246,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		 const independent_bits_engine& __rhs)
       { return __lhs._M_b == __rhs._M_b; }
 
+#if _GLIBCXX_HOSTED
       /**
        * @brief Extracts the current state of a % subtract_with_carry_engine
        *        random number generator engine @p __x from the input stream
@@ -1257,6 +1268,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  __is >> __x._M_b;
 	  return __is;
 	}
+#endif // _GLIBCXX_HOSTED
 
     private:
       _RandomNumberEngine _M_b;
@@ -1282,6 +1294,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	       _UIntType>& __rhs)
     { return !(__lhs == __rhs); }
 
+#if _GLIBCXX_HOSTED
   /**
    * @brief Inserts the current state of a %independent_bits_engine random
    *        number generator engine @p __x into the output stream @p __os.
@@ -1302,8 +1315,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __os << __x.base();
       return __os;
     }
+#endif // _GLIBCXX_HOSTED
 
-
+#if _GLIBCXX_HOSTED
   /**
    * @brief Produces random numbers by combining random numbers from some
    * base engine to produce random numbers with a specifies number of bits
@@ -1534,7 +1548,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	       const std::shuffle_order_engine<_RandomNumberEngine,
 	       __k>& __rhs)
     { return !(__lhs == __rhs); }
-
+#endif
 
   /**
    * The classic Minimum Standard rand0 of Lewis, Goodman, and Miller.
@@ -1586,10 +1600,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
 
+#if _GLIBCXX_HOSTED
   typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
+#endif // _GLIBCXX_HOSTED
 
   typedef minstd_rand0 default_random_engine;
 
+#if _GLIBCXX_HOSTED
   /**
    * A standard interface to a platform-specific non-deterministic
    * random number generator (if any are available).
@@ -1666,6 +1683,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       mt19937    _M_mt;
     };
   };
+#endif // _GLIBCXX_HOSTED
 
   /* @} */ // group random_generators
 
@@ -1693,6 +1711,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	       const std::uniform_int_distribution<_IntType>& __d2)
     { return !(__d1 == __d2); }
 
+#if _GLIBCXX_HOSTED
   /**
    * @brief Inserts a %uniform_int_distribution random number
    *        distribution @p __x into the output stream @p os.
@@ -6093,6 +6112,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     std::vector<result_type> _M_v;
   };
 
+#endif // _GLIBCXX_HOSTED
   /* @} */ // group random_utilities
 
   /* @} */ // group random
diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc
index b80ab82ba15..5aa5ad31b19 100644
--- a/libstdc++-v3/include/bits/random.tcc
+++ b/libstdc++-v3/include/bits/random.tcc
@@ -148,6 +148,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	seed(__sum);
       }
 
+#if _GLIBCXX_HOSTED
   template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m,
 	   typename _CharT, typename _Traits>
     std::basic_ostream<_CharT, _Traits>&
@@ -187,6 +188,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __is.flags(__flags);
       return __is;
     }
+#endif // _GLIBCXX_HOSTED
 
 
   template<typename _UIntType,
@@ -467,6 +469,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __z;
     }
 
+#if _GLIBCXX_HOSTED
   template<typename _UIntType, size_t __w,
 	   size_t __n, size_t __m, size_t __r,
 	   _UIntType __a, size_t __u, _UIntType __d, size_t __s,
@@ -518,6 +521,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __is.flags(__flags);
       return __is;
     }
+#endif // _GLIBCXX_HOSTED
 
 
   template<typename _UIntType, size_t __w, size_t __s, size_t __r>
@@ -626,6 +630,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __xi;
     }
 
+#if _GLIBCXX_HOSTED
   template<typename _UIntType, size_t __w, size_t __s, size_t __r,
 	   typename _CharT, typename _Traits>
     std::basic_ostream<_CharT, _Traits>&
@@ -671,6 +676,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __is.flags(__flags);
       return __is;
     }
+#endif // _GLIBCXX_HOSTED
 
 
   template<typename _RandomNumberEngine, size_t __p, size_t __r>
@@ -696,6 +702,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return _M_b();
     }
 
+#if _GLIBCXX_HOSTED
   template<typename _RandomNumberEngine, size_t __p, size_t __r,
 	   typename _CharT, typename _Traits>
     std::basic_ostream<_CharT, _Traits>&
@@ -736,6 +743,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __is.flags(__flags);
       return __is;
     }
+#endif // _GLIBCXX_HOSTED
 
 
   template<typename _RandomNumberEngine, size_t __w, typename _UIntType>
@@ -808,6 +816,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
 
+#if _GLIBCXX_HOSTED
   template<typename _RandomNumberEngine, size_t __k>
     constexpr size_t
     shuffle_order_engine<_RandomNumberEngine, __k>::table_size;
@@ -3349,6 +3358,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __ret;
     }
 
+#endif // _GLIBCXX_HOSTED
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index 3411a63b1a3..73de72f4a1e 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -59,7 +59,9 @@
 #include <cstdlib>	     // for rand
 #include <bits/algorithmfwd.h>
 #include <bits/stl_heap.h>
+#if _GLIBCXX_HOSTED
 #include <bits/stl_tempbuf.h>  // for _Temporary_buffer
+#endif
 #include <bits/predefined_ops.h>
 
 #if __cplusplus >= 201103L
@@ -1537,6 +1539,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // partition
 
+  // p0829 expcludes stable_sort, stable_partition and inplace_merge
+#if _GLIBCXX_HOSTED
   /// This is a helper function...
   /// Requires __first != __last and !__pred(__first)
   /// and __len == distance(__first, __last).
@@ -1660,6 +1664,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return std::__stable_partition(__first, __last,
 				     __gnu_cxx::__ops::__pred_iter(__pred));
     }
+#endif // _GLIBCXX_HOSTED
 
   /// This is a helper function for the sort routines.
   template<typename _RandomAccessIterator, typename _Compare>
@@ -2515,6 +2520,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 				  __len1 - __len11, __len2 - __len22, __comp);
     }
 
+  // p0829 expcludes stable_sort, stable_partition and inplace_merge
+#if _GLIBCXX_HOSTED
   template<typename _BidirectionalIterator, typename _Compare>
     void
     __inplace_merge(_BidirectionalIterator __first,
@@ -2624,6 +2631,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       std::__inplace_merge(__first, __middle, __last,
 			   __gnu_cxx::__ops::__iter_comp_iter(__comp));
     }
+#endif
 
 
   /// This is a helper function for the __merge_sort_loop routines.
@@ -2720,6 +2728,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
     }
 
+  // p0829 expcludes stable_sort, stable_partition and inplace_merge
+#if _GLIBCXX_HOSTED
   template<typename _RandomAccessIterator, typename _Pointer,
 	   typename _Distance, typename _Compare>
     void
@@ -2770,6 +2780,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
   // stable_sort
+#endif
 
   // Set algorithms: includes, set_union, set_intersection, set_difference,
   // set_symmetric_difference.  All of these algorithms have the precondition
@@ -4981,6 +4992,9 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
 				__gnu_cxx::__ops::__iter_comp_iter(__comp));
     }
 
+  // p0829 expcludes stable_sort, stable_partition and inplace_merge
+#if _GLIBCXX_HOSTED
+
   template<typename _RandomAccessIterator, typename _Compare>
     inline void
     __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
@@ -5069,6 +5083,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
       _GLIBCXX_STD_A::__stable_sort(__first, __last,
 				    __gnu_cxx::__ops::__iter_comp_iter(__comp));
     }
+#endif
 
   template<typename _InputIterator1, typename _InputIterator2,
 	   typename _OutputIterator,
diff --git a/libstdc++-v3/include/bits/stl_construct.h b/libstdc++-v3/include/bits/stl_construct.h
index bf063398ebe..016ab9213b2 100644
--- a/libstdc++-v3/include/bits/stl_construct.h
+++ b/libstdc++-v3/include/bits/stl_construct.h
@@ -198,6 +198,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	__traits::destroy(__alloc, std::__addressof(*__first));
     }
 
+#if _GLIBCXX_HOSTED
   template<typename _ForwardIterator, typename _Tp>
     inline void
     _Destroy(_ForwardIterator __first, _ForwardIterator __last,
@@ -205,6 +206,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
       _Destroy(__first, __last);
     }
+#endif // _GLIBCXX_HOSTED
 
 #if __cplusplus > 201402L
   template <typename _Tp>
diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h
index 0d42b253df1..e64dd870fa1 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -282,11 +282,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
     }
 
+#if _GLIBCXX_HOSTED
   template<typename _InputIterator, typename _ForwardIterator, typename _Tp>
     inline _ForwardIterator
     __uninitialized_copy_a(_InputIterator __first, _InputIterator __last,
 			   _ForwardIterator __result, allocator<_Tp>&)
     { return std::uninitialized_copy(__first, __last, __result); }
+#endif // _GLIBCXX_HOSTED
 
   template<typename _InputIterator, typename _ForwardIterator,
 	   typename _Allocator>
@@ -331,11 +333,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
     }
 
+#if _GLIBCXX_HOSTED
   template<typename _ForwardIterator, typename _Tp, typename _Tp2>
     inline void
     __uninitialized_fill_a(_ForwardIterator __first, _ForwardIterator __last,
 			   const _Tp& __x, allocator<_Tp2>&)
     { std::uninitialized_fill(__first, __last, __x); }
+#endif // _GLIBCXX_HOSTED
 
   template<typename _ForwardIterator, typename _Size, typename _Tp,
 	   typename _Allocator>
@@ -358,12 +362,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
     }
 
+#if _GLIBCXX_HOSTED
   template<typename _ForwardIterator, typename _Size, typename _Tp,
 	   typename _Tp2>
     inline _ForwardIterator
     __uninitialized_fill_n_a(_ForwardIterator __first, _Size __n, 
 			     const _Tp& __x, allocator<_Tp2>&)
     { return std::uninitialized_fill_n(__first, __n, __x); }
+#endif // _GLIBCXX_HOSTED
 
 
   // Extensions: __uninitialized_copy_move, __uninitialized_move_copy,
@@ -607,12 +613,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 // _GLIBCXX_HOSTED
 
 
   // __uninitialized_default_n_a
@@ -638,11 +646,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
     }
 
+#if _GLIBCXX_HOSTED
   template<typename _ForwardIterator, typename _Size, typename _Tp>
     inline _ForwardIterator
     __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, 
 				allocator<_Tp>&)
     { return std::__uninitialized_default_n(__first, __n); }
+#endif // _GLIBCXX_HOSTED
 
   template<bool _TrivialValueType>
     struct __uninitialized_default_novalue_1
@@ -901,6 +911,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __is_bitwise_relocatable
     : is_trivial<_Tp> { };
 
+#if _GLIBCXX_HOSTED
   template <typename _Tp, typename _Up>
     inline __enable_if_t<std::__is_bitwise_relocatable<_Tp>::value, _Tp*>
     __relocate_a_1(_Tp* __first, _Tp* __last,
@@ -911,6 +922,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	__builtin_memmove(__result, __first, __count * sizeof(_Tp));
       return __result + __count;
     }
+#endif // _GLIBCXX_HOSTED
 
   template <typename _InputIterator, typename _ForwardIterator,
 	    typename _Allocator>
diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h
index d8129747eb5..c14d68dd9bf 100644
--- a/libstdc++-v3/include/bits/unique_ptr.h
+++ b/libstdc++-v3/include/bits/unique_ptr.h
@@ -828,6 +828,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if __cplusplus > 201103L
 
+#if _GLIBCXX_HOSTED
 #define __cpp_lib_make_unique 201304
 
   template<typename _Tp>
@@ -859,6 +860,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     inline typename _MakeUniq<_Tp>::__invalid_type
     make_unique(_Args&&...) = delete;
 #endif
+#endif // _GLIBCXX_HOSTED
 
   // @} group pointer_abstractions
 
diff --git a/libstdc++-v3/include/c_global/cstring b/libstdc++-v3/include/c_global/cstring
index 5d656c507ad..c2b0d717cda 100644
--- a/libstdc++-v3/include/c_global/cstring
+++ b/libstdc++-v3/include/c_global/cstring
@@ -81,21 +81,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   using ::memset;
   using ::strcat;
   using ::strcmp;
-  using ::strcoll;
   using ::strcpy;
   using ::strcspn;
-  using ::strerror;
   using ::strlen;
   using ::strncat;
   using ::strncmp;
   using ::strncpy;
   using ::strspn;
-  using ::strtok;
-  using ::strxfrm;
   using ::strchr;
   using ::strpbrk;
   using ::strrchr;
   using ::strstr;
+#if _GLIBCXX_HOSTED
+  using ::strcoll;
+  using ::strerror;
+  using ::strtok;
+  using ::strxfrm;
+#endif // GLIBCXX_HOSTED
 
 #ifndef __CORRECT_ISO_CPP_STRING_H_PROTO
   inline void*
diff --git a/libstdc++-v3/include/c_std/cmath b/libstdc++-v3/include/c_std/cmath
index 2dcdff0ac68..232c1e9e31d 100644
--- a/libstdc++-v3/include/c_std/cmath
+++ b/libstdc++-v3/include/c_std/cmath
@@ -45,7 +45,10 @@
 #include <bits/cpp_type_traits.h>
 #include <ext/type_traits.h>
 
+
+#if _GLIBCXX_HOSTED
 #include <math.h>
+#endif // _GLIBCXX_HOSTED
 
 // Get rid of those macros defined in <math.h> in lieu of real functions.
 #undef abs
@@ -95,6 +98,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     abs(_Tp __x)
     { return __builtin_fabs(__x); }
 
+#if _GLIBCXX_HOSTED
   using ::acos;
 
   inline float
@@ -577,6 +581,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
 #endif /* _GLIBCXX_USE_C99_MATH */
+#endif // _GLIBCXX_HOSTED
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
diff --git a/libstdc++-v3/include/c_std/cstdlib b/libstdc++-v3/include/c_std/cstdlib
index 6472ae1dccb..1407a616eed 100644
--- a/libstdc++-v3/include/c_std/cstdlib
+++ b/libstdc++-v3/include/c_std/cstdlib
@@ -115,9 +115,43 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#if !_GLIBCXX_HOSTED
   using ::div_t;
   using ::ldiv_t;
+  using ::bsearch;
+  using ::qsort;
+  using ::div;
+  using ::ldiv;
+  using ::labs;
+#if defined(__GLIBCXX_TYPE_INT_N_0)
+  inline __GLIBCXX_TYPE_INT_N_0
+  abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
+#endif
+#if defined(__GLIBCXX_TYPE_INT_N_1)
+  inline __GLIBCXX_TYPE_INT_N_1
+  abs(__GLIBCXX_TYPE_INT_N_1 __x) { return __x >= 0 ? __x : -__x; }
+#endif
+#if defined(__GLIBCXX_TYPE_INT_N_2)
+  inline __GLIBCXX_TYPE_INT_N_2
+  abs(__GLIBCXX_TYPE_INT_N_2 __x) { return __x >= 0 ? __x : -__x; }
+#endif
+#if defined(__GLIBCXX_TYPE_INT_N_3)
+  inline __GLIBCXX_TYPE_INT_N_3
+  abs(__GLIBCXX_TYPE_INT_N_3 __x) { return __x >= 0 ? __x : -__x; }
+#endif
+  inline long
+  abs(long __i) { return __builtin_labs(__i); }
 
+#ifdef _GLIBCXX_USE_LONG_LONG
+  inline long long
+  abs(long long __x) { return __builtin_llabs (__x); }
+#endif
+
+  inline ldiv_t
+  div(long __i, long __j) { return ldiv(__i, __j); }
+
+
+#else
   using ::abort;
   using ::abs;
   using ::atexit;
@@ -129,21 +163,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   using ::atof;
   using ::atoi;
   using ::atol;
-  using ::bsearch;
   using ::calloc;
-  using ::div;
   using ::exit;
   using ::free;
   using ::getenv;
-  using ::labs;
-  using ::ldiv;
   using ::malloc;
 #ifdef _GLIBCXX_HAVE_MBSTATE_T
   using ::mblen;
   using ::mbstowcs;
   using ::mbtowc;
 #endif // _GLIBCXX_HAVE_MBSTATE_T
-  using ::qsort;
 #if __cplusplus >= 201103L
 # ifdef _GLIBCXX_HAVE_QUICK_EXIT
   using ::quick_exit;
@@ -161,34 +190,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   using ::wctomb;
 #endif // _GLIBCXX_USE_WCHAR_T
 
-  inline long
-  abs(long __i) { return __builtin_labs(__i); }
-
-#ifdef _GLIBCXX_USE_LONG_LONG
-  inline long long
-  abs(long long __x) { return __builtin_llabs (__x); }
-#endif
-
-#if defined(__GLIBCXX_TYPE_INT_N_0)
-  inline __GLIBCXX_TYPE_INT_N_0
-  abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
-#endif
-#if defined(__GLIBCXX_TYPE_INT_N_1)
-  inline __GLIBCXX_TYPE_INT_N_1
-  abs(__GLIBCXX_TYPE_INT_N_1 __x) { return __x >= 0 ? __x : -__x; }
-#endif
-#if defined(__GLIBCXX_TYPE_INT_N_2)
-  inline __GLIBCXX_TYPE_INT_N_2
-  abs(__GLIBCXX_TYPE_INT_N_2 __x) { return __x >= 0 ? __x : -__x; }
-#endif
-#if defined(__GLIBCXX_TYPE_INT_N_3)
-  inline __GLIBCXX_TYPE_INT_N_3
-  abs(__GLIBCXX_TYPE_INT_N_3 __x) { return __x >= 0 ? __x : -__x; }
-#endif
-
-  inline ldiv_t
-  div(long __i, long __j) { return ldiv(__i, __j); }
-
+#endif // _GLIBCXX_HOSTED
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
diff --git a/libstdc++-v3/include/c_std/cwchar b/libstdc++-v3/include/c_std/cwchar
index 6e260e72450..1f53d7aed01 100644
--- a/libstdc++-v3/include/c_std/cwchar
+++ b/libstdc++-v3/include/c_std/cwchar
@@ -228,7 +228,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
-#if _GLIBCXX_USE_C99_WCHAR
+#if _GLIBCXX_USE_C99_WCHAR && _GLIBCXX_HOSTED
 
 #undef wcstold
 #undef wcstoll
diff --git a/libstdc++-v3/include/std/algorithm b/libstdc++-v3/include/std/algorithm
index b5013a226e3..27bbfa81a2a 100644
--- a/libstdc++-v3/include/std/algorithm
+++ b/libstdc++-v3/include/std/algorithm
@@ -76,7 +76,7 @@
 # define __cpp_lib_parallel_algorithm 201603L
 #endif // C++17
 
-#ifdef _GLIBCXX_PARALLEL
+#ifdef _GLIBCXX_PARALLEL && _GLIBCXX_HOSTED
 # include <parallel/algorithm>
 #endif
 
diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array
index 02c6f4b4dbe..bed475bb1d3 100644
--- a/libstdc++-v3/include/std/array
+++ b/libstdc++-v3/include/std/array
@@ -36,7 +36,9 @@
 #else
 
 #include <utility>
+#if _GLIBCXX_HOSTED
 #include <stdexcept>
+#endif
 #include <bits/stl_algobase.h>
 #include <bits/range_access.h>
 
@@ -189,6 +191,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       operator[](size_type __n) const noexcept
       { return _AT_Type::_S_ref(_M_elems, __n); }
 
+#if _GLIBCXX_HOSTED
       _GLIBCXX17_CONSTEXPR reference
       at(size_type __n)
       {
@@ -210,6 +213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 					   __n, _Nm),
 	     _AT_Type::_S_ref(_M_elems, 0));
       }
+#endif // GLIBCXX_HOSTED
 
       _GLIBCXX17_CONSTEXPR reference
       front() noexcept
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index d6958301e8a..dc23abb72aa 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -44,10 +44,13 @@
 
 #pragma GCC system_header
 
-#include <string>
 #include <bits/functexcept.h>   // For invalid_argument, out_of_range,
                                 // overflow_error
+#if _GLIBCXX_HOSTED
+#include <string>
 #include <iosfwd>
+#endif
+
 #include <bits/cxxabi_forced.h>
 
 #if __cplusplus >= 201103L
@@ -217,6 +220,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	return __result;
       }
 
+#if _GLIBCXX_HOSTED
       unsigned long
       _M_do_to_ulong() const;
 
@@ -224,6 +228,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       unsigned long long
       _M_do_to_ullong() const;
 #endif
+#endif // _GLIBCXX_HOSTED
 
       // find first "on" bit
       size_t
@@ -288,6 +293,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	}
     }
 
+#if _GLIBCXX_HOSTED
   template<size_t _Nw>
     unsigned long
     _Base_bitset<_Nw>::_M_do_to_ulong() const
@@ -314,6 +320,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       return _M_w[0];
     }
 #endif
+#endif // _GLIBCXX_HOSTED
 
   template<size_t _Nw>
     size_t
@@ -755,6 +762,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base;
       typedef unsigned long _WordT;
 
+#if _GLIBCXX_HOSTED
       template<class _CharT, class _Traits, class _Alloc>
       void
       _M_check_initial_position(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
@@ -774,6 +782,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 				       ">= _Nb (which is %zu)"),
 				   __s, __position, _Nb);
       }
+#endif // _GLIBCXX_HOSTED
 
       void
       _M_do_sanitize() _GLIBCXX_NOEXCEPT
@@ -888,6 +897,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  @throw  std::invalid_argument  If a character appears in the string
        *                                 which is neither @a 0 nor @a 1.
        */
+#if _GLIBCXX_HOSTED
       template<class _CharT, class _Traits, class _Alloc>
 	explicit
 	bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
@@ -959,6 +969,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 							     __one);
 	}
 #endif
+#endif // _GLIBCXX_HOSTED
 
       // 23.3.5.2 bitset operations:
       //@{
@@ -1085,12 +1096,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  @param  __val  Either true or false, defaults to true.
        *  @throw  std::out_of_range  If @a pos is bigger the size of the %set.
        */
+#if _GLIBCXX_HOSTED
       bitset<_Nb>&
       set(size_t __position, bool __val = true)
       {
 	this->_M_check(__position, __N("bitset::set"));
 	return _Unchecked_set(__position, __val);
       }
+#endif // _GLIBCXX_HOSTED
 
       /**
        *  @brief Sets every bit to false.
@@ -1109,12 +1122,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *
        *  Same as writing @c set(pos,false).
        */
+#if _GLIBCXX_HOSTED
       bitset<_Nb>&
       reset(size_t __position)
       {
 	this->_M_check(__position, __N("bitset::reset"));
 	return _Unchecked_reset(__position);
       }
+#endif // _GLIBCXX_HOSTED
 
       /**
        *  @brief Toggles every bit to its opposite value.
@@ -1132,12 +1147,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  @param  __position  The index of the bit.
        *  @throw  std::out_of_range  If @a pos is bigger the size of the %set.
        */
+#if _GLIBCXX_HOSTED
       bitset<_Nb>&
       flip(size_t __position)
       {
 	this->_M_check(__position, __N("bitset::flip"));
 	return _Unchecked_flip(__position);
       }
+#endif // _GLIBCXX_HOSTED
 
       /// See the no-argument flip().
       bitset<_Nb>
@@ -1192,6 +1209,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        *  correspond to increasing bit positions (see the main class notes for
        *  an example).
        */
+#if _GLIBCXX_HOSTED
       template<class _CharT, class _Traits, class _Alloc>
 	std::basic_string<_CharT, _Traits, _Alloc>
 	to_string() const
@@ -1289,7 +1307,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	void
         _M_copy_to_string(std::basic_string<_CharT, _Traits,_Alloc>& __s) const
 	{ _M_copy_to_string(__s, _CharT('0'), _CharT('1')); }
-
+#endif // _GLIBCXX_HOSTED
       /// Returns the number of bits which are set.
       size_t
       count() const _GLIBCXX_NOEXCEPT
@@ -1383,6 +1401,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       { return this->_M_do_find_next(__prev, _Nb); }
     };
 
+#if _GLIBCXX_HOSTED
   // Definitions of non-inline member functions.
   template<size_t _Nb>
     template<class _CharT, class _Traits>
@@ -1417,6 +1436,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	  if (_Unchecked_test(__i - 1))
 	    _Traits::assign(__s[_Nb - __i], __one);
       }
+#endif // _GLIBCXX_HOSTED
 
   // 23.3.5.3 bitset operations:
   //@{
@@ -1465,6 +1485,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
    *  characters, and will only extract as many digits as the %bitset will
    *  hold.
   */
+#if _GLIBCXX_HOSTED
   template<class _CharT, class _Traits, size_t _Nb>
     std::basic_istream<_CharT, _Traits>&
     operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)
@@ -1546,6 +1567,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       __x._M_copy_to_string(__tmp, __ct.widen('0'), __ct.widen('1'));
       return __os << __tmp;
     }
+#endif // _GLIBCXX_HOSTED
   //@}
 
 _GLIBCXX_END_NAMESPACE_CONTAINER
diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index 9e63fa9c698..5b718ac4d6a 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -799,6 +799,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		 const time_point<_Clock, _Dur2>& __rhs)
       { return !(__lhs < __rhs); }
 
+#if _GLIBCXX_HOSTED
 
     // Clocks.
 
@@ -888,6 +889,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     using high_resolution_clock = system_clock;
 
     } // end inline namespace _V2
+#endif // _GLIBCXX_HOSTED
   } // namespace chrono
 
 #if __cplusplus > 201103L
diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index 8cf2c670648..b19a7089bd7 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -56,7 +56,9 @@
 #include <bits/functional_hash.h>
 #include <bits/invoke.h>
 #include <bits/refwrap.h>	// std::reference_wrapper and _Mem_fn_traits
+#if _GLIBCXX_HOSTED
 #include <bits/std_function.h>	// std::function
+#endif // _GLIBCXX_HOSTED
 #if __cplusplus > 201402L
 # include <unordered_map>
 # include <vector>
@@ -1014,7 +1016,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
   // Searchers
-#define __cpp_lib_boyer_moore_searcher 201603
 
   template<typename _ForwardIterator1, typename _BinaryPredicate = equal_to<>>
     class default_searcher
@@ -1044,6 +1045,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       tuple<_ForwardIterator1, _ForwardIterator1, _BinaryPredicate> _M_m;
     };
 
+#if _GLIBCXX_HOSTED
+#define __cpp_lib_boyer_moore_searcher 201603
   template<typename _Key, typename _Tp, typename _Hash, typename _Pred>
     struct __boyer_moore_map_base
     {
@@ -1286,6 +1289,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
       return std::make_pair(__last, __last);
     }
+#endif // _GLIBCXX_HOSTED
 
 #endif // C++17
 #endif // C++14
diff --git a/libstdc++-v3/include/std/iterator b/libstdc++-v3/include/std/iterator
index 9d9e19c4c6b..8e7d61263c5 100644
--- a/libstdc++-v3/include/std/iterator
+++ b/libstdc++-v3/include/std/iterator
@@ -61,10 +61,12 @@
 #include <bits/stl_iterator_base_types.h>
 #include <bits/stl_iterator_base_funcs.h>
 #include <bits/stl_iterator.h>
+#if _GLIBCXX_HOSTED
 #include <ostream>
 #include <istream>
 #include <bits/stream_iterator.h>
 #include <bits/streambuf_iterator.h>
+#endif // _GLIBCXX_HOSTED
 #include <bits/range_access.h>
 
 #if __cplusplus >= 201402L && ! defined _GLIBCXX_DEBUG // PR libstdc++/70303
diff --git a/libstdc++-v3/include/std/memory b/libstdc++-v3/include/std/memory
index b6950c76089..18d5e2c5bf9 100644
--- a/libstdc++-v3/include/std/memory
+++ b/libstdc++-v3/include/std/memory
@@ -60,31 +60,39 @@
  */
 
 #include <bits/stl_algobase.h>
-#include <bits/allocator.h>
+#if _GLIBCXX_HOSTED
+#  include <bits/allocator.h>
+#  include <bits/stl_tempbuf.h>
+#  include <bits/stl_raw_storage_iter.h>
+#endif // _GLIBCXX_HOSTED
 #include <bits/stl_construct.h>
 #include <bits/stl_uninitialized.h>
-#include <bits/stl_tempbuf.h>
-#include <bits/stl_raw_storage_iter.h>
 
 #if __cplusplus >= 201103L
 #  include <exception>        	  // std::exception
 #  include <typeinfo>         	  // std::type_info in get_deleter
-#  include <iosfwd>           	  // std::basic_ostream
-#  include <ext/atomicity.h>
-#  include <ext/concurrence.h>
+#if _GLIBCXX_HOSTED
+#    include <iosfwd>           	  // std::basic_ostream
+#    include <ext/atomicity.h>
+#    include <ext/concurrence.h>
+#endif // _GLIBCXX_HOSTED
 #  include <bits/functexcept.h>
 #  include <bits/stl_function.h>  // std::less
 #  include <bits/uses_allocator.h>
 #  include <type_traits>
 #  include <debug/debug.h>
 #  include <bits/unique_ptr.h>
-#  include <bits/shared_ptr.h>
-#  include <bits/shared_ptr_atomic.h>
+#if _GLIBCXX_HOSTED
+#    include <bits/shared_ptr.h>
+#    include <bits/shared_ptr_atomic.h>
 #  if _GLIBCXX_USE_DEPRECATED
 #    include <backward/auto_ptr.h>
 #  endif
+#endif // _GLIBCXX_HOSTED
 #else
+#if _GLIBCXX_HOSTED
 #  include <backward/auto_ptr.h>
+#endif // _GLIBCXX_HOSTED
 #endif
 
 #if __cplusplus >= 201103L
@@ -138,6 +146,7 @@ align(size_t __align, size_t __size, void*& __ptr, size_t& __space) noexcept
 
 // 20.7.4 [util.dynamic.safety], pointer safety
 
+#if _GLIBCXX_HOSTED
 enum class pointer_safety { relaxed, preferred, strict };
 
 inline void
@@ -155,6 +164,7 @@ undeclare_no_pointers(char*, size_t) { }
 
 inline pointer_safety
 get_pointer_safety() noexcept { return pointer_safety::relaxed; }
+#endif // _GLIBCXX_HOSTED
 
 #if __cplusplus > 201703L
   /// Inform the compiler that a pointer is aligned.
@@ -207,6 +217,7 @@ get_pointer_safety() noexcept { return pointer_safety::relaxed; }
 	}
     }
 
+#if _GLIBCXX_HOSTED
 #if __cpp_concepts
   template<typename _Tp>
     concept _Std_pair = __is_pair<_Tp>::value;
@@ -359,6 +370,7 @@ get_pointer_safety() noexcept { return pointer_safety::relaxed; }
       return ::new(__vp) _Tp(std::make_obj_using_allocator<_Tp>(__a,
 	    std::forward<_Args>(__args)...));
     }
+#endif // _GLIBCXX_HOSTED
 
 #endif // C++2a
 
@@ -366,6 +378,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 #endif // C++11
 
+#if _GLIBCXX_HOSTED
 #if __cplusplus > 201402L
 // Parallel STL algorithms
 # if __PSTL_EXECUTION_POLICIES_DEFINED
@@ -379,5 +392,6 @@ _GLIBCXX_END_NAMESPACE_VERSION
 // Feature test macro for parallel algorithms
 # define __cpp_lib_parallel_algorithm 201603L
 #endif // C++17
+#endif // _GLIBCXX_HOSTED
 
 #endif /* _GLIBCXX_MEMORY */
diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional
index 503d859bee6..92203e67a4d 100644
--- a/libstdc++-v3/include/std/optional
+++ b/libstdc++-v3/include/std/optional
@@ -73,6 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// Tag to disengage optional objects.
   inline constexpr nullopt_t nullopt { nullopt_t::_Construct::_Token };
 
+#if _GLIBCXX_HOSTED
   /**
    *  @brief Exception class thrown when a disengaged optional object is
    *  dereferenced.
@@ -97,6 +98,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   inline void
   __throw_bad_optional_access()
   { _GLIBCXX_THROW_OR_ABORT(bad_optional_access()); }
+#endif // _GLIBCXX_HOSTED
 
   // This class template manages construction/destruction of
   // the contained value for a std::optional.
@@ -915,6 +917,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       constexpr bool has_value() const noexcept
       { return this->_M_is_engaged(); }
 
+#if _GLIBCXX_HOSTED
       constexpr const _Tp&
       value() const&
       {
@@ -946,6 +949,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  ? std::move(this->_M_get())
 	  : (__throw_bad_optional_access(), std::move(this->_M_get()));
       }
+#endif // _GLIBCXX_HOSTED
 
       template<typename _Up>
 	constexpr _Tp
diff --git a/libstdc++-v3/include/std/random b/libstdc++-v3/include/std/random
index 67a54a28178..c6cb8756724 100644
--- a/libstdc++-v3/include/std/random
+++ b/libstdc++-v3/include/std/random
@@ -38,7 +38,9 @@
 #include <cmath>
 #include <cstdlib>
 #include <string>
+#if _GLIBCXX_HOSTED
 #include <iosfwd>
+#endif // _GLIBCXX_HOSTED
 #include <limits>
 #include <debug/debug.h>
 #include <type_traits>
diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string
index 6ccc06f337a..cb764fabd97 100644
--- a/libstdc++-v3/include/std/string
+++ b/libstdc++-v3/include/std/string
@@ -36,8 +36,9 @@
 #pragma GCC system_header
 
 #include <bits/c++config.h>
-#include <bits/stringfwd.h>
 #include <bits/char_traits.h>  // NB: In turn includes stl_algobase.h
+#if _GLIBCXX_HOSTED
+#include <bits/stringfwd.h>
 #include <bits/allocator.h>
 #include <bits/cpp_type_traits.h>
 #include <bits/localefwd.h>    // For operators >>, <<, and getline.
@@ -144,4 +145,5 @@ _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 #endif // C++20
 
+#endif // _GLIBCXX_HOSTED
 #endif /* _GLIBCXX_STRING */
diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view
index 42822cc41ab..6a490a3e9c1 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -38,7 +38,9 @@
 #if __cplusplus >= 201703L
 
 #include <limits>
+#if _GLIBCXX_HOSTED
 #include <iosfwd>
+#endif // _GLIBCXX_HOSTED
 #include <bits/char_traits.h>
 #include <bits/functional_hash.h>
 #include <bits/range_access.h>
@@ -49,6 +51,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #define __cpp_lib_string_view 201603
 
+#if _GLIBCXX_HOSTED
   // Helper for basic_string and basic_string_view members.
   constexpr size_t
   __sv_check(size_t __size, size_t __pos, const char* __s)
@@ -68,6 +71,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    return __testoff ? __off : __size - __pos;
   }
 
+#endif // _GLIBCXX_HOSTED
   /**
    *  @class basic_string_view <string_view>
    *  @brief  A non-owning reference to a string.
@@ -198,6 +202,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *(this->_M_str + __pos);
       }
 
+#if _GLIBCXX_HOSTED
       constexpr const_reference
       at(size_type __pos) const
       {
@@ -207,6 +212,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 				       "(which is %zu)"), __pos, this->size());
 	return *(this->_M_str + __pos);
       }
+#endif // _GLIBCXX_HOSTED
 
       constexpr const_reference
       front() const noexcept
@@ -252,6 +258,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       // [string.view.ops], string operations:
 
+#if _GLIBCXX_HOSTED
       size_type
       copy(_CharT* __str, size_type __n, size_type __pos = 0) const
       {
@@ -271,6 +278,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	const size_type __rlen = std::min(__n, _M_len - __pos);
 	return basic_string_view{_M_str + __pos, __rlen};
       }
+#endif // _GLIBCXX_HOSTED
 
       constexpr int
       compare(basic_string_view __str) const noexcept
@@ -282,6 +290,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return __ret;
       }
 
+#if _GLIBCXX_HOSTED
       constexpr int
       compare(size_type __pos1, size_type __n1, basic_string_view __str) const
       { return this->substr(__pos1, __n1).compare(__str); }
@@ -292,11 +301,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2));
       }
+#endif // _GLIBCXX_HOSTED
 
       __attribute__((__nonnull__)) constexpr int
       compare(const _CharT* __str) const noexcept
       { return this->compare(basic_string_view{__str}); }
 
+#if _GLIBCXX_HOSTED
       __attribute__((__nonnull__)) constexpr int
       compare(size_type __pos1, size_type __n1, const _CharT* __str) const
       { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
@@ -308,11 +319,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return this->substr(__pos1, __n1)
 		   .compare(basic_string_view(__str, __n2));
       }
+#endif // _GLIBCXX_HOSTED
 
 #if __cplusplus > 201703L
+#if _GLIBCXX_HOSTED
       constexpr bool
       starts_with(basic_string_view __x) const noexcept
       { return this->substr(0, __x.size()) == __x; }
+#endif // _GLIBCXX_HOSTED
 
       constexpr bool
       starts_with(_CharT __x) const noexcept
@@ -322,12 +336,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       starts_with(const _CharT* __x) const noexcept
       { return this->starts_with(basic_string_view(__x)); }
 
+#if _GLIBCXX_HOSTED
       constexpr bool
       ends_with(basic_string_view __x) const noexcept
       {
 	return this->size() >= __x.size()
 	    && this->compare(this->size() - __x.size(), npos, __x) == 0;
       }
+#endif // _GLIBCXX_HOSTED
 
       constexpr bool
       ends_with(_CharT __x) const noexcept
diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error
index b7891cbaa86..1d719c980b3 100644
--- a/libstdc++-v3/include/std/system_error
+++ b/libstdc++-v3/include/std/system_error
@@ -37,6 +37,7 @@
 
 #include <bits/c++config.h>
 #include <bits/error_constants.h>
+#if _GLIBCXX_HOSTED
 #include <iosfwd>
 #include <stdexcept>
 
@@ -421,4 +422,5 @@ _GLIBCXX_END_NAMESPACE_VERSION
 
 #endif // C++11
 
+#endif // _GLIBCXX_HOSTED
 #endif // _GLIBCXX_SYSTEM_ERROR

Reply via email to