Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __LIBPERF_INTERNAL_XYARRAY_H
0003 #define __LIBPERF_INTERNAL_XYARRAY_H
0004 
0005 #include <linux/compiler.h>
0006 #include <sys/types.h>
0007 
0008 struct xyarray {
0009     size_t row_size;
0010     size_t entry_size;
0011     size_t entries;
0012     size_t max_x;
0013     size_t max_y;
0014     char contents[] __aligned(8);
0015 };
0016 
0017 struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
0018 void xyarray__delete(struct xyarray *xy);
0019 void xyarray__reset(struct xyarray *xy);
0020 
0021 static inline void *__xyarray__entry(struct xyarray *xy, int x, int y)
0022 {
0023     return &xy->contents[x * xy->row_size + y * xy->entry_size];
0024 }
0025 
0026 static inline void *xyarray__entry(struct xyarray *xy, size_t x, size_t y)
0027 {
0028     if (x >= xy->max_x || y >= xy->max_y)
0029         return NULL;
0030     return __xyarray__entry(xy, x, y);
0031 }
0032 
0033 static inline int xyarray__max_y(struct xyarray *xy)
0034 {
0035     return xy->max_y;
0036 }
0037 
0038 static inline int xyarray__max_x(struct xyarray *xy)
0039 {
0040     return xy->max_x;
0041 }
0042 
0043 #endif /* __LIBPERF_INTERNAL_XYARRAY_H */