diff options
Diffstat (limited to 'include/asm-x86_64/bitops.h')
-rw-r--r-- | include/asm-x86_64/bitops.h | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h index a4d5d0909453..eb4df23e1e41 100644 --- a/include/asm-x86_64/bitops.h +++ b/include/asm-x86_64/bitops.h | |||
@@ -29,7 +29,7 @@ static __inline__ void set_bit(int nr, volatile void * addr) | |||
29 | { | 29 | { |
30 | __asm__ __volatile__( LOCK_PREFIX | 30 | __asm__ __volatile__( LOCK_PREFIX |
31 | "btsl %1,%0" | 31 | "btsl %1,%0" |
32 | :"=m" (ADDR) | 32 | :"+m" (ADDR) |
33 | :"dIr" (nr) : "memory"); | 33 | :"dIr" (nr) : "memory"); |
34 | } | 34 | } |
35 | 35 | ||
@@ -46,7 +46,7 @@ static __inline__ void __set_bit(int nr, volatile void * addr) | |||
46 | { | 46 | { |
47 | __asm__ volatile( | 47 | __asm__ volatile( |
48 | "btsl %1,%0" | 48 | "btsl %1,%0" |
49 | :"=m" (ADDR) | 49 | :"+m" (ADDR) |
50 | :"dIr" (nr) : "memory"); | 50 | :"dIr" (nr) : "memory"); |
51 | } | 51 | } |
52 | 52 | ||
@@ -64,7 +64,7 @@ static __inline__ void clear_bit(int nr, volatile void * addr) | |||
64 | { | 64 | { |
65 | __asm__ __volatile__( LOCK_PREFIX | 65 | __asm__ __volatile__( LOCK_PREFIX |
66 | "btrl %1,%0" | 66 | "btrl %1,%0" |
67 | :"=m" (ADDR) | 67 | :"+m" (ADDR) |
68 | :"dIr" (nr)); | 68 | :"dIr" (nr)); |
69 | } | 69 | } |
70 | 70 | ||
@@ -72,7 +72,7 @@ static __inline__ void __clear_bit(int nr, volatile void * addr) | |||
72 | { | 72 | { |
73 | __asm__ __volatile__( | 73 | __asm__ __volatile__( |
74 | "btrl %1,%0" | 74 | "btrl %1,%0" |
75 | :"=m" (ADDR) | 75 | :"+m" (ADDR) |
76 | :"dIr" (nr)); | 76 | :"dIr" (nr)); |
77 | } | 77 | } |
78 | 78 | ||
@@ -92,7 +92,7 @@ static __inline__ void __change_bit(int nr, volatile void * addr) | |||
92 | { | 92 | { |
93 | __asm__ __volatile__( | 93 | __asm__ __volatile__( |
94 | "btcl %1,%0" | 94 | "btcl %1,%0" |
95 | :"=m" (ADDR) | 95 | :"+m" (ADDR) |
96 | :"dIr" (nr)); | 96 | :"dIr" (nr)); |
97 | } | 97 | } |
98 | 98 | ||
@@ -109,7 +109,7 @@ static __inline__ void change_bit(int nr, volatile void * addr) | |||
109 | { | 109 | { |
110 | __asm__ __volatile__( LOCK_PREFIX | 110 | __asm__ __volatile__( LOCK_PREFIX |
111 | "btcl %1,%0" | 111 | "btcl %1,%0" |
112 | :"=m" (ADDR) | 112 | :"+m" (ADDR) |
113 | :"dIr" (nr)); | 113 | :"dIr" (nr)); |
114 | } | 114 | } |
115 | 115 | ||
@@ -127,7 +127,7 @@ static __inline__ int test_and_set_bit(int nr, volatile void * addr) | |||
127 | 127 | ||
128 | __asm__ __volatile__( LOCK_PREFIX | 128 | __asm__ __volatile__( LOCK_PREFIX |
129 | "btsl %2,%1\n\tsbbl %0,%0" | 129 | "btsl %2,%1\n\tsbbl %0,%0" |
130 | :"=r" (oldbit),"=m" (ADDR) | 130 | :"=r" (oldbit),"+m" (ADDR) |
131 | :"dIr" (nr) : "memory"); | 131 | :"dIr" (nr) : "memory"); |
132 | return oldbit; | 132 | return oldbit; |
133 | } | 133 | } |
@@ -147,7 +147,7 @@ static __inline__ int __test_and_set_bit(int nr, volatile void * addr) | |||
147 | 147 | ||
148 | __asm__( | 148 | __asm__( |
149 | "btsl %2,%1\n\tsbbl %0,%0" | 149 | "btsl %2,%1\n\tsbbl %0,%0" |
150 | :"=r" (oldbit),"=m" (ADDR) | 150 | :"=r" (oldbit),"+m" (ADDR) |
151 | :"dIr" (nr)); | 151 | :"dIr" (nr)); |
152 | return oldbit; | 152 | return oldbit; |
153 | } | 153 | } |
@@ -166,7 +166,7 @@ static __inline__ int test_and_clear_bit(int nr, volatile void * addr) | |||
166 | 166 | ||
167 | __asm__ __volatile__( LOCK_PREFIX | 167 | __asm__ __volatile__( LOCK_PREFIX |
168 | "btrl %2,%1\n\tsbbl %0,%0" | 168 | "btrl %2,%1\n\tsbbl %0,%0" |
169 | :"=r" (oldbit),"=m" (ADDR) | 169 | :"=r" (oldbit),"+m" (ADDR) |
170 | :"dIr" (nr) : "memory"); | 170 | :"dIr" (nr) : "memory"); |
171 | return oldbit; | 171 | return oldbit; |
172 | } | 172 | } |
@@ -186,7 +186,7 @@ static __inline__ int __test_and_clear_bit(int nr, volatile void * addr) | |||
186 | 186 | ||
187 | __asm__( | 187 | __asm__( |
188 | "btrl %2,%1\n\tsbbl %0,%0" | 188 | "btrl %2,%1\n\tsbbl %0,%0" |
189 | :"=r" (oldbit),"=m" (ADDR) | 189 | :"=r" (oldbit),"+m" (ADDR) |
190 | :"dIr" (nr)); | 190 | :"dIr" (nr)); |
191 | return oldbit; | 191 | return oldbit; |
192 | } | 192 | } |
@@ -198,7 +198,7 @@ static __inline__ int __test_and_change_bit(int nr, volatile void * addr) | |||
198 | 198 | ||
199 | __asm__ __volatile__( | 199 | __asm__ __volatile__( |
200 | "btcl %2,%1\n\tsbbl %0,%0" | 200 | "btcl %2,%1\n\tsbbl %0,%0" |
201 | :"=r" (oldbit),"=m" (ADDR) | 201 | :"=r" (oldbit),"+m" (ADDR) |
202 | :"dIr" (nr) : "memory"); | 202 | :"dIr" (nr) : "memory"); |
203 | return oldbit; | 203 | return oldbit; |
204 | } | 204 | } |
@@ -217,7 +217,7 @@ static __inline__ int test_and_change_bit(int nr, volatile void * addr) | |||
217 | 217 | ||
218 | __asm__ __volatile__( LOCK_PREFIX | 218 | __asm__ __volatile__( LOCK_PREFIX |
219 | "btcl %2,%1\n\tsbbl %0,%0" | 219 | "btcl %2,%1\n\tsbbl %0,%0" |
220 | :"=r" (oldbit),"=m" (ADDR) | 220 | :"=r" (oldbit),"+m" (ADDR) |
221 | :"dIr" (nr) : "memory"); | 221 | :"dIr" (nr) : "memory"); |
222 | return oldbit; | 222 | return oldbit; |
223 | } | 223 | } |
@@ -397,6 +397,22 @@ static __inline__ int fls64(__u64 x) | |||
397 | } | 397 | } |
398 | 398 | ||
399 | /** | 399 | /** |
400 | * fls - find last bit set | ||
401 | * @x: the word to search | ||
402 | * | ||
403 | * This is defined the same way as ffs. | ||
404 | */ | ||
405 | static __inline__ int fls(int x) | ||
406 | { | ||
407 | int r; | ||
408 | |||
409 | __asm__("bsrl %1,%0\n\t" | ||
410 | "cmovzl %2,%0" | ||
411 | : "=&r" (r) : "rm" (x), "rm" (-1)); | ||
412 | return r+1; | ||
413 | } | ||
414 | |||
415 | /** | ||
400 | * hweightN - returns the hamming weight of a N-bit word | 416 | * hweightN - returns the hamming weight of a N-bit word |
401 | * @x: the word to weigh | 417 | * @x: the word to weigh |
402 | * | 418 | * |
@@ -434,9 +450,6 @@ static __inline__ int fls64(__u64 x) | |||
434 | #define minix_find_first_zero_bit(addr,size) \ | 450 | #define minix_find_first_zero_bit(addr,size) \ |
435 | find_first_zero_bit((void*)addr,size) | 451 | find_first_zero_bit((void*)addr,size) |
436 | 452 | ||
437 | /* find last set bit */ | ||
438 | #define fls(x) generic_fls(x) | ||
439 | |||
440 | #endif /* __KERNEL__ */ | 453 | #endif /* __KERNEL__ */ |
441 | 454 | ||
442 | #endif /* _X86_64_BITOPS_H */ | 455 | #endif /* _X86_64_BITOPS_H */ |