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