summaryrefslogtreecommitdiff
path: root/src/ext
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-12-20 09:34:25 -0500
committerNick Mathewson <nickm@torproject.org>2017-12-20 09:37:18 -0500
commitaccd0ea65bb817ad8f2361c5ca06c40ac9a9a11f (patch)
treee8f11a2682cc219fcda06a792aa883e9620a616c /src/ext
parenteecfed0cd2c8c92175106e211d1662fa43fc60bc (diff)
downloadtor-accd0ea65bb817ad8f2361c5ca06c40ac9a9a11f.tar.gz
tor-accd0ea65bb817ad8f2361c5ca06c40ac9a9a11f.zip
Fix the clz32 and clz64 settings on MSVC.
Fixes bug 24633; bugfix on 0.2.9.1-alpha.
Diffstat (limited to 'src/ext')
-rw-r--r--src/ext/timeouts/timeout-bitops.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/ext/timeouts/timeout-bitops.c b/src/ext/timeouts/timeout-bitops.c
index a018f33b95..45466f6cb3 100644
--- a/src/ext/timeouts/timeout-bitops.c
+++ b/src/ext/timeouts/timeout-bitops.c
@@ -40,7 +40,7 @@ static __inline int clz32(unsigned long val)
{
DWORD zeros = 0;
_BitScanReverse(&zeros, val);
- return zeros;
+ return 31 - zeros;
}
#ifdef _WIN64
/* According to the documentation, these only exist on Win64. */
@@ -54,7 +54,7 @@ static __inline int clz64(uint64_t val)
{
DWORD zeros = 0;
_BitScanReverse64(&zeros, val);
- return zeros;
+ return 63 - zeros;
}
#else
static __inline int ctz64(uint64_t val)