Skip to content

Commit

Permalink
libbpf: Move insn_is_pseudo_func() to libbpf_internal.h
Browse files Browse the repository at this point in the history
Currently, insn_is_pseudo_func() is only used in libbpf.c, move it
to libbpf_internal.h so that it can be used in test_verifier, this
is preparation for later patch.

Suggested-by: Song Liu <song@kernel.org>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
  • Loading branch information
Tiezhu Yang authored and intel-lab-lkp committed Jan 17, 2024
1 parent a94216b commit d489189
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 0 additions & 5 deletions tools/lib/bpf/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,11 +748,6 @@ static bool is_call_insn(const struct bpf_insn *insn)
return insn->code == (BPF_JMP | BPF_CALL);
}

static bool insn_is_pseudo_func(struct bpf_insn *insn)
{
return is_ldimm64_insn(insn) && insn->src_reg == BPF_PSEUDO_FUNC;
}

static int
bpf_object__init_prog(struct bpf_object *obj, struct bpf_program *prog,
const char *name, size_t sec_idx, const char *sec_name,
Expand Down
5 changes: 5 additions & 0 deletions tools/lib/bpf/libbpf_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,11 @@ static inline bool is_ldimm64_insn(struct bpf_insn *insn)
return insn->code == (BPF_LD | BPF_IMM | BPF_DW);
}

static inline bool insn_is_pseudo_func(struct bpf_insn *insn)
{
return is_ldimm64_insn(insn) && insn->src_reg == BPF_PSEUDO_FUNC;
}

/* if fd is stdin, stdout, or stderr, dup to a fd greater than 2
* Takes ownership of the fd passed in, and closes it if calling
* fcntl(fd, F_DUPFD_CLOEXEC, 3).
Expand Down

0 comments on commit d489189

Please sign in to comment.