diff mbox series

[v2,bpf-next,2/4] libbpf: make skip_mods_and_typedefs available internally in libbpf

Message ID 1610921764-7526-3-git-send-email-alan.maguire@oracle.com
State New
Headers show
Series libbpf: BTF dumper support for typed data | expand

Commit Message

Alan Maguire Jan. 17, 2021, 10:16 p.m. UTC
btf_dump.c will need it for type-based data display.

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
 tools/lib/bpf/libbpf.c          | 4 +---
 tools/lib/bpf/libbpf_internal.h | 2 ++
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Andrii Nakryiko Jan. 21, 2021, 4:13 a.m. UTC | #1
On Sun, Jan 17, 2021 at 2:20 PM Alan Maguire <alan.maguire@oracle.com> wrote:
>
> btf_dump.c will need it for type-based data display.
>
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> ---

Given we make it into an internal API, let's call it
btf_skip_mods_and_typedefs()? Otherwise all ok.

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>  tools/lib/bpf/libbpf.c          | 4 +---
>  tools/lib/bpf/libbpf_internal.h | 2 ++
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 2abbc38..4ef84e1 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -73,8 +73,6 @@
>  #define __printf(a, b) __attribute__((format(printf, a, b)))
>
>  static struct bpf_map *bpf_object__add_map(struct bpf_object *obj);
> -static const struct btf_type *
> -skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id);
>
>  static int __base_pr(enum libbpf_print_level level, const char *format,
>                      va_list args)
> @@ -1885,7 +1883,7 @@ static int bpf_object__init_user_maps(struct bpf_object *obj, bool strict)
>         return 0;
>  }
>
> -static const struct btf_type *
> +const struct btf_type *
>  skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id)
>  {
>         const struct btf_type *t = btf__type_by_id(btf, id);
> diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
> index 969d0ac..c25d2df 100644
> --- a/tools/lib/bpf/libbpf_internal.h
> +++ b/tools/lib/bpf/libbpf_internal.h
> @@ -108,6 +108,8 @@ static inline void *libbpf_reallocarray(void *ptr, size_t nmemb, size_t size)
>  void *btf_add_mem(void **data, size_t *cap_cnt, size_t elem_sz,
>                   size_t cur_cnt, size_t max_cnt, size_t add_cnt);
>  int btf_ensure_mem(void **data, size_t *cap_cnt, size_t elem_sz, size_t need_cnt);
> +const struct btf_type *skip_mods_and_typedefs(const struct btf *btf, __u32 id,
> +                                             __u32 *res_id);
>
>  static inline bool libbpf_validate_opts(const char *opts,
>                                         size_t opts_sz, size_t user_sz,
> --
> 1.8.3.1
>
diff mbox series

Patch

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 2abbc38..4ef84e1 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -73,8 +73,6 @@ 
 #define __printf(a, b)	__attribute__((format(printf, a, b)))
 
 static struct bpf_map *bpf_object__add_map(struct bpf_object *obj);
-static const struct btf_type *
-skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id);
 
 static int __base_pr(enum libbpf_print_level level, const char *format,
 		     va_list args)
@@ -1885,7 +1883,7 @@  static int bpf_object__init_user_maps(struct bpf_object *obj, bool strict)
 	return 0;
 }
 
-static const struct btf_type *
+const struct btf_type *
 skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id)
 {
 	const struct btf_type *t = btf__type_by_id(btf, id);
diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
index 969d0ac..c25d2df 100644
--- a/tools/lib/bpf/libbpf_internal.h
+++ b/tools/lib/bpf/libbpf_internal.h
@@ -108,6 +108,8 @@  static inline void *libbpf_reallocarray(void *ptr, size_t nmemb, size_t size)
 void *btf_add_mem(void **data, size_t *cap_cnt, size_t elem_sz,
 		  size_t cur_cnt, size_t max_cnt, size_t add_cnt);
 int btf_ensure_mem(void **data, size_t *cap_cnt, size_t elem_sz, size_t need_cnt);
+const struct btf_type *skip_mods_and_typedefs(const struct btf *btf, __u32 id,
+					      __u32 *res_id);
 
 static inline bool libbpf_validate_opts(const char *opts,
 					size_t opts_sz, size_t user_sz,