mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +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
217
third_party/libcxx/__chrono/time_point.h
vendored
217
third_party/libcxx/__chrono/time_point.h
vendored
|
@ -28,128 +28,96 @@ _LIBCPP_PUSH_MACROS
|
|||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
namespace chrono
|
||||
{
|
||||
namespace chrono {
|
||||
|
||||
template <class _Clock, class _Duration = typename _Clock::duration>
|
||||
class _LIBCPP_TEMPLATE_VIS time_point
|
||||
{
|
||||
static_assert(__is_duration<_Duration>::value,
|
||||
"Second template parameter of time_point must be a std::chrono::duration");
|
||||
class _LIBCPP_TEMPLATE_VIS time_point {
|
||||
static_assert(__is_duration<_Duration>::value,
|
||||
"Second template parameter of time_point must be a std::chrono::duration");
|
||||
|
||||
public:
|
||||
typedef _Clock clock;
|
||||
typedef _Duration duration;
|
||||
typedef typename duration::rep rep;
|
||||
typedef typename duration::period period;
|
||||
typedef _Clock clock;
|
||||
typedef _Duration duration;
|
||||
typedef typename duration::rep rep;
|
||||
typedef typename duration::period period;
|
||||
|
||||
private:
|
||||
duration __d_;
|
||||
duration __d_;
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point() : __d_(duration::zero()) {}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit time_point(const duration& __d) : __d_(__d) {}
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point() : __d_(duration::zero()) {}
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit time_point(const duration& __d) : __d_(__d) {}
|
||||
|
||||
// conversions
|
||||
template <class _Duration2>
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
time_point(const time_point<clock, _Duration2>& __t,
|
||||
typename enable_if
|
||||
<
|
||||
is_convertible<_Duration2, duration>::value
|
||||
>::type* = nullptr)
|
||||
: __d_(__t.time_since_epoch()) {}
|
||||
// conversions
|
||||
template <class _Duration2, __enable_if_t<is_convertible<_Duration2, duration>::value, int> = 0>
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point(const time_point<clock, _Duration2>& __t)
|
||||
: __d_(__t.time_since_epoch()) {}
|
||||
|
||||
// observer
|
||||
// observer
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 duration time_since_epoch() const {return __d_;}
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 duration time_since_epoch() const { return __d_; }
|
||||
|
||||
// arithmetic
|
||||
// arithmetic
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator+=(const duration& __d) {
|
||||
__d_ += __d;
|
||||
return *this;
|
||||
}
|
||||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator-=(const duration& __d) {
|
||||
__d_ -= __d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// special values
|
||||
// special values
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() _NOEXCEPT {return time_point(duration::min());}
|
||||
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() _NOEXCEPT {return time_point(duration::max());}
|
||||
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR time_point min() _NOEXCEPT { return time_point(duration::min()); }
|
||||
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR time_point max() _NOEXCEPT { return time_point(duration::max()); }
|
||||
};
|
||||
|
||||
} // namespace chrono
|
||||
|
||||
template <class _Clock, class _Duration1, class _Duration2>
|
||||
struct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>,
|
||||
chrono::time_point<_Clock, _Duration2> >
|
||||
{
|
||||
typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
|
||||
struct _LIBCPP_TEMPLATE_VIS
|
||||
common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> > {
|
||||
typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
|
||||
};
|
||||
|
||||
namespace chrono {
|
||||
|
||||
template <class _ToDuration, class _Clock, class _Duration>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
time_point<_Clock, _ToDuration>
|
||||
time_point_cast(const time_point<_Clock, _Duration>& __t)
|
||||
{
|
||||
return time_point<_Clock, _ToDuration>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, _ToDuration>
|
||||
time_point_cast(const time_point<_Clock, _Duration>& __t) {
|
||||
return time_point<_Clock, _ToDuration>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER >= 17
|
||||
template <class _ToDuration, class _Clock, class _Duration>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
typename enable_if
|
||||
<
|
||||
__is_duration<_ToDuration>::value,
|
||||
time_point<_Clock, _ToDuration>
|
||||
>::type
|
||||
floor(const time_point<_Clock, _Duration>& __t)
|
||||
{
|
||||
return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())};
|
||||
template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
|
||||
inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> floor(const time_point<_Clock, _Duration>& __t) {
|
||||
return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())};
|
||||
}
|
||||
|
||||
template <class _ToDuration, class _Clock, class _Duration>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
typename enable_if
|
||||
<
|
||||
__is_duration<_ToDuration>::value,
|
||||
time_point<_Clock, _ToDuration>
|
||||
>::type
|
||||
ceil(const time_point<_Clock, _Duration>& __t)
|
||||
{
|
||||
return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())};
|
||||
template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
|
||||
inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> ceil(const time_point<_Clock, _Duration>& __t) {
|
||||
return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())};
|
||||
}
|
||||
|
||||
template <class _ToDuration, class _Clock, class _Duration>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
typename enable_if
|
||||
<
|
||||
__is_duration<_ToDuration>::value,
|
||||
time_point<_Clock, _ToDuration>
|
||||
>::type
|
||||
round(const time_point<_Clock, _Duration>& __t)
|
||||
{
|
||||
return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())};
|
||||
template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
|
||||
inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> round(const time_point<_Clock, _Duration>& __t) {
|
||||
return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())};
|
||||
}
|
||||
|
||||
template <class _Rep, class _Period>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
typename enable_if
|
||||
<
|
||||
numeric_limits<_Rep>::is_signed,
|
||||
duration<_Rep, _Period>
|
||||
>::type
|
||||
abs(duration<_Rep, _Period> __d)
|
||||
{
|
||||
return __d >= __d.zero() ? +__d : -__d;
|
||||
template <class _Rep, class _Period, enable_if_t<numeric_limits<_Rep>::is_signed, int> = 0>
|
||||
inline _LIBCPP_HIDE_FROM_ABI constexpr duration<_Rep, _Period> abs(duration<_Rep, _Period> __d) {
|
||||
return __d >= __d.zero() ? +__d : -__d;
|
||||
}
|
||||
#endif // _LIBCPP_STD_VER >= 17
|
||||
|
||||
// time_point ==
|
||||
|
||||
template <class _Clock, class _Duration1, class _Duration2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
bool
|
||||
operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
|
||||
{
|
||||
return __lhs.time_since_epoch() == __rhs.time_since_epoch();
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
|
||||
operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
|
||||
return __lhs.time_since_epoch() == __rhs.time_since_epoch();
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER <= 17
|
||||
|
@ -157,11 +125,9 @@ operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
|
|||
// time_point !=
|
||||
|
||||
template <class _Clock, class _Duration1, class _Duration2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
bool
|
||||
operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
|
||||
{
|
||||
return !(__lhs == __rhs);
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
|
||||
operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
|
||||
return !(__lhs == __rhs);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_STD_VER <= 17
|
||||
|
@ -169,41 +135,33 @@ operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
|
|||
// time_point <
|
||||
|
||||
template <class _Clock, class _Duration1, class _Duration2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
bool
|
||||
operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
|
||||
{
|
||||
return __lhs.time_since_epoch() < __rhs.time_since_epoch();
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
|
||||
operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
|
||||
return __lhs.time_since_epoch() < __rhs.time_since_epoch();
|
||||
}
|
||||
|
||||
// time_point >
|
||||
|
||||
template <class _Clock, class _Duration1, class _Duration2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
bool
|
||||
operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
|
||||
{
|
||||
return __rhs < __lhs;
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
|
||||
operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
|
||||
return __rhs < __lhs;
|
||||
}
|
||||
|
||||
// time_point <=
|
||||
|
||||
template <class _Clock, class _Duration1, class _Duration2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
bool
|
||||
operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
|
||||
{
|
||||
return !(__rhs < __lhs);
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
|
||||
operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
|
||||
return !(__rhs < __lhs);
|
||||
}
|
||||
|
||||
// time_point >=
|
||||
|
||||
template <class _Clock, class _Duration1, class _Duration2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
bool
|
||||
operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
|
||||
{
|
||||
return !(__lhs < __rhs);
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
|
||||
operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
|
||||
return !(__lhs < __rhs);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
@ -211,7 +169,7 @@ operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
|
|||
template <class _Clock, class _Duration1, three_way_comparable_with<_Duration1> _Duration2>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto
|
||||
operator<=>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
|
||||
return __lhs.time_since_epoch() <=> __rhs.time_since_epoch();
|
||||
return __lhs.time_since_epoch() <=> __rhs.time_since_epoch();
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
@ -219,43 +177,38 @@ operator<=>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock
|
|||
// time_point operator+(time_point x, duration y);
|
||||
|
||||
template <class _Clock, class _Duration1, class _Rep2, class _Period2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
|
||||
operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
|
||||
{
|
||||
typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr;
|
||||
return _Tr (__lhs.time_since_epoch() + __rhs);
|
||||
inline _LIBCPP_HIDE_FROM_ABI
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
|
||||
operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
|
||||
typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr;
|
||||
return _Tr(__lhs.time_since_epoch() + __rhs);
|
||||
}
|
||||
|
||||
// time_point operator+(duration x, time_point y);
|
||||
|
||||
template <class _Rep1, class _Period1, class _Clock, class _Duration2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
|
||||
operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
|
||||
{
|
||||
return __rhs + __lhs;
|
||||
inline _LIBCPP_HIDE_FROM_ABI
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
|
||||
operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
|
||||
return __rhs + __lhs;
|
||||
}
|
||||
|
||||
// time_point operator-(time_point x, duration y);
|
||||
|
||||
template <class _Clock, class _Duration1, class _Rep2, class _Period2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
|
||||
operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
|
||||
{
|
||||
typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret;
|
||||
return _Ret(__lhs.time_since_epoch() -__rhs);
|
||||
inline _LIBCPP_HIDE_FROM_ABI
|
||||
_LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
|
||||
operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
|
||||
typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret;
|
||||
return _Ret(__lhs.time_since_epoch() - __rhs);
|
||||
}
|
||||
|
||||
// duration operator-(time_point x, time_point y);
|
||||
|
||||
template <class _Clock, class _Duration1, class _Duration2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
|
||||
typename common_type<_Duration1, _Duration2>::type
|
||||
operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
|
||||
{
|
||||
return __lhs.time_since_epoch() - __rhs.time_since_epoch();
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename common_type<_Duration1, _Duration2>::type
|
||||
operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
|
||||
return __lhs.time_since_epoch() - __rhs.time_since_epoch();
|
||||
}
|
||||
|
||||
} // namespace chrono
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue