Commit d74be476 authored by Andi Kleen's avatar Andi Kleen Committed by Arnaldo Carvalho de Melo

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: default avatarAndi Kleen <ak@linux.intel.com>
Acked-by: default avatarJiri 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ba63f76e
...@@ -12,6 +12,8 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) ...@@ -12,6 +12,8 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
xy->entry_size = entry_size; xy->entry_size = entry_size;
xy->row_size = row_size; xy->row_size = row_size;
xy->entries = xlen * ylen; xy->entries = xlen * ylen;
xy->max_x = xlen;
xy->max_y = ylen;
} }
return xy; return xy;
......
...@@ -7,6 +7,8 @@ struct xyarray { ...@@ -7,6 +7,8 @@ struct xyarray {
size_t row_size; size_t row_size;
size_t entry_size; size_t entry_size;
size_t entries; size_t entries;
size_t max_x;
size_t max_y;
char contents[]; char contents[];
}; };
...@@ -19,4 +21,14 @@ static inline void *xyarray__entry(struct xyarray *xy, int x, int y) ...@@ -19,4 +21,14 @@ static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
return &xy->contents[x * xy->row_size + y * xy->entry_size]; return &xy->contents[x * xy->row_size + y * xy->entry_size];
} }
static inline int xyarray__max_y(struct xyarray *xy)
{
return xy->max_x;
}
static inline int xyarray__max_x(struct xyarray *xy)
{
return xy->max_y;
}
#endif /* _PERF_XYARRAY_H_ */ #endif /* _PERF_XYARRAY_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