summaryrefslogtreecommitdiffstats
path: root/contrib/timer-wheel
diff options
context:
space:
mode:
authorShyamsundar Ranganathan <srangana@redhat.com>2017-05-01 17:22:34 +0000
committerKaleb KEITHLEY <kkeithle@redhat.com>2017-05-01 21:43:38 +0000
commit9374338f9c2f126c6608625f750d5ea1f7ef6a06 (patch)
treeb9db965e337fde22a7668cb11ffb0351619a924f /contrib/timer-wheel
parentc92b8347aea8ce78ca3fbc49b88f5adadc98509b (diff)
Revert "contrib/timerwheel: probable bug on 32-bit, use __builtin_ffs()"
This reverts commit c92b8347aea8ce78ca3fbc49b88f5adadc98509b. Commit is not ready for a merge! Change-Id: I3b3b52f7bfb4781dd42160e2b1059b4cdeb17956 Reviewed-on: https://review.gluster.org/17147 Tested-by: Shyamsundar Ranganathan <srangana@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'contrib/timer-wheel')
-rw-r--r--contrib/timer-wheel/find_last_bit.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/contrib/timer-wheel/find_last_bit.c b/contrib/timer-wheel/find_last_bit.c
index 0479c52f904..054e90a076f 100644
--- a/contrib/timer-wheel/find_last_bit.c
+++ b/contrib/timer-wheel/find_last_bit.c
@@ -15,22 +15,15 @@
*/
/**
- * @find_first_bit
- * optimized implementation of find first bit in
+ * @find_last_bit
+ * optimized implementation of find last bit in
*/
#ifndef BITS_PER_LONG
-#ifdef __LP64__
#define BITS_PER_LONG 64
-#else
-#define BITS_PER_LONG 32
-#endif
#endif
-#if defined(__GNUC__) || defined(__clang__)
-#define ffs(p) __builtin_ffs(p)
-#else
-static inline int ffs(int x)
+static inline int fls(int x)
{
int r = 32;
@@ -58,7 +51,7 @@ static inline int ffs(int x)
}
return r;
}
-#endif
+
unsigned long gf_tw_find_last_bit(const unsigned long *addr, unsigned long size)
{
@@ -80,7 +73,7 @@ unsigned long gf_tw_find_last_bit(const unsigned long *addr, unsigned long size)
tmp = addr[--words];
if (tmp) {
found:
- return words * BITS_PER_LONG + ffs(tmp);
+ return words * BITS_PER_LONG + fls(tmp);
}
}