aboutsummaryrefslogtreecommitdiff
path: root/contrib/libc++
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libc++')
-rw-r--r--contrib/libc++/include/cmath12
-rw-r--r--contrib/libc++/include/complex158
-rw-r--r--contrib/libc++/include/optional104
-rw-r--r--contrib/libc++/include/regex2
-rw-r--r--contrib/libc++/include/string16
-rw-r--r--contrib/libc++/src/experimental/filesystem/filesystem_time_helper.h173
-rw-r--r--contrib/libc++/src/experimental/filesystem/operations.cpp167
-rw-r--r--contrib/libc++/src/include/refstring.h (renamed from contrib/libc++/include/__refstring)6
-rw-r--r--contrib/libc++/src/stdexcept.cpp2
9 files changed, 378 insertions, 262 deletions
diff --git a/contrib/libc++/include/cmath b/contrib/libc++/include/cmath
index b41f247af59c..917928a1f42f 100644
--- a/contrib/libc++/include/cmath
+++ b/contrib/libc++/include/cmath
@@ -549,7 +549,7 @@ hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
-__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isnan)
return __builtin_isnan(__lcpp_x);
@@ -561,7 +561,7 @@ __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
-__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
return isnan(__lcpp_x);
}
@@ -569,7 +569,7 @@ __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
-__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isinf)
return __builtin_isinf(__lcpp_x);
@@ -581,7 +581,7 @@ __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
-__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
return isinf(__lcpp_x);
}
@@ -589,7 +589,7 @@ __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
-__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isfinite)
return __builtin_isfinite(__lcpp_x);
@@ -601,7 +601,7 @@ __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
-__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
+__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
{
return isfinite(__lcpp_x);
}
diff --git a/contrib/libc++/include/complex b/contrib/libc++/include/complex
index d41971b3b4db..41a47cfba47c 100644
--- a/contrib/libc++/include/complex
+++ b/contrib/libc++/include/complex
@@ -599,39 +599,39 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __bc = __b * __c;
_Tp __x = __ac - __bd;
_Tp __y = __ad + __bc;
- if (__libcpp_isnan(__x) && __libcpp_isnan(__y))
+ if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
{
bool __recalc = false;
- if (__libcpp_isinf(__a) || __libcpp_isinf(__b))
+ if (__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b))
{
- __a = copysign(__libcpp_isinf(__a) ? _Tp(1) : _Tp(0), __a);
- __b = copysign(__libcpp_isinf(__b) ? _Tp(1) : _Tp(0), __b);
- if (__libcpp_isnan(__c))
+ __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
+ if (__libcpp_isnan_or_builtin(__c))
__c = copysign(_Tp(0), __c);
- if (__libcpp_isnan(__d))
+ if (__libcpp_isnan_or_builtin(__d))
__d = copysign(_Tp(0), __d);
__recalc = true;
}
- if (__libcpp_isinf(__c) || __libcpp_isinf(__d))
+ if (__libcpp_isinf_or_builtin(__c) || __libcpp_isinf_or_builtin(__d))
{
- __c = copysign(__libcpp_isinf(__c) ? _Tp(1) : _Tp(0), __c);
- __d = copysign(__libcpp_isinf(__d) ? _Tp(1) : _Tp(0), __d);
- if (__libcpp_isnan(__a))
+ __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
+ if (__libcpp_isnan_or_builtin(__a))
__a = copysign(_Tp(0), __a);
- if (__libcpp_isnan(__b))
+ if (__libcpp_isnan_or_builtin(__b))
__b = copysign(_Tp(0), __b);
__recalc = true;
}
- if (!__recalc && (__libcpp_isinf(__ac) || __libcpp_isinf(__bd) ||
- __libcpp_isinf(__ad) || __libcpp_isinf(__bc)))
+ if (!__recalc && (__libcpp_isinf_or_builtin(__ac) || __libcpp_isinf_or_builtin(__bd) ||
+ __libcpp_isinf_or_builtin(__ad) || __libcpp_isinf_or_builtin(__bc)))
{
- if (__libcpp_isnan(__a))
+ if (__libcpp_isnan_or_builtin(__a))
__a = copysign(_Tp(0), __a);
- if (__libcpp_isnan(__b))
+ if (__libcpp_isnan_or_builtin(__b))
__b = copysign(_Tp(0), __b);
- if (__libcpp_isnan(__c))
+ if (__libcpp_isnan_or_builtin(__c))
__c = copysign(_Tp(0), __c);
- if (__libcpp_isnan(__d))
+ if (__libcpp_isnan_or_builtin(__d))
__d = copysign(_Tp(0), __d);
__recalc = true;
}
@@ -674,7 +674,7 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __c = __w.real();
_Tp __d = __w.imag();
_Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));
- if (__libcpp_isfinite(__logbw))
+ if (__libcpp_isfinite_or_builtin(__logbw))
{
__ilogbw = static_cast<int>(__logbw);
__c = scalbn(__c, -__ilogbw);
@@ -683,24 +683,24 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __denom = __c * __c + __d * __d;
_Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
_Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
- if (__libcpp_isnan(__x) && __libcpp_isnan(__y))
+ if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
{
- if ((__denom == _Tp(0)) && (!__libcpp_isnan(__a) || !__libcpp_isnan(__b)))
+ if ((__denom == _Tp(0)) && (!__libcpp_isnan_or_builtin(__a) || !__libcpp_isnan_or_builtin(__b)))
{
__x = copysign(_Tp(INFINITY), __c) * __a;
__y = copysign(_Tp(INFINITY), __c) * __b;
}
- else if ((__libcpp_isinf(__a) || __libcpp_isinf(__b)) && __libcpp_isfinite(__c) && __libcpp_isfinite(__d))
+ else if ((__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b)) && __libcpp_isfinite_or_builtin(__c) && __libcpp_isfinite_or_builtin(__d))
{
- __a = copysign(__libcpp_isinf(__a) ? _Tp(1) : _Tp(0), __a);
- __b = copysign(__libcpp_isinf(__b) ? _Tp(1) : _Tp(0), __b);
+ __a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
__x = _Tp(INFINITY) * (__a * __c + __b * __d);
__y = _Tp(INFINITY) * (__b * __c - __a * __d);
}
- else if (__libcpp_isinf(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite(__a) && __libcpp_isfinite(__b))
+ else if (__libcpp_isinf_or_builtin(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite_or_builtin(__a) && __libcpp_isfinite_or_builtin(__b))
{
- __c = copysign(__libcpp_isinf(__c) ? _Tp(1) : _Tp(0), __c);
- __d = copysign(__libcpp_isinf(__d) ? _Tp(1) : _Tp(0), __d);
+ __c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
__x = _Tp(0) * (__a * __c + __b * __d);
__y = _Tp(0) * (__b * __c - __a * __d);
}
@@ -910,9 +910,9 @@ inline _LIBCPP_INLINE_VISIBILITY
_Tp
norm(const complex<_Tp>& __c)
{
- if (__libcpp_isinf(__c.real()))
+ if (__libcpp_isinf_or_builtin(__c.real()))
return abs(__c.real());
- if (__libcpp_isinf(__c.imag()))
+ if (__libcpp_isinf_or_builtin(__c.imag()))
return abs(__c.imag());
return __c.real() * __c.real() + __c.imag() * __c.imag();
}
@@ -955,7 +955,7 @@ complex<_Tp>
proj(const complex<_Tp>& __c)
{
std::complex<_Tp> __r = __c;
- if (__libcpp_isinf(__c.real()) || __libcpp_isinf(__c.imag()))
+ if (__libcpp_isinf_or_builtin(__c.real()) || __libcpp_isinf_or_builtin(__c.imag()))
__r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
return __r;
}
@@ -969,7 +969,7 @@ typename enable_if
>::type
proj(_Tp __re)
{
- if (__libcpp_isinf(__re))
+ if (__libcpp_isinf_or_builtin(__re))
__re = abs(__re);
return complex<_Tp>(__re);
}
@@ -993,25 +993,25 @@ template<class _Tp>
complex<_Tp>
polar(const _Tp& __rho, const _Tp& __theta = _Tp(0))
{
- if (__libcpp_isnan(__rho) || signbit(__rho))
+ if (__libcpp_isnan_or_builtin(__rho) || signbit(__rho))
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
- if (__libcpp_isnan(__theta))
+ if (__libcpp_isnan_or_builtin(__theta))
{
- if (__libcpp_isinf(__rho))
+ if (__libcpp_isinf_or_builtin(__rho))
return complex<_Tp>(__rho, __theta);
return complex<_Tp>(__theta, __theta);
}
- if (__libcpp_isinf(__theta))
+ if (__libcpp_isinf_or_builtin(__theta))
{
- if (__libcpp_isinf(__rho))
+ if (__libcpp_isinf_or_builtin(__rho))
return complex<_Tp>(__rho, _Tp(NAN));
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
}
_Tp __x = __rho * cos(__theta);
- if (__libcpp_isnan(__x))
+ if (__libcpp_isnan_or_builtin(__x))
__x = 0;
_Tp __y = __rho * sin(__theta);
- if (__libcpp_isnan(__y))
+ if (__libcpp_isnan_or_builtin(__y))
__y = 0;
return complex<_Tp>(__x, __y);
}
@@ -1042,13 +1042,13 @@ template<class _Tp>
complex<_Tp>
sqrt(const complex<_Tp>& __x)
{
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(_Tp(INFINITY), __x.imag());
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
if (__x.real() > _Tp(0))
- return complex<_Tp>(__x.real(), __libcpp_isnan(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
- return complex<_Tp>(__libcpp_isnan(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
+ return complex<_Tp>(__x.real(), __libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
+ return complex<_Tp>(__libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
}
return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
}
@@ -1060,21 +1060,21 @@ complex<_Tp>
exp(const complex<_Tp>& __x)
{
_Tp __i = __x.imag();
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
if (__x.real() < _Tp(0))
{
- if (!__libcpp_isfinite(__i))
+ if (!__libcpp_isfinite_or_builtin(__i))
__i = _Tp(1);
}
- else if (__i == 0 || !__libcpp_isfinite(__i))
+ else if (__i == 0 || !__libcpp_isfinite_or_builtin(__i))
{
- if (__libcpp_isinf(__i))
+ if (__libcpp_isinf_or_builtin(__i))
__i = _Tp(NAN);
return complex<_Tp>(__x.real(), __i);
}
}
- else if (__libcpp_isnan(__x.real()) && __x.imag() == 0)
+ else if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
return __x;
_Tp __e = exp(__x.real());
return complex<_Tp>(__e * cos(__i), __e * sin(__i));
@@ -1132,23 +1132,23 @@ complex<_Tp>
asinh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
- if (__libcpp_isnan(__x.imag()))
+ if (__libcpp_isnan_or_builtin(__x.imag()))
return __x;
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
}
- if (__libcpp_isnan(__x.real()))
+ if (__libcpp_isnan_or_builtin(__x.real()))
{
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
if (__x.imag() == 0)
return __x;
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) + _Tp(1)));
return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
@@ -1161,11 +1161,11 @@ complex<_Tp>
acosh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
- if (__libcpp_isnan(__x.imag()))
+ if (__libcpp_isnan_or_builtin(__x.imag()))
return complex<_Tp>(abs(__x.real()), __x.imag());
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
{
if (__x.real() > 0)
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
@@ -1176,13 +1176,13 @@ acosh(const complex<_Tp>& __x)
return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag()));
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
}
- if (__libcpp_isnan(__x.real()))
+ if (__libcpp_isnan_or_builtin(__x.real()))
{
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(abs(__x.imag()), __x.real());
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
@@ -1195,21 +1195,21 @@ complex<_Tp>
atanh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
{
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
}
- if (__libcpp_isnan(__x.imag()))
+ if (__libcpp_isnan_or_builtin(__x.imag()))
{
- if (__libcpp_isinf(__x.real()) || __x.real() == 0)
+ if (__libcpp_isinf_or_builtin(__x.real()) || __x.real() == 0)
return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());
return complex<_Tp>(__x.imag(), __x.imag());
}
- if (__libcpp_isnan(__x.real()))
+ if (__libcpp_isnan_or_builtin(__x.real()))
{
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
}
@@ -1227,11 +1227,11 @@ template<class _Tp>
complex<_Tp>
sinh(const complex<_Tp>& __x)
{
- if (__libcpp_isinf(__x.real()) && !__libcpp_isfinite(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
- if (__x.real() == 0 && !__libcpp_isfinite(__x.imag()))
+ if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
- if (__x.imag() == 0 && !__libcpp_isfinite(__x.real()))
+ if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
return __x;
return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));
}
@@ -1242,13 +1242,13 @@ template<class _Tp>
complex<_Tp>
cosh(const complex<_Tp>& __x)
{
- if (__libcpp_isinf(__x.real()) && !__libcpp_isfinite(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
return complex<_Tp>(abs(__x.real()), _Tp(NAN));
- if (__x.real() == 0 && !__libcpp_isfinite(__x.imag()))
+ if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
return complex<_Tp>(_Tp(NAN), __x.real());
if (__x.real() == 0 && __x.imag() == 0)
return complex<_Tp>(_Tp(1), __x.imag());
- if (__x.imag() == 0 && !__libcpp_isfinite(__x.real()))
+ if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
return complex<_Tp>(abs(__x.real()), __x.imag());
return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));
}
@@ -1259,19 +1259,19 @@ template<class _Tp>
complex<_Tp>
tanh(const complex<_Tp>& __x)
{
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
- if (!__libcpp_isfinite(__x.imag()))
+ if (!__libcpp_isfinite_or_builtin(__x.imag()))
return complex<_Tp>(_Tp(1), _Tp(0));
return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
}
- if (__libcpp_isnan(__x.real()) && __x.imag() == 0)
+ if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
return __x;
_Tp __2r(_Tp(2) * __x.real());
_Tp __2i(_Tp(2) * __x.imag());
_Tp __d(cosh(__2r) + cos(__2i));
_Tp __2rsh(sinh(__2r));
- if (__libcpp_isinf(__2rsh) && __libcpp_isinf(__d))
+ if (__libcpp_isinf_or_builtin(__2rsh) && __libcpp_isinf_or_builtin(__d))
return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1),
__2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
return complex<_Tp>(__2rsh/__d, sin(__2i)/__d);
@@ -1294,11 +1294,11 @@ complex<_Tp>
acos(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (__libcpp_isinf(__x.real()))
+ if (__libcpp_isinf_or_builtin(__x.real()))
{
- if (__libcpp_isnan(__x.imag()))
+ if (__libcpp_isnan_or_builtin(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
{
if (__x.real() < _Tp(0))
return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
@@ -1308,13 +1308,13 @@ acos(const complex<_Tp>& __x)
return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real());
return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real());
}
- if (__libcpp_isnan(__x.real()))
+ if (__libcpp_isnan_or_builtin(__x.real()))
{
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(__x.real(), -__x.imag());
return complex<_Tp>(__x.real(), __x.real());
}
- if (__libcpp_isinf(__x.imag()))
+ if (__libcpp_isinf_or_builtin(__x.imag()))
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
diff --git a/contrib/libc++/include/optional b/contrib/libc++/include/optional
index c0fd0e7bc49f..1fb953bab743 100644
--- a/contrib/libc++/include/optional
+++ b/contrib/libc++/include/optional
@@ -439,46 +439,122 @@ struct __optional_storage_base<_Tp, true>
}
};
-template <class _Tp, bool = is_trivially_copyable<_Tp>::value>
-struct __optional_storage;
-
-template <class _Tp>
-struct __optional_storage<_Tp, true> : __optional_storage_base<_Tp>
+template <class _Tp, bool = is_trivially_copy_constructible<_Tp>::value>
+struct __optional_copy_base : __optional_storage_base<_Tp>
{
using __optional_storage_base<_Tp>::__optional_storage_base;
};
template <class _Tp>
-struct __optional_storage<_Tp, false> : __optional_storage_base<_Tp>
+struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp>
{
- using value_type = _Tp;
using __optional_storage_base<_Tp>::__optional_storage_base;
_LIBCPP_INLINE_VISIBILITY
- __optional_storage() = default;
+ __optional_copy_base() = default;
_LIBCPP_INLINE_VISIBILITY
- __optional_storage(const __optional_storage& __opt)
+ __optional_copy_base(const __optional_copy_base& __opt)
{
this->__construct_from(__opt);
}
_LIBCPP_INLINE_VISIBILITY
- __optional_storage(__optional_storage&& __opt)
+ __optional_copy_base(__optional_copy_base&&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_base& operator=(const __optional_copy_base&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_base& operator=(__optional_copy_base&&) = default;
+};
+
+template <class _Tp, bool = is_trivially_move_constructible<_Tp>::value>
+struct __optional_move_base : __optional_copy_base<_Tp>
+{
+ using __optional_copy_base<_Tp>::__optional_copy_base;
+};
+
+template <class _Tp>
+struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp>
+{
+ using value_type = _Tp;
+ using __optional_copy_base<_Tp>::__optional_copy_base;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base() = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base(const __optional_move_base&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base(__optional_move_base&& __opt)
noexcept(is_nothrow_move_constructible_v<value_type>)
{
this->__construct_from(_VSTD::move(__opt));
}
_LIBCPP_INLINE_VISIBILITY
- __optional_storage& operator=(const __optional_storage& __opt)
+ __optional_move_base& operator=(const __optional_move_base&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_base& operator=(__optional_move_base&&) = default;
+};
+
+template <class _Tp, bool =
+ is_trivially_destructible<_Tp>::value &&
+ is_trivially_copy_constructible<_Tp>::value &&
+ is_trivially_copy_assignable<_Tp>::value>
+struct __optional_copy_assign_base : __optional_move_base<_Tp>
+{
+ using __optional_move_base<_Tp>::__optional_move_base;
+};
+
+template <class _Tp>
+struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp>
+{
+ using __optional_move_base<_Tp>::__optional_move_base;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base() = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base(const __optional_copy_assign_base&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base(__optional_copy_assign_base&&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_copy_assign_base& operator=(const __optional_copy_assign_base& __opt)
{
this->__assign_from(__opt);
return *this;
}
_LIBCPP_INLINE_VISIBILITY
- __optional_storage& operator=(__optional_storage&& __opt)
+ __optional_copy_assign_base& operator=(__optional_copy_assign_base&&) = default;
+};
+
+template <class _Tp, bool =
+ is_trivially_destructible<_Tp>::value &&
+ is_trivially_move_constructible<_Tp>::value &&
+ is_trivially_move_assignable<_Tp>::value>
+struct __optional_move_assign_base : __optional_copy_assign_base<_Tp>
+{
+ using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;
+};
+
+template <class _Tp>
+struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp>
+{
+ using value_type = _Tp;
+ using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base() = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base(const __optional_move_assign_base& __opt) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base(__optional_move_assign_base&&) = default;
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base& operator=(const __optional_move_assign_base&) = default;
+
+ _LIBCPP_INLINE_VISIBILITY
+ __optional_move_assign_base& operator=(__optional_move_assign_base&& __opt)
noexcept(is_nothrow_move_assignable_v<value_type> &&
is_nothrow_move_constructible_v<value_type>)
{
@@ -501,11 +577,11 @@ using __optional_sfinae_assign_base_t = __sfinae_assign_base<
template <class _Tp>
class optional
- : private __optional_storage<_Tp>
+ : private __optional_move_assign_base<_Tp>
, private __optional_sfinae_ctor_base_t<_Tp>
, private __optional_sfinae_assign_base_t<_Tp>
{
- using __base = __optional_storage<_Tp>;
+ using __base = __optional_move_assign_base<_Tp>;
public:
using value_type = _Tp;
diff --git a/contrib/libc++/include/regex b/contrib/libc++/include/regex
index 443c2e303465..77ca648109b2 100644
--- a/contrib/libc++/include/regex
+++ b/contrib/libc++/include/regex
@@ -6142,7 +6142,7 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
{
__flags_ |= regex_constants::__no_update_pos;
_BidirectionalIterator __start = __match_[0].second;
- if (__match_.empty())
+ if (__match_[0].first == __match_[0].second)
{
if (__start == __end_)
{
diff --git a/contrib/libc++/include/string b/contrib/libc++/include/string
index d1a3a1f8e6cc..010a4c7816ea 100644
--- a/contrib/libc++/include/string
+++ b/contrib/libc++/include/string
@@ -676,11 +676,11 @@ private:
};
#if _LIBCPP_BIG_ENDIAN
- enum {__short_mask = 0x01};
- enum {__long_mask = 0x1ul};
+ static const size_type __short_mask = 0x01;
+ static const size_type __long_mask = 0x1ul;
#else // _LIBCPP_BIG_ENDIAN
- enum {__short_mask = 0x80};
- enum {__long_mask = ~(size_type(~0) >> 1)};
+ static const size_type __short_mask = 0x80;
+ static const size_type __long_mask = ~(size_type(~0) >> 1);
#endif // _LIBCPP_BIG_ENDIAN
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
@@ -706,11 +706,11 @@ private:
};
#if _LIBCPP_BIG_ENDIAN
- enum {__short_mask = 0x80};
- enum {__long_mask = ~(size_type(~0) >> 1)};
+ static const size_type __short_mask = 0x80;
+ static const size_type __long_mask = ~(size_type(~0) >> 1);
#else // _LIBCPP_BIG_ENDIAN
- enum {__short_mask = 0x01};
- enum {__long_mask = 0x1ul};
+ static const size_type __short_mask = 0x01;
+ static const size_type __long_mask = 0x1ul;
#endif // _LIBCPP_BIG_ENDIAN
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
diff --git a/contrib/libc++/src/experimental/filesystem/filesystem_time_helper.h b/contrib/libc++/src/experimental/filesystem/filesystem_time_helper.h
new file mode 100644
index 000000000000..a60fdef5f0d9
--- /dev/null
+++ b/contrib/libc++/src/experimental/filesystem/filesystem_time_helper.h
@@ -0,0 +1,173 @@
+//===----------------------------------------------------------------------===////
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===////
+
+#ifndef FILESYSTEM_TIME_HELPER_H
+#define FILESYSTEM_TIME_HELPER_H
+
+#include "experimental/__config"
+#include "chrono"
+#include "cstdlib"
+#include "climits"
+
+#include <unistd.h>
+#include <sys/stat.h>
+#if !defined(UTIME_OMIT)
+#include <sys/time.h> // for ::utimes as used in __last_write_time
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM
+
+namespace time_detail { namespace {
+
+using namespace chrono;
+
+template <class FileTimeT,
+ bool IsFloat = is_floating_point<typename FileTimeT::rep>::value>
+struct fs_time_util_base {
+ static constexpr auto max_seconds =
+ duration_cast<seconds>(FileTimeT::duration::max()).count();
+
+ static constexpr auto max_nsec =
+ duration_cast<nanoseconds>(FileTimeT::duration::max() -
+ seconds(max_seconds))
+ .count();
+
+ static constexpr auto min_seconds =
+ duration_cast<seconds>(FileTimeT::duration::min()).count();
+
+ static constexpr auto min_nsec_timespec =
+ duration_cast<nanoseconds>(
+ (FileTimeT::duration::min() - seconds(min_seconds)) + seconds(1))
+ .count();
+
+ // Static assert that these values properly round trip.
+ static_assert((seconds(min_seconds) +
+ duration_cast<microseconds>(nanoseconds(min_nsec_timespec))) -
+ duration_cast<microseconds>(seconds(1)) ==
+ FileTimeT::duration::min(),
+ "");
+};
+
+template <class FileTimeT>
+struct fs_time_util_base<FileTimeT, true> {
+ static const long long max_seconds;
+ static const long long max_nsec;
+ static const long long min_seconds;
+ static const long long min_nsec_timespec;
+};
+
+template <class FileTimeT>
+const long long fs_time_util_base<FileTimeT, true>::max_seconds =
+ duration_cast<seconds>(FileTimeT::duration::max()).count();
+
+template <class FileTimeT>
+const long long fs_time_util_base<FileTimeT, true>::max_nsec =
+ duration_cast<nanoseconds>(FileTimeT::duration::max() -
+ seconds(max_seconds))
+ .count();
+
+template <class FileTimeT>
+const long long fs_time_util_base<FileTimeT, true>::min_seconds =
+ duration_cast<seconds>(FileTimeT::duration::min()).count();
+
+template <class FileTimeT>
+const long long fs_time_util_base<FileTimeT, true>::min_nsec_timespec =
+ duration_cast<nanoseconds>((FileTimeT::duration::min() -
+ seconds(min_seconds)) +
+ seconds(1))
+ .count();
+
+template <class FileTimeT, class TimeT, class TimeSpecT>
+struct fs_time_util : fs_time_util_base<FileTimeT> {
+ using Base = fs_time_util_base<FileTimeT>;
+ using Base::max_nsec;
+ using Base::max_seconds;
+ using Base::min_nsec_timespec;
+ using Base::min_seconds;
+
+public:
+ template <class CType, class ChronoType>
+ static bool checked_set(CType* out, ChronoType time) {
+ using Lim = numeric_limits<CType>;
+ if (time > Lim::max() || time < Lim::min())
+ return false;
+ *out = static_cast<CType>(time);
+ return true;
+ }
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(TimeSpecT tm) {
+ if (tm.tv_sec >= 0) {
+ return (tm.tv_sec < max_seconds) ||
+ (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
+ } else if (tm.tv_sec == (min_seconds - 1)) {
+ return tm.tv_nsec >= min_nsec_timespec;
+ } else {
+ return (tm.tv_sec >= min_seconds);
+ }
+ }
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 bool is_representable(FileTimeT tm) {
+ auto secs = duration_cast<seconds>(tm.time_since_epoch());
+ auto nsecs = duration_cast<nanoseconds>(tm.time_since_epoch() - secs);
+ if (nsecs.count() < 0) {
+ secs = secs + seconds(1);
+ nsecs = nsecs + seconds(1);
+ }
+ using TLim = numeric_limits<TimeT>;
+ if (secs.count() >= 0)
+ return secs.count() <= TLim::max();
+ return secs.count() >= TLim::min();
+ }
+
+ static _LIBCPP_CONSTEXPR_AFTER_CXX11 FileTimeT
+ convert_timespec(TimeSpecT tm) {
+ auto adj_msec = duration_cast<microseconds>(nanoseconds(tm.tv_nsec));
+ if (tm.tv_sec >= 0) {
+ auto Dur = seconds(tm.tv_sec) + microseconds(adj_msec);
+ return FileTimeT(Dur);
+ } else if (duration_cast<microseconds>(nanoseconds(tm.tv_nsec)).count() ==
+ 0) {
+ return FileTimeT(seconds(tm.tv_sec));
+ } else { // tm.tv_sec < 0
+ auto adj_subsec =
+ duration_cast<microseconds>(seconds(1) - nanoseconds(tm.tv_nsec));
+ auto Dur = seconds(tm.tv_sec + 1) - adj_subsec;
+ return FileTimeT(Dur);
+ }
+ }
+
+ template <class SubSecDurT, class SubSecT>
+ static bool set_times_checked(TimeT* sec_out, SubSecT* subsec_out,
+ FileTimeT tp) {
+ using namespace chrono;
+ auto dur = tp.time_since_epoch();
+ auto sec_dur = duration_cast<seconds>(dur);
+ auto subsec_dur = duration_cast<SubSecDurT>(dur - sec_dur);
+ // The tv_nsec and tv_usec fields must not be negative so adjust accordingly
+ if (subsec_dur.count() < 0) {
+ if (sec_dur.count() > min_seconds) {
+ sec_dur -= seconds(1);
+ subsec_dur += seconds(1);
+ } else {
+ subsec_dur = SubSecDurT::zero();
+ }
+ }
+ return checked_set(sec_out, sec_dur.count()) &&
+ checked_set(subsec_out, subsec_dur.count());
+ }
+};
+
+} // end namespace
+} // end namespace time_detail
+
+using time_detail::fs_time_util;
+
+_LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM
+
+#endif // FILESYSTEM_TIME_HELPER_H
diff --git a/contrib/libc++/src/experimental/filesystem/operations.cpp b/contrib/libc++/src/experimental/filesystem/operations.cpp
index e9bc0eb6e30e..641a3c53636d 100644
--- a/contrib/libc++/src/experimental/filesystem/operations.cpp
+++ b/contrib/libc++/src/experimental/filesystem/operations.cpp
@@ -15,6 +15,8 @@
#include "cstdlib"
#include "climits"
+#include "filesystem_time_helper.h"
+
#include <unistd.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
@@ -426,17 +428,20 @@ void __current_path(const path& p, std::error_code *ec) {
bool __equivalent(const path& p1, const path& p2, std::error_code *ec)
{
+ auto make_unsupported_error = [&]() {
+ set_or_throw(make_error_code(errc::not_supported), ec,
+ "equivalent", p1, p2);
+ return false;
+ };
std::error_code ec1, ec2;
struct ::stat st1 = {};
struct ::stat st2 = {};
auto s1 = detail::posix_stat(p1.native(), st1, &ec1);
+ if (!exists(s1))
+ return make_unsupported_error();
auto s2 = detail::posix_stat(p2.native(), st2, &ec2);
-
- if ((!exists(s1) && !exists(s2)) || (is_other(s1) && is_other(s2))) {
- set_or_throw(make_error_code(errc::not_supported), ec,
- "equivalent", p1, p2);
- return false;
- }
+ if (!exists(s2))
+ return make_unsupported_error();
if (ec) ec->clear();
return (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino);
}
@@ -502,17 +507,6 @@ bool __fs_is_empty(const path& p, std::error_code *ec)
namespace detail { namespace {
-using namespace std::chrono;
-
-template <class CType, class ChronoType>
-bool checked_set(CType* out, ChronoType time) {
- using Lim = numeric_limits<CType>;
- if (time > Lim::max() || time < Lim::min())
- return false;
- *out = static_cast<CType>(time);
- return true;
-}
-
using TimeSpec = struct timespec;
using StatT = struct stat;
@@ -525,137 +519,10 @@ __attribute__((unused)) // Suppress warning
TimeSpec extract_atime(StatT const& st) { return st.st_atim; }
#endif
-constexpr auto max_seconds = duration_cast<seconds>(
- file_time_type::duration::max()).count();
-
-constexpr auto max_nsec = duration_cast<nanoseconds>(
- file_time_type::duration::max() - seconds(max_seconds)).count();
-
-constexpr auto min_seconds = duration_cast<seconds>(
- file_time_type::duration::min()).count();
-
-constexpr auto min_nsec_timespec = duration_cast<nanoseconds>(
- (file_time_type::duration::min() - seconds(min_seconds)) + seconds(1)).count();
-
-// Static assert that these values properly round trip.
-static_assert((seconds(min_seconds) + duration_cast<microseconds>(nanoseconds(min_nsec_timespec)))
- - duration_cast<microseconds>(seconds(1))
- == file_time_type::duration::min(), "");
-
-constexpr auto max_time_t = numeric_limits<time_t>::max();
-constexpr auto min_time_t = numeric_limits<time_t>::min();
-
-#if !defined(__LP64__) && defined(__clang__)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
-#endif
-
-_LIBCPP_CONSTEXPR_AFTER_CXX11
-bool is_representable(TimeSpec const& tm) {
- if (tm.tv_sec >= 0) {
- return (tm.tv_sec < max_seconds) ||
- (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
- } else if (tm.tv_sec == (min_seconds - 1)) {
- return tm.tv_nsec >= min_nsec_timespec;
- } else {
- return (tm.tv_sec >= min_seconds);
- }
-}
-#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
-#if defined(__LP64__)
-static_assert(is_representable({max_seconds, max_nsec}), "");
-static_assert(!is_representable({max_seconds + 1, 0}), "");
-static_assert(!is_representable({max_seconds, max_nsec + 1}), "");
-static_assert(!is_representable({max_time_t, 0}), "");
-static_assert(is_representable({min_seconds, 0}), "");
-static_assert(is_representable({min_seconds - 1, min_nsec_timespec}), "");
-static_assert(is_representable({min_seconds - 1, min_nsec_timespec + 1}), "");
-static_assert(!is_representable({min_seconds - 1, min_nsec_timespec - 1}), "");
-static_assert(!is_representable({min_time_t, 999999999}), "");
-#else
-static_assert(is_representable({max_time_t, 999999999}), "");
-static_assert(is_representable({max_time_t, 1000000000}), "");
-static_assert(is_representable({min_time_t, 0}), "");
-#endif
-#endif
-
-_LIBCPP_CONSTEXPR_AFTER_CXX11
-bool is_representable(file_time_type const& tm) {
- auto secs = duration_cast<seconds>(tm.time_since_epoch());
- auto nsecs = duration_cast<nanoseconds>(tm.time_since_epoch() - secs);
- if (nsecs.count() < 0) {
- secs = secs + seconds(1);
- nsecs = nsecs + seconds(1);
- }
- using TLim = numeric_limits<time_t>;
- if (secs.count() >= 0)
- return secs.count() <= TLim::max();
- return secs.count() >= TLim::min();
-}
-#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
-#if defined(__LP64__)
-static_assert(is_representable(file_time_type::max()), "");
-static_assert(is_representable(file_time_type::min()), "");
-#else
-static_assert(!is_representable(file_time_type::max()), "");
-static_assert(!is_representable(file_time_type::min()), "");
-static_assert(is_representable(file_time_type(seconds(max_time_t))), "");
-static_assert(is_representable(file_time_type(seconds(min_time_t))), "");
-#endif
-#endif
-
-_LIBCPP_CONSTEXPR_AFTER_CXX11
-file_time_type convert_timespec(TimeSpec const& tm) {
- auto adj_msec = duration_cast<microseconds>(nanoseconds(tm.tv_nsec));
- if (tm.tv_sec >= 0) {
- auto Dur = seconds(tm.tv_sec) + microseconds(adj_msec);
- return file_time_type(Dur);
- } else if (duration_cast<microseconds>(nanoseconds(tm.tv_nsec)).count() == 0) {
- return file_time_type(seconds(tm.tv_sec));
- } else { // tm.tv_sec < 0
- auto adj_subsec = duration_cast<microseconds>(seconds(1) - nanoseconds(tm.tv_nsec));
- auto Dur = seconds(tm.tv_sec + 1) - adj_subsec;
- return file_time_type(Dur);
- }
-}
-#ifndef _LIBCPP_HAS_NO_CXX14_CONSTEXPR
-#if defined(__LP64__)
-static_assert(convert_timespec({max_seconds, max_nsec}) == file_time_type::max(), "");
-static_assert(convert_timespec({max_seconds, max_nsec - 1}) < file_time_type::max(), "");
-static_assert(convert_timespec({max_seconds - 1, 999999999}) < file_time_type::max(), "");
-static_assert(convert_timespec({min_seconds - 1, min_nsec_timespec}) == file_time_type::min(), "");
-static_assert(convert_timespec({min_seconds - 1, min_nsec_timespec + 1}) > file_time_type::min(), "");
-static_assert(convert_timespec({min_seconds , 0}) > file_time_type::min(), "");
-#else
-// FIXME add tests for 32 bit builds
-#endif
-#endif
-
-#if !defined(__LP64__) && defined(__clang__)
-#pragma clang diagnostic pop
-#endif
-
-template <class SubSecDurT, class SubSecT>
-bool set_times_checked(time_t* sec_out, SubSecT* subsec_out, file_time_type tp) {
- using namespace chrono;
- auto dur = tp.time_since_epoch();
- auto sec_dur = duration_cast<seconds>(dur);
- auto subsec_dur = duration_cast<SubSecDurT>(dur - sec_dur);
- // The tv_nsec and tv_usec fields must not be negative so adjust accordingly
- if (subsec_dur.count() < 0) {
- if (sec_dur.count() > min_seconds) {
- sec_dur -= seconds(1);
- subsec_dur += seconds(1);
- } else {
- subsec_dur = SubSecDurT::zero();
- }
- }
- return checked_set(sec_out, sec_dur.count())
- && checked_set(subsec_out, subsec_dur.count());
-}
-
}} // end namespace detail
+using FSTime = fs_time_util<file_time_type, time_t, struct timespec>;
+
file_time_type __last_write_time(const path& p, std::error_code *ec)
{
using namespace ::std::chrono;
@@ -668,12 +535,12 @@ file_time_type __last_write_time(const path& p, std::error_code *ec)
}
if (ec) ec->clear();
auto ts = detail::extract_mtime(st);
- if (!detail::is_representable(ts)) {
+ if (!FSTime::is_representable(ts)) {
set_or_throw(error_code(EOVERFLOW, generic_category()), ec,
"last_write_time", p);
return file_time_type::min();
}
- return detail::convert_timespec(ts);
+ return FSTime::convert_timespec(ts);
}
void __last_write_time(const path& p, file_time_type new_time,
@@ -698,7 +565,7 @@ void __last_write_time(const path& p, file_time_type new_time,
struct ::timeval tbuf[2];
tbuf[0].tv_sec = atime.tv_sec;
tbuf[0].tv_usec = duration_cast<microseconds>(nanoseconds(atime.tv_nsec)).count();
- const bool overflowed = !detail::set_times_checked<microseconds>(
+ const bool overflowed = !FSTime::set_times_checked<microseconds>(
&tbuf[1].tv_sec, &tbuf[1].tv_usec, new_time);
if (overflowed) {
@@ -714,7 +581,7 @@ void __last_write_time(const path& p, file_time_type new_time,
tbuf[0].tv_sec = 0;
tbuf[0].tv_nsec = UTIME_OMIT;
- const bool overflowed = !detail::set_times_checked<nanoseconds>(
+ const bool overflowed = !FSTime::set_times_checked<nanoseconds>(
&tbuf[1].tv_sec, &tbuf[1].tv_nsec, new_time);
if (overflowed) {
set_or_throw(make_error_code(errc::invalid_argument),
diff --git a/contrib/libc++/include/__refstring b/contrib/libc++/src/include/refstring.h
index 7f417a03c491..f0d5b4456da5 100644
--- a/contrib/libc++/include/__refstring
+++ b/contrib/libc++/src/include/refstring.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP___REFSTRING
-#define _LIBCPP___REFSTRING
+#ifndef _LIBCPP_REFSTRING_H
+#define _LIBCPP_REFSTRING_H
#include <__config>
#include <stdexcept>
@@ -124,4 +124,4 @@ bool __libcpp_refstring::__uses_refcount() const {
_LIBCPP_END_NAMESPACE_STD
-#endif //_LIBCPP___REFSTRING
+#endif //_LIBCPP_REFSTRING_H
diff --git a/contrib/libc++/src/stdexcept.cpp b/contrib/libc++/src/stdexcept.cpp
index 3f333309dd8f..5e06e521e404 100644
--- a/contrib/libc++/src/stdexcept.cpp
+++ b/contrib/libc++/src/stdexcept.cpp
@@ -11,7 +11,7 @@
#include "new"
#include "string"
#include "system_error"
-#include "__refstring"
+#include "include/refstring.h"
/* For _LIBCPPABI_VERSION */
#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \