Commit 3821af2f authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

[FLS64]: generic version

Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c865e5d9
...@@ -321,6 +321,7 @@ static inline int fls(int word) ...@@ -321,6 +321,7 @@ static inline int fls(int word)
#else #else
#define fls generic_fls #define fls generic_fls
#endif #endif
#define fls64 generic_fls64
/* Compute powers of two for the given integer. */ /* Compute powers of two for the given integer. */
static inline long floor_log2(unsigned long word) static inline long floor_log2(unsigned long word)
......
...@@ -332,6 +332,7 @@ static inline unsigned long __ffs(unsigned long word) ...@@ -332,6 +332,7 @@ static inline unsigned long __ffs(unsigned long word)
*/ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
/* /*
* ffs: find first bit set. This is defined the same way as * ffs: find first bit set. This is defined the same way as
...@@ -351,6 +352,7 @@ static inline unsigned long __ffs(unsigned long word) ...@@ -351,6 +352,7 @@ static inline unsigned long __ffs(unsigned long word)
#define fls(x) \ #define fls(x) \
( __builtin_constant_p(x) ? generic_fls(x) : \ ( __builtin_constant_p(x) ? generic_fls(x) : \
({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) ) ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) )
#define fls64(x) generic_fls64(x)
#define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); }) #define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); })
#define __ffs(x) (ffs(x) - 1) #define __ffs(x) (ffs(x) - 1)
#define ffz(x) __ffs( ~(x) ) #define ffz(x) __ffs( ~(x) )
......
...@@ -259,6 +259,7 @@ static inline unsigned long __ffs(unsigned long word) ...@@ -259,6 +259,7 @@ static inline unsigned long __ffs(unsigned long word)
*/ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
/* /*
* ffs: find first bit set. This is defined the same way as * ffs: find first bit set. This is defined the same way as
......
...@@ -240,6 +240,7 @@ static inline int test_bit(int nr, const volatile unsigned long *addr) ...@@ -240,6 +240,7 @@ static inline int test_bit(int nr, const volatile unsigned long *addr)
*/ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
/* /*
* hweightN - returns the hamming weight of a N-bit word * hweightN - returns the hamming weight of a N-bit word
......
...@@ -228,6 +228,7 @@ found_middle: ...@@ -228,6 +228,7 @@ found_middle:
\ \
bit ? 33 - bit : bit; \ bit ? 33 - bit : bit; \
}) })
#define fls64(x) generic_fls64(x)
/* /*
* Every architecture must define this function. It's the fastest * Every architecture must define this function. It's the fastest
......
...@@ -56,6 +56,7 @@ extern __inline__ int test_bit(int nr, const unsigned long * addr) ...@@ -56,6 +56,7 @@ extern __inline__ int test_bit(int nr, const unsigned long * addr)
*/ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
#ifdef __KERNEL__ #ifdef __KERNEL__
......
...@@ -406,5 +406,6 @@ found_middle: ...@@ -406,5 +406,6 @@ found_middle:
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
#endif /* _H8300_BITOPS_H */ #endif /* _H8300_BITOPS_H */
...@@ -372,6 +372,7 @@ static inline unsigned long ffz(unsigned long word) ...@@ -372,6 +372,7 @@ static inline unsigned long ffz(unsigned long word)
*/ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
#ifdef __KERNEL__ #ifdef __KERNEL__
......
...@@ -345,6 +345,7 @@ fls (int t) ...@@ -345,6 +345,7 @@ fls (int t)
x |= x >> 16; x |= x >> 16;
return ia64_popcnt(x); return ia64_popcnt(x);
} }
#define fls64(x) generic_fls64(x)
/* /*
* ffs: find first bit set. This is defined the same way as the libc and compiler builtin * ffs: find first bit set. This is defined the same way as the libc and compiler builtin
......
...@@ -465,6 +465,7 @@ static __inline__ unsigned long __ffs(unsigned long word) ...@@ -465,6 +465,7 @@ static __inline__ unsigned long __ffs(unsigned long word)
* fls: find last bit set. * fls: find last bit set.
*/ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
#ifdef __KERNEL__ #ifdef __KERNEL__
......
...@@ -310,6 +310,7 @@ static inline int fls(int x) ...@@ -310,6 +310,7 @@ static inline int fls(int x)
return 32 - cnt; return 32 - cnt;
} }
#define fls64(x) generic_fls64(x)
/* /*
* Every architecture must define this function. It's the fastest * Every architecture must define this function. It's the fastest
......
...@@ -499,5 +499,6 @@ found_middle: ...@@ -499,5 +499,6 @@ found_middle:
* fls: find last bit set. * fls: find last bit set.
*/ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
#endif /* _M68KNOMMU_BITOPS_H */ #endif /* _M68KNOMMU_BITOPS_H */
...@@ -695,7 +695,7 @@ static inline unsigned long fls(unsigned long word) ...@@ -695,7 +695,7 @@ static inline unsigned long fls(unsigned long word)
return flz(~word) + 1; return flz(~word) + 1;
} }
#define fls64(x) generic_fls64(x)
/* /*
* find_next_zero_bit - find the first zero bit in a memory region * find_next_zero_bit - find the first zero bit in a memory region
......
...@@ -263,6 +263,7 @@ static __inline__ int fls(int x) ...@@ -263,6 +263,7 @@ static __inline__ int fls(int x)
return ret; return ret;
} }
#define fls64(x) generic_fls64(x)
/* /*
* hweightN: returns the hamming weight (i.e. the number * hweightN: returns the hamming weight (i.e. the number
......
...@@ -310,6 +310,7 @@ static __inline__ int fls(unsigned int x) ...@@ -310,6 +310,7 @@ static __inline__ int fls(unsigned int x)
asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x)); asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x));
return 32 - lz; return 32 - lz;
} }
#define fls64(x) generic_fls64(x)
/* /*
* hweightN: returns the hamming weight (i.e. the number * hweightN: returns the hamming weight (i.e. the number
......
...@@ -839,6 +839,7 @@ static inline int sched_find_first_bit(unsigned long *b) ...@@ -839,6 +839,7 @@ static inline int sched_find_first_bit(unsigned long *b)
* fls: find last bit set. * fls: find last bit set.
*/ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
/* /*
* hweightN: returns the hamming weight (i.e. the number * hweightN: returns the hamming weight (i.e. the number
......
...@@ -470,6 +470,7 @@ found_middle: ...@@ -470,6 +470,7 @@ found_middle:
*/ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -510,6 +510,7 @@ found_middle: ...@@ -510,6 +510,7 @@ found_middle:
#define ffs(x) generic_ffs(x) #define ffs(x) generic_ffs(x)
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -298,6 +298,7 @@ static inline int ffs(int x) ...@@ -298,6 +298,7 @@ static inline int ffs(int x)
* Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
*/ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
/* /*
* hweightN: returns the hamming weight (i.e. the number * hweightN: returns the hamming weight (i.e. the number
......
...@@ -119,6 +119,7 @@ static inline unsigned long __ffs(unsigned long word) ...@@ -119,6 +119,7 @@ static inline unsigned long __ffs(unsigned long word)
*/ */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
#ifdef __KERNEL__ #ifdef __KERNEL__
......
...@@ -276,6 +276,7 @@ found_middle: ...@@ -276,6 +276,7 @@ found_middle:
#define ffs(x) generic_ffs (x) #define ffs(x) generic_ffs (x)
#define fls(x) generic_fls (x) #define fls(x) generic_fls (x)
#define fls64(x) generic_fls64(x)
#define __ffs(x) ffs(x) #define __ffs(x) ffs(x)
......
...@@ -409,6 +409,7 @@ static __inline__ int ffs(int x) ...@@ -409,6 +409,7 @@ static __inline__ int ffs(int x)
/* find last set bit */ /* find last set bit */
#define fls(x) generic_fls(x) #define fls(x) generic_fls(x)
#define fls64(x) generic_fls64(x)
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -245,6 +245,7 @@ static __inline__ int fls (unsigned int x) ...@@ -245,6 +245,7 @@ static __inline__ int fls (unsigned int x)
{ {
return __cntlz(x); return __cntlz(x);
} }
#define fls64(x) generic_fls64(x)
static __inline__ int static __inline__ int
find_next_bit(const unsigned long *addr, int size, int offset) find_next_bit(const unsigned long *addr, int size, int offset)
......
...@@ -76,6 +76,15 @@ static __inline__ int generic_fls(int x) ...@@ -76,6 +76,15 @@ static __inline__ int generic_fls(int x)
*/ */
#include <asm/bitops.h> #include <asm/bitops.h>
static inline int generic_fls64(__u64 x)
{
__u32 h = x >> 32;
if (h)
return fls(x) + 32;
return fls(x);
}
static __inline__ int get_bitmask_order(unsigned int count) static __inline__ int get_bitmask_order(unsigned int count)
{ {
int order; int order;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment