Added bsr() function to util

This commit is contained in:
SChernykh
2022-05-09 11:25:52 +02:00
parent 820c5db5e8
commit d23c46ff84
6 changed files with 98 additions and 10 deletions
+16
View File
@@ -203,6 +203,22 @@ FORCEINLINE uint64_t seconds_since_epoch()
return duration_cast<seconds>(steady_clock::now().time_since_epoch()).count();
}
uint64_t bsr_reference(uint64_t x);
#ifdef HAVE_BUILTIN_CLZLL
#define bsr(x) (63 - __builtin_clzll(x))
#elif defined HAVE_BITSCANREVERSE64
#pragma intrinsic(_BitScanReverse64)
FORCEINLINE uint64_t bsr(uint64_t x)
{
unsigned long index;
_BitScanReverse64(&index, x);
return index;
}
#else
#define bsr bsr_reference
#endif
} // namespace p2pool
namespace robin_hood {