xyarray.h 754 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _PERF_XYARRAY_H_
  3. #define _PERF_XYARRAY_H_ 1
  4. #include <linux/compiler.h>
  5. #include <sys/types.h>
  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[] __aligned(8);
  13. };
  14. struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
  15. void xyarray__delete(struct xyarray *xy);
  16. void xyarray__reset(struct xyarray *xy);
  17. static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
  18. {
  19. return &xy->contents[x * xy->row_size + y * xy->entry_size];
  20. }
  21. static inline int xyarray__max_y(struct xyarray *xy)
  22. {
  23. return xy->max_y;
  24. }
  25. static inline int xyarray__max_x(struct xyarray *xy)
  26. {
  27. return xy->max_x;
  28. }
  29. #endif /* _PERF_XYARRAY_H_ */