summaryrefslogtreecommitdiffstats
path: root/tools/bpf/bpftool/main.h
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2020-08-13 22:49:37 +0200
committerAlexei Starovoitov <ast@kernel.org>2020-08-14 01:45:41 +0200
commit09f44b753a7d120becc80213c3459183c8acd26b (patch)
tree797f74576998705a3d14183972e8bc227eef0793 /tools/bpf/bpftool/main.h
parentdoc: Add link to bpf helpers man page (diff)
downloadlinux-09f44b753a7d120becc80213c3459183c8acd26b.tar.xz
linux-09f44b753a7d120becc80213c3459183c8acd26b.zip
tools/bpftool: Fix compilation warnings in 32-bit mode
Fix few compilation warnings in bpftool when compiling in 32-bit mode. Abstract away u64 to pointer conversion into a helper function. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20200813204945.1020225-2-andriin@fb.com
Diffstat (limited to 'tools/bpf/bpftool/main.h')
-rw-r--r--tools/bpf/bpftool/main.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h
index e3a79b5a9960..c46e52137b87 100644
--- a/tools/bpf/bpftool/main.h
+++ b/tools/bpf/bpftool/main.h
@@ -21,7 +21,15 @@
/* Make sure we do not use kernel-only integer typedefs */
#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
-#define ptr_to_u64(ptr) ((__u64)(unsigned long)(ptr))
+static inline __u64 ptr_to_u64(const void *ptr)
+{
+ return (__u64)(unsigned long)ptr;
+}
+
+static inline void *u64_to_ptr(__u64 ptr)
+{
+ return (void *)(unsigned long)ptr;
+}
#define NEXT_ARG() ({ argc--; argv++; if (argc < 0) usage(); })
#define NEXT_ARGP() ({ (*argc)--; (*argv)++; if (*argc < 0) usage(); })