]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - tools/perf/util/xyarray.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-bionic-kernel.git] / tools / perf / util / xyarray.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
69aad6f1
ACM
2#ifndef _PERF_XYARRAY_H_
3#define _PERF_XYARRAY_H_ 1
4
5#include <sys/types.h>
6
7struct xyarray {
8 size_t row_size;
9 size_t entry_size;
b45f65e8 10 size_t entries;
d74be476
AK
11 size_t max_x;
12 size_t max_y;
69aad6f1
ACM
13 char contents[];
14};
15
16struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
17void xyarray__delete(struct xyarray *xy);
b45f65e8 18void xyarray__reset(struct xyarray *xy);
69aad6f1
ACM
19
20static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
21{
22 return &xy->contents[x * xy->row_size + y * xy->entry_size];
23}
24
d74be476
AK
25static inline int xyarray__max_y(struct xyarray *xy)
26{
3d8bba95 27 return xy->max_y;
d74be476
AK
28}
29
30static inline int xyarray__max_x(struct xyarray *xy)
31{
3d8bba95 32 return xy->max_x;
d74be476
AK
33}
34
69aad6f1 35#endif /* _PERF_XYARRAY_H_ */