Arnaldo Carvalho de Melo | cae68d4 | 2014-12-15 16:44:26 -0300 | [diff] [blame] | 1 | #ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_ |
| 2 | #define _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_ |
| 3 | |
| 4 | #include <asm/types.h> |
Arnaldo Carvalho de Melo | bb97070 | 2016-07-12 11:12:18 -0300 | [diff] [blame] | 5 | #include <asm/bitsperlong.h> |
Arnaldo Carvalho de Melo | cae68d4 | 2014-12-15 16:44:26 -0300 | [diff] [blame] | 6 | |
| 7 | static inline void set_bit(int nr, unsigned long *addr) |
| 8 | { |
| 9 | addr[nr / __BITS_PER_LONG] |= 1UL << (nr % __BITS_PER_LONG); |
| 10 | } |
| 11 | |
| 12 | static inline void clear_bit(int nr, unsigned long *addr) |
| 13 | { |
| 14 | addr[nr / __BITS_PER_LONG] &= ~(1UL << (nr % __BITS_PER_LONG)); |
| 15 | } |
| 16 | |
| 17 | static __always_inline int test_bit(unsigned int nr, const unsigned long *addr) |
| 18 | { |
| 19 | return ((1UL << (nr % __BITS_PER_LONG)) & |
| 20 | (((unsigned long *)addr)[nr / __BITS_PER_LONG])) != 0; |
| 21 | } |
| 22 | |
Matthew Wilcox | c68a2aa | 2016-12-16 11:52:43 -0500 | [diff] [blame] | 23 | #define __set_bit(nr, addr) set_bit(nr, addr) |
| 24 | #define __clear_bit(nr, addr) clear_bit(nr, addr) |
| 25 | |
Arnaldo Carvalho de Melo | cae68d4 | 2014-12-15 16:44:26 -0300 | [diff] [blame] | 26 | #endif /* _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_ */ |