diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-12-14 20:25:18 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-12-14 20:25:18 -0500 |
commit | a57cb1c1d7974c62a5c80f7869e35b492ace12cd (patch) | |
tree | 5a42ee9a668f171143464bc86013954c1bbe94ad /tools/testing/radix-tree/linux/bitops.h | |
parent | cf1b3341afab9d3ad02a76b3a619ea027dcf4e28 (diff) | |
parent | e1e14ab8411df344a17687821f8f78f0a1e73cbb (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton:
- a few misc things
- kexec updates
- DMA-mapping updates to better support networking DMA operations
- IPC updates
- various MM changes to improve DAX fault handling
- lots of radix-tree changes, mainly to the test suite. All leading up
to reimplementing the IDA/IDR code to be a wrapper layer over the
radix-tree. However the final trigger-pulling patch is held off for
4.11.
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (114 commits)
radix tree test suite: delete unused rcupdate.c
radix tree test suite: add new tag check
radix-tree: ensure counts are initialised
radix tree test suite: cache recently freed objects
radix tree test suite: add some more functionality
idr: reduce the number of bits per level from 8 to 6
rxrpc: abstract away knowledge of IDR internals
tpm: use idr_find(), not idr_find_slowpath()
idr: add ida_is_empty
radix tree test suite: check multiorder iteration
radix-tree: fix replacement for multiorder entries
radix-tree: add radix_tree_split_preload()
radix-tree: add radix_tree_split
radix-tree: add radix_tree_join
radix-tree: delete radix_tree_range_tag_if_tagged()
radix-tree: delete radix_tree_locate_item()
radix-tree: improve multiorder iterators
btrfs: fix race in btrfs_free_dummy_fs_info()
radix-tree: improve dump output
radix-tree: make radix_tree_find_next_bit more useful
...
Diffstat (limited to 'tools/testing/radix-tree/linux/bitops.h')
-rw-r--r-- | tools/testing/radix-tree/linux/bitops.h | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/tools/testing/radix-tree/linux/bitops.h b/tools/testing/radix-tree/linux/bitops.h index 71d58427ab60..a13e9bc76eec 100644 --- a/tools/testing/radix-tree/linux/bitops.h +++ b/tools/testing/radix-tree/linux/bitops.h | |||
@@ -2,9 +2,14 @@ | |||
2 | #define _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ | 2 | #define _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ |
3 | 3 | ||
4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
5 | #include <linux/bitops/find.h> | ||
6 | #include <linux/bitops/hweight.h> | ||
7 | #include <linux/kernel.h> | ||
5 | 8 | ||
6 | #define BITOP_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | 9 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) |
7 | #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) | 10 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) |
11 | #define BITS_PER_BYTE 8 | ||
12 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) | ||
8 | 13 | ||
9 | /** | 14 | /** |
10 | * __set_bit - Set a bit in memory | 15 | * __set_bit - Set a bit in memory |
@@ -17,16 +22,16 @@ | |||
17 | */ | 22 | */ |
18 | static inline void __set_bit(int nr, volatile unsigned long *addr) | 23 | static inline void __set_bit(int nr, volatile unsigned long *addr) |
19 | { | 24 | { |
20 | unsigned long mask = BITOP_MASK(nr); | 25 | unsigned long mask = BIT_MASK(nr); |
21 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 26 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
22 | 27 | ||
23 | *p |= mask; | 28 | *p |= mask; |
24 | } | 29 | } |
25 | 30 | ||
26 | static inline void __clear_bit(int nr, volatile unsigned long *addr) | 31 | static inline void __clear_bit(int nr, volatile unsigned long *addr) |
27 | { | 32 | { |
28 | unsigned long mask = BITOP_MASK(nr); | 33 | unsigned long mask = BIT_MASK(nr); |
29 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 34 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
30 | 35 | ||
31 | *p &= ~mask; | 36 | *p &= ~mask; |
32 | } | 37 | } |
@@ -42,8 +47,8 @@ static inline void __clear_bit(int nr, volatile unsigned long *addr) | |||
42 | */ | 47 | */ |
43 | static inline void __change_bit(int nr, volatile unsigned long *addr) | 48 | static inline void __change_bit(int nr, volatile unsigned long *addr) |
44 | { | 49 | { |
45 | unsigned long mask = BITOP_MASK(nr); | 50 | unsigned long mask = BIT_MASK(nr); |
46 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 51 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
47 | 52 | ||
48 | *p ^= mask; | 53 | *p ^= mask; |
49 | } | 54 | } |
@@ -59,8 +64,8 @@ static inline void __change_bit(int nr, volatile unsigned long *addr) | |||
59 | */ | 64 | */ |
60 | static inline int __test_and_set_bit(int nr, volatile unsigned long *addr) | 65 | static inline int __test_and_set_bit(int nr, volatile unsigned long *addr) |
61 | { | 66 | { |
62 | unsigned long mask = BITOP_MASK(nr); | 67 | unsigned long mask = BIT_MASK(nr); |
63 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 68 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
64 | unsigned long old = *p; | 69 | unsigned long old = *p; |
65 | 70 | ||
66 | *p = old | mask; | 71 | *p = old | mask; |
@@ -78,8 +83,8 @@ static inline int __test_and_set_bit(int nr, volatile unsigned long *addr) | |||
78 | */ | 83 | */ |
79 | static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) | 84 | static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) |
80 | { | 85 | { |
81 | unsigned long mask = BITOP_MASK(nr); | 86 | unsigned long mask = BIT_MASK(nr); |
82 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 87 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
83 | unsigned long old = *p; | 88 | unsigned long old = *p; |
84 | 89 | ||
85 | *p = old & ~mask; | 90 | *p = old & ~mask; |
@@ -90,8 +95,8 @@ static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) | |||
90 | static inline int __test_and_change_bit(int nr, | 95 | static inline int __test_and_change_bit(int nr, |
91 | volatile unsigned long *addr) | 96 | volatile unsigned long *addr) |
92 | { | 97 | { |
93 | unsigned long mask = BITOP_MASK(nr); | 98 | unsigned long mask = BIT_MASK(nr); |
94 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | 99 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); |
95 | unsigned long old = *p; | 100 | unsigned long old = *p; |
96 | 101 | ||
97 | *p = old ^ mask; | 102 | *p = old ^ mask; |
@@ -105,7 +110,7 @@ static inline int __test_and_change_bit(int nr, | |||
105 | */ | 110 | */ |
106 | static inline int test_bit(int nr, const volatile unsigned long *addr) | 111 | static inline int test_bit(int nr, const volatile unsigned long *addr) |
107 | { | 112 | { |
108 | return 1UL & (addr[BITOP_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); | 113 | return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); |
109 | } | 114 | } |
110 | 115 | ||
111 | /** | 116 | /** |
@@ -147,4 +152,9 @@ unsigned long find_next_bit(const unsigned long *addr, | |||
147 | unsigned long size, | 152 | unsigned long size, |
148 | unsigned long offset); | 153 | unsigned long offset); |
149 | 154 | ||
155 | static inline unsigned long hweight_long(unsigned long w) | ||
156 | { | ||
157 | return sizeof(w) == 4 ? hweight32(w) : hweight64(w); | ||
158 | } | ||
159 | |||
150 | #endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */ | 160 | #endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */ |