aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2013-08-14 09:07:30 -0400
committerChris Metcalf <cmetcalf@tilera.com>2013-09-03 14:53:27 -0400
commitd6a0aa314c06743b702931cb468f400b7615c5c9 (patch)
treeca6d0ad79d99ab5ad4bbe2b5e85e512acd13cb88 /arch
parentf6f380dff682749373d5a654a76e9bc8467010c5 (diff)
tile: use asm-generic/bitops/builtin-*.h
The definisions of __ffs(), __fls(), and ffs() for tile are almost same as asm-generic/bitops-*.h. The only difference is that it is defined as __always_inline or inline. So this switches to use those headers. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Chris Metcalf <cmetcalf@tilera.com> [moved #includes to end]
Diffstat (limited to 'arch')
-rw-r--r--arch/tile/include/asm/bitops.h41
1 files changed, 3 insertions, 38 deletions
diff --git a/arch/tile/include/asm/bitops.h b/arch/tile/include/asm/bitops.h
index bd186c4eaa50..d5a206865036 100644
--- a/arch/tile/include/asm/bitops.h
+++ b/arch/tile/include/asm/bitops.h
@@ -29,17 +29,6 @@
29#endif 29#endif
30 30
31/** 31/**
32 * __ffs - find first set bit in word
33 * @word: The word to search
34 *
35 * Undefined if no set bit exists, so code should check against 0 first.
36 */
37static inline unsigned long __ffs(unsigned long word)
38{
39 return __builtin_ctzl(word);
40}
41
42/**
43 * ffz - find first zero bit in word 32 * ffz - find first zero bit in word
44 * @word: The word to search 33 * @word: The word to search
45 * 34 *
@@ -50,33 +39,6 @@ static inline unsigned long ffz(unsigned long word)
50 return __builtin_ctzl(~word); 39 return __builtin_ctzl(~word);
51} 40}
52 41
53/**
54 * __fls - find last set bit in word
55 * @word: The word to search
56 *
57 * Undefined if no set bit exists, so code should check against 0 first.
58 */
59static inline unsigned long __fls(unsigned long word)
60{
61 return (sizeof(word) * 8) - 1 - __builtin_clzl(word);
62}
63
64/**
65 * ffs - find first set bit in word
66 * @x: the word to search
67 *
68 * This is defined the same way as the libc and compiler builtin ffs
69 * routines, therefore differs in spirit from the other bitops.
70 *
71 * ffs(value) returns 0 if value is 0 or the position of the first
72 * set bit if value is nonzero. The first (least significant) bit
73 * is at position 1.
74 */
75static inline int ffs(int x)
76{
77 return __builtin_ffs(x);
78}
79
80static inline int fls64(__u64 w) 42static inline int fls64(__u64 w)
81{ 43{
82 return (sizeof(__u64) * 8) - __builtin_clzll(w); 44 return (sizeof(__u64) * 8) - __builtin_clzll(w);
@@ -118,6 +80,9 @@ static inline unsigned long __arch_hweight64(__u64 w)
118 return __builtin_popcountll(w); 80 return __builtin_popcountll(w);
119} 81}
120 82
83#include <asm-generic/bitops/builtin-__ffs.h>
84#include <asm-generic/bitops/builtin-__fls.h>
85#include <asm-generic/bitops/builtin-ffs.h>
121#include <asm-generic/bitops/const_hweight.h> 86#include <asm-generic/bitops/const_hweight.h>
122#include <asm-generic/bitops/lock.h> 87#include <asm-generic/bitops/lock.h>
123#include <asm-generic/bitops/find.h> 88#include <asm-generic/bitops/find.h>