diff options
author | Andi Kleen <ak@linux.intel.com> | 2017-08-11 19:26:16 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-08-22 10:51:28 -0400 |
commit | d74be47673676eded2f0bb8274e752bed32c42d8 (patch) | |
tree | 2711d906813ca52a32d2595b6f55fd27704fc529 | |
parent | ba63f76e22ee723819c8cec86b31f7ea3182b2ed (diff) |
perf xyarray: Save max_x, max_y
Save the original array dimensions in xyarrays, so that users can
retrieve them later. Add some inline functions to access these fields.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20170811232634.30465-1-andi@firstfloor.org
[ As noticed by Jiri, fix up namespacing: xy__method() -> xyarray__method() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/xyarray.c | 2 | ||||
-rw-r--r-- | tools/perf/util/xyarray.h | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c index 7251fdbabced..c8f415d9877b 100644 --- a/tools/perf/util/xyarray.c +++ b/tools/perf/util/xyarray.c | |||
@@ -12,6 +12,8 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) | |||
12 | xy->entry_size = entry_size; | 12 | xy->entry_size = entry_size; |
13 | xy->row_size = row_size; | 13 | xy->row_size = row_size; |
14 | xy->entries = xlen * ylen; | 14 | xy->entries = xlen * ylen; |
15 | xy->max_x = xlen; | ||
16 | xy->max_y = ylen; | ||
15 | } | 17 | } |
16 | 18 | ||
17 | return xy; | 19 | return xy; |
diff --git a/tools/perf/util/xyarray.h b/tools/perf/util/xyarray.h index 7f30af371b7e..4ba726c90870 100644 --- a/tools/perf/util/xyarray.h +++ b/tools/perf/util/xyarray.h | |||
@@ -7,6 +7,8 @@ struct xyarray { | |||
7 | size_t row_size; | 7 | size_t row_size; |
8 | size_t entry_size; | 8 | size_t entry_size; |
9 | size_t entries; | 9 | size_t entries; |
10 | size_t max_x; | ||
11 | size_t max_y; | ||
10 | char contents[]; | 12 | char contents[]; |
11 | }; | 13 | }; |
12 | 14 | ||
@@ -19,4 +21,14 @@ static inline void *xyarray__entry(struct xyarray *xy, int x, int y) | |||
19 | return &xy->contents[x * xy->row_size + y * xy->entry_size]; | 21 | return &xy->contents[x * xy->row_size + y * xy->entry_size]; |
20 | } | 22 | } |
21 | 23 | ||
24 | static inline int xyarray__max_y(struct xyarray *xy) | ||
25 | { | ||
26 | return xy->max_x; | ||
27 | } | ||
28 | |||
29 | static inline int xyarray__max_x(struct xyarray *xy) | ||
30 | { | ||
31 | return xy->max_y; | ||
32 | } | ||
33 | |||
22 | #endif /* _PERF_XYARRAY_H_ */ | 34 | #endif /* _PERF_XYARRAY_H_ */ |