diff options
| -rw-r--r-- | contrib/timer-wheel/find_last_bit.c | 17 | 
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);  		}  	}  | 
