mirror of
https://github.com/torvalds/linux.git
synced 2026-12-06 05:14:35 +00:00
perf bpf: Add bpf.h to be used in eBPF proggies
So, the first helper is the one shortening a variable/function section
attribute, from, for instance:
char _license[] __attribute__((section("license"), used)) = "GPL";
to:
char _license[] SEC("license") = "GPL";
Convert empty.c to that and it becomes:
# cat ~acme/lib/examples/perf/bpf/empty.c
#include <bpf.h>
char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
#
Cc: Adrian Hunter <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Wang Nan <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
@@ -770,6 +770,7 @@ endif
|
||||
ifndef NO_LIBBPF
|
||||
$(call QUIET_INSTALL, lib) \
|
||||
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'
|
||||
$(INSTALL) include/bpf/*.h '$(DESTDIR_SQ)$(perf_include_instdir_SQ)/bpf'
|
||||
$(call QUIET_INSTALL, lib) \
|
||||
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'
|
||||
$(INSTALL) examples/bpf/*.c '$(DESTDIR_SQ)$(perf_examples_instdir_SQ)/bpf'
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
char _license[] __attribute__((section("license"), used)) = "GPL";
|
||||
int _version __attribute__((section("version"), used)) = LINUX_VERSION_CODE;
|
||||
#include <bpf.h>
|
||||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
int _version SEC("version") = LINUX_VERSION_CODE;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
#ifndef _PERF_BPF_H
|
||||
#define _PERF_BPF_H
|
||||
#define SEC(NAME) __attribute__((section(NAME), used))
|
||||
#endif /* _PERF_BPF_H */
|
||||
Reference in New Issue
Block a user