Debian Codegraph @

testdata/loader.h

raw symbols SCIP
1 /* BTF-style map definitions for loader.c */
2
3 #pragma once
4
5 #include "common.h"
6
7 struct {
8 __uint(type, BPF_MAP_TYPE_HASH);
9 __type(key, uint32_t);
10 __type(value, uint64_t);
11 __uint(max_entries, 1);
12 __uint(map_flags, BPF_F_NO_PREALLOC);
13 } hash_map __section(".maps");
14
15 struct {
16 __uint(type, BPF_MAP_TYPE_HASH);
17 __uint(key_size, sizeof(uint32_t));
18 __uint(value_size, sizeof(uint64_t));
19 __uint(max_entries, 2);
20 } hash_map2 __section(".maps");
21
22 struct {
23 __uint(type, BPF_MAP_TYPE_HASH);
24 __type(key, uint32_t);
25 __type(value, uint64_t);
26 __uint(max_entries, 1);
27 __uint(pinning, 1 /* LIBBPF_PIN_BY_NAME */);
28 } btf_pin __section(".maps");
29
30 // Named map type definition, without structure variable declaration.
31 struct inner_map_t {
32 __uint(type, BPF_MAP_TYPE_HASH);
33 __type(key, uint32_t);
34 __type(value, int);
35 __uint(max_entries, 1);
36 };
37
38 // Anonymous map type definition with structure variable declaration.
39 struct {
40 __uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
41 __uint(key_size, sizeof(uint32_t));
42 __uint(max_entries, 1);
43 __array(values, struct inner_map_t);
44 } btf_outer_map __section(".maps");
45
46 // Array of maps with anonymous inner struct.
47 struct {
48 __uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
49 __uint(key_size, sizeof(uint32_t));
50 __uint(max_entries, 1);
51 __array(
52 values, struct {
53 __uint(type, BPF_MAP_TYPE_HASH);
54 __uint(max_entries, 1);
55 __type(key, uint32_t);
56 __type(value, uint32_t);
57 });
58 } btf_outer_map_anon __section(".maps");
59
60 struct perf_event {
61 uint64_t foo;
62 uint64_t bar;
63 };
64
65 struct {
66 __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
67 __uint(max_entries, 4096);
68 __type(value, struct perf_event);
69 } perf_event_array __section(".maps");
70
71 typedef struct {
72 __uint(type, BPF_MAP_TYPE_ARRAY);
73 __uint(key_size, sizeof(uint32_t));
74 __uint(value_size, sizeof(uint64_t));
75 __uint(max_entries, 1);
76 } array_map_t;
77
78 // Map definition behind a typedef.
79 array_map_t btf_typedef_map __section(".maps");
80
81 #define __decl_tags __attribute__((btf_decl_tag("a"), btf_decl_tag("b")))
82
83 // Legacy map definition decorated with decl tags.
84 struct bpf_map_def bpf_decl_map __decl_tags __section("maps") = {
85 .type = BPF_MAP_TYPE_ARRAY,
86 .key_size = sizeof(uint32_t),
87 .value_size = sizeof(uint64_t),
88 .max_entries = 1,
89 };
90
91 // BTF map definition decorated with decl tags.
92 struct {
93 __uint(type, BPF_MAP_TYPE_ARRAY);
94 __uint(key_size, sizeof(uint32_t));
95 __uint(value_size, sizeof(uint64_t));
96 __uint(max_entries, 1);
97 } btf_decl_map __decl_tags __section(".maps");