]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix the clz32 and clz64 settings on MSVC.
authorNick Mathewson <nickm@torproject.org>
Wed, 20 Dec 2017 14:34:25 +0000 (09:34 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 20 Dec 2017 14:37:18 +0000 (09:37 -0500)
Fixes bug 24633; bugfix on 0.2.9.1-alpha.

changes/bug24633 [new file with mode: 0644]
src/ext/timeouts/timeout-bitops.c

diff --git a/changes/bug24633 b/changes/bug24633
new file mode 100644 (file)
index 0000000..028c7cc
--- /dev/null
@@ -0,0 +1,5 @@
+  o Minor bugfixes (portability, msvc):
+    - Fix a bug in the bit-counting parts of our timing-wheel code on
+      MSVC. (Note that MSVC is still not a supported build platform,
+      due to cyptographic timing channel risks.) Fixes bug 24633;
+      bugfix on 0.2.9.1-alpha.
index a018f33b9585002cae7fa17b6a0577d5e1f6cc1f..45466f6cb313ca795b4d4da4e05041bde832b6d7 100644 (file)
@@ -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)