Skip to content

Commit

Permalink
perf bpf: Add license(NAME) helper
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo committed May 15, 2018
1 parent 7542b76 commit 1f47730
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions tools/perf/examples/bpf/5sec.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ int func(void *ctx, int err, long sec)
return sec == 5;
}

char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
license(GPL);
3 changes: 1 addition & 2 deletions tools/perf/examples/bpf/empty.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <bpf.h>

char _license[] SEC("license") = "GPL";
int _version SEC("version") = LINUX_VERSION_CODE;
license(GPL);
5 changes: 5 additions & 0 deletions tools/perf/include/bpf/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
#ifndef _PERF_BPF_H
#define _PERF_BPF_H
#define SEC(NAME) __attribute__((section(NAME), used))

#define license(name) \
char _license[] SEC("license") = #name; \
int _version SEC("version") = LINUX_VERSION_CODE;

#endif /* _PERF_BPF_H */

0 comments on commit 1f47730

Please sign in to comment.