Debian Codegraph @

testsuite/systemtap.syscall/bpf.c

raw
1 /* COVERAGE: bpf */
2
3 #define _GNU_SOURCE
4 #include <unistd.h>
5 #include <sys/syscall.h>
6
7 #ifdef __NR_bpf
8
9 #include <linux/bpf.h>
10
11 static inline int __bpf(int cmd, union bpf_attr *attr, unsigned int size)
12 {
13 return syscall(__NR_bpf, cmd, attr, size);
14 }
15
16 int main()
17 {
18 int fd;
19
20 union bpf_attr attr = {
21 .map_type = BPF_MAP_TYPE_HASH,
22 .key_size = 4,
23 .value_size = 4,
24 .max_entries = 2
25 };
26
27 fd = __bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
28 //staptest// [[[[bpf (BPF_MAP_CREATE, XXXX, NNNN) = NNNN!!!!ni_syscall () = -NNNN]]]]
29 close(fd);
30
31 // Limit testing
32
33 __bpf(-1, NULL, 0);
34 //staptest// [[[[bpf (0x[f]+, 0x0, 0)!!!!ni_syscall ()]]]] = -NNNN
35
36 __bpf(0, (union bpf_attr *)-1, 0);
37 //staptest// [[[[bpf (BPF_MAP_CREATE, 0x[f]+, 0)!!!!ni_syscall ()]]]] = -NNNN
38
39 __bpf(0, NULL, -1);
40 //staptest// [[[[bpf (BPF_MAP_CREATE, 0x0, 4294967295)!!!!ni_syscall ()]]]] = -NNNN
41
42 return 0;
43 }
44 #else
45 int main()
46 {
47 return 0;
48 }
49 #endif