Debian Codegraph @

docs/examples/variables/variables_bpfel.go

raw symbols SCIP
1 // Code generated by bpf2go; DO NOT EDIT.
2 //go:build 386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || ppc64le || riscv64 || wasm
3
4 package main
5
6 import (
7 "bytes"
8 _ "embed"
9 "fmt"
10 "io"
11
12 "github.com/cilium/ebpf"
13 )
14
15 // Names of all BPF objects in the ELF.
16 //
17 // Used for safe lookups in a Collection or CollectionSpec.
18 const (
19 variablesProgConstExample = "const_example"
20 variablesProgGlobalExample = "global_example"
21 variablesProgHiddenExample = "hidden_example"
22 variablesVarConstU32 = "const_u32"
23 variablesVarGlobalU16 = "global_u16"
24 )
25
26 // loadVariables returns the embedded CollectionSpec for variables.
27 func loadVariables() (*ebpf.CollectionSpec, error) {
28 reader := bytes.NewReader(_VariablesBytes)
29 spec, err := ebpf.LoadCollectionSpecFromReader(reader)
30 if err != nil {
31 return nil, fmt.Errorf("can't load variables: %w", err)
32 }
33
34 return spec, err
35 }
36
37 // loadVariablesObjects loads variables and converts it into a struct.
38 //
39 // The following types are suitable as obj argument:
40 //
41 // *variablesObjects
42 // *variablesPrograms
43 // *variablesMaps
44 //
45 // See ebpf.CollectionSpec.LoadAndAssign documentation for details.
46 func loadVariablesObjects(obj any, opts *ebpf.CollectionOptions) error {
47 spec, err := loadVariables()
48 if err != nil {
49 return err
50 }
51
52 return spec.LoadAndAssign(obj, opts)
53 }
54
55 // variablesSpecs contains maps and programs before they are loaded into the kernel.
56 //
57 // It can be passed ebpf.CollectionSpec.Assign.
58 type variablesSpecs struct {
59 variablesProgramSpecs
60 variablesMapSpecs
61 variablesVariableSpecs
62 }
63
64 // variablesProgramSpecs contains programs before they are loaded into the kernel.
65 //
66 // It can be passed ebpf.CollectionSpec.Assign.
67 type variablesProgramSpecs struct {
68 ConstExample *ebpf.ProgramSpec `ebpf:"const_example"`
69 GlobalExample *ebpf.ProgramSpec `ebpf:"global_example"`
70 HiddenExample *ebpf.ProgramSpec `ebpf:"hidden_example"`
71 }
72
73 // variablesMapSpecs contains maps before they are loaded into the kernel.
74 //
75 // It can be passed ebpf.CollectionSpec.Assign.
76 type variablesMapSpecs struct {
77 }
78
79 // variablesVariableSpecs contains global variables before they are loaded into the kernel.
80 //
81 // It can be passed ebpf.CollectionSpec.Assign.
82 type variablesVariableSpecs struct {
83 ConstU32 *ebpf.VariableSpec `ebpf:"const_u32"`
84 GlobalU16 *ebpf.VariableSpec `ebpf:"global_u16"`
85 }
86
87 // variablesObjects contains all objects after they have been loaded into the kernel.
88 //
89 // It can be passed to loadVariablesObjects or ebpf.CollectionSpec.LoadAndAssign.
90 type variablesObjects struct {
91 variablesPrograms
92 variablesMaps
93 variablesVariables
94 }
95
96 func (o *variablesObjects) Close() error {
97 return _VariablesClose(
98 &o.variablesPrograms,
99 &o.variablesMaps,
100 )
101 }
102
103 // variablesMaps contains all maps after they have been loaded into the kernel.
104 //
105 // It can be passed to loadVariablesObjects or ebpf.CollectionSpec.LoadAndAssign.
106 type variablesMaps struct {
107 }
108
109 func (m *variablesMaps) Close() error {
110 return _VariablesClose()
111 }
112
113 // variablesVariables contains all global variables after they have been loaded into the kernel.
114 //
115 // It can be passed to loadVariablesObjects or ebpf.CollectionSpec.LoadAndAssign.
116 type variablesVariables struct {
117 ConstU32 *ebpf.Variable `ebpf:"const_u32"`
118 GlobalU16 *ebpf.Variable `ebpf:"global_u16"`
119 }
120
121 // variablesPrograms contains all programs after they have been loaded into the kernel.
122 //
123 // It can be passed to loadVariablesObjects or ebpf.CollectionSpec.LoadAndAssign.
124 type variablesPrograms struct {
125 ConstExample *ebpf.Program `ebpf:"const_example"`
126 GlobalExample *ebpf.Program `ebpf:"global_example"`
127 HiddenExample *ebpf.Program `ebpf:"hidden_example"`
128 }
129
130 func (p *variablesPrograms) Close() error {
131 return _VariablesClose(
132 p.ConstExample,
133 p.GlobalExample,
134 p.HiddenExample,
135 )
136 }
137
138 func _VariablesClose(closers ...io.Closer) error {
139 for _, closer := range closers {
140 if err := closer.Close(); err != nil {
141 return err
142 }
143 }
144 return nil
145 }
146
147 // Do not access this directly.
148 //
149 //go:embed variables_bpfel.o
150 var _VariablesBytes []byte