asmap bucketing ported from Komodo
This commit is contained in:
@@ -87,6 +87,27 @@ void static inline WriteBE64(unsigned char* ptr, uint64_t x)
|
||||
memcpy(ptr, (char*)&v, 8);
|
||||
}
|
||||
|
||||
/** Return the smallest number n such that (x >> n) == 0 (or 64 if the highest bit in x is set. */
|
||||
uint64_t static inline CountBits(uint64_t x)
|
||||
{
|
||||
#if HAVE_DECL___BUILTIN_CLZL
|
||||
if (sizeof(unsigned long) >= sizeof(uint64_t)) {
|
||||
return x ? 8 * sizeof(unsigned long) - __builtin_clzl(x) : 0;
|
||||
}
|
||||
#endif
|
||||
#if HAVE_DECL___BUILTIN_CLZLL
|
||||
if (sizeof(unsigned long long) >= sizeof(uint64_t)) {
|
||||
return x ? 8 * sizeof(unsigned long long) - __builtin_clzll(x) : 0;
|
||||
}
|
||||
#endif
|
||||
int ret = 0;
|
||||
while (x) {
|
||||
x >>= 1;
|
||||
++ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int inline init_and_check_sodium()
|
||||
{
|
||||
if (sodium_init() == -1) {
|
||||
@@ -124,5 +145,4 @@ int inline init_and_check_sodium()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // BITCOIN_CRYPTO_COMMON_H
|
||||
|
||||
Reference in New Issue
Block a user