mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +00:00
Upgrade to 2022-era LLVM LIBCXX
This commit is contained in:
parent
2f4ca71f26
commit
8e68384e15
2078 changed files with 165657 additions and 65010 deletions
200
third_party/libcxx/ios
vendored
200
third_party/libcxx/ios
vendored
|
@ -1,5 +1,5 @@
|
|||
// -*- C++ -*-
|
||||
//===---------------------------- ios -------------------------------------===//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
|
@ -10,25 +10,10 @@
|
|||
#ifndef _LIBCPP_IOS
|
||||
#define _LIBCPP_IOS
|
||||
|
||||
#include "third_party/libcxx/__config"
|
||||
#include "third_party/libcxx/iosfwd"
|
||||
#include "third_party/libcxx/__locale"
|
||||
#include "third_party/libcxx/system_error"
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
|
||||
#include "third_party/libcxx/atomic" // for __xindex_
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
/*
|
||||
ios synopsis
|
||||
|
||||
#include "third_party/libcxx/iosfwd"
|
||||
#include <iosfwd>
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
@ -225,6 +210,39 @@ storage-class-specifier const error_category& iostream_category() noexcept;
|
|||
|
||||
*/
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
|
||||
# error "The iostreams library is not supported since libc++ has been configured without support for localization."
|
||||
#endif
|
||||
|
||||
#include <__assert> // all public C++ headers provide the assertion handler
|
||||
#include <__fwd/ios.h>
|
||||
#include <__ios/fpos.h>
|
||||
#include <__locale>
|
||||
#include <__system_error/error_category.h>
|
||||
#include <__system_error/error_code.h>
|
||||
#include <__system_error/error_condition.h>
|
||||
#include <__system_error/system_error.h>
|
||||
#include <__utility/swap.h>
|
||||
#include <__verbose_abort>
|
||||
#include <version>
|
||||
|
||||
// standard-mandated includes
|
||||
|
||||
// [ios.syn]
|
||||
#include <iosfwd>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
|
||||
# include <__atomic/atomic.h> // for __xindex_
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
typedef ptrdiff_t streamsize;
|
||||
|
||||
class _LIBCPP_TYPE_VIS ios_base
|
||||
|
@ -308,11 +326,9 @@ public:
|
|||
typedef void (*event_callback)(event, ios_base&, int __index);
|
||||
void register_callback(event_callback __fn, int __index);
|
||||
|
||||
private:
|
||||
ios_base(const ios_base&); // = delete;
|
||||
ios_base& operator=(const ios_base&); // = delete;
|
||||
ios_base(const ios_base&) = delete;
|
||||
ios_base& operator=(const ios_base&) = delete;
|
||||
|
||||
public:
|
||||
static bool sync_with_stdio(bool __sync = true);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY iostate rdstate() const;
|
||||
|
@ -403,7 +419,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
|
|||
template <>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { };
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
|
||||
#ifdef _LIBCPP_CXX03_LANG
|
||||
template <>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { };
|
||||
#endif
|
||||
|
@ -431,16 +447,16 @@ class _LIBCPP_EXCEPTION_ABI ios_base::failure
|
|||
public:
|
||||
explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);
|
||||
explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);
|
||||
virtual ~failure() throw();
|
||||
_LIBCPP_HIDE_FROM_ABI failure(const failure&) _NOEXCEPT = default;
|
||||
~failure() _NOEXCEPT override;
|
||||
};
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __throw_failure(char const* __msg) {
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
|
||||
throw ios_base::failure(__msg);
|
||||
#else
|
||||
((void)__msg);
|
||||
_VSTD::abort();
|
||||
_LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -590,13 +606,6 @@ ios_base::exceptions(iostate __iostate)
|
|||
clear(__rdstate_);
|
||||
}
|
||||
|
||||
#if defined(_LIBCPP_CXX03_LANG)
|
||||
struct _LIBCPP_TYPE_VIS __cxx03_bool {
|
||||
typedef void (__cxx03_bool::*__bool_type)();
|
||||
void __true_value() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
class _LIBCPP_TEMPLATE_VIS basic_ios
|
||||
: public ios_base
|
||||
|
@ -613,17 +622,14 @@ public:
|
|||
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
|
||||
"traits_type::char_type must be the same type as CharT");
|
||||
|
||||
// __true_value will generate undefined references when linking unless
|
||||
// we give it internal linkage.
|
||||
|
||||
#if defined(_LIBCPP_CXX03_LANG)
|
||||
#ifdef _LIBCPP_CXX03_LANG
|
||||
// Preserve the ability to compare with literal 0,
|
||||
// and implicitly convert to bool, but not implicitly convert to int.
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
operator __cxx03_bool::__bool_type() const {
|
||||
return !fail() ? &__cxx03_bool::__true_value : nullptr;
|
||||
}
|
||||
operator void*() const {return fail() ? nullptr : (void*)this;}
|
||||
#else
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_EXPLICIT operator bool() const {return !fail();}
|
||||
explicit operator bool() const {return !fail();}
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY bool operator!() const {return fail();}
|
||||
|
@ -641,7 +647,7 @@ public:
|
|||
// 27.5.4.1 Constructor/destructor:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);
|
||||
virtual ~basic_ios();
|
||||
~basic_ios() override;
|
||||
|
||||
// 27.5.4.2 Members:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
|
@ -678,10 +684,8 @@ protected:
|
|||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void move(basic_ios& __rhs);
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void move(basic_ios&& __rhs) {move(__rhs);}
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_ios& __rhs) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
|
@ -709,7 +713,7 @@ void
|
|||
basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb)
|
||||
{
|
||||
ios_base::init(__sb);
|
||||
__tie_ = 0;
|
||||
__tie_ = nullptr;
|
||||
__fill_ = traits_type::eof();
|
||||
}
|
||||
|
||||
|
@ -766,7 +770,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
|||
char
|
||||
basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
|
||||
{
|
||||
return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
|
||||
return std::use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
|
@ -774,7 +778,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
|||
_CharT
|
||||
basic_ios<_CharT, _Traits>::widen(char __c) const
|
||||
{
|
||||
return use_facet<ctype<char_type> >(getloc()).widen(__c);
|
||||
return std::use_facet<ctype<char_type> >(getloc()).widen(__c);
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
|
@ -792,6 +796,8 @@ inline _LIBCPP_INLINE_VISIBILITY
|
|||
_CharT
|
||||
basic_ios<_CharT, _Traits>::fill(char_type __ch)
|
||||
{
|
||||
if (traits_type::eq_int_type(traits_type::eof(), __fill_))
|
||||
__fill_ = widen(' ');
|
||||
char_type __r = __fill_;
|
||||
__fill_ = __ch;
|
||||
return __r;
|
||||
|
@ -820,7 +826,7 @@ basic_ios<_CharT, _Traits>::move(basic_ios& __rhs)
|
|||
{
|
||||
ios_base::move(__rhs);
|
||||
__tie_ = __rhs.__tie_;
|
||||
__rhs.__tie_ = 0;
|
||||
__rhs.__tie_ = nullptr;
|
||||
__fill_ = __rhs.__fill_;
|
||||
}
|
||||
|
||||
|
@ -842,7 +848,13 @@ basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* _
|
|||
ios_base::set_rdbuf(__sb);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
|
||||
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
|
||||
#endif
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
boolalpha(ios_base& __str)
|
||||
{
|
||||
|
@ -850,7 +862,7 @@ boolalpha(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
noboolalpha(ios_base& __str)
|
||||
{
|
||||
|
@ -858,7 +870,7 @@ noboolalpha(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
showbase(ios_base& __str)
|
||||
{
|
||||
|
@ -866,7 +878,7 @@ showbase(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
noshowbase(ios_base& __str)
|
||||
{
|
||||
|
@ -874,7 +886,7 @@ noshowbase(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
showpoint(ios_base& __str)
|
||||
{
|
||||
|
@ -882,7 +894,7 @@ showpoint(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
noshowpoint(ios_base& __str)
|
||||
{
|
||||
|
@ -890,7 +902,7 @@ noshowpoint(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
showpos(ios_base& __str)
|
||||
{
|
||||
|
@ -898,7 +910,7 @@ showpos(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
noshowpos(ios_base& __str)
|
||||
{
|
||||
|
@ -906,7 +918,7 @@ noshowpos(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
skipws(ios_base& __str)
|
||||
{
|
||||
|
@ -914,7 +926,7 @@ skipws(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
noskipws(ios_base& __str)
|
||||
{
|
||||
|
@ -922,7 +934,7 @@ noskipws(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
uppercase(ios_base& __str)
|
||||
{
|
||||
|
@ -930,7 +942,7 @@ uppercase(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
nouppercase(ios_base& __str)
|
||||
{
|
||||
|
@ -938,7 +950,7 @@ nouppercase(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
unitbuf(ios_base& __str)
|
||||
{
|
||||
|
@ -946,7 +958,7 @@ unitbuf(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
nounitbuf(ios_base& __str)
|
||||
{
|
||||
|
@ -954,7 +966,7 @@ nounitbuf(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
internal(ios_base& __str)
|
||||
{
|
||||
|
@ -962,7 +974,7 @@ internal(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
left(ios_base& __str)
|
||||
{
|
||||
|
@ -970,7 +982,7 @@ left(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
right(ios_base& __str)
|
||||
{
|
||||
|
@ -978,7 +990,7 @@ right(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
dec(ios_base& __str)
|
||||
{
|
||||
|
@ -986,7 +998,7 @@ dec(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
hex(ios_base& __str)
|
||||
{
|
||||
|
@ -994,7 +1006,7 @@ hex(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
oct(ios_base& __str)
|
||||
{
|
||||
|
@ -1002,7 +1014,7 @@ oct(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
fixed(ios_base& __str)
|
||||
{
|
||||
|
@ -1010,7 +1022,7 @@ fixed(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
scientific(ios_base& __str)
|
||||
{
|
||||
|
@ -1018,7 +1030,7 @@ scientific(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
hexfloat(ios_base& __str)
|
||||
{
|
||||
|
@ -1026,7 +1038,7 @@ hexfloat(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_HIDE_FROM_ABI inline
|
||||
ios_base&
|
||||
defaultfloat(ios_base& __str)
|
||||
{
|
||||
|
@ -1034,33 +1046,21 @@ defaultfloat(ios_base& __str)
|
|||
return __str;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
class __save_flags
|
||||
{
|
||||
typedef basic_ios<_CharT, _Traits> __stream_type;
|
||||
typedef typename __stream_type::fmtflags fmtflags;
|
||||
|
||||
__stream_type& __stream_;
|
||||
fmtflags __fmtflags_;
|
||||
_CharT __fill_;
|
||||
|
||||
__save_flags(const __save_flags&);
|
||||
__save_flags& operator=(const __save_flags&);
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __save_flags(__stream_type& __stream)
|
||||
: __stream_(__stream),
|
||||
__fmtflags_(__stream.flags()),
|
||||
__fill_(__stream.fill())
|
||||
{}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~__save_flags()
|
||||
{
|
||||
__stream_.flags(__fmtflags_);
|
||||
__stream_.fill(__fill_);
|
||||
}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_IOS
|
||||
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
|
||||
# include <atomic>
|
||||
# include <concepts>
|
||||
# include <cstddef>
|
||||
# include <cstdlib>
|
||||
# include <cstring>
|
||||
# include <initializer_list>
|
||||
# include <limits>
|
||||
# include <new>
|
||||
# include <stdexcept>
|
||||
# include <system_error>
|
||||
# include <type_traits>
|
||||
# include <typeinfo>
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_IOS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue