Skip to content

Commit e9f1d8c

Browse files
committed
Squashed 'src/minisketch/' changes from 47f0a2d26f..a571ba20f9
a571ba20f9 Merge bitcoin-core/minisketch#68: Add missed `#include <string>` b9a7f7e2bc Merge bitcoin-core/minisketch#69: refactor: Drop unused `total` local variables 8a5af94edc Merge bitcoin-core/minisketch#70: build: Remove `-Qunused-arguments` workaround for clang + ccache c36f1f03a3 Merge bitcoin-core/minisketch#72: Fix MSVC implementation of `CountBits()` function 0078bedda6 Ignore `HAVE_CLZ` macro when building with MSVC 1c772918c4 Fix MSVC implementation of `CountBits()` function 98f87c55f4 build: Remove `-Qunused-arguments` workaround for clang + ccache 11a1e25c81 refactor: Drop unused `total` local variables ed6c8fcfd9 Add missed `#include <string>` git-subtree-dir: src/minisketch git-subtree-split: a571ba20f9dd1accab6a2309d066369878042ca6
1 parent 28a28a0 commit e9f1d8c

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

configure.ac

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ if test "x$use_ccache" != "xno"; then
124124
fi
125125
AC_MSG_RESULT($use_ccache)
126126
fi
127-
if test "x$use_ccache" = "xyes"; then
128-
AX_CHECK_COMPILE_FLAG([-Qunused-arguments],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Qunused-arguments"],,[[$CXXFLAG_WERROR]])
129-
fi
130127

131128
VERIFY_DEFINES=-DMINISKETCH_VERIFY
132129
RELEASE_DEFINES=

src/bench.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ int main(int argc, char** argv) {
6262
if (!states[0]) {
6363
printf(" -\t");
6464
} else {
65-
double total = 0.0;
6665
for (auto& state : states) {
6766
auto start = std::chrono::steady_clock::now();
6867
minisketch_decode(state, 2 * syndromes, roots.data());
6968
auto stop = std::chrono::steady_clock::now();
7069
std::chrono::duration<double> dur(stop - start);
71-
total += dur.count();
7270
benches.push_back(dur.count());
7371
}
7472
std::sort(benches.begin(), benches.end());
@@ -98,15 +96,13 @@ int main(int argc, char** argv) {
9896
if (!states[0]) {
9997
printf(" -\t");
10098
} else {
101-
double total = 0.0;
10299
for (auto& state : states) {
103100
auto start = std::chrono::steady_clock::now();
104101
for (auto val : data) {
105102
minisketch_add_uint64(state, val);
106103
}
107104
auto stop = std::chrono::steady_clock::now();
108105
std::chrono::duration<double> dur(stop - start);
109-
total += dur.count();
110106
benches.push_back(dur.count());
111107
}
112108
std::sort(benches.begin(), benches.end());

src/int_utils.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,7 @@ constexpr inline I Mask() { return ((I((I(-1)) << (std::numeric_limits<I>::digit
129129
/** Compute the smallest power of two that is larger than val. */
130130
template<typename I>
131131
static inline int CountBits(I val, int max) {
132-
#ifdef HAVE_CLZ
133-
(void)max;
134-
if (val == 0) return 0;
135-
if (std::numeric_limits<unsigned>::digits >= std::numeric_limits<I>::digits) {
136-
return std::numeric_limits<unsigned>::digits - __builtin_clz(val);
137-
} else if (std::numeric_limits<unsigned long>::digits >= std::numeric_limits<I>::digits) {
138-
return std::numeric_limits<unsigned long>::digits - __builtin_clzl(val);
139-
} else {
140-
return std::numeric_limits<unsigned long long>::digits - __builtin_clzll(val);
141-
}
142-
#elif _MSC_VER
132+
#ifdef _MSC_VER
143133
(void)max;
144134
unsigned long index;
145135
unsigned char ret;
@@ -149,7 +139,17 @@ static inline int CountBits(I val, int max) {
149139
ret = _BitScanReverse64(&index, val);
150140
}
151141
if (!ret) return 0;
152-
return index;
142+
return index + 1;
143+
#elif HAVE_CLZ
144+
(void)max;
145+
if (val == 0) return 0;
146+
if (std::numeric_limits<unsigned>::digits >= std::numeric_limits<I>::digits) {
147+
return std::numeric_limits<unsigned>::digits - __builtin_clz(val);
148+
} else if (std::numeric_limits<unsigned long>::digits >= std::numeric_limits<I>::digits) {
149+
return std::numeric_limits<unsigned long>::digits - __builtin_clzl(val);
150+
} else {
151+
return std::numeric_limits<unsigned long long>::digits - __builtin_clzll(val);
152+
}
153153
#else
154154
while (max && (val >> (max - 1) == 0)) --max;
155155
return max;

src/test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <limits>
1010
#include <random>
1111
#include <stdexcept>
12+
#include <string>
1213
#include <vector>
1314

1415
#include "../include/minisketch.h"

0 commit comments

Comments
 (0)