Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libbpf: Expose btf_type_by_id() internally

btf_type_by_id() is internal-only convenience API returning non-const pointer
to struct btf_type. Expose it outside of btf.c for re-use.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210318194036.3521577-2-andrii@kernel.org

authored by

Andrii Nakryiko and committed by
Alexei Starovoitov
e14ef4bf fdc13979

+6 -1
+1 -1
tools/lib/bpf/btf.c
··· 435 435 } 436 436 437 437 /* internal helper returning non-const pointer to a type */ 438 - static struct btf_type *btf_type_by_id(struct btf *btf, __u32 type_id) 438 + struct btf_type *btf_type_by_id(struct btf *btf, __u32 type_id) 439 439 { 440 440 if (type_id == 0) 441 441 return &btf_void;
+5
tools/lib/bpf/libbpf_internal.h
··· 107 107 return realloc(ptr, total); 108 108 } 109 109 110 + struct btf; 111 + struct btf_type; 112 + 113 + struct btf_type *btf_type_by_id(struct btf *btf, __u32 type_id); 114 + 110 115 void *btf_add_mem(void **data, size_t *cap_cnt, size_t elem_sz, 111 116 size_t cur_cnt, size_t max_cnt, size_t add_cnt); 112 117 int btf_ensure_mem(void **data, size_t *cap_cnt, size_t elem_sz, size_t need_cnt);