aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ia64/Kconfig4
-rw-r--r--arch/ia64/lib/Makefile2
-rw-r--r--arch/ia64/lib/bitop.c88
-rw-r--r--include/asm-ia64/bitops.h67
4 files changed, 22 insertions, 139 deletions
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index d790a6d90261..edffe25a477a 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -34,6 +34,10 @@ config RWSEM_XCHGADD_ALGORITHM
34 bool 34 bool
35 default y 35 default y
36 36
37config GENERIC_FIND_NEXT_BIT
38 bool
39 default y
40
37config GENERIC_CALIBRATE_DELAY 41config GENERIC_CALIBRATE_DELAY
38 bool 42 bool
39 default y 43 default y
diff --git a/arch/ia64/lib/Makefile b/arch/ia64/lib/Makefile
index ac64664a1807..d8536a2c22a9 100644
--- a/arch/ia64/lib/Makefile
+++ b/arch/ia64/lib/Makefile
@@ -6,7 +6,7 @@ obj-y := io.o
6 6
7lib-y := __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \ 7lib-y := __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o \
8 __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o \ 8 __divdi3.o __udivdi3.o __moddi3.o __umoddi3.o \
9 bitop.o checksum.o clear_page.o csum_partial_copy.o \ 9 checksum.o clear_page.o csum_partial_copy.o \
10 clear_user.o strncpy_from_user.o strlen_user.o strnlen_user.o \ 10 clear_user.o strncpy_from_user.o strlen_user.o strnlen_user.o \
11 flush.o ip_fast_csum.o do_csum.o \ 11 flush.o ip_fast_csum.o do_csum.o \
12 memset.o strlen.o 12 memset.o strlen.o
diff --git a/arch/ia64/lib/bitop.c b/arch/ia64/lib/bitop.c
deleted file mode 100644
index 82e299c8464e..000000000000
--- a/arch/ia64/lib/bitop.c
+++ /dev/null
@@ -1,88 +0,0 @@
1#include <linux/compiler.h>
2#include <linux/types.h>
3#include <asm/intrinsics.h>
4#include <linux/module.h>
5#include <linux/bitops.h>
6
7/*
8 * Find next zero bit in a bitmap reasonably efficiently..
9 */
10
11int __find_next_zero_bit (const void *addr, unsigned long size, unsigned long offset)
12{
13 unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
14 unsigned long result = offset & ~63UL;
15 unsigned long tmp;
16
17 if (offset >= size)
18 return size;
19 size -= result;
20 offset &= 63UL;
21 if (offset) {
22 tmp = *(p++);
23 tmp |= ~0UL >> (64-offset);
24 if (size < 64)
25 goto found_first;
26 if (~tmp)
27 goto found_middle;
28 size -= 64;
29 result += 64;
30 }
31 while (size & ~63UL) {
32 if (~(tmp = *(p++)))
33 goto found_middle;
34 result += 64;
35 size -= 64;
36 }
37 if (!size)
38 return result;
39 tmp = *p;
40found_first:
41 tmp |= ~0UL << size;
42 if (tmp == ~0UL) /* any bits zero? */
43 return result + size; /* nope */
44found_middle:
45 return result + ffz(tmp);
46}
47EXPORT_SYMBOL(__find_next_zero_bit);
48
49/*
50 * Find next bit in a bitmap reasonably efficiently..
51 */
52int __find_next_bit(const void *addr, unsigned long size, unsigned long offset)
53{
54 unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
55 unsigned long result = offset & ~63UL;
56 unsigned long tmp;
57
58 if (offset >= size)
59 return size;
60 size -= result;
61 offset &= 63UL;
62 if (offset) {
63 tmp = *(p++);
64 tmp &= ~0UL << offset;
65 if (size < 64)
66 goto found_first;
67 if (tmp)
68 goto found_middle;
69 size -= 64;
70 result += 64;
71 }
72 while (size & ~63UL) {
73 if ((tmp = *(p++)))
74 goto found_middle;
75 result += 64;
76 size -= 64;
77 }
78 if (!size)
79 return result;
80 tmp = *p;
81 found_first:
82 tmp &= ~0UL >> (64-size);
83 if (tmp == 0UL) /* Are any bits set? */
84 return result + size; /* Nope. */
85 found_middle:
86 return result + __ffs(tmp);
87}
88EXPORT_SYMBOL(__find_next_bit);
diff --git a/include/asm-ia64/bitops.h b/include/asm-ia64/bitops.h
index eccb01c79c1a..90921e162793 100644
--- a/include/asm-ia64/bitops.h
+++ b/include/asm-ia64/bitops.h
@@ -5,8 +5,8 @@
5 * Copyright (C) 1998-2003 Hewlett-Packard Co 5 * Copyright (C) 1998-2003 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com> 6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 * 7 *
8 * 02/06/02 find_next_bit() and find_first_bit() added from Erich Focht's ia64 O(1) 8 * 02/06/02 find_next_bit() and find_first_bit() added from Erich Focht's ia64
9 * scheduler patch 9 * O(1) scheduler patch
10 */ 10 */
11 11
12#include <linux/compiler.h> 12#include <linux/compiler.h>
@@ -25,9 +25,9 @@
25 * restricted to acting on a single-word quantity. 25 * restricted to acting on a single-word quantity.
26 * 26 *
27 * The address must be (at least) "long" aligned. 27 * The address must be (at least) "long" aligned.
28 * Note that there are driver (e.g., eepro100) which use these operations to operate on 28 * Note that there are driver (e.g., eepro100) which use these operations to
29 * hw-defined data-structures, so we can't easily change these operations to force a 29 * operate on hw-defined data-structures, so we can't easily change these
30 * bigger alignment. 30 * operations to force a bigger alignment.
31 * 31 *
32 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). 32 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
33 */ 33 */
@@ -284,8 +284,8 @@ test_bit (int nr, const volatile void *addr)
284 * ffz - find the first zero bit in a long word 284 * ffz - find the first zero bit in a long word
285 * @x: The long word to find the bit in 285 * @x: The long word to find the bit in
286 * 286 *
287 * Returns the bit-number (0..63) of the first (least significant) zero bit. Undefined if 287 * Returns the bit-number (0..63) of the first (least significant) zero bit.
288 * no zero exists, so code should check against ~0UL first... 288 * Undefined if no zero exists, so code should check against ~0UL first...
289 */ 289 */
290static inline unsigned long 290static inline unsigned long
291ffz (unsigned long x) 291ffz (unsigned long x)
@@ -345,13 +345,14 @@ fls (int t)
345 x |= x >> 16; 345 x |= x >> 16;
346 return ia64_popcnt(x); 346 return ia64_popcnt(x);
347} 347}
348#define fls64(x) generic_fls64(x) 348
349#include <asm-generic/bitops/fls64.h>
349 350
350/* 351/*
351 * ffs: find first bit set. This is defined the same way as the libc and compiler builtin 352 * ffs: find first bit set. This is defined the same way as the libc and
352 * ffs routines, therefore differs in spirit from the above ffz (man ffs): it operates on 353 * compiler builtin ffs routines, therefore differs in spirit from the above
353 * "int" values only and the result value is the bit number + 1. ffs(0) is defined to 354 * ffz (man ffs): it operates on "int" values only and the result value is the
354 * return zero. 355 * bit number + 1. ffs(0) is defined to return zero.
355 */ 356 */
356#define ffs(x) __builtin_ffs(x) 357#define ffs(x) __builtin_ffs(x)
357 358
@@ -373,51 +374,17 @@ hweight64 (unsigned long x)
373 374
374#endif /* __KERNEL__ */ 375#endif /* __KERNEL__ */
375 376
376extern int __find_next_zero_bit (const void *addr, unsigned long size, 377#include <asm-generic/bitops/find.h>
377 unsigned long offset);
378extern int __find_next_bit(const void *addr, unsigned long size,
379 unsigned long offset);
380
381#define find_next_zero_bit(addr, size, offset) \
382 __find_next_zero_bit((addr), (size), (offset))
383#define find_next_bit(addr, size, offset) \
384 __find_next_bit((addr), (size), (offset))
385
386/*
387 * The optimizer actually does good code for this case..
388 */
389#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
390
391#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
392 378
393#ifdef __KERNEL__ 379#ifdef __KERNEL__
394 380
395#define __clear_bit(nr, addr) clear_bit(nr, addr) 381#include <asm-generic/bitops/ext2-non-atomic.h>
396 382
397#define ext2_set_bit __test_and_set_bit
398#define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a) 383#define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a)
399#define ext2_clear_bit __test_and_clear_bit
400#define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a) 384#define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a)
401#define ext2_test_bit test_bit
402#define ext2_find_first_zero_bit find_first_zero_bit
403#define ext2_find_next_zero_bit find_next_zero_bit
404
405/* Bitmap functions for the minix filesystem. */
406#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr)
407#define minix_set_bit(nr,addr) __set_bit(nr,addr)
408#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr)
409#define minix_test_bit(nr,addr) test_bit(nr,addr)
410#define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size)
411 385
412static inline int 386#include <asm-generic/bitops/minix.h>
413sched_find_first_bit (unsigned long *b) 387#include <asm-generic/bitops/sched.h>
414{
415 if (unlikely(b[0]))
416 return __ffs(b[0]);
417 if (unlikely(b[1]))
418 return 64 + __ffs(b[1]);
419 return __ffs(b[2]) + 128;
420}
421 388
422#endif /* __KERNEL__ */ 389#endif /* __KERNEL__ */
423 390