Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static inline int clz32(unsigned int a)
#ifdef _MSC_VER
unsigned long idx;
_BitScanReverse(&idx, a);
return 31 ^ idx;
return 31 - idx;
#else
return __builtin_clz(a);
#endif
Expand All @@ -160,7 +160,7 @@ static inline int clz64(uint64_t a)
#ifdef _MSC_VER
unsigned long idx;
_BitScanReverse64(&idx, a);
return 63 ^ idx;
return 63 - idx;
#else
return __builtin_clzll(a);
#endif
Expand All @@ -172,7 +172,7 @@ static inline int ctz32(unsigned int a)
#ifdef _MSC_VER
unsigned long idx;
_BitScanForward(&idx, a);
return 31 ^ idx;
return (int)idx;
#else
return __builtin_ctz(a);
#endif
Expand All @@ -184,7 +184,7 @@ static inline int ctz64(uint64_t a)
#ifdef _MSC_VER
unsigned long idx;
_BitScanForward64(&idx, a);
return 63 ^ idx;
return (int)idx;
#else
return __builtin_ctzll(a);
#endif
Expand Down