aboutsummaryrefslogtreecommitdiffstats
path: root/tools/include/asm-generic/bitops/atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/include/asm-generic/bitops/atomic.h')
-rw-r--r--tools/include/asm-generic/bitops/atomic.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/include/asm-generic/bitops/atomic.h b/tools/include/asm-generic/bitops/atomic.h
new file mode 100644
index 000000000000..4bccd7c3d5d6
--- /dev/null
+++ b/tools/include/asm-generic/bitops/atomic.h
@@ -0,0 +1,22 @@
1#ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_
2#define _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_
3
4#include <asm/types.h>
5
6static inline void set_bit(int nr, unsigned long *addr)
7{
8 addr[nr / __BITS_PER_LONG] |= 1UL << (nr % __BITS_PER_LONG);
9}
10
11static inline void clear_bit(int nr, unsigned long *addr)
12{
13 addr[nr / __BITS_PER_LONG] &= ~(1UL << (nr % __BITS_PER_LONG));
14}
15
16static __always_inline int test_bit(unsigned int nr, const unsigned long *addr)
17{
18 return ((1UL << (nr % __BITS_PER_LONG)) &
19 (((unsigned long *)addr)[nr / __BITS_PER_LONG])) != 0;
20}
21
22#endif /* _TOOLS_LINUX_ASM_GENERIC_BITOPS_ATOMIC_H_ */