perf bpf: Add license(NAME) helper
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 4 May 2018 18:18:31 +0000 (15:18 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 15 May 2018 17:31:24 +0000 (14:31 -0300)
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>
tools/perf/examples/bpf/5sec.c
tools/perf/examples/bpf/empty.c
tools/perf/include/bpf/bpf.h

index 3d1ed34aec8ba8cd5918f76ad46171b1c7fd8339..6fc3697ac749341f38cb97e52bc674342b795066 100644 (file)
@@ -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);
index 86f97763355d718a15147d8f8446b3a4f5aa9e20..3776d26db9e79ed2644506c4a932a0ccd69f3e8b 100644 (file)
@@ -1,4 +1,3 @@
 #include <bpf.h>
 
-char _license[] SEC("license") = "GPL";
-int _version SEC("version") = LINUX_VERSION_CODE;
+license(GPL);
index 003afcab4e51fec7408d3810865b95a498df912f..cdfd18b9c318ca0b899cc62e63e1fa662da24399 100644 (file)
@@ -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 */