diff options
Diffstat (limited to 'tools/testing/radix-tree/linux')
24 files changed, 672 insertions, 0 deletions
diff --git a/tools/testing/radix-tree/linux/bitops.h b/tools/testing/radix-tree/linux/bitops.h new file mode 100644 index 000000000000..71d58427ab60 --- /dev/null +++ b/tools/testing/radix-tree/linux/bitops.h | |||
@@ -0,0 +1,150 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | |||
6 | #define BITOP_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | ||
7 | #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) | ||
8 | |||
9 | /** | ||
10 | * __set_bit - Set a bit in memory | ||
11 | * @nr: the bit to set | ||
12 | * @addr: the address to start counting from | ||
13 | * | ||
14 | * Unlike set_bit(), this function is non-atomic and may be reordered. | ||
15 | * If it's called on the same region of memory simultaneously, the effect | ||
16 | * may be that only one operation succeeds. | ||
17 | */ | ||
18 | static inline void __set_bit(int nr, volatile unsigned long *addr) | ||
19 | { | ||
20 | unsigned long mask = BITOP_MASK(nr); | ||
21 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
22 | |||
23 | *p |= mask; | ||
24 | } | ||
25 | |||
26 | static inline void __clear_bit(int nr, volatile unsigned long *addr) | ||
27 | { | ||
28 | unsigned long mask = BITOP_MASK(nr); | ||
29 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
30 | |||
31 | *p &= ~mask; | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * __change_bit - Toggle a bit in memory | ||
36 | * @nr: the bit to change | ||
37 | * @addr: the address to start counting from | ||
38 | * | ||
39 | * Unlike change_bit(), this function is non-atomic and may be reordered. | ||
40 | * If it's called on the same region of memory simultaneously, the effect | ||
41 | * may be that only one operation succeeds. | ||
42 | */ | ||
43 | static inline void __change_bit(int nr, volatile unsigned long *addr) | ||
44 | { | ||
45 | unsigned long mask = BITOP_MASK(nr); | ||
46 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
47 | |||
48 | *p ^= mask; | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * __test_and_set_bit - Set a bit and return its old value | ||
53 | * @nr: Bit to set | ||
54 | * @addr: Address to count from | ||
55 | * | ||
56 | * This operation is non-atomic and can be reordered. | ||
57 | * If two examples of this operation race, one can appear to succeed | ||
58 | * but actually fail. You must protect multiple accesses with a lock. | ||
59 | */ | ||
60 | static inline int __test_and_set_bit(int nr, volatile unsigned long *addr) | ||
61 | { | ||
62 | unsigned long mask = BITOP_MASK(nr); | ||
63 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
64 | unsigned long old = *p; | ||
65 | |||
66 | *p = old | mask; | ||
67 | return (old & mask) != 0; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * __test_and_clear_bit - Clear a bit and return its old value | ||
72 | * @nr: Bit to clear | ||
73 | * @addr: Address to count from | ||
74 | * | ||
75 | * This operation is non-atomic and can be reordered. | ||
76 | * If two examples of this operation race, one can appear to succeed | ||
77 | * but actually fail. You must protect multiple accesses with a lock. | ||
78 | */ | ||
79 | static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) | ||
80 | { | ||
81 | unsigned long mask = BITOP_MASK(nr); | ||
82 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
83 | unsigned long old = *p; | ||
84 | |||
85 | *p = old & ~mask; | ||
86 | return (old & mask) != 0; | ||
87 | } | ||
88 | |||
89 | /* WARNING: non atomic and it can be reordered! */ | ||
90 | static inline int __test_and_change_bit(int nr, | ||
91 | volatile unsigned long *addr) | ||
92 | { | ||
93 | unsigned long mask = BITOP_MASK(nr); | ||
94 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
95 | unsigned long old = *p; | ||
96 | |||
97 | *p = old ^ mask; | ||
98 | return (old & mask) != 0; | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | * test_bit - Determine whether a bit is set | ||
103 | * @nr: bit number to test | ||
104 | * @addr: Address to start counting from | ||
105 | */ | ||
106 | static inline int test_bit(int nr, const volatile unsigned long *addr) | ||
107 | { | ||
108 | return 1UL & (addr[BITOP_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); | ||
109 | } | ||
110 | |||
111 | /** | ||
112 | * __ffs - find first bit in word. | ||
113 | * @word: The word to search | ||
114 | * | ||
115 | * Undefined if no bit exists, so code should check against 0 first. | ||
116 | */ | ||
117 | static inline unsigned long __ffs(unsigned long word) | ||
118 | { | ||
119 | int num = 0; | ||
120 | |||
121 | if ((word & 0xffffffff) == 0) { | ||
122 | num += 32; | ||
123 | word >>= 32; | ||
124 | } | ||
125 | if ((word & 0xffff) == 0) { | ||
126 | num += 16; | ||
127 | word >>= 16; | ||
128 | } | ||
129 | if ((word & 0xff) == 0) { | ||
130 | num += 8; | ||
131 | word >>= 8; | ||
132 | } | ||
133 | if ((word & 0xf) == 0) { | ||
134 | num += 4; | ||
135 | word >>= 4; | ||
136 | } | ||
137 | if ((word & 0x3) == 0) { | ||
138 | num += 2; | ||
139 | word >>= 2; | ||
140 | } | ||
141 | if ((word & 0x1) == 0) | ||
142 | num += 1; | ||
143 | return num; | ||
144 | } | ||
145 | |||
146 | unsigned long find_next_bit(const unsigned long *addr, | ||
147 | unsigned long size, | ||
148 | unsigned long offset); | ||
149 | |||
150 | #endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */ | ||
diff --git a/tools/testing/radix-tree/linux/bitops/__ffs.h b/tools/testing/radix-tree/linux/bitops/__ffs.h new file mode 100644 index 000000000000..9a3274aecf83 --- /dev/null +++ b/tools/testing/radix-tree/linux/bitops/__ffs.h | |||
@@ -0,0 +1,43 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS___FFS_H_ | ||
2 | #define _ASM_GENERIC_BITOPS___FFS_H_ | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | /** | ||
7 | * __ffs - find first bit in word. | ||
8 | * @word: The word to search | ||
9 | * | ||
10 | * Undefined if no bit exists, so code should check against 0 first. | ||
11 | */ | ||
12 | static inline unsigned long __ffs(unsigned long word) | ||
13 | { | ||
14 | int num = 0; | ||
15 | |||
16 | #if BITS_PER_LONG == 64 | ||
17 | if ((word & 0xffffffff) == 0) { | ||
18 | num += 32; | ||
19 | word >>= 32; | ||
20 | } | ||
21 | #endif | ||
22 | if ((word & 0xffff) == 0) { | ||
23 | num += 16; | ||
24 | word >>= 16; | ||
25 | } | ||
26 | if ((word & 0xff) == 0) { | ||
27 | num += 8; | ||
28 | word >>= 8; | ||
29 | } | ||
30 | if ((word & 0xf) == 0) { | ||
31 | num += 4; | ||
32 | word >>= 4; | ||
33 | } | ||
34 | if ((word & 0x3) == 0) { | ||
35 | num += 2; | ||
36 | word >>= 2; | ||
37 | } | ||
38 | if ((word & 0x1) == 0) | ||
39 | num += 1; | ||
40 | return num; | ||
41 | } | ||
42 | |||
43 | #endif /* _ASM_GENERIC_BITOPS___FFS_H_ */ | ||
diff --git a/tools/testing/radix-tree/linux/bitops/ffs.h b/tools/testing/radix-tree/linux/bitops/ffs.h new file mode 100644 index 000000000000..fbbb43af7dc0 --- /dev/null +++ b/tools/testing/radix-tree/linux/bitops/ffs.h | |||
@@ -0,0 +1,41 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_FFS_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_FFS_H_ | ||
3 | |||
4 | /** | ||
5 | * ffs - find first bit set | ||
6 | * @x: the word to search | ||
7 | * | ||
8 | * This is defined the same way as | ||
9 | * the libc and compiler builtin ffs routines, therefore | ||
10 | * differs in spirit from the above ffz (man ffs). | ||
11 | */ | ||
12 | static inline int ffs(int x) | ||
13 | { | ||
14 | int r = 1; | ||
15 | |||
16 | if (!x) | ||
17 | return 0; | ||
18 | if (!(x & 0xffff)) { | ||
19 | x >>= 16; | ||
20 | r += 16; | ||
21 | } | ||
22 | if (!(x & 0xff)) { | ||
23 | x >>= 8; | ||
24 | r += 8; | ||
25 | } | ||
26 | if (!(x & 0xf)) { | ||
27 | x >>= 4; | ||
28 | r += 4; | ||
29 | } | ||
30 | if (!(x & 3)) { | ||
31 | x >>= 2; | ||
32 | r += 2; | ||
33 | } | ||
34 | if (!(x & 1)) { | ||
35 | x >>= 1; | ||
36 | r += 1; | ||
37 | } | ||
38 | return r; | ||
39 | } | ||
40 | |||
41 | #endif /* _ASM_GENERIC_BITOPS_FFS_H_ */ | ||
diff --git a/tools/testing/radix-tree/linux/bitops/ffz.h b/tools/testing/radix-tree/linux/bitops/ffz.h new file mode 100644 index 000000000000..6744bd4cdf46 --- /dev/null +++ b/tools/testing/radix-tree/linux/bitops/ffz.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_FFZ_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_FFZ_H_ | ||
3 | |||
4 | /* | ||
5 | * ffz - find first zero in word. | ||
6 | * @word: The word to search | ||
7 | * | ||
8 | * Undefined if no zero exists, so code should check against ~0UL first. | ||
9 | */ | ||
10 | #define ffz(x) __ffs(~(x)) | ||
11 | |||
12 | #endif /* _ASM_GENERIC_BITOPS_FFZ_H_ */ | ||
diff --git a/tools/testing/radix-tree/linux/bitops/find.h b/tools/testing/radix-tree/linux/bitops/find.h new file mode 100644 index 000000000000..72a51e5a12ef --- /dev/null +++ b/tools/testing/radix-tree/linux/bitops/find.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_FIND_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_FIND_H_ | ||
3 | |||
4 | extern unsigned long find_next_bit(const unsigned long *addr, unsigned long | ||
5 | size, unsigned long offset); | ||
6 | |||
7 | extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned | ||
8 | long size, unsigned long offset); | ||
9 | |||
10 | #define find_first_bit(addr, size) find_next_bit((addr), (size), 0) | ||
11 | #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) | ||
12 | |||
13 | #endif /*_ASM_GENERIC_BITOPS_FIND_H_ */ | ||
diff --git a/tools/testing/radix-tree/linux/bitops/fls.h b/tools/testing/radix-tree/linux/bitops/fls.h new file mode 100644 index 000000000000..850859bc5069 --- /dev/null +++ b/tools/testing/radix-tree/linux/bitops/fls.h | |||
@@ -0,0 +1,41 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_FLS_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_FLS_H_ | ||
3 | |||
4 | /** | ||
5 | * fls - find last (most-significant) bit set | ||
6 | * @x: the word to search | ||
7 | * | ||
8 | * This is defined the same way as ffs. | ||
9 | * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. | ||
10 | */ | ||
11 | |||
12 | static inline int fls(int x) | ||
13 | { | ||
14 | int r = 32; | ||
15 | |||
16 | if (!x) | ||
17 | return 0; | ||
18 | if (!(x & 0xffff0000u)) { | ||
19 | x <<= 16; | ||
20 | r -= 16; | ||
21 | } | ||
22 | if (!(x & 0xff000000u)) { | ||
23 | x <<= 8; | ||
24 | r -= 8; | ||
25 | } | ||
26 | if (!(x & 0xf0000000u)) { | ||
27 | x <<= 4; | ||
28 | r -= 4; | ||
29 | } | ||
30 | if (!(x & 0xc0000000u)) { | ||
31 | x <<= 2; | ||
32 | r -= 2; | ||
33 | } | ||
34 | if (!(x & 0x80000000u)) { | ||
35 | x <<= 1; | ||
36 | r -= 1; | ||
37 | } | ||
38 | return r; | ||
39 | } | ||
40 | |||
41 | #endif /* _ASM_GENERIC_BITOPS_FLS_H_ */ | ||
diff --git a/tools/testing/radix-tree/linux/bitops/fls64.h b/tools/testing/radix-tree/linux/bitops/fls64.h new file mode 100644 index 000000000000..1b6b17ce2428 --- /dev/null +++ b/tools/testing/radix-tree/linux/bitops/fls64.h | |||
@@ -0,0 +1,14 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_FLS64_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_FLS64_H_ | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | static inline int fls64(__u64 x) | ||
7 | { | ||
8 | __u32 h = x >> 32; | ||
9 | if (h) | ||
10 | return fls(h) + 32; | ||
11 | return fls(x); | ||
12 | } | ||
13 | |||
14 | #endif /* _ASM_GENERIC_BITOPS_FLS64_H_ */ | ||
diff --git a/tools/testing/radix-tree/linux/bitops/hweight.h b/tools/testing/radix-tree/linux/bitops/hweight.h new file mode 100644 index 000000000000..fbbc383771da --- /dev/null +++ b/tools/testing/radix-tree/linux/bitops/hweight.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_HWEIGHT_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_HWEIGHT_H_ | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | extern unsigned int hweight32(unsigned int w); | ||
7 | extern unsigned int hweight16(unsigned int w); | ||
8 | extern unsigned int hweight8(unsigned int w); | ||
9 | extern unsigned long hweight64(__u64 w); | ||
10 | |||
11 | #endif /* _ASM_GENERIC_BITOPS_HWEIGHT_H_ */ | ||
diff --git a/tools/testing/radix-tree/linux/bitops/le.h b/tools/testing/radix-tree/linux/bitops/le.h new file mode 100644 index 000000000000..b9c7e5d2d2ad --- /dev/null +++ b/tools/testing/radix-tree/linux/bitops/le.h | |||
@@ -0,0 +1,53 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_LE_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_LE_H_ | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | #include <asm/byteorder.h> | ||
6 | |||
7 | #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) | ||
8 | #define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) | ||
9 | |||
10 | #if defined(__LITTLE_ENDIAN) | ||
11 | |||
12 | #define generic_test_le_bit(nr, addr) test_bit(nr, addr) | ||
13 | #define generic___set_le_bit(nr, addr) __set_bit(nr, addr) | ||
14 | #define generic___clear_le_bit(nr, addr) __clear_bit(nr, addr) | ||
15 | |||
16 | #define generic_test_and_set_le_bit(nr, addr) test_and_set_bit(nr, addr) | ||
17 | #define generic_test_and_clear_le_bit(nr, addr) test_and_clear_bit(nr, addr) | ||
18 | |||
19 | #define generic___test_and_set_le_bit(nr, addr) __test_and_set_bit(nr, addr) | ||
20 | #define generic___test_and_clear_le_bit(nr, addr) __test_and_clear_bit(nr, addr) | ||
21 | |||
22 | #define generic_find_next_zero_le_bit(addr, size, offset) find_next_zero_bit(addr, size, offset) | ||
23 | |||
24 | #elif defined(__BIG_ENDIAN) | ||
25 | |||
26 | #define generic_test_le_bit(nr, addr) \ | ||
27 | test_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
28 | #define generic___set_le_bit(nr, addr) \ | ||
29 | __set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
30 | #define generic___clear_le_bit(nr, addr) \ | ||
31 | __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
32 | |||
33 | #define generic_test_and_set_le_bit(nr, addr) \ | ||
34 | test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
35 | #define generic_test_and_clear_le_bit(nr, addr) \ | ||
36 | test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
37 | |||
38 | #define generic___test_and_set_le_bit(nr, addr) \ | ||
39 | __test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
40 | #define generic___test_and_clear_le_bit(nr, addr) \ | ||
41 | __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) | ||
42 | |||
43 | extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, | ||
44 | unsigned long size, unsigned long offset); | ||
45 | |||
46 | #else | ||
47 | #error "Please fix <asm/byteorder.h>" | ||
48 | #endif | ||
49 | |||
50 | #define generic_find_first_zero_le_bit(addr, size) \ | ||
51 | generic_find_next_zero_le_bit((addr), (size), 0) | ||
52 | |||
53 | #endif /* _ASM_GENERIC_BITOPS_LE_H_ */ | ||
diff --git a/tools/testing/radix-tree/linux/bitops/non-atomic.h b/tools/testing/radix-tree/linux/bitops/non-atomic.h new file mode 100644 index 000000000000..46a825cf2ae1 --- /dev/null +++ b/tools/testing/radix-tree/linux/bitops/non-atomic.h | |||
@@ -0,0 +1,111 @@ | |||
1 | #ifndef _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ | ||
2 | #define _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | #define BITOP_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) | ||
7 | #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) | ||
8 | |||
9 | /** | ||
10 | * __set_bit - Set a bit in memory | ||
11 | * @nr: the bit to set | ||
12 | * @addr: the address to start counting from | ||
13 | * | ||
14 | * Unlike set_bit(), this function is non-atomic and may be reordered. | ||
15 | * If it's called on the same region of memory simultaneously, the effect | ||
16 | * may be that only one operation succeeds. | ||
17 | */ | ||
18 | static inline void __set_bit(int nr, volatile unsigned long *addr) | ||
19 | { | ||
20 | unsigned long mask = BITOP_MASK(nr); | ||
21 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
22 | |||
23 | *p |= mask; | ||
24 | } | ||
25 | |||
26 | static inline void __clear_bit(int nr, volatile unsigned long *addr) | ||
27 | { | ||
28 | unsigned long mask = BITOP_MASK(nr); | ||
29 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
30 | |||
31 | *p &= ~mask; | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * __change_bit - Toggle a bit in memory | ||
36 | * @nr: the bit to change | ||
37 | * @addr: the address to start counting from | ||
38 | * | ||
39 | * Unlike change_bit(), this function is non-atomic and may be reordered. | ||
40 | * If it's called on the same region of memory simultaneously, the effect | ||
41 | * may be that only one operation succeeds. | ||
42 | */ | ||
43 | static inline void __change_bit(int nr, volatile unsigned long *addr) | ||
44 | { | ||
45 | unsigned long mask = BITOP_MASK(nr); | ||
46 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
47 | |||
48 | *p ^= mask; | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * __test_and_set_bit - Set a bit and return its old value | ||
53 | * @nr: Bit to set | ||
54 | * @addr: Address to count from | ||
55 | * | ||
56 | * This operation is non-atomic and can be reordered. | ||
57 | * If two examples of this operation race, one can appear to succeed | ||
58 | * but actually fail. You must protect multiple accesses with a lock. | ||
59 | */ | ||
60 | static inline int __test_and_set_bit(int nr, volatile unsigned long *addr) | ||
61 | { | ||
62 | unsigned long mask = BITOP_MASK(nr); | ||
63 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
64 | unsigned long old = *p; | ||
65 | |||
66 | *p = old | mask; | ||
67 | return (old & mask) != 0; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * __test_and_clear_bit - Clear a bit and return its old value | ||
72 | * @nr: Bit to clear | ||
73 | * @addr: Address to count from | ||
74 | * | ||
75 | * This operation is non-atomic and can be reordered. | ||
76 | * If two examples of this operation race, one can appear to succeed | ||
77 | * but actually fail. You must protect multiple accesses with a lock. | ||
78 | */ | ||
79 | static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) | ||
80 | { | ||
81 | unsigned long mask = BITOP_MASK(nr); | ||
82 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
83 | unsigned long old = *p; | ||
84 | |||
85 | *p = old & ~mask; | ||
86 | return (old & mask) != 0; | ||
87 | } | ||
88 | |||
89 | /* WARNING: non atomic and it can be reordered! */ | ||
90 | static inline int __test_and_change_bit(int nr, | ||
91 | volatile unsigned long *addr) | ||
92 | { | ||
93 | unsigned long mask = BITOP_MASK(nr); | ||
94 | unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); | ||
95 | unsigned long old = *p; | ||
96 | |||
97 | *p = old ^ mask; | ||
98 | return (old & mask) != 0; | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | * test_bit - Determine whether a bit is set | ||
103 | * @nr: bit number to test | ||
104 | * @addr: Address to start counting from | ||
105 | */ | ||
106 | static inline int test_bit(int nr, const volatile unsigned long *addr) | ||
107 | { | ||
108 | return 1UL & (addr[BITOP_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); | ||
109 | } | ||
110 | |||
111 | #endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */ | ||
diff --git a/tools/testing/radix-tree/linux/bug.h b/tools/testing/radix-tree/linux/bug.h new file mode 100644 index 000000000000..ccbe444977df --- /dev/null +++ b/tools/testing/radix-tree/linux/bug.h | |||
@@ -0,0 +1 @@ | |||
#define WARN_ON_ONCE(x) assert(x) | |||
diff --git a/tools/testing/radix-tree/linux/cpu.h b/tools/testing/radix-tree/linux/cpu.h new file mode 100644 index 000000000000..60a40459f269 --- /dev/null +++ b/tools/testing/radix-tree/linux/cpu.h | |||
@@ -0,0 +1,34 @@ | |||
1 | |||
2 | #define hotcpu_notifier(a, b) | ||
3 | |||
4 | #define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */ | ||
5 | #define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */ | ||
6 | #define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */ | ||
7 | #define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */ | ||
8 | #define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */ | ||
9 | #define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */ | ||
10 | #define CPU_DYING 0x0008 /* CPU (unsigned)v not running any task, | ||
11 | * not handling interrupts, soon dead. | ||
12 | * Called on the dying cpu, interrupts | ||
13 | * are already disabled. Must not | ||
14 | * sleep, must not fail */ | ||
15 | #define CPU_POST_DEAD 0x0009 /* CPU (unsigned)v dead, cpu_hotplug | ||
16 | * lock is dropped */ | ||
17 | #define CPU_STARTING 0x000A /* CPU (unsigned)v soon running. | ||
18 | * Called on the new cpu, just before | ||
19 | * enabling interrupts. Must not sleep, | ||
20 | * must not fail */ | ||
21 | #define CPU_DYING_IDLE 0x000B /* CPU (unsigned)v dying, reached | ||
22 | * idle loop. */ | ||
23 | #define CPU_BROKEN 0x000C /* CPU (unsigned)v did not die properly, | ||
24 | * perhaps due to preemption. */ | ||
25 | #define CPU_TASKS_FROZEN 0x0010 | ||
26 | |||
27 | #define CPU_ONLINE_FROZEN (CPU_ONLINE | CPU_TASKS_FROZEN) | ||
28 | #define CPU_UP_PREPARE_FROZEN (CPU_UP_PREPARE | CPU_TASKS_FROZEN) | ||
29 | #define CPU_UP_CANCELED_FROZEN (CPU_UP_CANCELED | CPU_TASKS_FROZEN) | ||
30 | #define CPU_DOWN_PREPARE_FROZEN (CPU_DOWN_PREPARE | CPU_TASKS_FROZEN) | ||
31 | #define CPU_DOWN_FAILED_FROZEN (CPU_DOWN_FAILED | CPU_TASKS_FROZEN) | ||
32 | #define CPU_DEAD_FROZEN (CPU_DEAD | CPU_TASKS_FROZEN) | ||
33 | #define CPU_DYING_FROZEN (CPU_DYING | CPU_TASKS_FROZEN) | ||
34 | #define CPU_STARTING_FROZEN (CPU_STARTING | CPU_TASKS_FROZEN) | ||
diff --git a/tools/testing/radix-tree/linux/export.h b/tools/testing/radix-tree/linux/export.h new file mode 100644 index 000000000000..b6afd131998d --- /dev/null +++ b/tools/testing/radix-tree/linux/export.h | |||
@@ -0,0 +1,2 @@ | |||
1 | |||
2 | #define EXPORT_SYMBOL(sym) | ||
diff --git a/tools/testing/radix-tree/linux/gfp.h b/tools/testing/radix-tree/linux/gfp.h new file mode 100644 index 000000000000..0e37f7a760eb --- /dev/null +++ b/tools/testing/radix-tree/linux/gfp.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef _GFP_H | ||
2 | #define _GFP_H | ||
3 | |||
4 | #define __GFP_BITS_SHIFT 22 | ||
5 | #define __GFP_BITS_MASK ((gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) | ||
6 | #define __GFP_WAIT 1 | ||
7 | #define __GFP_ACCOUNT 0 | ||
8 | #define __GFP_NOWARN 0 | ||
9 | |||
10 | #endif | ||
diff --git a/tools/testing/radix-tree/linux/kernel.h b/tools/testing/radix-tree/linux/kernel.h new file mode 100644 index 000000000000..27d5fe41515a --- /dev/null +++ b/tools/testing/radix-tree/linux/kernel.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef _KERNEL_H | ||
2 | #define _KERNEL_H | ||
3 | |||
4 | #include <assert.h> | ||
5 | #include <string.h> | ||
6 | #include <stdio.h> | ||
7 | #include <stddef.h> | ||
8 | #include <limits.h> | ||
9 | |||
10 | #ifndef NULL | ||
11 | #define NULL 0 | ||
12 | #endif | ||
13 | |||
14 | #define BUG_ON(expr) assert(!(expr)) | ||
15 | #define __init | ||
16 | #define panic(expr) | ||
17 | #define printk printf | ||
18 | #define __force | ||
19 | #define likely(c) (c) | ||
20 | #define unlikely(c) (c) | ||
21 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) | ||
22 | |||
23 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) | ||
24 | |||
25 | #define container_of(ptr, type, member) ({ \ | ||
26 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | ||
27 | (type *)( (char *)__mptr - offsetof(type, member) );}) | ||
28 | #define min(a, b) ((a) < (b) ? (a) : (b)) | ||
29 | |||
30 | static inline int in_interrupt(void) | ||
31 | { | ||
32 | return 0; | ||
33 | } | ||
34 | #endif /* _KERNEL_H */ | ||
diff --git a/tools/testing/radix-tree/linux/kmemleak.h b/tools/testing/radix-tree/linux/kmemleak.h new file mode 100644 index 000000000000..155f112786c4 --- /dev/null +++ b/tools/testing/radix-tree/linux/kmemleak.h | |||
@@ -0,0 +1 @@ | |||
static inline void kmemleak_update_trace(const void *ptr) { } | |||
diff --git a/tools/testing/radix-tree/linux/mempool.h b/tools/testing/radix-tree/linux/mempool.h new file mode 100644 index 000000000000..6a2dc55b41d6 --- /dev/null +++ b/tools/testing/radix-tree/linux/mempool.h | |||
@@ -0,0 +1,16 @@ | |||
1 | |||
2 | #include <linux/slab.h> | ||
3 | |||
4 | typedef void *(mempool_alloc_t)(int gfp_mask, void *pool_data); | ||
5 | typedef void (mempool_free_t)(void *element, void *pool_data); | ||
6 | |||
7 | typedef struct { | ||
8 | mempool_alloc_t *alloc; | ||
9 | mempool_free_t *free; | ||
10 | void *data; | ||
11 | } mempool_t; | ||
12 | |||
13 | void *mempool_alloc(mempool_t *pool, int gfp_mask); | ||
14 | void mempool_free(void *element, mempool_t *pool); | ||
15 | mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn, | ||
16 | mempool_free_t *free_fn, void *pool_data); | ||
diff --git a/tools/testing/radix-tree/linux/notifier.h b/tools/testing/radix-tree/linux/notifier.h new file mode 100644 index 000000000000..70e4797d5a46 --- /dev/null +++ b/tools/testing/radix-tree/linux/notifier.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _NOTIFIER_H | ||
2 | #define _NOTIFIER_H | ||
3 | |||
4 | struct notifier_block; | ||
5 | |||
6 | #define NOTIFY_OK 0x0001 /* Suits me */ | ||
7 | |||
8 | #endif | ||
diff --git a/tools/testing/radix-tree/linux/percpu.h b/tools/testing/radix-tree/linux/percpu.h new file mode 100644 index 000000000000..5837f1d56f17 --- /dev/null +++ b/tools/testing/radix-tree/linux/percpu.h | |||
@@ -0,0 +1,7 @@ | |||
1 | |||
2 | #define DEFINE_PER_CPU(type, val) type val | ||
3 | |||
4 | #define __get_cpu_var(var) var | ||
5 | #define this_cpu_ptr(var) var | ||
6 | #define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); (ptr); }) | ||
7 | #define per_cpu(var, cpu) (*per_cpu_ptr(&(var), cpu)) | ||
diff --git a/tools/testing/radix-tree/linux/preempt.h b/tools/testing/radix-tree/linux/preempt.h new file mode 100644 index 000000000000..6210672e3baa --- /dev/null +++ b/tools/testing/radix-tree/linux/preempt.h | |||
@@ -0,0 +1,4 @@ | |||
1 | /* */ | ||
2 | |||
3 | #define preempt_disable() do { } while (0) | ||
4 | #define preempt_enable() do { } while (0) | ||
diff --git a/tools/testing/radix-tree/linux/radix-tree.h b/tools/testing/radix-tree/linux/radix-tree.h new file mode 100644 index 000000000000..ce694ddd4aea --- /dev/null +++ b/tools/testing/radix-tree/linux/radix-tree.h | |||
@@ -0,0 +1 @@ | |||
#include "../../../../include/linux/radix-tree.h" | |||
diff --git a/tools/testing/radix-tree/linux/rcupdate.h b/tools/testing/radix-tree/linux/rcupdate.h new file mode 100644 index 000000000000..f7129ea2a899 --- /dev/null +++ b/tools/testing/radix-tree/linux/rcupdate.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef _RCUPDATE_H | ||
2 | #define _RCUPDATE_H | ||
3 | |||
4 | #include <urcu.h> | ||
5 | |||
6 | #define rcu_dereference_raw(p) rcu_dereference(p) | ||
7 | #define rcu_dereference_protected(p, cond) rcu_dereference(p) | ||
8 | |||
9 | #endif | ||
diff --git a/tools/testing/radix-tree/linux/slab.h b/tools/testing/radix-tree/linux/slab.h new file mode 100644 index 000000000000..57282506c21d --- /dev/null +++ b/tools/testing/radix-tree/linux/slab.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef SLAB_H | ||
2 | #define SLAB_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | |||
6 | #define GFP_KERNEL 1 | ||
7 | #define SLAB_HWCACHE_ALIGN 1 | ||
8 | #define SLAB_PANIC 2 | ||
9 | #define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */ | ||
10 | |||
11 | static inline int gfpflags_allow_blocking(gfp_t mask) | ||
12 | { | ||
13 | return 1; | ||
14 | } | ||
15 | |||
16 | struct kmem_cache { | ||
17 | int size; | ||
18 | void (*ctor)(void *); | ||
19 | }; | ||
20 | |||
21 | void *kmem_cache_alloc(struct kmem_cache *cachep, int flags); | ||
22 | void kmem_cache_free(struct kmem_cache *cachep, void *objp); | ||
23 | |||
24 | struct kmem_cache * | ||
25 | kmem_cache_create(const char *name, size_t size, size_t offset, | ||
26 | unsigned long flags, void (*ctor)(void *)); | ||
27 | |||
28 | #endif /* SLAB_H */ | ||
diff --git a/tools/testing/radix-tree/linux/types.h b/tools/testing/radix-tree/linux/types.h new file mode 100644 index 000000000000..72a9d85f6c76 --- /dev/null +++ b/tools/testing/radix-tree/linux/types.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef _TYPES_H | ||
2 | #define _TYPES_H | ||
3 | |||
4 | #define __rcu | ||
5 | #define __read_mostly | ||
6 | |||
7 | #define BITS_PER_LONG (sizeof(long) * 8) | ||
8 | |||
9 | struct list_head { | ||
10 | struct list_head *next, *prev; | ||
11 | }; | ||
12 | |||
13 | static inline void INIT_LIST_HEAD(struct list_head *list) | ||
14 | { | ||
15 | list->next = list; | ||
16 | list->prev = list; | ||
17 | } | ||
18 | |||
19 | typedef struct { | ||
20 | unsigned int x; | ||
21 | } spinlock_t; | ||
22 | |||
23 | #define uninitialized_var(x) x = x | ||
24 | |||
25 | typedef unsigned gfp_t; | ||
26 | #include <linux/gfp.h> | ||
27 | |||
28 | #endif | ||