Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andi Kleen and committed by
Arnaldo Carvalho de Melo
d74be476 ba63f76e

+14
+2
tools/perf/util/xyarray.c
··· 12 12 xy->entry_size = entry_size; 13 13 xy->row_size = row_size; 14 14 xy->entries = xlen * ylen; 15 + xy->max_x = xlen; 16 + xy->max_y = ylen; 15 17 } 16 18 17 19 return xy;
+12
tools/perf/util/xyarray.h
··· 7 7 size_t row_size; 8 8 size_t entry_size; 9 9 size_t entries; 10 + size_t max_x; 11 + size_t max_y; 10 12 char contents[]; 11 13 }; 12 14 ··· 19 17 static inline void *xyarray__entry(struct xyarray *xy, int x, int y) 20 18 { 21 19 return &xy->contents[x * xy->row_size + y * xy->entry_size]; 20 + } 21 + 22 + static inline int xyarray__max_y(struct xyarray *xy) 23 + { 24 + return xy->max_x; 25 + } 26 + 27 + static inline int xyarray__max_x(struct xyarray *xy) 28 + { 29 + return xy->max_y; 22 30 } 23 31 24 32 #endif /* _PERF_XYARRAY_H_ */