Commit 4b247fa7 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

libperf: Adopt xyarray class from perf

Move the xyarray class from perf to libperf, because it's going to be
used in both.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20190721112506.12306-58-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 453fa030
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
#include "util/parse-events.h" #include "util/parse-events.h"
#include "util/cpumap.h" #include "util/cpumap.h"
#include "util/xyarray.h"
#include "util/sort.h" #include "util/sort.h"
#include "util/string2.h" #include "util/string2.h"
#include "util/term.h" #include "util/term.h"
......
...@@ -4,6 +4,7 @@ libperf-y += threadmap.o ...@@ -4,6 +4,7 @@ libperf-y += threadmap.o
libperf-y += evsel.o libperf-y += evsel.o
libperf-y += evlist.o libperf-y += evlist.o
libperf-y += zalloc.o libperf-y += zalloc.o
libperf-y += xyarray.o
$(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE $(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE
$(call rule_mkdir) $(call rule_mkdir)
......
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0 */
#ifndef _PERF_XYARRAY_H_ #ifndef __LIBPERF_INTERNAL_XYARRAY_H
#define _PERF_XYARRAY_H_ 1 #define __LIBPERF_INTERNAL_XYARRAY_H
#include <sys/types.h> #include <sys/types.h>
...@@ -32,4 +32,4 @@ static inline int xyarray__max_x(struct xyarray *xy) ...@@ -32,4 +32,4 @@ static inline int xyarray__max_x(struct xyarray *xy)
return xy->max_x; return xy->max_x;
} }
#endif /* _PERF_XYARRAY_H_ */ #endif /* __LIBPERF_INTERNAL_XYARRAY_H */
// SPDX-License-Identifier: GPL-2.0
#include <internal/xyarray.h>
#include <linux/zalloc.h>
#include <stdlib.h>
#include <string.h>
struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
{
size_t row_size = ylen * entry_size;
struct xyarray *xy = zalloc(sizeof(*xy) + xlen * row_size);
if (xy != NULL) {
xy->entry_size = entry_size;
xy->row_size = row_size;
xy->entries = xlen * ylen;
xy->max_x = xlen;
xy->max_y = ylen;
}
return xy;
}
void xyarray__reset(struct xyarray *xy)
{
size_t n = xy->entries * xy->entry_size;
memset(xy->contents, 0, n);
}
void xyarray__delete(struct xyarray *xy)
{
free(xy);
}
...@@ -69,7 +69,6 @@ perf-y += svghelper.o ...@@ -69,7 +69,6 @@ perf-y += svghelper.o
perf-y += sort.o perf-y += sort.o
perf-y += hist.o perf-y += hist.o
perf-y += util.o perf-y += util.o
perf-y += xyarray.o
perf-y += cpumap.o perf-y += cpumap.o
perf-y += cputopo.o perf-y += cputopo.o
perf-y += cgroup.o perf-y += cgroup.o
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#ifndef __PERF_COUNTS_H #ifndef __PERF_COUNTS_H
#define __PERF_COUNTS_H #define __PERF_COUNTS_H
#include "xyarray.h" #include <internal/xyarray.h>
struct perf_counts_values { struct perf_counts_values {
union { union {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include <linux/types.h> #include <linux/types.h>
#include <internal/evsel.h> #include <internal/evsel.h>
#include "xyarray.h" #include <internal/xyarray.h>
#include "symbol_conf.h" #include "symbol_conf.h"
#include "cpumap.h" #include "cpumap.h"
#include "counts.h" #include "counts.h"
......
...@@ -20,7 +20,6 @@ util/namespaces.c ...@@ -20,7 +20,6 @@ util/namespaces.c
../lib/vsprintf.c ../lib/vsprintf.c
util/thread_map.c util/thread_map.c
util/util.c util/util.c
util/xyarray.c
util/cgroup.c util/cgroup.c
util/parse-branch-options.c util/parse-branch-options.c
util/rblist.c util/rblist.c
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "xyarray.h"
#include "rblist.h" #include "rblist.h"
#include "perf.h" #include "perf.h"
#include "event.h" #include "event.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment