@@ -45,12 +45,12 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uin
45
45
// /
46
46
// / The algorithm is based on
47
47
// / http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
48
- // / Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that
49
- // / function requires its input to have at least one bit set the value of
50
- // / zero is set to one. This means the first element of the lookup table is
51
- // / zero.
48
+ // / Instead of using IntegerLogBase2 it uses __countl_zero. Previously, it
49
+ // / used __libcpp_clz. Since that function requires its input to have at
50
+ // / least one bit set the value of zero is set to one. This means the first
51
+ // / element of the lookup table is zero.
52
52
static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width (_Tp __v) {
53
- auto __t = (32 - std::__libcpp_clz (static_cast <type>(__v | 1 ))) * 1233 >> 12 ;
53
+ auto __t = (32 - std::__countl_zero (static_cast <type>(__v | 1 ))) * 1233 >> 12 ;
54
54
return __t - (__v < __itoa::__pow10_32[__t ]) + 1 ;
55
55
}
56
56
@@ -71,12 +71,12 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uin
71
71
// /
72
72
// / The algorithm is based on
73
73
// / http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
74
- // / Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that
75
- // / function requires its input to have at least one bit set the value of
76
- // / zero is set to one. This means the first element of the lookup table is
77
- // / zero.
74
+ // / Instead of using IntegerLogBase2 it uses __countl_zero. Previously, it
75
+ // / used __libcpp_clz. Since that function requires its input to have at
76
+ // / least one bit set the value of zero is set to one. This means the first
77
+ // / element of the lookup table is zero.
78
78
static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width (_Tp __v) {
79
- auto __t = (64 - std::__libcpp_clz (static_cast <type>(__v | 1 ))) * 1233 >> 12 ;
79
+ auto __t = (64 - std::__countl_zero (static_cast <type>(__v | 1 ))) * 1233 >> 12 ;
80
80
return __t - (__v < __itoa::__pow10_64[__t ]) + 1 ;
81
81
}
82
82
@@ -98,15 +98,15 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__u
98
98
// /
99
99
// / The algorithm is based on
100
100
// / http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
101
- // / Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that
102
- // / function requires its input to have at least one bit set the value of
103
- // / zero is set to one. This means the first element of the lookup table is
104
- // / zero.
101
+ // / Instead of using IntegerLogBase2 it uses __countl_zero. Previously, it
102
+ // / used __libcpp_clz. Since that function requires its input to have at
103
+ // / least one bit set the value of zero is set to one. This means the first
104
+ // / element of the lookup table is zero.
105
105
static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width (_Tp __v) {
106
106
_LIBCPP_ASSERT_INTERNAL (
107
107
__v > numeric_limits<uint64_t >::max (), " The optimizations for this algorithm fail when this isn't true." );
108
108
// There's always a bit set in the upper 64-bits.
109
- auto __t = (128 - std::__libcpp_clz (static_cast <uint64_t >(__v >> 64 ))) * 1233 >> 12 ;
109
+ auto __t = (128 - std::__countl_zero (static_cast <uint64_t >(__v >> 64 ))) * 1233 >> 12 ;
110
110
_LIBCPP_ASSERT_INTERNAL (__t >= __itoa::__pow10_128_offset, " Index out of bounds" );
111
111
// __t is adjusted since the lookup table misses the lower entries.
112
112
return __t - (__v < __itoa::__pow10_128[__t - __itoa::__pow10_128_offset]) + 1 ;
0 commit comments