Files

44 lines
960 B
C
Raw Permalink Normal View History

/* SPDX-License-Identifier: GPL-2.0 */
2019-07-21 13:24:44 +02:00
#ifndef __LIBPERF_INTERNAL_XYARRAY_H
#define __LIBPERF_INTERNAL_XYARRAY_H
2011-01-03 16:39:04 -02:00
#include <linux/compiler.h>
2011-01-03 16:39:04 -02:00
#include <sys/types.h>
struct xyarray {
size_t row_size;
size_t entry_size;
size_t entries;
2017-08-11 16:26:16 -07:00
size_t max_x;
size_t max_y;
char contents[] __aligned(8);
2011-01-03 16:39:04 -02:00
};
struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
void xyarray__delete(struct xyarray *xy);
void xyarray__reset(struct xyarray *xy);
2011-01-03 16:39:04 -02:00
static inline void *__xyarray__entry(struct xyarray *xy, int x, int y)
2011-01-03 16:39:04 -02:00
{
return &xy->contents[x * xy->row_size + y * xy->entry_size];
}
static inline void *xyarray__entry(struct xyarray *xy, size_t x, size_t y)
{
if (x >= xy->max_x || y >= xy->max_y)
return NULL;
return __xyarray__entry(xy, x, y);
}
2017-08-11 16:26:16 -07:00
static inline int xyarray__max_y(struct xyarray *xy)
{
return xy->max_y;
2017-08-11 16:26:16 -07:00
}
static inline int xyarray__max_x(struct xyarray *xy)
{
return xy->max_x;
2017-08-11 16:26:16 -07:00
}
2019-07-21 13:24:44 +02:00
#endif /* __LIBPERF_INTERNAL_XYARRAY_H */