From 9374338f9c2f126c6608625f750d5ea1f7ef6a06 Mon Sep 17 00:00:00 2001 From: Shyamsundar Ranganathan Date: Mon, 1 May 2017 17:22:34 +0000 Subject: 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 Reviewed-by: Kaleb KEITHLEY Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- contrib/timer-wheel/find_last_bit.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'contrib/timer-wheel') 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); } } -- cgit