diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-18 17:13:22 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-18 17:33:41 -0400 |
commit | de1e17b1d0c81be472039798698b517c8a68b516 (patch) | |
tree | 62dd99a543f9f37fb390be7ffc393907b9b82a1c /tools | |
parent | ad430729ae00dd63f7dcadbeb638e589bc03b5a3 (diff) |
tools: Copy the bitops files accessed from the kernel and check for drift
copy some more kernel files accessed from tools/, check for drift.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-omz8xdyvvxgjiuqzwj6ecm6j@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/include/asm-generic/bitops/__fls.h | 44 | ||||
-rw-r--r-- | tools/include/asm-generic/bitops/arch_hweight.h | 26 | ||||
-rw-r--r-- | tools/include/asm-generic/bitops/const_hweight.h | 44 | ||||
-rw-r--r-- | tools/include/asm-generic/bitops/fls.h | 42 | ||||
-rw-r--r-- | tools/include/asm-generic/bitops/fls64.h | 37 | ||||
-rw-r--r-- | tools/perf/MANIFEST | 5 | ||||
-rw-r--r-- | tools/perf/Makefile.perf | 15 |
7 files changed, 203 insertions, 10 deletions
diff --git a/tools/include/asm-generic/bitops/__fls.h b/tools/include/asm-generic/bitops/__fls.h index 494c9c615d1c..a60a7ccb6782 100644 --- a/tools/include/asm-generic/bitops/__fls.h +++ b/tools/include/asm-generic/bitops/__fls.h | |||
@@ -1 +1,43 @@ | |||
1 | #include "../../../../include/asm-generic/bitops/__fls.h" | 1 | #ifndef _ASM_GENERIC_BITOPS___FLS_H_ |
2 | #define _ASM_GENERIC_BITOPS___FLS_H_ | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | /** | ||
7 | * __fls - find last (most-significant) set bit in a long word | ||
8 | * @word: the word to search | ||
9 | * | ||
10 | * Undefined if no set bit exists, so code should check against 0 first. | ||
11 | */ | ||
12 | static __always_inline unsigned long __fls(unsigned long word) | ||
13 | { | ||
14 | int num = BITS_PER_LONG - 1; | ||
15 | |||
16 | #if BITS_PER_LONG == 64 | ||
17 | if (!(word & (~0ul << 32))) { | ||
18 | num -= 32; | ||
19 | word <<= 32; | ||
20 | } | ||
21 | #endif | ||
22 | if (!(word & (~0ul << (BITS_PER_LONG-16)))) { | ||
23 | num -= 16; | ||
24 | word <<= 16; | ||
25 | } | ||
26 | if (!(word & (~0ul << (BITS_PER_LONG-8)))) { | ||
27 | num -= 8; | ||
28 | word <<= 8; | ||
29 | } | ||
30 | if (!(word & (~0ul << (BITS_PER_LONG-4)))) { | ||
31 | num -= 4; | ||
32 | word <<= 4; | ||
33 | } | ||
34 | if (!(word & (~0ul << (BITS_PER_LONG-2)))) { | ||
35 | num -= 2; | ||
36 | word <<= 2; | ||
37 | } | ||
38 | if (!(word & (~0ul << (BITS_PER_LONG-1)))) | ||
39 | num -= 1; | ||
40 | return num; | ||
41 | } | ||
42 | |||
43 | #endif /* _ASM_GENERIC_BITOPS___FLS_H_ */ | ||
diff --git a/tools/include/asm-generic/bitops/arch_hweight.h b/tools/include/asm-generic/bitops/arch_hweight.h index 318bb2b202b0..6a211f40665c 100644 --- a/tools/include/asm-generic/bitops/arch_hweight.h +++ b/tools/include/asm-generic/bitops/arch_hweight.h | |||
@@ -1 +1,25 @@ | |||
1 | #include "../../../../include/asm-generic/bitops/arch_hweight.h" | 1 | #ifndef _ASM_GENERIC_BITOPS_ARCH_HWEIGHT_H_ |
2 | #define _ASM_GENERIC_BITOPS_ARCH_HWEIGHT_H_ | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | static inline unsigned int __arch_hweight32(unsigned int w) | ||
7 | { | ||
8 | return __sw_hweight32(w); | ||
9 | } | ||
10 | |||
11 | static inline unsigned int __arch_hweight16(unsigned int w) | ||
12 | { | ||
13 | return __sw_hweight16(w); | ||
14 | } | ||
15 | |||
16 | static inline unsigned int __arch_hweight8(unsigned int w) | ||
17 | { | ||
18 | return __sw_hweight8(w); | ||
19 | } | ||
20 | |||
21 | static inline unsigned long __arch_hweight64(__u64 w) | ||
22 | { | ||
23 | return __sw_hweight64(w); | ||
24 | } | ||
25 | #endif /* _ASM_GENERIC_BITOPS_HWEIGHT_H_ */ | ||
diff --git a/tools/include/asm-generic/bitops/const_hweight.h b/tools/include/asm-generic/bitops/const_hweight.h index 0afd644aff83..0a7e06623470 100644 --- a/tools/include/asm-generic/bitops/const_hweight.h +++ b/tools/include/asm-generic/bitops/const_hweight.h | |||
@@ -1 +1,43 @@ | |||
1 | #include "../../../../include/asm-generic/bitops/const_hweight.h" | 1 | #ifndef _ASM_GENERIC_BITOPS_CONST_HWEIGHT_H_ |
2 | #define _ASM_GENERIC_BITOPS_CONST_HWEIGHT_H_ | ||
3 | |||
4 | /* | ||
5 | * Compile time versions of __arch_hweightN() | ||
6 | */ | ||
7 | #define __const_hweight8(w) \ | ||
8 | ((unsigned int) \ | ||
9 | ((!!((w) & (1ULL << 0))) + \ | ||
10 | (!!((w) & (1ULL << 1))) + \ | ||
11 | (!!((w) & (1ULL << 2))) + \ | ||
12 | (!!((w) & (1ULL << 3))) + \ | ||
13 | (!!((w) & (1ULL << 4))) + \ | ||
14 | (!!((w) & (1ULL << 5))) + \ | ||
15 | (!!((w) & (1ULL << 6))) + \ | ||
16 | (!!((w) & (1ULL << 7))))) | ||
17 | |||
18 | #define __const_hweight16(w) (__const_hweight8(w) + __const_hweight8((w) >> 8 )) | ||
19 | #define __const_hweight32(w) (__const_hweight16(w) + __const_hweight16((w) >> 16)) | ||
20 | #define __const_hweight64(w) (__const_hweight32(w) + __const_hweight32((w) >> 32)) | ||
21 | |||
22 | /* | ||
23 | * Generic interface. | ||
24 | */ | ||
25 | #define hweight8(w) (__builtin_constant_p(w) ? __const_hweight8(w) : __arch_hweight8(w)) | ||
26 | #define hweight16(w) (__builtin_constant_p(w) ? __const_hweight16(w) : __arch_hweight16(w)) | ||
27 | #define hweight32(w) (__builtin_constant_p(w) ? __const_hweight32(w) : __arch_hweight32(w)) | ||
28 | #define hweight64(w) (__builtin_constant_p(w) ? __const_hweight64(w) : __arch_hweight64(w)) | ||
29 | |||
30 | /* | ||
31 | * Interface for known constant arguments | ||
32 | */ | ||
33 | #define HWEIGHT8(w) (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight8(w)) | ||
34 | #define HWEIGHT16(w) (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight16(w)) | ||
35 | #define HWEIGHT32(w) (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight32(w)) | ||
36 | #define HWEIGHT64(w) (BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + __const_hweight64(w)) | ||
37 | |||
38 | /* | ||
39 | * Type invariant interface to the compile time constant hweight functions. | ||
40 | */ | ||
41 | #define HWEIGHT(w) HWEIGHT64((u64)w) | ||
42 | |||
43 | #endif /* _ASM_GENERIC_BITOPS_CONST_HWEIGHT_H_ */ | ||
diff --git a/tools/include/asm-generic/bitops/fls.h b/tools/include/asm-generic/bitops/fls.h index 0e4995fa0248..0576d1f42f43 100644 --- a/tools/include/asm-generic/bitops/fls.h +++ b/tools/include/asm-generic/bitops/fls.h | |||
@@ -1 +1,41 @@ | |||
1 | #include "../../../../include/asm-generic/bitops/fls.h" | 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 __always_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/include/asm-generic/bitops/fls64.h b/tools/include/asm-generic/bitops/fls64.h index 35bee0071e78..b097cf8444e3 100644 --- a/tools/include/asm-generic/bitops/fls64.h +++ b/tools/include/asm-generic/bitops/fls64.h | |||
@@ -1 +1,36 @@ | |||
1 | #include "../../../../include/asm-generic/bitops/fls64.h" | 1 | #ifndef _ASM_GENERIC_BITOPS_FLS64_H_ |
2 | #define _ASM_GENERIC_BITOPS_FLS64_H_ | ||
3 | |||
4 | #include <asm/types.h> | ||
5 | |||
6 | /** | ||
7 | * fls64 - find last set bit in a 64-bit word | ||
8 | * @x: the word to search | ||
9 | * | ||
10 | * This is defined in a similar way as the libc and compiler builtin | ||
11 | * ffsll, but returns the position of the most significant set bit. | ||
12 | * | ||
13 | * fls64(value) returns 0 if value is 0 or the position of the last | ||
14 | * set bit if value is nonzero. The last (most significant) bit is | ||
15 | * at position 64. | ||
16 | */ | ||
17 | #if BITS_PER_LONG == 32 | ||
18 | static __always_inline int fls64(__u64 x) | ||
19 | { | ||
20 | __u32 h = x >> 32; | ||
21 | if (h) | ||
22 | return fls(h) + 32; | ||
23 | return fls(x); | ||
24 | } | ||
25 | #elif BITS_PER_LONG == 64 | ||
26 | static __always_inline int fls64(__u64 x) | ||
27 | { | ||
28 | if (x == 0) | ||
29 | return 0; | ||
30 | return __fls(x) + 1; | ||
31 | } | ||
32 | #else | ||
33 | #error BITS_PER_LONG not 32 or 64 | ||
34 | #endif | ||
35 | |||
36 | #endif /* _ASM_GENERIC_BITOPS_FLS64_H_ */ | ||
diff --git a/tools/perf/MANIFEST b/tools/perf/MANIFEST index e18df995bd3c..eeb2fdc3392f 100644 --- a/tools/perf/MANIFEST +++ b/tools/perf/MANIFEST | |||
@@ -77,11 +77,6 @@ tools/include/linux/stringify.h | |||
77 | tools/include/linux/types.h | 77 | tools/include/linux/types.h |
78 | tools/include/linux/err.h | 78 | tools/include/linux/err.h |
79 | tools/include/linux/bitmap.h | 79 | tools/include/linux/bitmap.h |
80 | include/asm-generic/bitops/arch_hweight.h | ||
81 | include/asm-generic/bitops/const_hweight.h | ||
82 | include/asm-generic/bitops/fls64.h | ||
83 | include/asm-generic/bitops/__fls.h | ||
84 | include/asm-generic/bitops/fls.h | ||
85 | include/linux/list.h | 80 | include/linux/list.h |
86 | include/linux/hash.h | 81 | include/linux/hash.h |
87 | tools/arch/*/include/uapi/asm/perf_regs.h | 82 | tools/arch/*/include/uapi/asm/perf_regs.h |
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index a129fbc1ed37..580f4e208c7a 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf | |||
@@ -411,6 +411,21 @@ $(PERF_IN): prepare FORCE | |||
411 | @(test -f ../../arch/arm64/include/uapi/asm/kvm.h && ( \ | 411 | @(test -f ../../arch/arm64/include/uapi/asm/kvm.h && ( \ |
412 | (diff -B ../arch/arm64/include/uapi/asm/kvm.h ../../arch/arm64/include/uapi/asm/kvm.h >/dev/null) \ | 412 | (diff -B ../arch/arm64/include/uapi/asm/kvm.h ../../arch/arm64/include/uapi/asm/kvm.h >/dev/null) \ |
413 | || echo "Warning: tools/arch/arm64/include/uapi/asm/kvm.h differs from kernel" >&2 )) || true | 413 | || echo "Warning: tools/arch/arm64/include/uapi/asm/kvm.h differs from kernel" >&2 )) || true |
414 | @(test -f ../../include/asm-generic/bitops/arch_hweight.h && ( \ | ||
415 | (diff -B ../include/asm-generic/bitops/arch_hweight.h ../../include/asm-generic/bitops/arch_hweight.h >/dev/null) \ | ||
416 | || echo "Warning: tools/include/asm-generic/bitops/arch_hweight.h differs from kernel" >&2 )) || true | ||
417 | @(test -f ../../include/asm-generic/bitops/const_hweight.h && ( \ | ||
418 | (diff -B ../include/asm-generic/bitops/const_hweight.h ../../include/asm-generic/bitops/const_hweight.h >/dev/null) \ | ||
419 | || echo "Warning: tools/include/asm-generic/bitops/const_hweight.h differs from kernel" >&2 )) || true | ||
420 | @(test -f ../../include/asm-generic/bitops/__fls.h && ( \ | ||
421 | (diff -B ../include/asm-generic/bitops/__fls.h ../../include/asm-generic/bitops/__fls.h >/dev/null) \ | ||
422 | || echo "Warning: tools/include/asm-generic/bitops/__fls.h differs from kernel" >&2 )) || true | ||
423 | @(test -f ../../include/asm-generic/bitops/fls.h && ( \ | ||
424 | (diff -B ../include/asm-generic/bitops/fls.h ../../include/asm-generic/bitops/fls.h >/dev/null) \ | ||
425 | || echo "Warning: tools/include/asm-generic/bitops/fls.h differs from kernel" >&2 )) || true | ||
426 | @(test -f ../../include/asm-generic/bitops/fls64.h && ( \ | ||
427 | (diff -B ../include/asm-generic/bitops/fls64.h ../../include/asm-generic/bitops/fls64.h >/dev/null) \ | ||
428 | || echo "Warning: tools/include/asm-generic/bitops/fls64.h differs from kernel" >&2 )) || true | ||
414 | $(Q)$(MAKE) $(build)=perf | 429 | $(Q)$(MAKE) $(build)=perf |
415 | 430 | ||
416 | $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST) | 431 | $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(LIBTRACEEVENT_DYNAMIC_LIST) |