Source file c_function_generated.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
module CI = Cstubs_internals

external _1_libbpf_major_version : unit -> Unsigned.uint32
  = "_1_libbpf_major_version" 

external _2_libbpf_minor_version : unit -> Unsigned.uint32
  = "_2_libbpf_minor_version" 

external _3_libbpf_version_string : unit -> CI.voidp
  = "_3_libbpf_version_string" 

external _4_libbpf_strerror : int -> _ CI.fatptr -> Unsigned.size_t -> int
  = "_4_libbpf_strerror" 

external _5_libbpf_bpf_attach_type_str : Unsigned.uint32 -> CI.voidp
  = "_5_libbpf_bpf_attach_type_str" 

external _6_libbpf_bpf_link_type_str : Unsigned.uint32 -> CI.voidp
  = "_6_libbpf_bpf_link_type_str" 

external _7_libbpf_bpf_map_type_str : Unsigned.uint32 -> CI.voidp
  = "_7_libbpf_bpf_map_type_str" 

external _8_libbpf_bpf_prog_type_str : Unsigned.uint32 -> CI.voidp
  = "_8_libbpf_bpf_prog_type_str" 

external _9_libbpf_set_print : _ CI.fatfunptr -> CI.voidp
  = "_9_libbpf_set_print" 

external _10_bpf_object__open : _ CI.fatptr -> CI.voidp
  = "_10_bpf_object__open" 

external _11_bpf_object__load : _ CI.fatptr -> int = "_11_bpf_object__load" 

external _12_bpf_object__find_program_by_name
  : _ CI.fatptr -> _ CI.fatptr -> CI.voidp
  = "_12_bpf_object__find_program_by_name" 

external _13_bpf_object__next_program
  : _ CI.fatptr -> _ CI.fatptr -> CI.voidp = "_13_bpf_object__next_program" 

external _14_bpf_program__pin : _ CI.fatptr -> _ CI.fatptr -> int
  = "_14_bpf_program__pin" 

external _15_bpf_program__unpin : _ CI.fatptr -> _ CI.fatptr -> int
  = "_15_bpf_program__unpin" 

external _16_bpf_program__attach : _ CI.fatptr -> CI.voidp
  = "_16_bpf_program__attach" 

external _17_bpf_program__fd : _ CI.fatptr -> int = "_17_bpf_program__fd" 

external _18_bpf_link__pin : _ CI.fatptr -> _ CI.fatptr -> int
  = "_18_bpf_link__pin" 

external _19_bpf_link__unpin : _ CI.fatptr -> int = "_19_bpf_link__unpin" 

external _20_bpf_link__destroy : _ CI.fatptr -> int = "_20_bpf_link__destroy" 

external _21_bpf_object__close : _ CI.fatptr -> unit
  = "_21_bpf_object__close" 

external _22_bpf_object__find_map_by_name
  : _ CI.fatptr -> _ CI.fatptr -> CI.voidp
  = "_22_bpf_object__find_map_by_name" 

external _23_bpf_map__fd : _ CI.fatptr -> int = "_23_bpf_map__fd" 

external _24_bpf_map__lookup_elem
  : _ CI.fatptr -> _ CI.fatptr -> Unsigned.size_t -> _ CI.fatptr ->
    Unsigned.size_t -> Unsigned.uint64 -> int
  = "_24_bpf_map__lookup_elem_byte6" "_24_bpf_map__lookup_elem" 

external _25_bpf_map__update_elem
  : _ CI.fatptr -> _ CI.fatptr -> Unsigned.size_t -> _ CI.fatptr ->
    Unsigned.size_t -> Unsigned.uint64 -> int
  = "_25_bpf_map__update_elem_byte6" "_25_bpf_map__update_elem" 

external _26_bpf_map__delete_elem
  : _ CI.fatptr -> _ CI.fatptr -> Unsigned.size_t -> Unsigned.uint64 -> int
  = "_26_bpf_map__delete_elem" 

external _27_bpf_tc_hook_create : _ CI.fatptr -> int
  = "_27_bpf_tc_hook_create" 

external _28_bpf_tc_hook_destroy : _ CI.fatptr -> int
  = "_28_bpf_tc_hook_destroy" 

