diff options
Diffstat (limited to 'include/asm-x86')
-rw-r--r-- | include/asm-x86/bitops_32.h | 58 | ||||
-rw-r--r-- | include/asm-x86/bitops_64.h | 23 |
2 files changed, 0 insertions, 81 deletions
diff --git a/include/asm-x86/bitops_32.h b/include/asm-x86/bitops_32.h index ba2c0defafa8..2e863021bf81 100644 --- a/include/asm-x86/bitops_32.h +++ b/include/asm-x86/bitops_32.h | |||
@@ -4,64 +4,6 @@ | |||
4 | /* | 4 | /* |
5 | * Copyright 1992, Linus Torvalds. | 5 | * Copyright 1992, Linus Torvalds. |
6 | */ | 6 | */ |
7 | |||
8 | #ifndef CONFIG_GENERIC_FIND_FIRST_BIT | ||
9 | /** | ||
10 | * find_first_zero_bit - find the first zero bit in a memory region | ||
11 | * @addr: The address to start the search at | ||
12 | * @size: The maximum size to search | ||
13 | * | ||
14 | * Returns the bit number of the first zero bit, not the number of the byte | ||
15 | * containing a bit. | ||
16 | */ | ||
17 | static inline int find_first_zero_bit(const unsigned long *addr, unsigned size) | ||
18 | { | ||
19 | int d0, d1, d2; | ||
20 | int res; | ||
21 | |||
22 | if (!size) | ||
23 | return 0; | ||
24 | /* This looks at memory. | ||
25 | * Mark it volatile to tell gcc not to move it around | ||
26 | */ | ||
27 | asm volatile("movl $-1,%%eax\n\t" | ||
28 | "xorl %%edx,%%edx\n\t" | ||
29 | "repe; scasl\n\t" | ||
30 | "je 1f\n\t" | ||
31 | "xorl -4(%%edi),%%eax\n\t" | ||
32 | "subl $4,%%edi\n\t" | ||
33 | "bsfl %%eax,%%edx\n" | ||
34 | "1:\tsubl %%ebx,%%edi\n\t" | ||
35 | "shll $3,%%edi\n\t" | ||
36 | "addl %%edi,%%edx" | ||
37 | : "=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2) | ||
38 | : "1" ((size + 31) >> 5), "2" (addr), | ||
39 | "b" (addr) : "memory"); | ||
40 | return res; | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * find_first_bit - find the first set bit in a memory region | ||
45 | * @addr: The address to start the search at | ||
46 | * @size: The maximum size to search | ||
47 | * | ||
48 | * Returns the bit number of the first set bit, not the number of the byte | ||
49 | * containing a bit. | ||
50 | */ | ||
51 | static inline unsigned find_first_bit(const unsigned long *addr, unsigned size) | ||
52 | { | ||
53 | unsigned x = 0; | ||
54 | |||
55 | while (x < size) { | ||
56 | unsigned long val = *addr++; | ||
57 | if (val) | ||
58 | return __ffs(val) + x; | ||
59 | x += sizeof(*addr) << 3; | ||
60 | } | ||
61 | return x; | ||
62 | } | ||
63 | #endif | ||
64 | |||
65 | #ifdef __KERNEL__ | 7 | #ifdef __KERNEL__ |
66 | 8 | ||
67 | #include <asm-generic/bitops/sched.h> | 9 | #include <asm-generic/bitops/sched.h> |
diff --git a/include/asm-x86/bitops_64.h b/include/asm-x86/bitops_64.h index 4081d7ecc2bd..cb23122d23f1 100644 --- a/include/asm-x86/bitops_64.h +++ b/include/asm-x86/bitops_64.h | |||
@@ -4,29 +4,6 @@ | |||
4 | /* | 4 | /* |
5 | * Copyright 1992, Linus Torvalds. | 5 | * Copyright 1992, Linus Torvalds. |
6 | */ | 6 | */ |
7 | |||
8 | #ifndef CONFIG_GENERIC_FIND_FIRST_BIT | ||
9 | extern long find_first_zero_bit(const unsigned long *addr, unsigned long size); | ||
10 | extern long find_first_bit(const unsigned long *addr, unsigned long size); | ||
11 | |||
12 | /* return index of first bet set in val or max when no bit is set */ | ||
13 | static inline long __scanbit(unsigned long val, unsigned long max) | ||
14 | { | ||
15 | asm("bsfq %1,%0 ; cmovz %2,%0" : "=&r" (val) : "r" (val), "r" (max)); | ||
16 | return val; | ||
17 | } | ||
18 | |||
19 | #define find_first_bit(addr, size) \ | ||
20 | ((__builtin_constant_p((size)) && (size) <= BITS_PER_LONG \ | ||
21 | ? (__scanbit(*(unsigned long *)(addr), (size))) \ | ||
22 | : find_first_bit((addr), (size)))) | ||
23 | |||
24 | #define find_first_zero_bit(addr, size) \ | ||
25 | ((__builtin_constant_p((size)) && (size) <= BITS_PER_LONG \ | ||
26 | ? (__scanbit(~*(unsigned long *)(addr), (size))) \ | ||
27 | : find_first_zero_bit((addr), (size)))) | ||
28 | #endif | ||
29 | |||
30 | static inline void set_bit_string(unsigned long *bitmap, unsigned long i, | 7 | static inline void set_bit_string(unsigned long *bitmap, unsigned long i, |
31 | int len) | 8 | int len) |
32 | { | 9 | { |