]> Git Repo - linux.git/blob - tools/perf/examples/bpf/hello.c
Merge tag 'amd-drm-next-6.5-2023-06-09' of https://gitlab.freedesktop.org/agd5f/linux...
[linux.git] / tools / perf / examples / bpf / hello.c
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/bpf.h>
3 #include <bpf/bpf_helpers.h>
4
5 struct __bpf_stdout__ {
6         __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
7         __type(key, int);
8         __type(value, __u32);
9         __uint(max_entries, __NR_CPUS__);
10 } __bpf_stdout__ SEC(".maps");
11
12 #define puts(from) \
13         ({ const int __len = sizeof(from); \
14            char __from[sizeof(from)] = from;                    \
15            bpf_perf_event_output(args, &__bpf_stdout__, BPF_F_CURRENT_CPU, \
16                           &__from, __len & (sizeof(from) - 1)); })
17
18 struct syscall_enter_args;
19
20 SEC("raw_syscalls:sys_enter")
21 int sys_enter(struct syscall_enter_args *args)
22 {
23         puts("Hello, world\n");
24         return 0;
25 }
26
27 char _license[] SEC("license") = "GPL";
This page took 0.035495 seconds and 4 git commands to generate.