external _29_bpf_tc_attach : _ CI.fatptr -> _ CI.fatptr -> int
  = "_29_bpf_tc_attach" 

external _30_bpf_tc_detach : _ CI.fatptr -> _ CI.fatptr -> int
  = "_30_bpf_tc_detach" 

external _31_ring_buffer__new
  : int -> _ CI.fatfunptr -> _ CI.fatptr -> _ CI.fatptr -> CI.voidp
  = "_31_ring_buffer__new" 

external _32_ring_buffer__poll : _ CI.fatptr -> int -> int
  = "_32_ring_buffer__poll" 

external _33_ring_buffer__free : _ CI.fatptr -> unit
  = "_33_ring_buffer__free" 

external _34_ring_buffer__consume : _ CI.fatptr -> int
  = "_34_ring_buffer__consume" 

external _35_ring_buffer__epoll_fd : _ CI.fatptr -> int
  = "_35_ring_buffer__epoll_fd" 

type 'a result = 'a
type 'a return = 'a
type 'a fn =
 | Returns  : 'a CI.typ   -> 'a return fn
 | Function : 'a CI.typ * 'b fn  -> ('a -> 'b) fn
let map_result f x = f x
let returning t = Returns t
let (@->) f p = Function (f, p)
let foreign : type a b. string -> (a -> b) fn -> (a -> b) =
  fun name t -> match t, name with
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)),
  "ring_buffer__epoll_fd" ->
  (fun x1 -> let CI.CPointer x2 = x1 in _35_ring_buffer__epoll_fd x2)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)),
  "ring_buffer__consume" ->
  (fun x3 -> let CI.CPointer x4 = x3 in _34_ring_buffer__consume x4)
| Function (CI.Pointer _, Returns CI.Void), "ring_buffer__free" ->
  (fun x5 -> let CI.CPointer x6 = x5 in _33_ring_buffer__free x6)
| Function
    (CI.Pointer _,
     Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int))),
  "ring_buffer__poll" ->
  (fun x7 x9 -> let CI.CPointer x8 = x7 in _32_ring_buffer__poll x8 x9)
| Function
    (CI.Primitive CI.Int,
     Function
       (CI.View {CI.ty = CI.Funptr _; write = x12; _},
        Function
          (CI.Pointer _,
           Function
             (CI.Pointer _,
              Returns (CI.View {CI.ty = CI.Pointer x19; read = x20; _}))))),
  "ring_buffer__new" ->
  (fun x10 x11 x15 x17 ->
    let CI.CPointer x18 = x17 in
    let CI.CPointer x16 = x15 in
    let CI.Static_funptr x14 = x12 x11 in
    let x13 = x14 in
    x20 (CI.make_ptr x19 (_31_ring_buffer__new x10 x13 x16 x18)))
| Function
    (CI.Pointer _, Function (CI.Pointer _, Returns (CI.Primitive CI.Int))),
  "bpf_tc_detach" ->
  (fun x21 x23 ->
    let CI.CPointer x24 = x23 in
    let CI.CPointer x22 = x21 in _30_bpf_tc_detach x22 x24)
| Function
    (CI.Pointer _, Function (CI.Pointer _, Returns (CI.Primitive CI.Int))),
  "bpf_tc_attach" ->
  (fun x25 x27 ->
    let CI.CPointer x28 = x27 in
    let CI.CPointer x26 = x25 in _29_bpf_tc_attach x26 x28)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)),
  "bpf_tc_hook_destroy" ->
  (fun x29 -> let CI.CPointer x30 = x29 in _28_bpf_tc_hook_destroy x30)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)),
  "bpf_tc_hook_create" ->
  (fun x31 -> let CI.CPointer x32 = x31 in _27_bpf_tc_hook_create x32)
| Function
    (CI.Pointer _,
     Function
       (CI.Pointer _,
        Function
          (CI.Primitive CI.Size_t,
           Function (CI.Primitive CI.Uint64_t, Returns (CI.Primitive CI.Int))))),
  "bpf_map__delete_elem" ->
  (fun x33 x35 x37 x38 ->
    let CI.CPointer x36 = x35 in
    let CI.CPointer x34 = x33 in _26_bpf_map__delete_elem x34 x36 x37 x38)
