From: Arnaldo Carvalho de Melo Date: Tue, 6 Nov 2018 18:21:45 +0000 (-0300) Subject: perf bpf: Add unistd.h to the headers accessible to bpf proggies X-Git-Tag: v5.4-rc1~1977^2~9^2~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1475d35c4a6174d4ec633b9af5713e9770b3ac0d;p=platform%2Fkernel%2Flinux-rpi.git perf bpf: Add unistd.h to the headers accessible to bpf proggies Start with a getpid() function wrapping BPF_FUNC_get_current_pid_tgid, idea is to mimic the system headers. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-zo8hv22onidep7tm785dzxfk@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/include/bpf/unistd.h b/tools/perf/include/bpf/unistd.h new file mode 100644 index 0000000..ca7877f --- /dev/null +++ b/tools/perf/include/bpf/unistd.h @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: LGPL-2.1 + +#include + +static int (*bpf_get_current_pid_tgid)(void) = (void *)BPF_FUNC_get_current_pid_tgid; + +static pid_t getpid(void) +{ + return bpf_get_current_pid_tgid(); +}