File tree Expand file tree Collapse file tree 1 file changed +5
-23
lines changed Expand file tree Collapse file tree 1 file changed +5
-23
lines changed Original file line number Diff line number Diff line change 5
5
#ifndef BITCOIN_CRYPTO_COMMON_H
6
6
#define BITCOIN_CRYPTO_COMMON_H
7
7
8
- #if defined(HAVE_CONFIG_H )
9
- #include <config/bitcoin-config.h>
10
- #endif
11
-
12
- #include <stdint.h>
13
- #include <string.h>
14
-
15
8
#include < compat/endian.h>
16
9
10
+ #include < bit>
11
+ #include < cstdint>
12
+ #include < cstring>
13
+
17
14
uint16_t static inline ReadLE16 (const unsigned char * ptr)
18
15
{
19
16
uint16_t x;
@@ -89,22 +86,7 @@ void static inline WriteBE64(unsigned char* ptr, uint64_t x)
89
86
/* * Return the smallest number n such that (x >> n) == 0 (or 64 if the highest bit in x is set. */
90
87
uint64_t static inline CountBits (uint64_t x)
91
88
{
92
- #if HAVE_BUILTIN_CLZL
93
- if (sizeof (unsigned long ) >= sizeof (uint64_t )) {
94
- return x ? 8 * sizeof (unsigned long ) - __builtin_clzl (x ) : 0 ;
95
- }
96
- #endif
97
- #if HAVE_BUILTIN_CLZLL
98
- if (sizeof (unsigned long long ) >= sizeof (uint64_t )) {
99
- return x ? 8 * sizeof (unsigned long long ) - __builtin_clzll (x ) : 0 ;
100
- }
101
- #endif
102
- int ret = 0 ;
103
- while (x ) {
104
- x >>= 1 ;
105
- ++ ret ;
106
- }
107
- return ret ;
89
+ return std::bit_width (x);
108
90
}
109
91
110
92
#endif // BITCOIN_CRYPTO_COMMON_H
You can’t perform that action at this time.
0 commit comments