1 #ifndef __ASM_SH_BITOPS_CAS_H
2 #define __ASM_SH_BITOPS_CAS_H
4 static inline unsigned __bo_cas(volatile unsigned *p
, unsigned old
, unsigned new)
6 __asm__
__volatile__("cas.l %1,%0,@r0"
13 static inline void set_bit(int nr
, volatile void *addr
)
16 volatile unsigned *a
= addr
;
19 mask
= 1U << (nr
& 0x1f);
22 while (__bo_cas(a
, old
, old
|mask
) != old
);
25 static inline void clear_bit(int nr
, volatile void *addr
)
28 volatile unsigned *a
= addr
;
31 mask
= 1U << (nr
& 0x1f);
34 while (__bo_cas(a
, old
, old
&~mask
) != old
);
37 static inline void change_bit(int nr
, volatile void *addr
)
40 volatile unsigned *a
= addr
;
43 mask
= 1U << (nr
& 0x1f);
46 while (__bo_cas(a
, old
, old
^mask
) != old
);
49 static inline int test_and_set_bit(int nr
, volatile void *addr
)
52 volatile unsigned *a
= addr
;
55 mask
= 1U << (nr
& 0x1f);
58 while (__bo_cas(a
, old
, old
|mask
) != old
);
60 return !!(old
& mask
);
63 static inline int test_and_clear_bit(int nr
, volatile void *addr
)
66 volatile unsigned *a
= addr
;
69 mask
= 1U << (nr
& 0x1f);
72 while (__bo_cas(a
, old
, old
&~mask
) != old
);
74 return !!(old
& mask
);
77 static inline int test_and_change_bit(int nr
, volatile void *addr
)
80 volatile unsigned *a
= addr
;
83 mask
= 1U << (nr
& 0x1f);
86 while (__bo_cas(a
, old
, old
^mask
) != old
);
88 return !!(old
& mask
);
91 #include <asm-generic/bitops/non-atomic.h>
93 #endif /* __ASM_SH_BITOPS_CAS_H */