xref: /openbmc/linux/tools/perf/util/bpf-prologue.h (revision 1c2dd16a)
1 /*
2  * Copyright (C) 2015, He Kuang <hekuang@huawei.com>
3  * Copyright (C) 2015, Huawei Inc.
4  */
5 #ifndef __BPF_PROLOGUE_H
6 #define __BPF_PROLOGUE_H
7 
8 #include <linux/compiler.h>
9 #include <linux/filter.h>
10 #include "probe-event.h"
11 
12 #define BPF_PROLOGUE_MAX_ARGS 3
13 #define BPF_PROLOGUE_START_ARG_REG BPF_REG_3
14 #define BPF_PROLOGUE_FETCH_RESULT_REG BPF_REG_2
15 
16 #ifdef HAVE_BPF_PROLOGUE
17 int bpf__gen_prologue(struct probe_trace_arg *args, int nargs,
18 		      struct bpf_insn *new_prog, size_t *new_cnt,
19 		      size_t cnt_space);
20 #else
21 #include <errno.h>
22 
23 static inline int
24 bpf__gen_prologue(struct probe_trace_arg *args __maybe_unused,
25 		  int nargs __maybe_unused,
26 		  struct bpf_insn *new_prog __maybe_unused,
27 		  size_t *new_cnt,
28 		  size_t cnt_space __maybe_unused)
29 {
30 	if (!new_cnt)
31 		return -EINVAL;
32 	*new_cnt = 0;
33 	return -ENOTSUP;
34 }
35 #endif
36 #endif /* __BPF_PROLOGUE_H */
37