mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +00:00
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:
parent
62ace3623a
commit
5660ec4741
1585 changed files with 117353 additions and 271644 deletions
11
third_party/libcxx/__charconv/chars_format.h
vendored
11
third_party/libcxx/__charconv/chars_format.h
vendored
|
@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
|||
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
|
||||
enum class _LIBCPP_ENUM_VIS chars_format { scientific = 0x1, fixed = 0x2, hex = 0x4, general = fixed | scientific };
|
||||
enum class chars_format { scientific = 0x1, fixed = 0x2, hex = 0x4, general = fixed | scientific };
|
||||
|
||||
inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator~(chars_format __x) {
|
||||
return chars_format(~std::__to_underlying(__x));
|
||||
|
@ -39,20 +39,17 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator^(chars_format __x,
|
|||
return chars_format(std::__to_underlying(__x) ^ std::__to_underlying(__y));
|
||||
}
|
||||
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
|
||||
operator&=(chars_format& __x, chars_format __y) {
|
||||
inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format& operator&=(chars_format& __x, chars_format __y) {
|
||||
__x = __x & __y;
|
||||
return __x;
|
||||
}
|
||||
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
|
||||
operator|=(chars_format& __x, chars_format __y) {
|
||||
inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format& operator|=(chars_format& __x, chars_format __y) {
|
||||
__x = __x | __y;
|
||||
return __x;
|
||||
}
|
||||
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
|
||||
operator^=(chars_format& __x, chars_format __y) {
|
||||
inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format& operator^=(chars_format& __x, chars_format __y) {
|
||||
__x = __x ^ __y;
|
||||
return __x;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#define _LIBCPP___CHARCONV_FROM_CHARS_INTEGRAL_H
|
||||
|
||||
#include <__algorithm/copy_n.h>
|
||||
#include <__assert>
|
||||
#include <__charconv/from_chars_result.h>
|
||||
#include <__charconv/traits.h>
|
||||
#include <__config>
|
||||
|
@ -124,7 +125,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts...
|
|||
return __r;
|
||||
}
|
||||
|
||||
template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
|
||||
template <typename _Tp, __enable_if_t<is_unsigned<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
|
||||
__from_chars_atoi(const char* __first, const char* __last, _Tp& __value) {
|
||||
using __tx = __itoa::__traits<_Tp>;
|
||||
|
@ -145,7 +146,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) {
|
|||
});
|
||||
}
|
||||
|
||||
template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
|
||||
template <typename _Tp, __enable_if_t<is_signed<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
|
||||
__from_chars_atoi(const char* __first, const char* __last, _Tp& __value) {
|
||||
using __t = decltype(std::__to_unsigned_like(__value));
|
||||
|
@ -170,7 +171,7 @@ inline constexpr float __from_chars_log2f_lut[35] = {
|
|||
4.321928, 4.3923173, 4.4594316, 4.523562, 4.5849624, 4.643856, 4.70044, 4.7548876, 4.807355,
|
||||
4.857981, 4.9068904, 4.9541965, 5, 5.044394, 5.087463, 5.129283, 5.169925};
|
||||
|
||||
template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
|
||||
template <typename _Tp, __enable_if_t<is_unsigned<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
|
||||
__from_chars_integral(const char* __first, const char* __last, _Tp& __value, int __base) {
|
||||
if (__base == 10)
|
||||
|
@ -211,23 +212,23 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value, int
|
|||
__base);
|
||||
}
|
||||
|
||||
template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
|
||||
template <typename _Tp, __enable_if_t<is_signed<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
|
||||
__from_chars_integral(const char* __first, const char* __last, _Tp& __value, int __base) {
|
||||
using __t = decltype(std::__to_unsigned_like(__value));
|
||||
return std::__sign_combinator(__first, __last, __value, __from_chars_integral<__t>, __base);
|
||||
}
|
||||
|
||||
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
|
||||
template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
|
||||
from_chars(const char* __first, const char* __last, _Tp& __value) {
|
||||
return std::__from_chars_atoi(__first, __last, __value);
|
||||
}
|
||||
|
||||
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
|
||||
template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result
|
||||
from_chars(const char* __first, const char* __last, _Tp& __value, int __base) {
|
||||
_LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
|
||||
_LIBCPP_ASSERT_UNCATEGORIZED(2 <= __base && __base <= 36, "base not in [2, 36]");
|
||||
return std::__from_chars_integral(__first, __last, __value, __base);
|
||||
}
|
||||
#endif // _LIBCPP_STD_VER >= 17
|
||||
|
|
|
@ -21,12 +21,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
|||
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
|
||||
struct _LIBCPP_TYPE_VIS from_chars_result {
|
||||
struct _LIBCPP_EXPORTED_FROM_ABI from_chars_result {
|
||||
const char* ptr;
|
||||
errc ec;
|
||||
# if _LIBCPP_STD_VER >= 20
|
||||
_LIBCPP_HIDE_FROM_ABI friend bool operator==(const from_chars_result&, const from_chars_result&) = default;
|
||||
# endif
|
||||
# if _LIBCPP_STD_VER >= 26
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return ec == errc{}; }
|
||||
# endif
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 17
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#define _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H
|
||||
|
||||
#include <__algorithm/copy_n.h>
|
||||
#include <__assert>
|
||||
#include <__charconv/tables.h>
|
||||
#include <__config>
|
||||
#include <cstdint>
|
||||
|
@ -132,14 +133,14 @@ __base_10_u64(char* __buffer, uint64_t __value) noexcept {
|
|||
/// range that can be used. However the range is sufficient for
|
||||
/// \ref __base_10_u128.
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept {
|
||||
_LIBCPP_ASSERT(__exp >= __pow10_128_offset, "Index out of bounds");
|
||||
_LIBCPP_ASSERT_INTERNAL(__exp >= __pow10_128_offset, "Index out of bounds");
|
||||
return __pow10_128[__exp - __pow10_128_offset];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char*
|
||||
__base_10_u128(char* __buffer, __uint128_t __value) noexcept {
|
||||
_LIBCPP_ASSERT(
|
||||
__value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
|
||||
_LIBCPP_ASSERT_INTERNAL(
|
||||
__value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fails when this isn't true.");
|
||||
|
||||
// Unlike the 64 to 32 bit case the 128 bit case the "upper half" can't be
|
||||
// stored in the "lower half". Instead we first need to handle the top most
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#ifndef _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H
|
||||
#define _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H
|
||||
|
||||
#include <__availability>
|
||||
#include <__charconv/chars_format.h>
|
||||
#include <__charconv/to_chars_result.h>
|
||||
#include <__config>
|
||||
|
@ -23,31 +22,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
|||
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
|
||||
to_chars(char* __first, char* __last, float __value);
|
||||
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
|
||||
to_chars(char* __first, char* __last, double __value);
|
||||
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
|
||||
to_chars(char* __first, char* __last, long double __value);
|
||||
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
|
||||
to_chars(char* __first, char* __last, float __value, chars_format __fmt);
|
||||
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
|
||||
to_chars(char* __first, char* __last, double __value, chars_format __fmt);
|
||||
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
|
||||
to_chars(char* __first, char* __last, long double __value, chars_format __fmt);
|
||||
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
|
||||
to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision);
|
||||
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
|
||||
to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision);
|
||||
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result
|
||||
_LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_result
|
||||
to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision);
|
||||
#endif // _LIBCPP_STD_VER >= 17
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#define _LIBCPP___CHARCONV_TO_CHARS_INTEGRAL_H
|
||||
|
||||
#include <__algorithm/copy_n.h>
|
||||
#include <__assert>
|
||||
#include <__bit/countl.h>
|
||||
#include <__charconv/tables.h>
|
||||
#include <__charconv/to_chars_base_10.h>
|
||||
|
@ -222,23 +223,23 @@ struct _LIBCPP_HIDDEN __integral<16> {
|
|||
|
||||
} // namespace __itoa
|
||||
|
||||
template <unsigned _Base, typename _Tp, typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
|
||||
template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) >= sizeof(unsigned)), int> = 0>
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_width(_Tp __value) {
|
||||
return __itoa::__integral<_Base>::__width(__value);
|
||||
}
|
||||
|
||||
template <unsigned _Base, typename _Tp, typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
|
||||
template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) < sizeof(unsigned)), int> = 0>
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_width(_Tp __value) {
|
||||
return std::__to_chars_integral_width<_Base>(static_cast<unsigned>(__value));
|
||||
}
|
||||
|
||||
template <unsigned _Base, typename _Tp, typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0>
|
||||
template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) >= sizeof(unsigned)), int> = 0>
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
|
||||
__to_chars_integral(char* __first, char* __last, _Tp __value) {
|
||||
return __itoa::__integral<_Base>::__to_chars(__first, __last, __value);
|
||||
}
|
||||
|
||||
template <unsigned _Base, typename _Tp, typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0>
|
||||
template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) < sizeof(unsigned)), int> = 0>
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
|
||||
__to_chars_integral(char* __first, char* __last, _Tp __value) {
|
||||
return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value));
|
||||
|
@ -246,7 +247,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value) {
|
|||
|
||||
template <typename _Tp>
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_width(_Tp __value, unsigned __base) {
|
||||
_LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value.");
|
||||
_LIBCPP_ASSERT_INTERNAL(__value >= 0, "The function requires a non-negative value.");
|
||||
|
||||
unsigned __base_2 = __base * __base;
|
||||
unsigned __base_3 = __base_2 * __base;
|
||||
|
@ -300,7 +301,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_
|
|||
return {__last, errc(0)};
|
||||
}
|
||||
|
||||
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
|
||||
template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
|
||||
to_chars(char* __first, char* __last, _Tp __value) {
|
||||
using _Type = __make_32_64_or_128_bit_t<_Tp>;
|
||||
|
@ -308,10 +309,10 @@ to_chars(char* __first, char* __last, _Tp __value) {
|
|||
return std::__to_chars_itoa(__first, __last, static_cast<_Type>(__value), is_signed<_Tp>());
|
||||
}
|
||||
|
||||
template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
|
||||
template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
|
||||
inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
|
||||
to_chars(char* __first, char* __last, _Tp __value, int __base) {
|
||||
_LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]");
|
||||
_LIBCPP_ASSERT_UNCATEGORIZED(2 <= __base && __base <= 36, "base not in [2, 36]");
|
||||
|
||||
using _Type = __make_32_64_or_128_bit_t<_Tp>;
|
||||
return std::__to_chars_integral(__first, __last, static_cast<_Type>(__value), __base, is_signed<_Tp>());
|
||||
|
|
|
@ -21,12 +21,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
|||
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
|
||||
struct _LIBCPP_TYPE_VIS to_chars_result {
|
||||
struct _LIBCPP_EXPORTED_FROM_ABI to_chars_result {
|
||||
char* ptr;
|
||||
errc ec;
|
||||
# if _LIBCPP_STD_VER >= 20
|
||||
_LIBCPP_HIDE_FROM_ABI friend bool operator==(const to_chars_result&, const to_chars_result&) = default;
|
||||
# endif
|
||||
# if _LIBCPP_STD_VER >= 26
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return ec == errc{}; }
|
||||
# endif
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 17
|
||||
|
|
5
third_party/libcxx/__charconv/traits.h
vendored
5
third_party/libcxx/__charconv/traits.h
vendored
|
@ -10,6 +10,7 @@
|
|||
#ifndef _LIBCPP___CHARCONV_TRAITS
|
||||
#define _LIBCPP___CHARCONV_TRAITS
|
||||
|
||||
#include <__assert>
|
||||
#include <__bit/countl.h>
|
||||
#include <__charconv/tables.h>
|
||||
#include <__charconv/to_chars_base_10.h>
|
||||
|
@ -101,11 +102,11 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__u
|
|||
/// zero is set to one. This means the first element of the lookup table is
|
||||
/// zero.
|
||||
static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
|
||||
_LIBCPP_ASSERT(
|
||||
_LIBCPP_ASSERT_INTERNAL(
|
||||
__v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
|
||||
// There's always a bit set in the upper 64-bits.
|
||||
auto __t = (128 - std::__libcpp_clz(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12;
|
||||
_LIBCPP_ASSERT(__t >= __itoa::__pow10_128_offset, "Index out of bounds");
|
||||
_LIBCPP_ASSERT_INTERNAL(__t >= __itoa::__pow10_128_offset, "Index out of bounds");
|
||||
// __t is adjusted since the lookup table misses the lower entries.
|
||||
return __t - (__v < __itoa::__pow10_128[__t - __itoa::__pow10_128_offset]) + 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue