diff options
author | Stephen Hemminger <shemminger@osdl.org> | 2005-12-21 22:31:36 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-01-03 16:11:07 -0500 |
commit | 90933fc8ba5cc9034e3c04ee19938a22b0b4fe4e (patch) | |
tree | e42a78d253b375025cf73efe0f582d2722619397 | |
parent | 3821af2fe13700cab6fd67367128fa180e43f8b8 (diff) |
[FLS64]: x86_64 version
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/asm-x86_64/bitops.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h index 94b52c8ce97f..a4d5d0909453 100644 --- a/include/asm-x86_64/bitops.h +++ b/include/asm-x86_64/bitops.h | |||
@@ -340,6 +340,20 @@ static __inline__ unsigned long __ffs(unsigned long word) | |||
340 | return word; | 340 | return word; |
341 | } | 341 | } |
342 | 342 | ||
343 | /* | ||
344 | * __fls: find last bit set. | ||
345 | * @word: The word to search | ||
346 | * | ||
347 | * Undefined if no zero exists, so code should check against ~0UL first. | ||
348 | */ | ||
349 | static __inline__ unsigned long __fls(unsigned long word) | ||
350 | { | ||
351 | __asm__("bsrq %1,%0" | ||
352 | :"=r" (word) | ||
353 | :"rm" (word)); | ||
354 | return word; | ||
355 | } | ||
356 | |||
343 | #ifdef __KERNEL__ | 357 | #ifdef __KERNEL__ |
344 | 358 | ||
345 | static inline int sched_find_first_bit(const unsigned long *b) | 359 | static inline int sched_find_first_bit(const unsigned long *b) |
@@ -370,6 +384,19 @@ static __inline__ int ffs(int x) | |||
370 | } | 384 | } |
371 | 385 | ||
372 | /** | 386 | /** |
387 | * fls64 - find last bit set in 64 bit word | ||
388 | * @x: the word to search | ||
389 | * | ||
390 | * This is defined the same way as fls. | ||
391 | */ | ||
392 | static __inline__ int fls64(__u64 x) | ||
393 | { | ||
394 | if (x == 0) | ||
395 | return 0; | ||
396 | return __fls(x) + 1; | ||
397 | } | ||
398 | |||
399 | /** | ||
373 | * hweightN - returns the hamming weight of a N-bit word | 400 | * hweightN - returns the hamming weight of a N-bit word |
374 | * @x: the word to weigh | 401 | * @x: the word to weigh |
375 | * | 402 | * |
@@ -409,7 +436,6 @@ static __inline__ int ffs(int x) | |||
409 | 436 | ||
410 | /* find last set bit */ | 437 | /* find last set bit */ |
411 | #define fls(x) generic_fls(x) | 438 | #define fls(x) generic_fls(x) |
412 | #define fls64(x) generic_fls64(x) | ||
413 | 439 | ||
414 | #endif /* __KERNEL__ */ | 440 | #endif /* __KERNEL__ */ |
415 | 441 | ||