aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxxmsvc/.yandex_meta/patches/21-bits.patch
blob: c6e8f0f03b6b5eba674b9dd9df808cefaff5c1fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
diff --git a/include/__bit_reference b/include/__bit_reference
index 423acee..60e7786 100644
--- a/include/__bit_reference
+++ b/include/__bit_reference
@@ -28,7 +28,7 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> class __bit_iterator;
+template <class _Cp, bool _IsConst, class = typename _Cp::__storage_type> class __bit_iterator;
 template <class _Cp> class __bit_const_reference;
 
 template <class _Tp>
@@ -1102,7 +1102,7 @@ equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __b
 }
 
 template <class _Cp, bool _IsConst,
-          typename _Cp::__storage_type>
+          class>
 class __bit_iterator
 {
 public:
diff --git a/include/__bits b/include/__bits
index 1eee8f5..f6835aa 100644
--- a/include/__bits
+++ b/include/__bits
@@ -69,7 +69,7 @@ int __libcpp_ctz(unsigned __x) {
 inline _LIBCPP_INLINE_VISIBILITY
 int __libcpp_ctz(unsigned long __x) {
     static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
-    return __ctz(static_cast<unsigned>(__x));
+    return __libcpp_ctz(static_cast<unsigned>(__x));
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
@@ -133,7 +133,11 @@ inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long __x) {
 
 inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long long __x) {
   static_assert(sizeof(unsigned long long) == 8, "");
+#if defined(_M_IX86)
+  return __popcnt(__x) + __popcnt(__x >> 32);
+#else
   return __popcnt64(__x);
+#endif
 }
 
 #endif // _LIBCPP_COMPILER_MSVC