elang/base/bits.h
inline int CountLeadingZeros64(uint64_t value) {
#if ELANG_HAS_BUILT_IN_LZCNT && COMPILER_MSVC
  return static_cast<int>(__lzcnt64(value));
#elif COMPILER_MSVC
  unsigned long result;  // NOLINT(runtime/int)
  if (!_BitScanReverse64(&result, value))
    return 64;
  return static_cast<int>(63 - result);
#else
  value = value | (value >> 1);
  value = value | (value >> 2);
  value = value | (value >> 4);
  value = value | (value >> 8);
  value = value | (value >> 16);
  value = value | (value >> 32);
  return CountPopulation64(~value);
#endif
}
// Returns the number of bits set in |value|.
Returns the number of bits set in |value|.
Returns the number of bits set in |value| .
inline int CountLeadingZeros64(uint64_t value) {
#if ELANG_HAS_BUILT_IN_LZCNT && COMPILER_MSVC
  return static_cast<int>(__lzcnt64(value));
#elif COMPILER_MSVC
  unsigned long result;  
  if (!_BitScanReverse64(&result, value))
    return 64;
  return static_cast<int>(63 - result);
#else
  value = value | (value >> 1);
  value = value | (value >> 2);
  value = value | (value >> 4);
  value = value | (value >> 8);
  value = value | (value >> 16);
  value = value | (value >> 32);
  return CountPopulation64(~value);
#endif
}
inline int CountLeadingZeros64 ( uint64_t value ) { #if ELANG_HAS_BUILT_IN_LZCNT && COMPILER_MSVC return static_cast < int > ( __lzcnt64 ( value ) ) ; #elif COMPILER_MSVC unsigned long result ; if ( ! _BitScanReverse64 ( & result , value ) ) return 64 ; return static_cast < int > ( 63 - result ) ; #else value = value | ( value >> 1 ) ; value = value | ( value >> 2 ) ; value = value | ( value >> 4 ) ; value = value | ( value >> 8 ) ; value = value | ( value >> 16 ) ; value = value | ( value >> 32 ) ; return CountPopulation64 ( ~ value ) ; #endif }
Returns the number of bits set in |value|.
Returns the number of bits set in |value| .
// NOLINT(runtime/int)