-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbpf-utils.h
More file actions
22 lines (20 loc) · 757 Bytes
/
bpf-utils.h
File metadata and controls
22 lines (20 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#define SEC(name) __attribute__((section(name), used))
#define INLINE __attribute__((__always_inline__)) static inline
#define debug_printf(fmt, ...) do \
{ \
char _fmt[] = fmt; \
bpf_trace_printk(_fmt, sizeof(_fmt), ##__VA_ARGS__); \
} while (0)
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define ntohs(x) __builtin_bswap16(x)
#define htons(x) __builtin_bswap16(x)
#define ntohl(x) __builtin_bswap32(x)
#define htonl(x) __builtin_bswap32(x)
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define ntohs(x) (x)
#define htons(x) (x)
#define ntohl(x) (x)
#define htonl(x) (x)
#else
#error "Unknown __BYTE_ORDER__"
#endif