Merge tag 'drm-misc-fixes-2017-11-20' of git://anongit.freedesktop.org/drm/drm-misc...
[linux-2.6-microblaze.git] / tools / perf / util / xyarray.h
1 #ifndef _PERF_XYARRAY_H_
2 #define _PERF_XYARRAY_H_ 1
3
4 #include <sys/types.h>
5
6 struct xyarray {
7         size_t row_size;
8         size_t entry_size;
9         size_t entries;
10         size_t max_x;
11         size_t max_y;
12         char contents[];
13 };
14
15 struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
16 void xyarray__delete(struct xyarray *xy);
17 void xyarray__reset(struct xyarray *xy);
18
19 static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
20 {
21         return &xy->contents[x * xy->row_size + y * xy->entry_size];
22 }
23
24 static inline int xyarray__max_y(struct xyarray *xy)
25 {
26         return xy->max_y;
27 }
28
29 static inline int xyarray__max_x(struct xyarray *xy)
30 {
31         return xy->max_x;
32 }
33
34 #endif /* _PERF_XYARRAY_H_ */