| 1 |
#pragma once |
| 2 |
|
| 3 |
typedef _Bool bool; |
| 4 |
typedef unsigned char uint8_t; |
| 5 |
typedef unsigned short uint16_t; |
| 6 |
typedef unsigned int uint32_t; |
| 7 |
typedef signed int int32_t; |
| 8 |
typedef unsigned long uint64_t; |
| 9 |
|
| 10 |
enum libbpf_tristate { |
| 11 |
TRI_NO = 0, |
| 12 |
TRI_YES = 1, |
| 13 |
TRI_MODULE = 2, |
| 14 |
}; |
| 15 |
|
| 16 |
#define ___bpf_concat(a, b) ____bpf_concat(a, b) |
| 17 |
#define ____bpf_concat(a, b) a ## b |
| 18 |
|
| 19 |
#define __section(NAME) __attribute__((section(NAME), used)) |
| 20 |
#define __uint(name, val) int(*name)[val] |
| 21 |
#define __type(name, val) typeof(val) *name |
| 22 |
#define __array(name, val) typeof(val) *name[] |
| 23 |
#define __ulong(name, val) enum { ___bpf_concat(__unique_value, __COUNTER__) = val } name |
| 24 |
|
| 25 |
#define __kconfig __attribute__((section(".kconfig"))) |
| 26 |
#define __ksym __attribute__((section(".ksyms"))) |
| 27 |
#define __noinline __attribute__((noinline)) |
| 28 |
#define __weak __attribute__((weak)) |
| 29 |
|
| 30 |
#define __hidden __attribute__((visibility("hidden"))) |
| 31 |
|
| 32 |
#define bpf_ksym_exists(sym) \ |
| 33 |
({ \ |
| 34 |
_Static_assert(!__builtin_constant_p(!!sym), #sym " should be marked as __weak"); \ |
| 35 |
!!sym; \ |
| 36 |
}) |
| 37 |
|
| 38 |
#define core_access __builtin_preserve_access_index |
| 39 |
|
| 40 |
#define BPF_MAP_TYPE_HASH (1) |
| 41 |
#define BPF_MAP_TYPE_ARRAY (2) |
| 42 |
#define BPF_MAP_TYPE_PROG_ARRAY (3) |
| 43 |
#define BPF_MAP_TYPE_PERF_EVENT_ARRAY (4) |
| 44 |
#define BPF_MAP_TYPE_ARRAY_OF_MAPS (12) |
| 45 |
#define BPF_MAP_TYPE_HASH_OF_MAPS (13) |
| 46 |
#define BPF_MAP_TYPE_ARENA (33) |
| 47 |
|
| 48 |
#define BPF_F_NO_PREALLOC (1U << 0) |
| 49 |
#define BPF_F_MMAPABLE (1U << 10) |
| 50 |
#define BPF_F_CURRENT_CPU (0xffffffffULL) |
| 51 |
|
| 52 |
|
| 53 |
struct bpf_map_def { |
| 54 |
unsigned int type; |
| 55 |
unsigned int key_size; |
| 56 |
unsigned int value_size; |
| 57 |
unsigned int max_entries; |
| 58 |
unsigned int map_flags; |
| 59 |
}; |
| 60 |
|
| 61 |
static void *(*bpf_map_lookup_elem)(const void *map, const void *key) = (void *)1; |
| 62 |
|
| 63 |
static long (*bpf_map_update_elem)(const void *map, const void *key, const void *value, uint64_t flags) = (void *)2; |
| 64 |
|
| 65 |
static long (*bpf_trace_printk)(const char *fmt, uint32_t fmt_size, ...) = (void *)6; |
| 66 |
|
| 67 |
static uint32_t (*bpf_get_smp_processor_id)(void) = (void *)8; |
| 68 |
|
| 69 |
static long (*bpf_tail_call)(void *ctx, void *prog_array_map, uint32_t index) = (void *)12; |
| 70 |
|
| 71 |
static int (*bpf_perf_event_output)(const void *ctx, const void *map, uint64_t index, const void *data, uint64_t size) = (void *)25; |
| 72 |
|
| 73 |
static void *(*bpf_get_current_task)() = (void *)35; |
| 74 |
|
| 75 |
static long (*bpf_probe_read_kernel)(void *dst, uint32_t size, const void *unsafe_ptr) = (void *)113; |
| 76 |
|
| 77 |
static long (*bpf_for_each_map_elem)(const void *map, void *callback_fn, void *callback_ctx, uint64_t flags) = (void *)164; |