Release Cosmopolitan v3.6.0

This release is an atomic upgrade to GCC 14.1.0 with C23 and C++23
This commit is contained in:
Justine Tunney 2024-07-23 03:16:17 -07:00
parent 62ace3623a
commit 5660ec4741
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
1585 changed files with 117353 additions and 271644 deletions

View file

@ -32,166 +32,141 @@ struct _LIBCPP_TEMPLATE_VIS coroutine_handle;
template <>
struct _LIBCPP_TEMPLATE_VIS coroutine_handle<void> {
public:
// [coroutine.handle.con], construct/reset
constexpr coroutine_handle() noexcept = default;
// [coroutine.handle.con], construct/reset
constexpr coroutine_handle() noexcept = default;
_LIBCPP_HIDE_FROM_ABI
constexpr coroutine_handle(nullptr_t) noexcept {}
_LIBCPP_HIDE_FROM_ABI constexpr coroutine_handle(nullptr_t) noexcept {}
_LIBCPP_HIDE_FROM_ABI
coroutine_handle& operator=(nullptr_t) noexcept {
__handle_ = nullptr;
return *this;
}
_LIBCPP_HIDE_FROM_ABI coroutine_handle& operator=(nullptr_t) noexcept {
__handle_ = nullptr;
return *this;
}
// [coroutine.handle.export.import], export/import
_LIBCPP_HIDE_FROM_ABI
constexpr void* address() const noexcept { return __handle_; }
// [coroutine.handle.export.import], export/import
_LIBCPP_HIDE_FROM_ABI constexpr void* address() const noexcept { return __handle_; }
_LIBCPP_HIDE_FROM_ABI
static constexpr coroutine_handle from_address(void* __addr) noexcept {
coroutine_handle __tmp;
__tmp.__handle_ = __addr;
return __tmp;
}
_LIBCPP_HIDE_FROM_ABI static constexpr coroutine_handle from_address(void* __addr) noexcept {
coroutine_handle __tmp;
__tmp.__handle_ = __addr;
return __tmp;
}
// [coroutine.handle.observers], observers
_LIBCPP_HIDE_FROM_ABI
constexpr explicit operator bool() const noexcept {
return __handle_ != nullptr;
}
// [coroutine.handle.observers], observers
_LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return __handle_ != nullptr; }
_LIBCPP_HIDE_FROM_ABI
bool done() const {
_LIBCPP_ASSERT(__is_suspended(), "done() can be called only on suspended coroutines");
return __builtin_coro_done(__handle_);
}
_LIBCPP_HIDE_FROM_ABI bool done() const {
_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(__is_suspended(), "done() can be called only on suspended coroutines");
return __builtin_coro_done(__handle_);
}
// [coroutine.handle.resumption], resumption
_LIBCPP_HIDE_FROM_ABI
void operator()() const { resume(); }
// [coroutine.handle.resumption], resumption
_LIBCPP_HIDE_FROM_ABI void operator()() const { resume(); }
_LIBCPP_HIDE_FROM_ABI
void resume() const {
_LIBCPP_ASSERT(__is_suspended(), "resume() can be called only on suspended coroutines");
_LIBCPP_ASSERT(!done(), "resume() has undefined behavior when the coroutine is done");
__builtin_coro_resume(__handle_);
}
_LIBCPP_HIDE_FROM_ABI void resume() const {
_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(__is_suspended(), "resume() can be called only on suspended coroutines");
_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(!done(), "resume() has undefined behavior when the coroutine is done");
__builtin_coro_resume(__handle_);
}
_LIBCPP_HIDE_FROM_ABI
void destroy() const {
_LIBCPP_ASSERT(__is_suspended(), "destroy() can be called only on suspended coroutines");
__builtin_coro_destroy(__handle_);
}
_LIBCPP_HIDE_FROM_ABI void destroy() const {
_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(__is_suspended(), "destroy() can be called only on suspended coroutines");
__builtin_coro_destroy(__handle_);
}
private:
_LIBCPP_HIDE_FROM_ABI bool __is_suspended() const {
// FIXME actually implement a check for if the coro is suspended.
return __handle_ != nullptr;
}
_LIBCPP_HIDE_FROM_ABI bool __is_suspended() const {
// FIXME actually implement a check for if the coro is suspended.
return __handle_ != nullptr;
}
void* __handle_ = nullptr;
void* __handle_ = nullptr;
};
// [coroutine.handle.compare]
inline _LIBCPP_HIDE_FROM_ABI
constexpr bool operator==(coroutine_handle<> __x, coroutine_handle<> __y) noexcept {
return __x.address() == __y.address();
inline _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(coroutine_handle<> __x, coroutine_handle<> __y) noexcept {
return __x.address() == __y.address();
}
inline _LIBCPP_HIDE_FROM_ABI
constexpr strong_ordering operator<=>(coroutine_handle<> __x, coroutine_handle<> __y) noexcept {
return compare_three_way()(__x.address(), __y.address());
inline _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
operator<=>(coroutine_handle<> __x, coroutine_handle<> __y) noexcept {
return compare_three_way()(__x.address(), __y.address());
}
template <class _Promise>
struct _LIBCPP_TEMPLATE_VIS coroutine_handle {
public:
// [coroutine.handle.con], construct/reset
constexpr coroutine_handle() noexcept = default;
// [coroutine.handle.con], construct/reset
constexpr coroutine_handle() noexcept = default;
_LIBCPP_HIDE_FROM_ABI
constexpr coroutine_handle(nullptr_t) noexcept {}
_LIBCPP_HIDE_FROM_ABI constexpr coroutine_handle(nullptr_t) noexcept {}
_LIBCPP_HIDE_FROM_ABI
static coroutine_handle from_promise(_Promise& __promise) {
using _RawPromise = __remove_cv_t<_Promise>;
coroutine_handle __tmp;
__tmp.__handle_ =
__builtin_coro_promise(_VSTD::addressof(const_cast<_RawPromise&>(__promise)), alignof(_Promise), true);
return __tmp;
}
_LIBCPP_HIDE_FROM_ABI static coroutine_handle from_promise(_Promise& __promise) {
using _RawPromise = __remove_cv_t<_Promise>;
coroutine_handle __tmp;
__tmp.__handle_ =
__builtin_coro_promise(std::addressof(const_cast<_RawPromise&>(__promise)), alignof(_Promise), true);
return __tmp;
}
_LIBCPP_HIDE_FROM_ABI
coroutine_handle& operator=(nullptr_t) noexcept {
__handle_ = nullptr;
return *this;
}
_LIBCPP_HIDE_FROM_ABI coroutine_handle& operator=(nullptr_t) noexcept {
__handle_ = nullptr;
return *this;
}
// [coroutine.handle.export.import], export/import
_LIBCPP_HIDE_FROM_ABI
constexpr void* address() const noexcept { return __handle_; }
// [coroutine.handle.export.import], export/import
_LIBCPP_HIDE_FROM_ABI constexpr void* address() const noexcept { return __handle_; }
_LIBCPP_HIDE_FROM_ABI
static constexpr coroutine_handle from_address(void* __addr) noexcept {
coroutine_handle __tmp;
__tmp.__handle_ = __addr;
return __tmp;
}
_LIBCPP_HIDE_FROM_ABI static constexpr coroutine_handle from_address(void* __addr) noexcept {
coroutine_handle __tmp;
__tmp.__handle_ = __addr;
return __tmp;
}
// [coroutine.handle.conv], conversion
_LIBCPP_HIDE_FROM_ABI
constexpr operator coroutine_handle<>() const noexcept {
return coroutine_handle<>::from_address(address());
}
// [coroutine.handle.conv], conversion
_LIBCPP_HIDE_FROM_ABI constexpr operator coroutine_handle<>() const noexcept {
return coroutine_handle<>::from_address(address());
}
// [coroutine.handle.observers], observers
_LIBCPP_HIDE_FROM_ABI
constexpr explicit operator bool() const noexcept {
return __handle_ != nullptr;
}
// [coroutine.handle.observers], observers
_LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return __handle_ != nullptr; }
_LIBCPP_HIDE_FROM_ABI
bool done() const {
_LIBCPP_ASSERT(__is_suspended(), "done() can be called only on suspended coroutines");
return __builtin_coro_done(__handle_);
}
_LIBCPP_HIDE_FROM_ABI bool done() const {
_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(__is_suspended(), "done() can be called only on suspended coroutines");
return __builtin_coro_done(__handle_);
}
// [coroutine.handle.resumption], resumption
_LIBCPP_HIDE_FROM_ABI
void operator()() const { resume(); }
// [coroutine.handle.resumption], resumption
_LIBCPP_HIDE_FROM_ABI void operator()() const { resume(); }
_LIBCPP_HIDE_FROM_ABI
void resume() const {
_LIBCPP_ASSERT(__is_suspended(), "resume() can be called only on suspended coroutines");
_LIBCPP_ASSERT(!done(), "resume() has undefined behavior when the coroutine is done");
__builtin_coro_resume(__handle_);
}
_LIBCPP_HIDE_FROM_ABI void resume() const {
_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(__is_suspended(), "resume() can be called only on suspended coroutines");
_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(!done(), "resume() has undefined behavior when the coroutine is done");
__builtin_coro_resume(__handle_);
}
_LIBCPP_HIDE_FROM_ABI
void destroy() const {
_LIBCPP_ASSERT(__is_suspended(), "destroy() can be called only on suspended coroutines");
__builtin_coro_destroy(__handle_);
}
_LIBCPP_HIDE_FROM_ABI void destroy() const {
_LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(__is_suspended(), "destroy() can be called only on suspended coroutines");
__builtin_coro_destroy(__handle_);
}
// [coroutine.handle.promise], promise access
_LIBCPP_HIDE_FROM_ABI
_Promise& promise() const {
return *static_cast<_Promise*>(__builtin_coro_promise(this->__handle_, alignof(_Promise), false));
}
// [coroutine.handle.promise], promise access
_LIBCPP_HIDE_FROM_ABI _Promise& promise() const {
return *static_cast<_Promise*>(__builtin_coro_promise(this->__handle_, alignof(_Promise), false));
}
private:
_LIBCPP_HIDE_FROM_ABI bool __is_suspended() const {
// FIXME actually implement a check for if the coro is suspended.
return __handle_ != nullptr;
}
void* __handle_ = nullptr;
_LIBCPP_HIDE_FROM_ABI bool __is_suspended() const {
// FIXME actually implement a check for if the coro is suspended.
return __handle_ != nullptr;
}
void* __handle_ = nullptr;
};
// [coroutine.handle.hash]
template <class _Tp>
struct hash<coroutine_handle<_Tp>> {
_LIBCPP_HIDE_FROM_ABI
size_t operator()(const coroutine_handle<_Tp>& __v) const noexcept { return hash<void*>()(__v.address()); }
_LIBCPP_HIDE_FROM_ABI size_t operator()(const coroutine_handle<_Tp>& __v) const noexcept {
return hash<void*>()(__v.address());
}
};
_LIBCPP_END_NAMESPACE_STD

View file

@ -34,17 +34,12 @@ template <class _Tp, class = void>
struct __coroutine_traits_sfinae {};
template <class _Tp>
struct __coroutine_traits_sfinae<
_Tp, __void_t<typename _Tp::promise_type> >
{
struct __coroutine_traits_sfinae< _Tp, __void_t<typename _Tp::promise_type> > {
using promise_type = typename _Tp::promise_type;
};
template <class _Ret, class... _Args>
struct coroutine_traits
: public __coroutine_traits_sfinae<_Ret>
{
};
struct coroutine_traits : public __coroutine_traits_sfinae<_Ret> {};
_LIBCPP_END_NAMESPACE_STD

View file

@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC)
# if __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC)
// [coroutine.noop]
// [coroutine.promise.noop]
@ -30,80 +30,67 @@ struct noop_coroutine_promise {};
template <>
struct _LIBCPP_TEMPLATE_VIS coroutine_handle<noop_coroutine_promise> {
public:
// [coroutine.handle.noop.conv], conversion
_LIBCPP_HIDE_FROM_ABI
constexpr operator coroutine_handle<>() const noexcept {
return coroutine_handle<>::from_address(address());
}
// [coroutine.handle.noop.conv], conversion
_LIBCPP_HIDE_FROM_ABI constexpr operator coroutine_handle<>() const noexcept {
return coroutine_handle<>::from_address(address());
}
// [coroutine.handle.noop.observers], observers
_LIBCPP_HIDE_FROM_ABI
constexpr explicit operator bool() const noexcept { return true; }
_LIBCPP_HIDE_FROM_ABI
constexpr bool done() const noexcept { return false; }
// [coroutine.handle.noop.observers], observers
_LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return true; }
_LIBCPP_HIDE_FROM_ABI constexpr bool done() const noexcept { return false; }
// [coroutine.handle.noop.resumption], resumption
_LIBCPP_HIDE_FROM_ABI
constexpr void operator()() const noexcept {}
_LIBCPP_HIDE_FROM_ABI
constexpr void resume() const noexcept {}
_LIBCPP_HIDE_FROM_ABI
constexpr void destroy() const noexcept {}
// [coroutine.handle.noop.resumption], resumption
_LIBCPP_HIDE_FROM_ABI constexpr void operator()() const noexcept {}
_LIBCPP_HIDE_FROM_ABI constexpr void resume() const noexcept {}
_LIBCPP_HIDE_FROM_ABI constexpr void destroy() const noexcept {}
// [coroutine.handle.noop.promise], promise access
_LIBCPP_HIDE_FROM_ABI
noop_coroutine_promise& promise() const noexcept {
return *static_cast<noop_coroutine_promise*>(
__builtin_coro_promise(this->__handle_, alignof(noop_coroutine_promise), false));
}
// [coroutine.handle.noop.promise], promise access
_LIBCPP_HIDE_FROM_ABI noop_coroutine_promise& promise() const noexcept {
return *static_cast<noop_coroutine_promise*>(
__builtin_coro_promise(this->__handle_, alignof(noop_coroutine_promise), false));
}
// [coroutine.handle.noop.address], address
_LIBCPP_HIDE_FROM_ABI
constexpr void* address() const noexcept { return __handle_; }
// [coroutine.handle.noop.address], address
_LIBCPP_HIDE_FROM_ABI constexpr void* address() const noexcept { return __handle_; }
private:
_LIBCPP_HIDE_FROM_ABI
friend coroutine_handle<noop_coroutine_promise> noop_coroutine() noexcept;
_LIBCPP_HIDE_FROM_ABI friend coroutine_handle<noop_coroutine_promise> noop_coroutine() noexcept;
#if __has_builtin(__builtin_coro_noop)
_LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept {
this->__handle_ = __builtin_coro_noop();
}
# if __has_builtin(__builtin_coro_noop)
_LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept { this->__handle_ = __builtin_coro_noop(); }
void* __handle_ = nullptr;
void* __handle_ = nullptr;
#elif defined(_LIBCPP_COMPILER_GCC)
// GCC doesn't implement __builtin_coro_noop().
// Construct the coroutine frame manually instead.
struct __noop_coroutine_frame_ty_ {
static void __dummy_resume_destroy_func() { }
# elif defined(_LIBCPP_COMPILER_GCC)
// GCC doesn't implement __builtin_coro_noop().
// Construct the coroutine frame manually instead.
struct __noop_coroutine_frame_ty_ {
static void __dummy_resume_destroy_func() {}
void (*__resume_)() = __dummy_resume_destroy_func;
void (*__destroy_)() = __dummy_resume_destroy_func;
struct noop_coroutine_promise __promise_;
};
void (*__resume_)() = __dummy_resume_destroy_func;
void (*__destroy_)() = __dummy_resume_destroy_func;
struct noop_coroutine_promise __promise_;
};
static __noop_coroutine_frame_ty_ __noop_coroutine_frame_;
static __noop_coroutine_frame_ty_ __noop_coroutine_frame_;
void* __handle_ = &__noop_coroutine_frame_;
void* __handle_ = &__noop_coroutine_frame_;
_LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept = default;
_LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept = default;
#endif // __has_builtin(__builtin_coro_noop)
# endif // __has_builtin(__builtin_coro_noop)
};
using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>;
#if defined(_LIBCPP_COMPILER_GCC)
inline noop_coroutine_handle::__noop_coroutine_frame_ty_
noop_coroutine_handle::__noop_coroutine_frame_{};
#endif
# if defined(_LIBCPP_COMPILER_GCC)
inline noop_coroutine_handle::__noop_coroutine_frame_ty_ noop_coroutine_handle::__noop_coroutine_frame_{};
# endif
// [coroutine.noop.coroutine]
inline _LIBCPP_HIDE_FROM_ABI
noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle(); }
inline _LIBCPP_HIDE_FROM_ABI noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle(); }
#endif // __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC)
# endif // __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC)
_LIBCPP_END_NAMESPACE_STD

