mirror of
https://github.com/torvalds/linux.git
synced 2024-12-15 23:51:46 +00:00
d74be47673
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>
35 lines
674 B
C
35 lines
674 B
C
#ifndef _PERF_XYARRAY_H_
|
|
#define _PERF_XYARRAY_H_ 1
|
|
|
|
#include <sys/types.h>
|
|
|
|
struct xyarray {
|
|
size_t row_size;
|
|
size_t entry_size;
|
|
size_t entries;
|
|
size_t max_x;
|
|
size_t max_y;
|
|
char contents[];
|
|
};
|
|
|
|
struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
|
|
void xyarray__delete(struct xyarray *xy);
|
|
void xyarray__reset(struct xyarray *xy);
|
|
|
|
static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
|
|
{
|
|
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_ */
|