perf bpf: Add unistd.h to the headers accessible to bpf proggies
authorArnaldo Carvalho de Melo <[email protected]>
Tue, 6 Nov 2018 18:21:45 +0000 (15:21 -0300)
committerArnaldo Carvalho de Melo <[email protected]>
Wed, 21 Nov 2018 15:00:30 +0000 (12:00 -0300)
Start with a getpid() function wrapping BPF_FUNC_get_current_pid_tgid,
idea is to mimic the system headers.

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]>
tools/perf/include/bpf/unistd.h [new file with mode: 0644]

diff --git a/tools/perf/include/bpf/unistd.h b/tools/perf/include/bpf/unistd.h
new file mode 100644 (file)
index 0000000..ca7877f
--- /dev/null
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: LGPL-2.1
+
+#include <bpf.h>
+
+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();
+}