Path: blob/master/tools/lib/perf/include/internal/xyarray.h
26302 views
/* SPDX-License-Identifier: GPL-2.0 */1#ifndef __LIBPERF_INTERNAL_XYARRAY_H2#define __LIBPERF_INTERNAL_XYARRAY_H34#include <linux/compiler.h>5#include <sys/types.h>67struct xyarray {8size_t row_size;9size_t entry_size;10size_t entries;11size_t max_x;12size_t max_y;13char contents[] __aligned(8);14};1516struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);17void xyarray__delete(struct xyarray *xy);18void xyarray__reset(struct xyarray *xy);1920static inline void *__xyarray__entry(struct xyarray *xy, int x, int y)21{22return &xy->contents[x * xy->row_size + y * xy->entry_size];23}2425static inline void *xyarray__entry(struct xyarray *xy, size_t x, size_t y)26{27if (x >= xy->max_x || y >= xy->max_y)28return NULL;29return __xyarray__entry(xy, x, y);30}3132static inline int xyarray__max_y(struct xyarray *xy)33{34return xy->max_y;35}3637static inline int xyarray__max_x(struct xyarray *xy)38{39return xy->max_x;40}4142#endif /* __LIBPERF_INTERNAL_XYARRAY_H */434445