1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
2 #ifndef __BPF_HELPERS__
3 #define __BPF_HELPERS__
5 #include "bpf_helper_defs.h"
7 #define __uint(name, val) int (*name)[val]
8 #define __type(name, val) typeof(val) *name
10 /* Helper macro to print out debug messages */
11 #define bpf_printk(fmt, ...) \
13 char ____fmt[] = fmt; \
14 bpf_trace_printk(____fmt, sizeof(____fmt), \
19 * Helper macro to place programs, maps, license in
20 * different sections in elf_bpf file. Section names
21 * are interpreted by elf_bpf loader
23 #define SEC(NAME) __attribute__((section(NAME), used))
25 #ifndef __always_inline
26 #define __always_inline __attribute__((always_inline))
29 #define __weak __attribute__((weak))
33 * Helper structure used by eBPF C program
34 * to describe BPF map attributes to libbpf loader
38 unsigned int key_size
;
39 unsigned int value_size
;
40 unsigned int max_entries
;
41 unsigned int map_flags
;
44 enum libbpf_pin_type
{
46 /* PIN_BY_NAME: pin maps by name (in /sys/fs/bpf by default) */
50 enum libbpf_tristate
{
56 #define __kconfig __attribute__((section(".kconfig")))