Move the xyarray class from perf to libperf, because it's going to be used in both.
Unified · Split
| @@ -38,7 +38,6 @@ · 37 unmodified lines | |||
| 38 | #include <subcmd/parse-options.h> | 38 | #include <subcmd/parse-options.h> |
| 39 | #include "util/parse-events.h" | 39 | #include "util/parse-events.h" |
| 40 | #include "util/cpumap.h" | 40 | #include "util/cpumap.h" |
| 41 | #include "util/xyarray.h" | ||
| 42 | #include "util/sort.h" | 41 | #include "util/sort.h" |
| 43 | #include "util/string2.h" | 42 | #include "util/string2.h" |
| 44 | #include "util/term.h" | 43 | #include "util/term.h" |
| @@ -4,6 +4,7 @@ libperf-y += threadmap.o · 3 unmodified lines | |||
| 4 | libperf-y += evsel.o | 4 | libperf-y += evsel.o |
| 5 | libperf-y += evlist.o | 5 | libperf-y += evlist.o |
| 6 | libperf-y += zalloc.o | 6 | libperf-y += zalloc.o |
| 7 | libperf-y += xyarray.o | ||
| 7 | 8 | ||
| 8 | $(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE | 9 | $(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE |
| 9 | $(call rule_mkdir) | 10 | $(call rule_mkdir) |
| @@ -1,6 +1,6 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef _PERF_XYARRAY_H_ | 2 | #ifndef __LIBPERF_INTERNAL_XYARRAY_H |
| 3 | #define _PERF_XYARRAY_H_ 1 | 3 | #define __LIBPERF_INTERNAL_XYARRAY_H |
| 4 | 4 | ||
| 5 | #include <sys/types.h> | 5 | #include <sys/types.h> |
| 6 | 6 | ||
| @@ -32,4 +32,4 @@ static inline int xyarray__max_x(struct xyarray *xy) · 25 unmodified lines | |||
| 32 | return xy->max_x; | 32 | return xy->max_x; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | #endif /* _PERF_XYARRAY_H_ */ | 35 | #endif /* __LIBPERF_INTERNAL_XYARRAY_H */ |
| @@ -0,0 +1,33 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | ||
| 2 | #include <internal/xyarray.h> | ||
| 3 | #include <linux/zalloc.h> | ||
| 4 | #include <stdlib.h> | ||
| 5 | #include <string.h> | ||
| 6 | |||
| 7 | struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) | ||
| 8 | { | ||
| 9 | size_t row_size = ylen * entry_size; | ||
| 10 | struct xyarray *xy = zalloc(sizeof(*xy) + xlen * row_size); | ||
| 11 | |||
| 12 | if (xy != NULL) { | ||
| 13 | xy->entry_size = entry_size; | ||
| 14 | xy->row_size = row_size; | ||
| 15 | xy->entries = xlen * ylen; | ||
| 16 | xy->max_x = xlen; | ||
| 17 | xy->max_y = ylen; | ||
| 18 | } | ||
| 19 | |||
| 20 | return xy; | ||
| 21 | } | ||
| 22 | |||
| 23 | void xyarray__reset(struct xyarray *xy) | ||
| 24 | { | ||
| 25 | size_t n = xy->entries * xy->entry_size; | ||
| 26 | |||
| 27 | memset(xy->contents, 0, n); | ||
| 28 | } | ||
| 29 | |||
| 30 | void xyarray__delete(struct xyarray *xy) | ||
| 31 | { | ||
| 32 | free(xy); | ||
| 33 | } | ||
| @@ -69,7 +69,6 @@ perf-y += svghelper.o · 68 unmodified lines | |||
| 69 | perf-y += sort.o | 69 | perf-y += sort.o |
| 70 | perf-y += hist.o | 70 | perf-y += hist.o |
| 71 | perf-y += util.o | 71 | perf-y += util.o |
| 72 | perf-y += xyarray.o | ||
| 73 | perf-y += cpumap.o | 72 | perf-y += cpumap.o |
| 74 | perf-y += cputopo.o | 73 | perf-y += cputopo.o |
| 75 | perf-y += cgroup.o | 74 | perf-y += cgroup.o |
| @@ -2,7 +2,7 @@ · 1 unmodified line | |||
| 2 | #ifndef __PERF_COUNTS_H | 2 | #ifndef __PERF_COUNTS_H |
| 3 | #define __PERF_COUNTS_H | 3 | #define __PERF_COUNTS_H |
| 4 | 4 | ||
| 5 | #include "xyarray.h" | 5 | #include <internal/xyarray.h> |
| 6 | 6 | ||
| 7 | struct perf_counts_values { | 7 | struct perf_counts_values { |
| 8 | union { | 8 | union { |
| @@ -8,7 +8,7 @@ · 7 unmodified lines | |||
| 8 | #include <linux/perf_event.h> | 8 | #include <linux/perf_event.h> |
| 9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
| 10 | #include <internal/evsel.h> | 10 | #include <internal/evsel.h> |
| 11 | #include "xyarray.h" | 11 | #include <internal/xyarray.h> |
| 12 | #include "symbol_conf.h" | 12 | #include "symbol_conf.h" |
| 13 | #include "cpumap.h" | 13 | #include "cpumap.h" |
| 14 | #include "counts.h" | 14 | #include "counts.h" |
| @@ -20,7 +20,6 @@ util/namespaces.c · 19 unmodified lines | |||
| 20 | ../lib/vsprintf.c | 20 | ../lib/vsprintf.c |
| 21 | util/thread_map.c | 21 | util/thread_map.c |
| 22 | util/util.c | 22 | util/util.c |
| 23 | util/xyarray.c | ||
| 24 | util/cgroup.c | 23 | util/cgroup.c |
| 25 | util/parse-branch-options.c | 24 | util/parse-branch-options.c |
| 26 | util/rblist.c | 25 | util/rblist.c |
| @@ -8,7 +8,6 @@ · 7 unmodified lines | |||
| 8 | #include <sys/time.h> | 8 | #include <sys/time.h> |
| 9 | #include <sys/resource.h> | 9 | #include <sys/resource.h> |
| 10 | #include <sys/wait.h> | 10 | #include <sys/wait.h> |
| 11 | #include "xyarray.h" | ||
| 12 | #include "rblist.h" | 11 | #include "rblist.h" |
| 13 | #include "perf.h" | 12 | #include "perf.h" |
| 14 | #include "event.h" | 13 | #include "event.h" |