| Function
    (CI.Pointer _,
     Function
       (CI.Pointer _,
        Function
          (CI.Primitive CI.Size_t,
           Function
             (CI.Pointer _,
              Function
                (CI.Primitive CI.Size_t,
                 Function
                   (CI.Primitive CI.Uint64_t, Returns (CI.Primitive CI.Int))))))),
  "bpf_map__update_elem" ->
  (fun x39 x41 x43 x44 x46 x47 ->
    let CI.CPointer x45 = x44 in
    let CI.CPointer x42 = x41 in
    let CI.CPointer x40 = x39 in
    _25_bpf_map__update_elem x40 x42 x43 x45 x46 x47)
| Function
    (CI.Pointer _,
     Function
       (CI.Pointer _,
        Function
          (CI.Primitive CI.Size_t,
           Function
             (CI.Pointer _,
              Function
                (CI.Primitive CI.Size_t,
                 Function
                   (CI.Primitive CI.Uint64_t, Returns (CI.Primitive CI.Int))))))),
  "bpf_map__lookup_elem" ->
  (fun x48 x50 x52 x53 x55 x56 ->
    let CI.CPointer x54 = x53 in
    let CI.CPointer x51 = x50 in
    let CI.CPointer x49 = x48 in
    _24_bpf_map__lookup_elem x49 x51 x52 x54 x55 x56)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "bpf_map__fd" ->
  (fun x57 -> let CI.CPointer x58 = x57 in _23_bpf_map__fd x58)
| Function
    (CI.Pointer _,
     Function
       (CI.View {CI.ty = CI.Pointer _; write = x62; _},
        Returns (CI.View {CI.ty = CI.Pointer x65; read = x66; _}))),
  "bpf_object__find_map_by_name" ->
  (fun x59 x61 ->
    let CI.CPointer x64 = x62 x61 in
    let CI.CPointer x60 = x59 in
    let x63 = x64 in
    x66 (CI.make_ptr x65 (_22_bpf_object__find_map_by_name x60 x63)))
| Function (CI.Pointer _, Returns CI.Void), "bpf_object__close" ->
  (fun x67 -> let CI.CPointer x68 = x67 in _21_bpf_object__close x68)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "bpf_link__destroy" ->
  (fun x69 -> let CI.CPointer x70 = x69 in _20_bpf_link__destroy x70)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "bpf_link__unpin" ->
  (fun x71 -> let CI.CPointer x72 = x71 in _19_bpf_link__unpin x72)
| Function
    (CI.Pointer _, Function (CI.Pointer _, Returns (CI.Primitive CI.Int))),
  "bpf_link__pin" ->
  (fun x73 x75 ->
    let CI.CPointer x76 = x75 in
    let CI.CPointer x74 = x73 in _18_bpf_link__pin x74 x76)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "bpf_program__fd" ->
  (fun x77 -> let CI.CPointer x78 = x77 in _17_bpf_program__fd x78)
| Function
    (CI.Pointer _, Returns (CI.View {CI.ty = CI.Pointer x81; read = x82; _})),
  "bpf_program__attach" ->
  (fun x79 ->
    let CI.CPointer x80 = x79 in
    x82 (CI.make_ptr x81 (_16_bpf_program__attach x80)))
| Function
    (CI.Pointer _, Function (CI.Pointer _, Returns (CI.Primitive CI.Int))),
  "bpf_program__unpin" ->
  (fun x83 x85 ->
    let CI.CPointer x86 = x85 in
    let CI.CPointer x84 = x83 in _15_bpf_program__unpin x84 x86)
| Function
    (CI.Pointer _, Function (CI.Pointer _, Returns (CI.Primitive CI.Int))),
  "bpf_program__pin" ->
  (fun x87 x89 ->
    let CI.CPointer x90 = x89 in
    let CI.CPointer x88 = x87 in _14_bpf_program__pin x88 x90)
| Function (CI.Pointer _, Function (CI.Pointer _, Returns (CI.Pointer x95))),
  "bpf_object__next_program" ->
  (fun x91 x93 ->
    let CI.CPointer x94 = x93 in
    let CI.CPointer x92 = x91 in
    CI.make_ptr x95 (_13_bpf_object__next_program x92 x94))
