0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOT_BITOPS_H
0014 #define BOOT_BITOPS_H
0015 #define _LINUX_BITOPS_H
0016
0017 #include <linux/types.h>
0018 #include <asm/asm.h>
0019
0020 static inline bool constant_test_bit(int nr, const void *addr)
0021 {
0022 const u32 *p = (const u32 *)addr;
0023 return ((1UL << (nr & 31)) & (p[nr >> 5])) != 0;
0024 }
0025 static inline bool variable_test_bit(int nr, const void *addr)
0026 {
0027 bool v;
0028 const u32 *p = (const u32 *)addr;
0029
0030 asm("btl %2,%1" CC_SET(c) : CC_OUT(c) (v) : "m" (*p), "Ir" (nr));
0031 return v;
0032 }
0033
0034 #define test_bit(nr,addr) \
0035 (__builtin_constant_p(nr) ? \
0036 constant_test_bit((nr),(addr)) : \
0037 variable_test_bit((nr),(addr)))
0038
0039 static inline void set_bit(int nr, void *addr)
0040 {
0041 asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
0042 }
0043
0044 #endif