aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-i386/bitops.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-i386/bitops.h')
-rw-r--r--include/asm-i386/bitops.h53
1 files changed, 33 insertions, 20 deletions
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
index ddf1739dc7fd..88e6ca248cd7 100644
--- a/include/asm-i386/bitops.h
+++ b/include/asm-i386/bitops.h
@@ -43,7 +43,7 @@ static inline void set_bit(int nr, volatile unsigned long * addr)
43{ 43{
44 __asm__ __volatile__( LOCK_PREFIX 44 __asm__ __volatile__( LOCK_PREFIX
45 "btsl %1,%0" 45 "btsl %1,%0"
46 :"=m" (ADDR) 46 :"+m" (ADDR)
47 :"Ir" (nr)); 47 :"Ir" (nr));
48} 48}
49 49
@@ -60,7 +60,7 @@ static inline void __set_bit(int nr, volatile unsigned long * addr)
60{ 60{
61 __asm__( 61 __asm__(
62 "btsl %1,%0" 62 "btsl %1,%0"
63 :"=m" (ADDR) 63 :"+m" (ADDR)
64 :"Ir" (nr)); 64 :"Ir" (nr));
65} 65}
66 66
@@ -78,7 +78,7 @@ static inline void clear_bit(int nr, volatile unsigned long * addr)
78{ 78{
79 __asm__ __volatile__( LOCK_PREFIX 79 __asm__ __volatile__( LOCK_PREFIX
80 "btrl %1,%0" 80 "btrl %1,%0"
81 :"=m" (ADDR) 81 :"+m" (ADDR)
82 :"Ir" (nr)); 82 :"Ir" (nr));
83} 83}
84 84
@@ -86,7 +86,7 @@ static inline void __clear_bit(int nr, volatile unsigned long * addr)
86{ 86{
87 __asm__ __volatile__( 87 __asm__ __volatile__(
88 "btrl %1,%0" 88 "btrl %1,%0"
89 :"=m" (ADDR) 89 :"+m" (ADDR)
90 :"Ir" (nr)); 90 :"Ir" (nr));
91} 91}
92#define smp_mb__before_clear_bit() barrier() 92#define smp_mb__before_clear_bit() barrier()
@@ -105,7 +105,7 @@ static inline void __change_bit(int nr, volatile unsigned long * addr)
105{ 105{
106 __asm__ __volatile__( 106 __asm__ __volatile__(
107 "btcl %1,%0" 107 "btcl %1,%0"
108 :"=m" (ADDR) 108 :"+m" (ADDR)
109 :"Ir" (nr)); 109 :"Ir" (nr));
110} 110}
111 111
@@ -123,7 +123,7 @@ static inline void change_bit(int nr, volatile unsigned long * addr)
123{ 123{
124 __asm__ __volatile__( LOCK_PREFIX 124 __asm__ __volatile__( LOCK_PREFIX
125 "btcl %1,%0" 125 "btcl %1,%0"
126 :"=m" (ADDR) 126 :"+m" (ADDR)
127 :"Ir" (nr)); 127 :"Ir" (nr));
128} 128}
129 129
@@ -142,7 +142,7 @@ static inline int test_and_set_bit(int nr, volatile unsigned long * addr)
142 142
143 __asm__ __volatile__( LOCK_PREFIX 143 __asm__ __volatile__( LOCK_PREFIX
144 "btsl %2,%1\n\tsbbl %0,%0" 144 "btsl %2,%1\n\tsbbl %0,%0"
145 :"=r" (oldbit),"=m" (ADDR) 145 :"=r" (oldbit),"+m" (ADDR)
146 :"Ir" (nr) : "memory"); 146 :"Ir" (nr) : "memory");
147 return oldbit; 147 return oldbit;
148} 148}
@@ -162,7 +162,7 @@ static inline int __test_and_set_bit(int nr, volatile unsigned long * addr)
162 162
163 __asm__( 163 __asm__(
164 "btsl %2,%1\n\tsbbl %0,%0" 164 "btsl %2,%1\n\tsbbl %0,%0"
165 :"=r" (oldbit),"=m" (ADDR) 165 :"=r" (oldbit),"+m" (ADDR)
166 :"Ir" (nr)); 166 :"Ir" (nr));
167 return oldbit; 167 return oldbit;
168} 168}
@@ -182,7 +182,7 @@ static inline int test_and_clear_bit(int nr, volatile unsigned long * addr)
182 182
183 __asm__ __volatile__( LOCK_PREFIX 183 __asm__ __volatile__( LOCK_PREFIX
184 "btrl %2,%1\n\tsbbl %0,%0" 184 "btrl %2,%1\n\tsbbl %0,%0"
185 :"=r" (oldbit),"=m" (ADDR) 185 :"=r" (oldbit),"+m" (ADDR)
186 :"Ir" (nr) : "memory"); 186 :"Ir" (nr) : "memory");
187 return oldbit; 187 return oldbit;
188} 188}
@@ -202,7 +202,7 @@ static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)
202 202
203 __asm__( 203 __asm__(
204 "btrl %2,%1\n\tsbbl %0,%0" 204 "btrl %2,%1\n\tsbbl %0,%0"
205 :"=r" (oldbit),"=m" (ADDR) 205 :"=r" (oldbit),"+m" (ADDR)
206 :"Ir" (nr)); 206 :"Ir" (nr));
207 return oldbit; 207 return oldbit;
208} 208}
@@ -214,7 +214,7 @@ static inline int __test_and_change_bit(int nr, volatile unsigned long *addr)
214 214
215 __asm__ __volatile__( 215 __asm__ __volatile__(
216 "btcl %2,%1\n\tsbbl %0,%0" 216 "btcl %2,%1\n\tsbbl %0,%0"
217 :"=r" (oldbit),"=m" (ADDR) 217 :"=r" (oldbit),"+m" (ADDR)
218 :"Ir" (nr) : "memory"); 218 :"Ir" (nr) : "memory");
219 return oldbit; 219 return oldbit;
220} 220}
@@ -233,7 +233,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long* addr)
233 233
234 __asm__ __volatile__( LOCK_PREFIX 234 __asm__ __volatile__( LOCK_PREFIX
235 "btcl %2,%1\n\tsbbl %0,%0" 235 "btcl %2,%1\n\tsbbl %0,%0"
236 :"=r" (oldbit),"=m" (ADDR) 236 :"=r" (oldbit),"+m" (ADDR)
237 :"Ir" (nr) : "memory"); 237 :"Ir" (nr) : "memory");
238 return oldbit; 238 return oldbit;
239} 239}
@@ -247,7 +247,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long* addr)
247static int test_bit(int nr, const volatile void * addr); 247static int test_bit(int nr, const volatile void * addr);
248#endif 248#endif
249 249
250static inline int constant_test_bit(int nr, const volatile unsigned long *addr) 250static __always_inline int constant_test_bit(int nr, const volatile unsigned long *addr)
251{ 251{
252 return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0; 252 return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0;
253} 253}
@@ -332,9 +332,9 @@ static inline unsigned long __ffs(unsigned long word)
332 * Returns the bit-number of the first set bit, not the number of the byte 332 * Returns the bit-number of the first set bit, not the number of the byte
333 * containing a bit. 333 * containing a bit.
334 */ 334 */
335static inline int find_first_bit(const unsigned long *addr, unsigned size) 335static inline unsigned find_first_bit(const unsigned long *addr, unsigned size)
336{ 336{
337 int x = 0; 337 unsigned x = 0;
338 338
339 while (x < size) { 339 while (x < size) {
340 unsigned long val = *addr++; 340 unsigned long val = *addr++;
@@ -367,11 +367,7 @@ static inline unsigned long ffz(unsigned long word)
367 return word; 367 return word;
368} 368}
369 369
370/* 370#define fls64(x) generic_fls64(x)
371 * fls: find last bit set.
372 */
373
374#define fls(x) generic_fls(x)
375 371
376#ifdef __KERNEL__ 372#ifdef __KERNEL__
377 373
@@ -414,6 +410,23 @@ static inline int ffs(int x)
414} 410}
415 411
416/** 412/**
413 * fls - find last bit set
414 * @x: the word to search
415 *
416 * This is defined the same way as ffs.
417 */
418static inline int fls(int x)
419{
420 int r;
421
422 __asm__("bsrl %1,%0\n\t"
423 "jnz 1f\n\t"
424 "movl $-1,%0\n"
425 "1:" : "=r" (r) : "rm" (x));
426 return r+1;
427}
428
429/**
417 * hweightN - returns the hamming weight of a N-bit word 430 * hweightN - returns the hamming weight of a N-bit word
418 * @x: the word to weigh 431 * @x: the word to weigh
419 * 432 *