diff options
author | Akinobu Mita <mita@miraclelinux.com> | 2006-03-26 04:39:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-26 11:57:13 -0500 |
commit | d2d7cdcf6e6d2a3db9885316d075940f12324413 (patch) | |
tree | ed772d4213ed5adc3410d088693f5be5cf79dbe6 /include | |
parent | 4c5aea053d64bee7a776a4b874e1b417e9f316fe (diff) |
[PATCH] bitops: m68knommu: use generic bitops
- remove ffs()
- remove __ffs()
- remove sched_find_first_bit()
- remove ffz()
- remove find_{next,first}{,_zero}_bit()
- remove generic_hweight()
- remove minix_{test,set,test_and_clear,test,find_first_zero}_bit()
- remove generic_fls()
- remove generic_fls64()
Signed-off-by: Akinobu Mita <mita@miraclelinux.com>
Cc: Greg Ungerer <gerg@uclinux.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-m68knommu/bitops.h | 221 |
1 files changed, 9 insertions, 212 deletions
diff --git a/include/asm-m68knommu/bitops.h b/include/asm-m68knommu/bitops.h index 00c4a2548e60..0b68ccd327f7 100644 --- a/include/asm-m68knommu/bitops.h +++ b/include/asm-m68knommu/bitops.h | |||
@@ -12,104 +12,10 @@ | |||
12 | 12 | ||
13 | #ifdef __KERNEL__ | 13 | #ifdef __KERNEL__ |
14 | 14 | ||
15 | /* | 15 | #include <asm-generic/bitops/ffs.h> |
16 | * Generic ffs(). | 16 | #include <asm-generic/bitops/__ffs.h> |
17 | */ | 17 | #include <asm-generic/bitops/sched.h> |
18 | static inline int ffs(int x) | 18 | #include <asm-generic/bitops/ffz.h> |
19 | { | ||
20 | int r = 1; | ||
21 | |||
22 | if (!x) | ||
23 | return 0; | ||
24 | if (!(x & 0xffff)) { | ||
25 | x >>= 16; | ||
26 | r += 16; | ||
27 | } | ||
28 | if (!(x & 0xff)) { | ||
29 | x >>= 8; | ||
30 | r += 8; | ||
31 | } | ||
32 | if (!(x & 0xf)) { | ||
33 | x >>= 4; | ||
34 | r += 4; | ||
35 | } | ||
36 | if (!(x & 3)) { | ||
37 | x >>= 2; | ||
38 | r += 2; | ||
39 | } | ||
40 | if (!(x & 1)) { | ||
41 | x >>= 1; | ||
42 | r += 1; | ||
43 | } | ||
44 | return r; | ||
45 | } | ||
46 | |||
47 | /* | ||
48 | * Generic __ffs(). | ||
49 | */ | ||
50 | static inline int __ffs(int x) | ||
51 | { | ||
52 | int r = 0; | ||
53 | |||
54 | if (!x) | ||
55 | return 0; | ||
56 | if (!(x & 0xffff)) { | ||
57 | x >>= 16; | ||
58 | r += 16; | ||
59 | } | ||
60 | if (!(x & 0xff)) { | ||
61 | x >>= 8; | ||
62 | r += 8; | ||
63 | } | ||
64 | if (!(x & 0xf)) { | ||
65 | x >>= 4; | ||
66 | r += 4; | ||
67 | } | ||
68 | if (!(x & 3)) { | ||
69 | x >>= 2; | ||
70 | r += 2; | ||
71 | } | ||
72 | if (!(x & 1)) { | ||
73 | x >>= 1; | ||
74 | r += 1; | ||
75 | } | ||
76 | return r; | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | * Every architecture must define this function. It's the fastest | ||
81 | * way of searching a 140-bit bitmap where the first 100 bits are | ||
82 | * unlikely to be set. It's guaranteed that at least one of the 140 | ||
83 | * bits is cleared. | ||
84 | */ | ||
85 | static inline int sched_find_first_bit(unsigned long *b) | ||
86 | { | ||
87 | if (unlikely(b[0])) | ||
88 | return __ffs(b[0]); | ||
89 | if (unlikely(b[1])) | ||
90 | return __ffs(b[1]) + 32; | ||
91 | if (unlikely(b[2])) | ||
92 | return __ffs(b[2]) + 64; | ||
93 | if (b[3]) | ||
94 | return __ffs(b[3]) + 96; | ||
95 | return __ffs(b[4]) + 128; | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * ffz = Find First Zero in word. Undefined if no zero exists, | ||
100 | * so code should check against ~0UL first.. | ||
101 | */ | ||
102 | static __inline__ unsigned long ffz(unsigned long word) | ||
103 | { | ||
104 | unsigned long result = 0; | ||
105 | |||
106 | while(word & 1) { | ||
107 | result++; | ||
108 | word >>= 1; | ||
109 | } | ||
110 | return result; | ||
111 | } | ||
112 | |||
113 | 19 | ||
114 | static __inline__ void set_bit(int nr, volatile unsigned long * addr) | 20 | static __inline__ void set_bit(int nr, volatile unsigned long * addr) |
115 | { | 21 | { |
@@ -254,98 +160,8 @@ static __inline__ int __test_bit(int nr, const volatile unsigned long * addr) | |||
254 | __constant_test_bit((nr),(addr)) : \ | 160 | __constant_test_bit((nr),(addr)) : \ |
255 | __test_bit((nr),(addr))) | 161 | __test_bit((nr),(addr))) |
256 | 162 | ||
257 | #define find_first_zero_bit(addr, size) \ | 163 | #include <asm-generic/bitops/find.h> |
258 | find_next_zero_bit((addr), (size), 0) | 164 | #include <asm-generic/bitops/hweight.h> |
259 | #define find_first_bit(addr, size) \ | ||
260 | find_next_bit((addr), (size), 0) | ||
261 | |||
262 | static __inline__ int find_next_zero_bit (const void * addr, int size, int offset) | ||
263 | { | ||
264 | unsigned long *p = ((unsigned long *) addr) + (offset >> 5); | ||
265 | unsigned long result = offset & ~31UL; | ||
266 | unsigned long tmp; | ||
267 | |||
268 | if (offset >= size) | ||
269 | return size; | ||
270 | size -= result; | ||
271 | offset &= 31UL; | ||
272 | if (offset) { | ||
273 | tmp = *(p++); | ||
274 | tmp |= ~0UL >> (32-offset); | ||
275 | if (size < 32) | ||
276 | goto found_first; | ||
277 | if (~tmp) | ||
278 | goto found_middle; | ||
279 | size -= 32; | ||
280 | result += 32; | ||
281 | } | ||
282 | while (size & ~31UL) { | ||
283 | if (~(tmp = *(p++))) | ||
284 | goto found_middle; | ||
285 | result += 32; | ||
286 | size -= 32; | ||
287 | } | ||
288 | if (!size) | ||
289 | return result; | ||
290 | tmp = *p; | ||
291 | |||
292 | found_first: | ||
293 | tmp |= ~0UL << size; | ||
294 | found_middle: | ||
295 | return result + ffz(tmp); | ||
296 | } | ||
297 | |||
298 | /* | ||
299 | * Find next one bit in a bitmap reasonably efficiently. | ||
300 | */ | ||
301 | static __inline__ unsigned long find_next_bit(const unsigned long *addr, | ||
302 | unsigned long size, unsigned long offset) | ||
303 | { | ||
304 | unsigned int *p = ((unsigned int *) addr) + (offset >> 5); | ||
305 | unsigned int result = offset & ~31UL; | ||
306 | unsigned int tmp; | ||
307 | |||
308 | if (offset >= size) | ||
309 | return size; | ||
310 | size -= result; | ||
311 | offset &= 31UL; | ||
312 | if (offset) { | ||
313 | tmp = *p++; | ||
314 | tmp &= ~0UL << offset; | ||
315 | if (size < 32) | ||
316 | goto found_first; | ||
317 | if (tmp) | ||
318 | goto found_middle; | ||
319 | size -= 32; | ||
320 | result += 32; | ||
321 | } | ||
322 | while (size >= 32) { | ||
323 | if ((tmp = *p++) != 0) | ||
324 | goto found_middle; | ||
325 | result += 32; | ||
326 | size -= 32; | ||
327 | } | ||
328 | if (!size) | ||
329 | return result; | ||
330 | tmp = *p; | ||
331 | |||
332 | found_first: | ||
333 | tmp &= ~0UL >> (32 - size); | ||
334 | if (tmp == 0UL) /* Are any bits set? */ | ||
335 | return result + size; /* Nope. */ | ||
336 | found_middle: | ||
337 | return result + __ffs(tmp); | ||
338 | } | ||
339 | |||
340 | /* | ||
341 | * hweightN: returns the hamming weight (i.e. the number | ||
342 | * of bits set) of a N-bit word | ||
343 | */ | ||
344 | |||
345 | #define hweight32(x) generic_hweight32(x) | ||
346 | #define hweight16(x) generic_hweight16(x) | ||
347 | #define hweight8(x) generic_hweight8(x) | ||
348 | |||
349 | 165 | ||
350 | static __inline__ int ext2_set_bit(int nr, volatile void * addr) | 166 | static __inline__ int ext2_set_bit(int nr, volatile void * addr) |
351 | { | 167 | { |
@@ -475,30 +291,11 @@ found_middle: | |||
475 | return result + ffz(__swab32(tmp)); | 291 | return result + ffz(__swab32(tmp)); |
476 | } | 292 | } |
477 | 293 | ||
478 | /* Bitmap functions for the minix filesystem. */ | 294 | #include <asm-generic/bitops/minix.h> |
479 | #define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr) | ||
480 | #define minix_set_bit(nr,addr) __set_bit(nr,addr) | ||
481 | #define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr) | ||
482 | #define minix_test_bit(nr,addr) test_bit(nr,addr) | ||
483 | #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) | ||
484 | |||
485 | /** | ||
486 | * hweightN - returns the hamming weight of a N-bit word | ||
487 | * @x: the word to weigh | ||
488 | * | ||
489 | * The Hamming Weight of a number is the total number of bits set in it. | ||
490 | */ | ||
491 | |||
492 | #define hweight32(x) generic_hweight32(x) | ||
493 | #define hweight16(x) generic_hweight16(x) | ||
494 | #define hweight8(x) generic_hweight8(x) | ||
495 | 295 | ||
496 | #endif /* __KERNEL__ */ | 296 | #endif /* __KERNEL__ */ |
497 | 297 | ||
498 | /* | 298 | #include <asm-generic/bitops/fls.h> |
499 | * fls: find last bit set. | 299 | #include <asm-generic/bitops/fls64.h> |
500 | */ | ||
501 | #define fls(x) generic_fls(x) | ||
502 | #define fls64(x) generic_fls64(x) | ||
503 | 300 | ||
504 | #endif /* _M68KNOMMU_BITOPS_H */ | 301 | #endif /* _M68KNOMMU_BITOPS_H */ |