mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-01 12:04:08 +00:00
[FLS64]: x86_64 version
Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3821af2fe1
commit
90933fc8ba
1 changed files with 27 additions and 1 deletions
|
@ -340,6 +340,20 @@ static __inline__ unsigned long __ffs(unsigned long word)
|
||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* __fls: find last bit set.
|
||||||
|
* @word: The word to search
|
||||||
|
*
|
||||||
|
* Undefined if no zero exists, so code should check against ~0UL first.
|
||||||
|
*/
|
||||||
|
static __inline__ unsigned long __fls(unsigned long word)
|
||||||
|
{
|
||||||
|
__asm__("bsrq %1,%0"
|
||||||
|
:"=r" (word)
|
||||||
|
:"rm" (word));
|
||||||
|
return word;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
|
|
||||||
static inline int sched_find_first_bit(const unsigned long *b)
|
static inline int sched_find_first_bit(const unsigned long *b)
|
||||||
|
@ -369,6 +383,19 @@ static __inline__ int ffs(int x)
|
||||||
return r+1;
|
return r+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fls64 - find last bit set in 64 bit word
|
||||||
|
* @x: the word to search
|
||||||
|
*
|
||||||
|
* This is defined the same way as fls.
|
||||||
|
*/
|
||||||
|
static __inline__ int fls64(__u64 x)
|
||||||
|
{
|
||||||
|
if (x == 0)
|
||||||
|
return 0;
|
||||||
|
return __fls(x) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hweightN - returns the hamming weight of a N-bit word
|
* hweightN - returns the hamming weight of a N-bit word
|
||||||
* @x: the word to weigh
|
* @x: the word to weigh
|
||||||
|
@ -409,7 +436,6 @@ 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__ */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue