Commit b299dcd7 authored by Kenton Varda's avatar Kenton Varda

Implement lg() for MSVC.

parent 209b82d9
......@@ -28,7 +28,16 @@ namespace _ {
static inline uint lg(uint value) {
// Compute floor(log2(value)).
//
// Undefined for value = 0.
#if _MSC_VER
unsigned long i;
auto found = _BitScanReverse(&i, value);
KJ_DASSERT(found); // !found means value = 0
return i;
#else
return sizeof(uint) * 8 - 1 - __builtin_clz(value);
#endif
}
void throwDuplicateTableRow() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment