aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-arm
diff options
context:
space:
mode:
authorAkinobu Mita <mita@miraclelinux.com>2006-03-26 04:39:19 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-26 11:57:12 -0500
commitb89c3b165fbec605c60fd5a9e32d647e4c0befbb (patch)
treeff54d1aefdf2674b30d87e304eb2e6dfa0d34fc2 /include/asm-arm
parentf7c29678739e69b8298496f926e87e5991e745e8 (diff)
[PATCH] bitops: arm: use generic bitops
- remove __{,test_and_}{set,clear,change}_bit() and test_bit() - if __LINUX_ARM_ARCH__ < 5 - remove ffz() - remove __ffs() - remove generic_fls() - remove generic_ffs() - remove generic_fls64() - remove sched_find_first_bit() - remove generic_hweight{32,16,8}() Signed-off-by: Akinobu Mita <mita@miraclelinux.com> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-arm')
-rw-r--r--include/asm-arm/bitops.h146
1 files changed, 10 insertions, 136 deletions
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index eaecd553e856..0ac54b1a8bad 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -117,65 +117,7 @@ ____atomic_test_and_change_bit(unsigned int bit, volatile unsigned long *p)
117 return res & mask; 117 return res & mask;
118} 118}
119 119
120/* 120#include <asm-generic/bitops/non-atomic.h>
121 * Now the non-atomic variants. We let the compiler handle all
122 * optimisations for these. These are all _native_ endian.
123 */
124static inline void __set_bit(int nr, volatile unsigned long *p)
125{
126 p[nr >> 5] |= (1UL << (nr & 31));
127}
128
129static inline void __clear_bit(int nr, volatile unsigned long *p)
130{
131 p[nr >> 5] &= ~(1UL << (nr & 31));
132}
133
134static inline void __change_bit(int nr, volatile unsigned long *p)
135{
136 p[nr >> 5] ^= (1UL << (nr & 31));
137}
138
139static inline int __test_and_set_bit(int nr, volatile unsigned long *p)
140{
141 unsigned long oldval, mask = 1UL << (nr & 31);
142
143 p += nr >> 5;
144
145 oldval = *p;
146 *p = oldval | mask;
147 return oldval & mask;
148}
149
150static inline int __test_and_clear_bit(int nr, volatile unsigned long *p)
151{
152 unsigned long oldval, mask = 1UL << (nr & 31);
153
154 p += nr >> 5;
155
156 oldval = *p;
157 *p = oldval & ~mask;
158 return oldval & mask;
159}
160
161static inline int __test_and_change_bit(int nr, volatile unsigned long *p)
162{
163 unsigned long oldval, mask = 1UL << (nr & 31);
164
165 p += nr >> 5;
166
167 oldval = *p;
168 *p = oldval ^ mask;
169 return oldval & mask;
170}
171
172/*
173 * This routine doesn't need to be atomic.
174 */
175static inline int __test_bit(int nr, const volatile unsigned long * p)
176{
177 return (p[nr >> 5] >> (nr & 31)) & 1UL;
178}
179 121
180/* 122/*
181 * A note about Endian-ness. 123 * A note about Endian-ness.
@@ -261,7 +203,6 @@ extern int _find_next_bit_be(const unsigned long *p, int size, int offset);
261#define test_and_set_bit(nr,p) ATOMIC_BITOP_LE(test_and_set_bit,nr,p) 203#define test_and_set_bit(nr,p) ATOMIC_BITOP_LE(test_and_set_bit,nr,p)
262#define test_and_clear_bit(nr,p) ATOMIC_BITOP_LE(test_and_clear_bit,nr,p) 204#define test_and_clear_bit(nr,p) ATOMIC_BITOP_LE(test_and_clear_bit,nr,p)
263#define test_and_change_bit(nr,p) ATOMIC_BITOP_LE(test_and_change_bit,nr,p) 205#define test_and_change_bit(nr,p) ATOMIC_BITOP_LE(test_and_change_bit,nr,p)
264#define test_bit(nr,p) __test_bit(nr,p)
265#define find_first_zero_bit(p,sz) _find_first_zero_bit_le(p,sz) 206#define find_first_zero_bit(p,sz) _find_first_zero_bit_le(p,sz)
266#define find_next_zero_bit(p,sz,off) _find_next_zero_bit_le(p,sz,off) 207#define find_next_zero_bit(p,sz,off) _find_next_zero_bit_le(p,sz,off)
267#define find_first_bit(p,sz) _find_first_bit_le(p,sz) 208#define find_first_bit(p,sz) _find_first_bit_le(p,sz)
@@ -280,7 +221,6 @@ extern int _find_next_bit_be(const unsigned long *p, int size, int offset);
280#define test_and_set_bit(nr,p) ATOMIC_BITOP_BE(test_and_set_bit,nr,p) 221#define test_and_set_bit(nr,p) ATOMIC_BITOP_BE(test_and_set_bit,nr,p)
281#define test_and_clear_bit(nr,p) ATOMIC_BITOP_BE(test_and_clear_bit,nr,p) 222#define test_and_clear_bit(nr,p) ATOMIC_BITOP_BE(test_and_clear_bit,nr,p)
282#define test_and_change_bit(nr,p) ATOMIC_BITOP_BE(test_and_change_bit,nr,p) 223#define test_and_change_bit(nr,p) ATOMIC_BITOP_BE(test_and_change_bit,nr,p)
283#define test_bit(nr,p) __test_bit(nr,p)
284#define find_first_zero_bit(p,sz) _find_first_zero_bit_be(p,sz) 224#define find_first_zero_bit(p,sz) _find_first_zero_bit_be(p,sz)
285#define find_next_zero_bit(p,sz,off) _find_next_zero_bit_be(p,sz,off) 225#define find_next_zero_bit(p,sz,off) _find_next_zero_bit_be(p,sz,off)
286#define find_first_bit(p,sz) _find_first_bit_be(p,sz) 226#define find_first_bit(p,sz) _find_first_bit_be(p,sz)
@@ -292,55 +232,10 @@ extern int _find_next_bit_be(const unsigned long *p, int size, int offset);
292 232
293#if __LINUX_ARM_ARCH__ < 5 233#if __LINUX_ARM_ARCH__ < 5
294 234
295/* 235#include <asm-generic/bitops/ffz.h>
296 * ffz = Find First Zero in word. Undefined if no zero exists, 236#include <asm-generic/bitops/__ffs.h>
297 * so code should check against ~0UL first.. 237#include <asm-generic/bitops/fls.h>
298 */ 238#include <asm-generic/bitops/ffs.h>
299static inline unsigned long ffz(unsigned long word)
300{
301 int k;
302
303 word = ~word;
304 k = 31;
305 if (word & 0x0000ffff) { k -= 16; word <<= 16; }
306 if (word & 0x00ff0000) { k -= 8; word <<= 8; }
307 if (word & 0x0f000000) { k -= 4; word <<= 4; }
308 if (word & 0x30000000) { k -= 2; word <<= 2; }
309 if (word & 0x40000000) { k -= 1; }
310 return k;
311}
312
313/*
314 * ffz = Find First Zero in word. Undefined if no zero exists,
315 * so code should check against ~0UL first..
316 */
317static inline unsigned long __ffs(unsigned long word)
318{
319 int k;
320
321 k = 31;
322 if (word & 0x0000ffff) { k -= 16; word <<= 16; }
323 if (word & 0x00ff0000) { k -= 8; word <<= 8; }
324 if (word & 0x0f000000) { k -= 4; word <<= 4; }
325 if (word & 0x30000000) { k -= 2; word <<= 2; }
326 if (word & 0x40000000) { k -= 1; }
327 return k;
328}
329
330/*
331 * fls: find last bit set.
332 */
333
334#define fls(x) generic_fls(x)
335#define fls64(x) generic_fls64(x)
336
337/*
338 * ffs: find first bit set. This is defined the same way as
339 * the libc and compiler builtin ffs routines, therefore
340 * differs in spirit from the above ffz (man ffs).
341 */
342
343#define ffs(x) generic_ffs(x)
344 239
345#else 240#else
346 241
@@ -381,37 +276,16 @@ static inline int constant_fls(int x)
381#define fls(x) \ 276#define fls(x) \
382 ( __builtin_constant_p(x) ? constant_fls(x) : \ 277 ( __builtin_constant_p(x) ? constant_fls(x) : \
383 ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) ) 278 ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) )
384#define fls64(x) generic_fls64(x)
385#define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); }) 279#define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); })
386#define __ffs(x) (ffs(x) - 1) 280#define __ffs(x) (ffs(x) - 1)
387#define ffz(x) __ffs( ~(x) ) 281#define ffz(x) __ffs( ~(x) )
388 282
389#endif 283#endif
390 284
391/* 285#include <asm-generic/bitops/fls64.h>
392 * Find first bit set in a 168-bit bitmap, where the first
393 * 128 bits are unlikely to be set.
394 */
395static inline int sched_find_first_bit(const unsigned long *b)
396{
397 unsigned long v;
398 unsigned int off;
399
400 for (off = 0; v = b[off], off < 4; off++) {
401 if (unlikely(v))
402 break;
403 }
404 return __ffs(v) + off * 32;
405}
406
407/*
408 * hweightN: returns the hamming weight (i.e. the number
409 * of bits set) of a N-bit word
410 */
411 286
412#define hweight32(x) generic_hweight32(x) 287#include <asm-generic/bitops/sched.h>
413#define hweight16(x) generic_hweight16(x) 288#include <asm-generic/bitops/hweight.h>
414#define hweight8(x) generic_hweight8(x)
415 289
416/* 290/*
417 * Ext2 is defined to use little-endian byte ordering. 291 * Ext2 is defined to use little-endian byte ordering.
@@ -426,7 +300,7 @@ static inline int sched_find_first_bit(const unsigned long *b)
426#define ext2_clear_bit_atomic(lock,nr,p) \ 300#define ext2_clear_bit_atomic(lock,nr,p) \
427 test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) 301 test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
428#define ext2_test_bit(nr,p) \ 302#define ext2_test_bit(nr,p) \
429 __test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) 303 test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
430#define ext2_find_first_zero_bit(p,sz) \ 304#define ext2_find_first_zero_bit(p,sz) \
431 _find_first_zero_bit_le(p,sz) 305 _find_first_zero_bit_le(p,sz)
432#define ext2_find_next_zero_bit(p,sz,off) \ 306#define ext2_find_next_zero_bit(p,sz,off) \
@@ -439,7 +313,7 @@ static inline int sched_find_first_bit(const unsigned long *b)
439#define minix_set_bit(nr,p) \ 313#define minix_set_bit(nr,p) \
440 __set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) 314 __set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
441#define minix_test_bit(nr,p) \ 315#define minix_test_bit(nr,p) \
442 __test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) 316 test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
443#define minix_test_and_set_bit(nr,p) \ 317#define minix_test_and_set_bit(nr,p) \
444 __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p)) 318 __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
445#define minix_test_and_clear_bit(nr,p) \ 319#define minix_test_and_clear_bit(nr,p) \