treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / lib / bpf / bpf_helpers.h
blobf69cc208778a2de76479b4458d8cf56b7127ec30
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, ...) \
12 ({ \
13 char ____fmt[] = fmt; \
14 bpf_trace_printk(____fmt, sizeof(____fmt), \
15 ##__VA_ARGS__); \
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))
27 #endif
28 #ifndef __weak
29 #define __weak __attribute__((weak))
30 #endif
33 * Helper structure used by eBPF C program
34 * to describe BPF map attributes to libbpf loader
36 struct bpf_map_def {
37 unsigned int type;
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 {
45 LIBBPF_PIN_NONE,
46 /* PIN_BY_NAME: pin maps by name (in /sys/fs/bpf by default) */
47 LIBBPF_PIN_BY_NAME,
50 enum libbpf_tristate {
51 TRI_NO = 0,
52 TRI_YES = 1,
53 TRI_MODULE = 2,
56 #define __kconfig __attribute__((section(".kconfig")))
58 #endif