| Function
    (CI.Pointer _,
     Function
       (CI.View {CI.ty = CI.Pointer _; write = x99; _},
        Returns (CI.View {CI.ty = CI.Pointer x102; read = x103; _}))),
  "bpf_object__find_program_by_name" ->
  (fun x96 x98 ->
    let CI.CPointer x101 = x99 x98 in
    let CI.CPointer x97 = x96 in
    let x100 = x101 in
    x103 (CI.make_ptr x102 (_12_bpf_object__find_program_by_name x97 x100)))
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "bpf_object__load" ->
  (fun x104 -> let CI.CPointer x105 = x104 in _11_bpf_object__load x105)
| Function
    (CI.View {CI.ty = CI.Pointer _; write = x107; _},
     Returns (CI.View {CI.ty = CI.Pointer x110; read = x111; _})),
  "bpf_object__open" ->
  (fun x106 ->
    let CI.CPointer x109 = x107 x106 in
    let x108 = x109 in x111 (CI.make_ptr x110 (_10_bpf_object__open x108)))
| Function
    (CI.View {CI.ty = CI.Funptr _; write = x113; _},
     Returns (CI.View {CI.ty = CI.Funptr x116; read = x117; _})),
  "libbpf_set_print" ->
  (fun x112 ->
    let CI.Static_funptr x115 = x113 x112 in
    let x114 = x115 in x117 (CI.make_fun_ptr x116 (_9_libbpf_set_print x114)))
| Function
    (CI.View {CI.ty = CI.Primitive CI.Uint32_t; write = x119; _},
     Returns (CI.View {CI.ty = CI.Pointer x121; read = x122; _})),
  "libbpf_bpf_prog_type_str" ->
  (fun x118 ->
    let x120 = x119 x118 in
    x122 (CI.make_ptr x121 (_8_libbpf_bpf_prog_type_str x120)))
| Function
    (CI.View {CI.ty = CI.Primitive CI.Uint32_t; write = x124; _},
     Returns (CI.View {CI.ty = CI.Pointer x126; read = x127; _})),
  "libbpf_bpf_map_type_str" ->
  (fun x123 ->
    let x125 = x124 x123 in
    x127 (CI.make_ptr x126 (_7_libbpf_bpf_map_type_str x125)))
| Function
    (CI.View {CI.ty = CI.Primitive CI.Uint32_t; write = x129; _},
     Returns (CI.View {CI.ty = CI.Pointer x131; read = x132; _})),
  "libbpf_bpf_link_type_str" ->
  (fun x128 ->
    let x130 = x129 x128 in
    x132 (CI.make_ptr x131 (_6_libbpf_bpf_link_type_str x130)))
| Function
    (CI.View {CI.ty = CI.Primitive CI.Uint32_t; write = x134; _},
     Returns (CI.View {CI.ty = CI.Pointer x136; read = x137; _})),
  "libbpf_bpf_attach_type_str" ->
  (fun x133 ->
    let x135 = x134 x133 in
    x137 (CI.make_ptr x136 (_5_libbpf_bpf_attach_type_str x135)))
| Function
    (CI.Primitive CI.Int,
     Function
       (CI.Pointer _,
        Function (CI.Primitive CI.Size_t, Returns (CI.Primitive CI.Int)))),
  "libbpf_strerror" ->
  (fun x138 x139 x141 ->
    let CI.CPointer x140 = x139 in _4_libbpf_strerror x138 x140 x141)
| Function
    (CI.Void, Returns (CI.View {CI.ty = CI.Pointer x143; read = x144; _})),
  "libbpf_version_string" ->
  (fun x142 -> x144 (CI.make_ptr x143 (_3_libbpf_version_string x142)))
| Function (CI.Void, Returns (CI.Primitive CI.Uint32_t)),
  "libbpf_minor_version" -> _2_libbpf_minor_version
| Function (CI.Void, Returns (CI.Primitive CI.Uint32_t)),
  "libbpf_major_version" -> _1_libbpf_major_version
| _, s ->  Printf.ksprintf failwith "No match for %s" s


let foreign_value : type a. string -> a Ctypes.typ -> a Ctypes.ptr =
  fun name t -> match t, name with
| _, s ->  Printf.ksprintf failwith "No match for %s" s