View file

@ -22,21 +22,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// [coroutine.trivial.awaitables]
struct suspend_never {
_LIBCPP_HIDE_FROM_ABI
constexpr bool await_ready() const noexcept { return true; }
_LIBCPP_HIDE_FROM_ABI
constexpr void await_suspend(coroutine_handle<>) const noexcept {}
_LIBCPP_HIDE_FROM_ABI
constexpr void await_resume() const noexcept {}
_LIBCPP_HIDE_FROM_ABI constexpr bool await_ready() const noexcept { return true; }
_LIBCPP_HIDE_FROM_ABI constexpr void await_suspend(coroutine_handle<>) const noexcept {}
_LIBCPP_HIDE_FROM_ABI constexpr void await_resume() const noexcept {}
};
struct suspend_always {
_LIBCPP_HIDE_FROM_ABI
constexpr bool await_ready() const noexcept { return false; }
_LIBCPP_HIDE_FROM_ABI
constexpr void await_suspend(coroutine_handle<>) const noexcept {}
_LIBCPP_HIDE_FROM_ABI
constexpr void await_resume() const noexcept {}
_LIBCPP_HIDE_FROM_ABI constexpr bool await_ready() const noexcept { return false; }
_LIBCPP_HIDE_FROM_ABI constexpr void await_suspend(coroutine_handle<>) const noexcept {}
_LIBCPP_HIDE_FROM_ABI constexpr void await_resume() const noexcept {}
};
_LIBCPP_END_NAMESPACE_STD