bpf-prologue.h 906 B

12345678910111213141516171819202122232425262728293031323334353637
  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. #include <linux/compiler.h>
  9. #include <linux/filter.h>
  10. #include "probe-event.h"
  11. #define BPF_PROLOGUE_MAX_ARGS 3
  12. #define BPF_PROLOGUE_START_ARG_REG BPF_REG_3
  13. #define BPF_PROLOGUE_FETCH_RESULT_REG BPF_REG_2
  14. #ifdef HAVE_BPF_PROLOGUE
  15. int bpf__gen_prologue(struct probe_trace_arg *args, int nargs,
  16. struct bpf_insn *new_prog, size_t *new_cnt,
  17. size_t cnt_space);
  18. #else
  19. #include <errno.h>
  20. static inline int
  21. bpf__gen_prologue(struct probe_trace_arg *args __maybe_unused,
  22. int nargs __maybe_unused,
  23. struct bpf_insn *new_prog __maybe_unused,
  24. size_t *new_cnt,
  25. size_t cnt_space __maybe_unused)
  26. {
  27. if (!new_cnt)
  28. return -EINVAL;
  29. *new_cnt = 0;
  30. return -ENOTSUP;
  31. }
  32. #endif
  33. #endif /* __BPF_PROLOGUE_H */