History

libperf: Adopt xyarray class from perf

Move the xyarray class from perf to libperf, because it's going to be used in both.

Jiri Olsa committed 7 years ago

Commit 4b247fa1 parent 453fa039 files · +39 −9Browse files

Unified · Split

9 files
  1. tools/perf/builtin-top.c +0 −1
  2. tools/perf/lib/Build +1 −0
  3. tools/perf/lib/include/internal/xyarray.h +3 −3
  4. tools/perf/lib/xyarray.c +33 −0
  5. tools/perf/util/Build +0 −1
  6. tools/perf/util/counts.h +1 −1
  7. tools/perf/util/evsel.h +1 −1
  8. tools/perf/util/python-ext-sources +0 −1
  9. tools/perf/util/stat.h +0 −1
tools/perf/builtin-top.c+0−1
@@ -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"
tools/perf/lib/Build+1−0
@@ -4,6 +4,7 @@ libperf-y += threadmap.o · 3 unmodified lines
4libperf-y += evsel.o4libperf-y += evsel.o
5libperf-y += evlist.o5libperf-y += evlist.o
6libperf-y += zalloc.o6libperf-y += zalloc.o
7libperf-y += xyarray.o
7 8
8$(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE9$(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE
9 $(call rule_mkdir)10 $(call rule_mkdir)
tools/perf/lib/include/internal/xyarray.hrenamed from tools/perf/util/xyarray.h+3−3
@@ -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_ 13#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 */
tools/perf/lib/xyarray.c+33−0
@@ -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
7struct 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
23void xyarray__reset(struct xyarray *xy)
24{
25 size_t n = xy->entries * xy->entry_size;
26
27 memset(xy->contents, 0, n);
28}
29
30void xyarray__delete(struct xyarray *xy)
31{
32 free(xy);
33}
tools/perf/util/Build+0−1
@@ -69,7 +69,6 @@ perf-y += svghelper.o · 68 unmodified lines
69perf-y += sort.o69perf-y += sort.o
70perf-y += hist.o70perf-y += hist.o
71perf-y += util.o71perf-y += util.o
72perf-y += xyarray.o
73perf-y += cpumap.o72perf-y += cpumap.o
74perf-y += cputopo.o73perf-y += cputopo.o
75perf-y += cgroup.o74perf-y += cgroup.o
tools/perf/util/counts.h+1−1
@@ -2,7 +2,7 @@ · 1 unmodified line
2#ifndef __PERF_COUNTS_H2#ifndef __PERF_COUNTS_H
3#define __PERF_COUNTS_H3#define __PERF_COUNTS_H
4 4
5#include "xyarray.h"5#include <internal/xyarray.h>
6 6
7struct perf_counts_values {7struct perf_counts_values {
8 union {8 union {
tools/perf/util/evsel.h+1−1
@@ -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"
tools/perf/util/python-ext-sources+0−1
@@ -20,7 +20,6 @@ util/namespaces.c · 19 unmodified lines
20../lib/vsprintf.c20../lib/vsprintf.c
21util/thread_map.c21util/thread_map.c
22util/util.c22util/util.c
23util/xyarray.c
24util/cgroup.c23util/cgroup.c
25util/parse-branch-options.c24util/parse-branch-options.c
26util/rblist.c25util/rblist.c
tools/perf/util/stat.h+0−1
@@ -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"

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t