1 #ifndef _ALPHA_BITOPS_H
2 #define _ALPHA_BITOPS_H
4 #ifndef _LINUX_BITOPS_H
5 #error only <linux/bitops.h> can be included directly
8 #include <asm/compiler.h>
9 #include <asm/barrier.h>
31 int *
m = ((
int *) addr) + (nr >> 5);
41 :
"=&r" (temp),
"=m" (*m)
42 :
"Ir" (1
UL << (nr & 31)),
"m" (*m));
49 __set_bit(
unsigned long nr,
volatile void * addr)
51 int *m = ((
int *) addr) + (nr >> 5);
56 #define smp_mb__before_clear_bit() smp_mb()
57 #define smp_mb__after_clear_bit() smp_mb()
60 clear_bit(
unsigned long nr,
volatile void * addr)
63 int *m = ((
int *) addr) + (nr >> 5);
73 :
"=&r" (temp),
"=m" (*m)
74 :
"Ir" (1
UL << (nr & 31)),
"m" (*m));
90 int *m = ((
int *) addr) + (nr >> 5);
92 *m &= ~(1 << (nr & 31));
103 change_bit(
unsigned long nr,
volatile void * addr)
106 int *m = ((
int *) addr) + (nr >> 5);
116 :
"=&r" (temp),
"=m" (*m)
117 :
"Ir" (1
UL << (nr & 31)),
"m" (*m));
126 int *m = ((
int *) addr) + (nr >> 5);
128 *m ^= 1 << (nr & 31);
134 unsigned long oldbit;
136 int *m = ((
int *) addr) + (nr >> 5);
155 :
"=&r" (temp),
"=m" (*m),
"=&r" (oldbit)
156 :
"Ir" (1
UL << (nr & 31)),
"m" (*m) :
"memory");
164 unsigned long oldbit;
166 int *m = ((
int *) addr) + (nr >> 5);
182 :
"=&r" (temp),
"=m" (*m),
"=&r" (oldbit)
183 :
"Ir" (1
UL << (nr & 31)),
"m" (*m) :
"memory");
194 unsigned long mask = 1 << (nr & 0x1f);
195 int *m = ((
int *) addr) + (nr >> 5);
199 return (old & mask) != 0;
205 unsigned long oldbit;
207 int *m = ((
int *) addr) + (nr >> 5);
226 :
"=&r" (temp),
"=m" (*m),
"=&r" (oldbit)
227 :
"Ir" (1
UL << (nr & 31)),
"m" (*m) :
"memory");
238 unsigned long mask = 1 << (nr & 0x1f);
239 int *m = ((
int *) addr) + (nr >> 5);
243 return (old & mask) != 0;
249 unsigned long oldbit;
251 int *m = ((
int *) addr) + (nr >> 5);
268 :
"=&r" (temp),
"=m" (*m),
"=&r" (oldbit)
269 :
"Ir" (1
UL << (nr & 31)),
"m" (*m) :
"memory");
280 unsigned long mask = 1 << (nr & 0x1f);
281 int *m = ((
int *) addr) + (nr >> 5);
285 return (old & mask) != 0;
289 test_bit(
int nr,
const volatile void * addr)
291 return (1
UL & (((
const int *) addr)[nr >> 5] >> (nr & 31))) != 0
UL;
301 static inline unsigned long ffz_b(
unsigned long x)
303 unsigned long sum, x1, x2, x4;
310 sum += (x4 != 0) * 4;
316 static inline unsigned long ffz(
unsigned long word)
318 #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
322 unsigned long bits, qofs, bofs;
329 return qofs*8 + bofs;
336 static inline unsigned long __ffs(
unsigned long word)
338 #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
342 unsigned long bits, qofs, bofs;
349 return qofs*8 + bofs;
361 static inline int ffs(
int word)
364 return word ? result : 0;
370 #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
371 static inline int fls64(
unsigned long word)
378 static inline int fls64(
unsigned long x)
380 unsigned long t,
a,
r;
385 r = a*8 + __flsm1_tab[
t] + (x != 0);
391 static inline unsigned long __fls(
unsigned long x)
396 static inline int fls(
int x)
398 return fls64((
unsigned int) x);
406 #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
408 static inline unsigned long __arch_hweight64(
unsigned long w)
413 static inline unsigned int __arch_hweight32(
unsigned int w)
415 return __arch_hweight64(w);
418 static inline unsigned int __arch_hweight16(
unsigned int w)
420 return __arch_hweight64(w & 0xffff);
423 static inline unsigned int __arch_hweight8(
unsigned int w)
425 return __arch_hweight64(w & 0xff);
444 static inline unsigned long
445 sched_find_first_bit(
const unsigned long b[2])
447 unsigned long b0, b1, ofs,
tmp;
452 tmp = (b0 ? b0 : b1);
454 return __ffs(tmp) + ofs;