diff mbox series

[v2,bpf,2/3] bpf: Replace [u]int32_t and [u]int64_t in libbpf

Message ID 20180721182043.1401089-3-kafai@fb.com
State Changes Requested, archived
Delegated to: BPF Maintainers
Headers show
Series Introduce BPF_ANNOTATE_KV_PAIR | expand

Commit Message

Martin KaFai Lau July 21, 2018, 6:20 p.m. UTC
This patch replaces [u]int32_t and [u]int64_t usage with
__[su]32 and __[su]64.  The same change goes for [u]int16_t
and [u]int8_t.

Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
---
 tools/lib/bpf/btf.c    | 28 +++++++++++++---------------
 tools/lib/bpf/btf.h    |  8 ++++----
 tools/lib/bpf/libbpf.c | 12 ++++++------
 tools/lib/bpf/libbpf.h |  4 ++--
 4 files changed, 25 insertions(+), 27 deletions(-)

Comments

Yonghong Song July 23, 2018, 6:04 p.m. UTC | #1
On 7/21/18 11:20 AM, Martin KaFai Lau wrote:
> This patch replaces [u]int32_t and [u]int64_t usage with
> __[su]32 and __[su]64.  The same change goes for [u]int16_t
> and [u]int8_t.
> 
> Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> ---
>   tools/lib/bpf/btf.c    | 28 +++++++++++++---------------
>   tools/lib/bpf/btf.h    |  8 ++++----
>   tools/lib/bpf/libbpf.c | 12 ++++++------
>   tools/lib/bpf/libbpf.h |  4 ++--
>   4 files changed, 25 insertions(+), 27 deletions(-)
> 
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index 8c54a4b6f187..ce77b5b57912 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -2,7 +2,6 @@
>   /* Copyright (c) 2018 Facebook */
>   
>   #include <stdlib.h>
> -#include <stdint.h>
>   #include <string.h>
>   #include <unistd.h>
>   #include <errno.h>
> @@ -27,13 +26,13 @@ struct btf {
>   	struct btf_type **types;
>   	const char *strings;
>   	void *nohdr_data;
> -	uint32_t nr_types;
> -	uint32_t types_size;
> -	uint32_t data_size;
> +	__u32 nr_types;
> +	__u32 types_size;
> +	__u32 data_size;
>   	int fd;
>   };
>   
> -static const char *btf_name_by_offset(const struct btf *btf, uint32_t offset)
> +static const char *btf_name_by_offset(const struct btf *btf, __u32 offset)
>   {
>   	if (offset < btf->hdr->str_len)
>   		return &btf->strings[offset];
> @@ -151,7 +150,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
>   
>   	while (next_type < end_type) {
>   		struct btf_type *t = next_type;
> -		uint16_t vlen = BTF_INFO_VLEN(t->info);
> +		__u16 vlen = BTF_INFO_VLEN(t->info);
>   		int err;
>   
>   		next_type += sizeof(*t);
> @@ -191,7 +190,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
>   }
>   
>   static const struct btf_type *btf_type_by_id(const struct btf *btf,
> -					     uint32_t type_id)
> +					     __u32 type_id)
>   {
>   	if (type_id > btf->nr_types)
>   		return NULL;
> @@ -226,12 +225,12 @@ static int64_t btf_type_size(const struct btf_type *t)

Missing this one:
    static int64_t btf_type_size(const struct btf_type *t)

There are a couple of instances of using u32 instead of __u32, better to 
use __u32 everywhere in the same file:
                 u32 expand_by, new_size;
         u32 meta_left;


>   
>   #define MAX_RESOLVE_DEPTH 32
>   
> -int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
> +__s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
>   {
>   	const struct btf_array *array;
>   	const struct btf_type *t;
> -	uint32_t nelems = 1;
> -	int64_t size = -1;
> +	__u32 nelems = 1;
> +	__s64 size = -1;
>   	int i;
>   
>   	t = btf_type_by_id(btf, type_id);
> @@ -271,9 +270,9 @@ int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
>   	return nelems * size;
>   }
>   
> -int32_t btf__find_by_name(const struct btf *btf, const char *type_name)
> +__s32 btf__find_by_name(const struct btf *btf, const char *type_name)
>   {
> -	uint32_t i;
> +	__u32 i;
>   
>   	if (!strcmp(type_name, "void"))
>   		return 0;
> @@ -302,10 +301,9 @@ void btf__free(struct btf *btf)
>   	free(btf);
>   }
>   
> -struct btf *btf__new(uint8_t *data, uint32_t size,
> -		     btf_print_fn_t err_log)
> +struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
>   {
> -	uint32_t log_buf_size = 0;
> +	__u32 log_buf_size = 0;
>   	char *log_buf = NULL;
>   	struct btf *btf;
>   	int err;
> diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
> index 74bb344035bb..ed3a84370ccc 100644
> --- a/tools/lib/bpf/btf.h
> +++ b/tools/lib/bpf/btf.h
> @@ -4,7 +4,7 @@
>   #ifndef __BPF_BTF_H
>   #define __BPF_BTF_H
>   
> -#include <stdint.h>
> +#include <linux/types.h>
>   
>   #define BTF_ELF_SEC ".BTF"
>   
> @@ -14,9 +14,9 @@ typedef int (*btf_print_fn_t)(const char *, ...)
>   	__attribute__((format(printf, 1, 2)));
>   
>   void btf__free(struct btf *btf);
> -struct btf *btf__new(uint8_t *data, uint32_t size, btf_print_fn_t err_log);
> -int32_t btf__find_by_name(const struct btf *btf, const char *type_name);
> -int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id);
> +struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
> +__s32 btf__find_by_name(const struct btf *btf, const char *type_name);
> +__s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
>   int btf__fd(const struct btf *btf);
>   
>   #endif
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index a1e96b5de5ff..6deb4fe4fffe 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -216,8 +216,8 @@ struct bpf_map {
>   	size_t offset;
>   	int map_ifindex;
>   	struct bpf_map_def def;
> -	uint32_t btf_key_type_id;
> -	uint32_t btf_value_type_id;
> +	__u32 btf_key_type_id;
> +	__u32 btf_value_type_id;
>   	void *priv;
>   	bpf_map_clear_priv_t clear_priv;
>   };
> @@ -1016,8 +1016,8 @@ static int bpf_map_find_btf_info(struct bpf_map *map, const struct btf *btf)
>   {
>   	struct bpf_map_def *def = &map->def;
>   	const size_t max_name = 256;
> -	int64_t key_size, value_size;
> -	int32_t key_id, value_id;
> +	__s64 key_size, value_size;
> +	__s32 key_id, value_id;
>   	char name[max_name];
>   
>   	/* Find key type by name from BTF */
> @@ -2089,12 +2089,12 @@ const char *bpf_map__name(struct bpf_map *map)
>   	return map ? map->name : NULL;
>   }
>   
> -uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map)
> +__u32 bpf_map__btf_key_type_id(const struct bpf_map *map)
>   {
>   	return map ? map->btf_key_type_id : 0;
>   }
>   
> -uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map)
> +__u32 bpf_map__btf_value_type_id(const struct bpf_map *map)
>   {
>   	return map ? map->btf_value_type_id : 0;
>   }
> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> index 09976531aa74..b33ae02f7d0e 100644
> --- a/tools/lib/bpf/libbpf.h
> +++ b/tools/lib/bpf/libbpf.h
> @@ -244,8 +244,8 @@ bpf_map__next(struct bpf_map *map, struct bpf_object *obj);
>   int bpf_map__fd(struct bpf_map *map);
>   const struct bpf_map_def *bpf_map__def(struct bpf_map *map);
>   const char *bpf_map__name(struct bpf_map *map);
> -uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map);
> -uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map);
> +__u32 bpf_map__btf_key_type_id(const struct bpf_map *map);
> +__u32 bpf_map__btf_value_type_id(const struct bpf_map *map);
>   
>   typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *);
>   int bpf_map__set_priv(struct bpf_map *map, void *priv,
>
Martin KaFai Lau July 23, 2018, 6:41 p.m. UTC | #2
On Mon, Jul 23, 2018 at 11:04:34AM -0700, Yonghong Song wrote:
> 
> 
> On 7/21/18 11:20 AM, Martin KaFai Lau wrote:
> > This patch replaces [u]int32_t and [u]int64_t usage with
> > __[su]32 and __[su]64.  The same change goes for [u]int16_t
> > and [u]int8_t.
> > 
> > Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
> > Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> > ---
> >   tools/lib/bpf/btf.c    | 28 +++++++++++++---------------
> >   tools/lib/bpf/btf.h    |  8 ++++----
> >   tools/lib/bpf/libbpf.c | 12 ++++++------
> >   tools/lib/bpf/libbpf.h |  4 ++--
> >   4 files changed, 25 insertions(+), 27 deletions(-)
> > 
> > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> > index 8c54a4b6f187..ce77b5b57912 100644
> > --- a/tools/lib/bpf/btf.c
> > +++ b/tools/lib/bpf/btf.c
> > @@ -2,7 +2,6 @@
> >   /* Copyright (c) 2018 Facebook */
> >   #include <stdlib.h>
> > -#include <stdint.h>
> >   #include <string.h>
> >   #include <unistd.h>
> >   #include <errno.h>
> > @@ -27,13 +26,13 @@ struct btf {
> >   	struct btf_type **types;
> >   	const char *strings;
> >   	void *nohdr_data;
> > -	uint32_t nr_types;
> > -	uint32_t types_size;
> > -	uint32_t data_size;
> > +	__u32 nr_types;
> > +	__u32 types_size;
> > +	__u32 data_size;
> >   	int fd;
> >   };
> > -static const char *btf_name_by_offset(const struct btf *btf, uint32_t offset)
> > +static const char *btf_name_by_offset(const struct btf *btf, __u32 offset)
> >   {
> >   	if (offset < btf->hdr->str_len)
> >   		return &btf->strings[offset];
> > @@ -151,7 +150,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
> >   	while (next_type < end_type) {
> >   		struct btf_type *t = next_type;
> > -		uint16_t vlen = BTF_INFO_VLEN(t->info);
> > +		__u16 vlen = BTF_INFO_VLEN(t->info);
> >   		int err;
> >   		next_type += sizeof(*t);
> > @@ -191,7 +190,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
> >   }
> >   static const struct btf_type *btf_type_by_id(const struct btf *btf,
> > -					     uint32_t type_id)
> > +					     __u32 type_id)
> >   {
> >   	if (type_id > btf->nr_types)
> >   		return NULL;
> > @@ -226,12 +225,12 @@ static int64_t btf_type_size(const struct btf_type *t)
> 
> Missing this one:
>    static int64_t btf_type_size(const struct btf_type *t)
> 
> There are a couple of instances of using u32 instead of __u32, better to use
> __u32 everywhere in the same file:
>                 u32 expand_by, new_size;
>         u32 meta_left;
Thanks for pointing them out.  Will make the changes.

> 
> 
> >   #define MAX_RESOLVE_DEPTH 32
> > -int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
> > +__s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
> >   {
> >   	const struct btf_array *array;
> >   	const struct btf_type *t;
> > -	uint32_t nelems = 1;
> > -	int64_t size = -1;
> > +	__u32 nelems = 1;
> > +	__s64 size = -1;
> >   	int i;
> >   	t = btf_type_by_id(btf, type_id);
> > @@ -271,9 +270,9 @@ int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
> >   	return nelems * size;
> >   }
> > -int32_t btf__find_by_name(const struct btf *btf, const char *type_name)
> > +__s32 btf__find_by_name(const struct btf *btf, const char *type_name)
> >   {
> > -	uint32_t i;
> > +	__u32 i;
> >   	if (!strcmp(type_name, "void"))
> >   		return 0;
> > @@ -302,10 +301,9 @@ void btf__free(struct btf *btf)
> >   	free(btf);
> >   }
> > -struct btf *btf__new(uint8_t *data, uint32_t size,
> > -		     btf_print_fn_t err_log)
> > +struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
> >   {
> > -	uint32_t log_buf_size = 0;
> > +	__u32 log_buf_size = 0;
> >   	char *log_buf = NULL;
> >   	struct btf *btf;
> >   	int err;
> > diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
> > index 74bb344035bb..ed3a84370ccc 100644
> > --- a/tools/lib/bpf/btf.h
> > +++ b/tools/lib/bpf/btf.h
> > @@ -4,7 +4,7 @@
> >   #ifndef __BPF_BTF_H
> >   #define __BPF_BTF_H
> > -#include <stdint.h>
> > +#include <linux/types.h>
> >   #define BTF_ELF_SEC ".BTF"
> > @@ -14,9 +14,9 @@ typedef int (*btf_print_fn_t)(const char *, ...)
> >   	__attribute__((format(printf, 1, 2)));
> >   void btf__free(struct btf *btf);
> > -struct btf *btf__new(uint8_t *data, uint32_t size, btf_print_fn_t err_log);
> > -int32_t btf__find_by_name(const struct btf *btf, const char *type_name);
> > -int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id);
> > +struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
> > +__s32 btf__find_by_name(const struct btf *btf, const char *type_name);
> > +__s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
> >   int btf__fd(const struct btf *btf);
> >   #endif
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index a1e96b5de5ff..6deb4fe4fffe 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -216,8 +216,8 @@ struct bpf_map {
> >   	size_t offset;
> >   	int map_ifindex;
> >   	struct bpf_map_def def;
> > -	uint32_t btf_key_type_id;
> > -	uint32_t btf_value_type_id;
> > +	__u32 btf_key_type_id;
> > +	__u32 btf_value_type_id;
> >   	void *priv;
> >   	bpf_map_clear_priv_t clear_priv;
> >   };
> > @@ -1016,8 +1016,8 @@ static int bpf_map_find_btf_info(struct bpf_map *map, const struct btf *btf)
> >   {
> >   	struct bpf_map_def *def = &map->def;
> >   	const size_t max_name = 256;
> > -	int64_t key_size, value_size;
> > -	int32_t key_id, value_id;
> > +	__s64 key_size, value_size;
> > +	__s32 key_id, value_id;
> >   	char name[max_name];
> >   	/* Find key type by name from BTF */
> > @@ -2089,12 +2089,12 @@ const char *bpf_map__name(struct bpf_map *map)
> >   	return map ? map->name : NULL;
> >   }
> > -uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map)
> > +__u32 bpf_map__btf_key_type_id(const struct bpf_map *map)
> >   {
> >   	return map ? map->btf_key_type_id : 0;
> >   }
> > -uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map)
> > +__u32 bpf_map__btf_value_type_id(const struct bpf_map *map)
> >   {
> >   	return map ? map->btf_value_type_id : 0;
> >   }
> > diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> > index 09976531aa74..b33ae02f7d0e 100644
> > --- a/tools/lib/bpf/libbpf.h
> > +++ b/tools/lib/bpf/libbpf.h
> > @@ -244,8 +244,8 @@ bpf_map__next(struct bpf_map *map, struct bpf_object *obj);
> >   int bpf_map__fd(struct bpf_map *map);
> >   const struct bpf_map_def *bpf_map__def(struct bpf_map *map);
> >   const char *bpf_map__name(struct bpf_map *map);
> > -uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map);
> > -uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map);
> > +__u32 bpf_map__btf_key_type_id(const struct bpf_map *map);
> > +__u32 bpf_map__btf_value_type_id(const struct bpf_map *map);
> >   typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *);
> >   int bpf_map__set_priv(struct bpf_map *map, void *priv,
> >
diff mbox series

Patch

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 8c54a4b6f187..ce77b5b57912 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -2,7 +2,6 @@ 
 /* Copyright (c) 2018 Facebook */
 
 #include <stdlib.h>
-#include <stdint.h>
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
@@ -27,13 +26,13 @@  struct btf {
 	struct btf_type **types;
 	const char *strings;
 	void *nohdr_data;
-	uint32_t nr_types;
-	uint32_t types_size;
-	uint32_t data_size;
+	__u32 nr_types;
+	__u32 types_size;
+	__u32 data_size;
 	int fd;
 };
 
-static const char *btf_name_by_offset(const struct btf *btf, uint32_t offset)
+static const char *btf_name_by_offset(const struct btf *btf, __u32 offset)
 {
 	if (offset < btf->hdr->str_len)
 		return &btf->strings[offset];
@@ -151,7 +150,7 @@  static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
 
 	while (next_type < end_type) {
 		struct btf_type *t = next_type;
-		uint16_t vlen = BTF_INFO_VLEN(t->info);
+		__u16 vlen = BTF_INFO_VLEN(t->info);
 		int err;
 
 		next_type += sizeof(*t);
@@ -191,7 +190,7 @@  static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
 }
 
 static const struct btf_type *btf_type_by_id(const struct btf *btf,
-					     uint32_t type_id)
+					     __u32 type_id)
 {
 	if (type_id > btf->nr_types)
 		return NULL;
@@ -226,12 +225,12 @@  static int64_t btf_type_size(const struct btf_type *t)
 
 #define MAX_RESOLVE_DEPTH 32
 
-int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
+__s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
 {
 	const struct btf_array *array;
 	const struct btf_type *t;
-	uint32_t nelems = 1;
-	int64_t size = -1;
+	__u32 nelems = 1;
+	__s64 size = -1;
 	int i;
 
 	t = btf_type_by_id(btf, type_id);
@@ -271,9 +270,9 @@  int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id)
 	return nelems * size;
 }
 
-int32_t btf__find_by_name(const struct btf *btf, const char *type_name)
+__s32 btf__find_by_name(const struct btf *btf, const char *type_name)
 {
-	uint32_t i;
+	__u32 i;
 
 	if (!strcmp(type_name, "void"))
 		return 0;
@@ -302,10 +301,9 @@  void btf__free(struct btf *btf)
 	free(btf);
 }
 
-struct btf *btf__new(uint8_t *data, uint32_t size,
-		     btf_print_fn_t err_log)
+struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
 {
-	uint32_t log_buf_size = 0;
+	__u32 log_buf_size = 0;
 	char *log_buf = NULL;
 	struct btf *btf;
 	int err;
diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
index 74bb344035bb..ed3a84370ccc 100644
--- a/tools/lib/bpf/btf.h
+++ b/tools/lib/bpf/btf.h
@@ -4,7 +4,7 @@ 
 #ifndef __BPF_BTF_H
 #define __BPF_BTF_H
 
-#include <stdint.h>
+#include <linux/types.h>
 
 #define BTF_ELF_SEC ".BTF"
 
@@ -14,9 +14,9 @@  typedef int (*btf_print_fn_t)(const char *, ...)
 	__attribute__((format(printf, 1, 2)));
 
 void btf__free(struct btf *btf);
-struct btf *btf__new(uint8_t *data, uint32_t size, btf_print_fn_t err_log);
-int32_t btf__find_by_name(const struct btf *btf, const char *type_name);
-int64_t btf__resolve_size(const struct btf *btf, uint32_t type_id);
+struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
+__s32 btf__find_by_name(const struct btf *btf, const char *type_name);
+__s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
 int btf__fd(const struct btf *btf);
 
 #endif
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index a1e96b5de5ff..6deb4fe4fffe 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -216,8 +216,8 @@  struct bpf_map {
 	size_t offset;
 	int map_ifindex;
 	struct bpf_map_def def;
-	uint32_t btf_key_type_id;
-	uint32_t btf_value_type_id;
+	__u32 btf_key_type_id;
+	__u32 btf_value_type_id;
 	void *priv;
 	bpf_map_clear_priv_t clear_priv;
 };
@@ -1016,8 +1016,8 @@  static int bpf_map_find_btf_info(struct bpf_map *map, const struct btf *btf)
 {
 	struct bpf_map_def *def = &map->def;
 	const size_t max_name = 256;
-	int64_t key_size, value_size;
-	int32_t key_id, value_id;
+	__s64 key_size, value_size;
+	__s32 key_id, value_id;
 	char name[max_name];
 
 	/* Find key type by name from BTF */
@@ -2089,12 +2089,12 @@  const char *bpf_map__name(struct bpf_map *map)
 	return map ? map->name : NULL;
 }
 
-uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map)
+__u32 bpf_map__btf_key_type_id(const struct bpf_map *map)
 {
 	return map ? map->btf_key_type_id : 0;
 }
 
-uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map)
+__u32 bpf_map__btf_value_type_id(const struct bpf_map *map)
 {
 	return map ? map->btf_value_type_id : 0;
 }
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 09976531aa74..b33ae02f7d0e 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -244,8 +244,8 @@  bpf_map__next(struct bpf_map *map, struct bpf_object *obj);
 int bpf_map__fd(struct bpf_map *map);
 const struct bpf_map_def *bpf_map__def(struct bpf_map *map);
 const char *bpf_map__name(struct bpf_map *map);
-uint32_t bpf_map__btf_key_type_id(const struct bpf_map *map);
-uint32_t bpf_map__btf_value_type_id(const struct bpf_map *map);
+__u32 bpf_map__btf_key_type_id(const struct bpf_map *map);
+__u32 bpf_map__btf_value_type_id(const struct bpf_map *map);
 
 typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *);
 int bpf_map__set_priv(struct bpf_map *map, void *priv,