mirror of
https://gitee.com/openharmony/third_party_libbpf
synced 2024-10-07 22:43:33 +00:00
cb658e9724
This patch makes sure we build AF_XDP-related code as part of libbpf. This also required copying few uapi/linux headers and adding few used definitions in include headers. Signed-off-by: Andrii Nakryiko <andriin@fb.com>
45 lines
983 B
C
45 lines
983 B
C
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
|
|
|
|
#ifndef __LINUX_KERNEL_H
|
|
#define __LINUX_KERNEL_H
|
|
|
|
#ifndef offsetof
|
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
|
#endif
|
|
|
|
#ifndef container_of
|
|
#define container_of(ptr, type, member) ({ \
|
|
const typeof(((type *)0)->member) * __mptr = (ptr); \
|
|
(type *)((char *)__mptr - offsetof(type, member)); })
|
|
#endif
|
|
|
|
#ifndef max
|
|
#define max(x, y) ({ \
|
|
typeof(x) _max1 = (x); \
|
|
typeof(y) _max2 = (y); \
|
|
(void) (&_max1 == &_max2); \
|
|
_max1 > _max2 ? _max1 : _max2; })
|
|
#endif
|
|
|
|
#ifndef min
|
|
#define min(x, y) ({ \
|
|
typeof(x) _min1 = (x); \
|
|
typeof(y) _min2 = (y); \
|
|
(void) (&_min1 == &_min2); \
|
|
_min1 < _min2 ? _min1 : _min2; })
|
|
#endif
|
|
|
|
#ifndef roundup
|
|
#define roundup(x, y) ( \
|
|
{ \
|
|
const typeof(y) __y = y; \
|
|
(((x) + (__y - 1)) / __y) * __y; \
|
|
} \
|
|
)
|
|
#endif
|
|
|
|
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
|
#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
|
|
|
#endif
|