Skip to content

Commit 1f47730

Browse files
committed
perf bpf: Add license(NAME) helper
To further reduce boilerplate. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-vst6hj335s0ebxzqltes3nsc@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 7542b76 commit 1f47730

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎tools/perf/examples/bpf/5sec.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,4 @@ int func(void *ctx, int err, long sec)
4040
return sec == 5;
4141
}
4242

43-
char _license[] SEC("license") = "GPL";
44-
int _version SEC("version") = LINUX_VERSION_CODE;
43+
license(GPL);

‎tools/perf/examples/bpf/empty.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#include <bpf.h>
22

3-
char _license[] SEC("license") = "GPL";
4-
int _version SEC("version") = LINUX_VERSION_CODE;
3+
license(GPL);

‎tools/perf/include/bpf/bpf.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22
#ifndef _PERF_BPF_H
33
#define _PERF_BPF_H
44
#define SEC(NAME) __attribute__((section(NAME), used))
5+
6+
#define license(name) \
7+
char _license[] SEC("license") = #name; \
8+
int _version SEC("version") = LINUX_VERSION_CODE;
9+
510
#endif /* _PERF_BPF_H */

0 commit comments

Comments
 (0)