diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-01-08 10:33:37 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-01-08 10:35:46 -0500 |
commit | 915b0882c3108a21e9b3b5e176d3151ad522242d (patch) | |
tree | a14074f90fa12b1c0e3cca660397b8400cec58e7 /tools/perf | |
parent | 64af4e0da419ef9e9db0d34a3b5836adbf90a5e8 (diff) |
tools lib: Move bitmap.[ch] from tools/perf/ to tools/{lib,include}/
So that lib/find_bit.c doesn't requires anything inside tools/perf/
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: George Spelvin <linux@horizon.com
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Yury Norov <yury.norov@gmail.com>
Link: http://lkml.kernel.org/n/tip-7lxe7jgohaac5faodndhdmvk@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/Build | 5 | ||||
-rw-r--r-- | tools/perf/util/bitmap.c | 31 | ||||
-rw-r--r-- | tools/perf/util/include/linux/bitmap.h | 68 | ||||
-rw-r--r-- | tools/perf/util/python-ext-sources | 2 |
4 files changed, 6 insertions, 100 deletions
diff --git a/tools/perf/util/Build b/tools/perf/util/Build index e8bc10b41b66..5eec53a3f4ac 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build | |||
@@ -132,6 +132,7 @@ CFLAGS_pmu-bison.o += -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w | |||
132 | $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c | 132 | $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c |
133 | $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c | 133 | $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c |
134 | 134 | ||
135 | CFLAGS_bitmap.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" | ||
135 | CFLAGS_find_bit.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" | 136 | CFLAGS_find_bit.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" |
136 | CFLAGS_rbtree.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" | 137 | CFLAGS_rbtree.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" |
137 | CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" | 138 | CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))" |
@@ -142,6 +143,10 @@ $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE | |||
142 | $(call rule_mkdir) | 143 | $(call rule_mkdir) |
143 | $(call if_changed_dep,cc_o_c) | 144 | $(call if_changed_dep,cc_o_c) |
144 | 145 | ||
146 | $(OUTPUT)util/bitmap.o: ../lib/bitmap.c FORCE | ||
147 | $(call rule_mkdir) | ||
148 | $(call if_changed_dep,cc_o_c) | ||
149 | |||
145 | $(OUTPUT)util/find_bit.o: ../lib/find_bit.c FORCE | 150 | $(OUTPUT)util/find_bit.o: ../lib/find_bit.c FORCE |
146 | $(call rule_mkdir) | 151 | $(call rule_mkdir) |
147 | $(call if_changed_dep,cc_o_c) | 152 | $(call if_changed_dep,cc_o_c) |
diff --git a/tools/perf/util/bitmap.c b/tools/perf/util/bitmap.c deleted file mode 100644 index 0a1adc1111fd..000000000000 --- a/tools/perf/util/bitmap.c +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | /* | ||
2 | * From lib/bitmap.c | ||
3 | * Helper functions for bitmap.h. | ||
4 | * | ||
5 | * This source code is licensed under the GNU General Public License, | ||
6 | * Version 2. See the file COPYING for more details. | ||
7 | */ | ||
8 | #include <linux/bitmap.h> | ||
9 | |||
10 | int __bitmap_weight(const unsigned long *bitmap, int bits) | ||
11 | { | ||
12 | int k, w = 0, lim = bits/BITS_PER_LONG; | ||
13 | |||
14 | for (k = 0; k < lim; k++) | ||
15 | w += hweight_long(bitmap[k]); | ||
16 | |||
17 | if (bits % BITS_PER_LONG) | ||
18 | w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); | ||
19 | |||
20 | return w; | ||
21 | } | ||
22 | |||
23 | void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, | ||
24 | const unsigned long *bitmap2, int bits) | ||
25 | { | ||
26 | int k; | ||
27 | int nr = BITS_TO_LONGS(bits); | ||
28 | |||
29 | for (k = 0; k < nr; k++) | ||
30 | dst[k] = bitmap1[k] | bitmap2[k]; | ||
31 | } | ||
diff --git a/tools/perf/util/include/linux/bitmap.h b/tools/perf/util/include/linux/bitmap.h deleted file mode 100644 index 28f5493da491..000000000000 --- a/tools/perf/util/include/linux/bitmap.h +++ /dev/null | |||
@@ -1,68 +0,0 @@ | |||
1 | #ifndef _PERF_BITOPS_H | ||
2 | #define _PERF_BITOPS_H | ||
3 | |||
4 | #include <string.h> | ||
5 | #include <linux/bitops.h> | ||
6 | |||
7 | #define DECLARE_BITMAP(name,bits) \ | ||
8 | unsigned long name[BITS_TO_LONGS(bits)] | ||
9 | |||
10 | int __bitmap_weight(const unsigned long *bitmap, int bits); | ||
11 | void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, | ||
12 | const unsigned long *bitmap2, int bits); | ||
13 | |||
14 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) | ||
15 | |||
16 | #define BITMAP_LAST_WORD_MASK(nbits) \ | ||
17 | ( \ | ||
18 | ((nbits) % BITS_PER_LONG) ? \ | ||
19 | (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ | ||
20 | ) | ||
21 | |||
22 | #define small_const_nbits(nbits) \ | ||
23 | (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) | ||
24 | |||
25 | static inline void bitmap_zero(unsigned long *dst, int nbits) | ||
26 | { | ||
27 | if (small_const_nbits(nbits)) | ||
28 | *dst = 0UL; | ||
29 | else { | ||
30 | int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); | ||
31 | memset(dst, 0, len); | ||
32 | } | ||
33 | } | ||
34 | |||
35 | static inline int bitmap_weight(const unsigned long *src, int nbits) | ||
36 | { | ||
37 | if (small_const_nbits(nbits)) | ||
38 | return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits)); | ||
39 | return __bitmap_weight(src, nbits); | ||
40 | } | ||
41 | |||
42 | static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, | ||
43 | const unsigned long *src2, int nbits) | ||
44 | { | ||
45 | if (small_const_nbits(nbits)) | ||
46 | *dst = *src1 | *src2; | ||
47 | else | ||
48 | __bitmap_or(dst, src1, src2, nbits); | ||
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 | static inline int test_and_set_bit(int nr, unsigned long *addr) | ||
57 | { | ||
58 | unsigned long mask = BIT_MASK(nr); | ||
59 | unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); | ||
60 | unsigned long old; | ||
61 | |||
62 | old = *p; | ||
63 | *p = old | mask; | ||
64 | |||
65 | return (old & mask) != 0; | ||
66 | } | ||
67 | |||
68 | #endif /* _PERF_BITOPS_H */ | ||
diff --git a/tools/perf/util/python-ext-sources b/tools/perf/util/python-ext-sources index f15d14fb35eb..8162ba0e2e57 100644 --- a/tools/perf/util/python-ext-sources +++ b/tools/perf/util/python-ext-sources | |||
@@ -10,7 +10,7 @@ util/ctype.c | |||
10 | util/evlist.c | 10 | util/evlist.c |
11 | util/evsel.c | 11 | util/evsel.c |
12 | util/cpumap.c | 12 | util/cpumap.c |
13 | util/bitmap.c | 13 | ../lib/bitmap.c |
14 | ../lib/find_bit.c | 14 | ../lib/find_bit.c |
15 | ../lib/hweight.c | 15 | ../lib/hweight.c |
16 | util/thread_map.c | 16 | util/thread_map.c |