diff --git a/libcxx/include/charconv b/libcxx/include/charconv --- a/libcxx/include/charconv +++ b/libcxx/include/charconv @@ -74,6 +74,7 @@ */ #include <__availability> +#include <__bits> #include <__config> #include <__errc> #include <__utility/to_underlying.h> @@ -204,13 +205,11 @@ { using type = uint64_t; -#if !defined(_LIBCPP_COMPILER_MSVC) static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v) { - auto __t = (64 - __builtin_clzll(__v | 1)) * 1233 >> 12; + auto __t = (64 - _VSTD::__libcpp_clz(static_cast(__v | 1))) * 1233 >> 12; return __t - (__v < __pow10_64[__t]) + 1; } -#endif _LIBCPP_AVAILABILITY_TO_CHARS static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) @@ -227,13 +226,11 @@ { using type = uint32_t; -#if !defined(_LIBCPP_COMPILER_MSVC) static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v) { - auto __t = (32 - __builtin_clz(__v | 1)) * 1233 >> 12; + auto __t = (32 - _VSTD::__libcpp_clz(static_cast(__v | 1))) * 1233 >> 12; return __t - (__v < __pow10_32[__t]) + 1; } -#endif _LIBCPP_AVAILABILITY_TO_CHARS static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) @@ -354,28 +351,10 @@ using __tx = __itoa::__traits<_Tp>; auto __diff = __last - __first; -#if !defined(_LIBCPP_COMPILER_MSVC) if (__tx::digits <= __diff || __tx::__width(__value) <= __diff) return {__tx::__convert(__value, __first), errc(0)}; else return {__last, errc::value_too_large}; -#else - if (__tx::digits <= __diff) - return {__tx::__convert(__value, __first), {}}; - else - { - char __buf[__tx::digits]; - auto __p = __tx::__convert(__value, __buf); - auto __len = __p - __buf; - if (__len <= __diff) - { - _VSTD::memcpy(__first, __buf, __len); - return {__first + __len, {}}; - } - else - return {__last, errc::value_too_large}; - } -#endif } template